Figured it out finally!
Just need to make <%= @info %> into <%= @info.to_json.html_safe %>. That
kept the quotes as " and not ".
On Sunday, June 30, 2013 12:31:01 PM UTC-7, Brian Wobst wrote:
>
> I'm trying to include dynamic data.
>
> This code:
>
> <% @info = @urges.inject([['Day','Morning','Afternoon','Evening']]) do
> |ar, t|
> ar << [t.date.strftime("%m/%d/%y"), t.morning, t.afternoon,
> t.evening]
> end
> %>
>
> outputs:
>
> [["Day", "Morning", "Afternoon", "Evening"], ["06/30/13", 1, 5, 3],
> ["06/29/13", 5, 3, 7], ["06/28/13", 3, 2, 3]]
>
> When I try to call @info like this:
>
> var data = google.visualization.arrayToDataTable(<%= @info %>);
>
> The chart doesn't render. However, if I copy the exact same output and
> hardcode it in like this:
>
> var data = google.visualization.arrayToDataTable([["Day", "Morning",
> "Afternoon", "Evening"], ["06/30/13", 1, 5, 3], ["06/29/13", 5, 3, 7],
> ["06/28/13", 3, 2, 3]]);
>
> It works. What gives?
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.