Hey,
I am trying to convert an array to a JSON string, which can be assigned to
a Google Visualization datatable.
However, whatever I try, I keep getting errors. Even with the example of
Google Visualization API!
This is what I have:
String haha = "{" +
> " cols: [{id: 'task', label: 'Task',
> type: 'string'}," +
> " {id: 'hours', label: 'Hours per Day',
> type: 'number'}]," +
> " rows: [{c:[{v: 'Work'}, {v: 11}]}," +
> " {c:[{v: 'Eat'}, {v: 2}]}," +
> " {c:[{v: 'Commute'}, {v: 2}]}," +
> " {c:[{v: 'Watch TV'}, {v:2}]}," +
> " {c:[{v: 'Sleep'}, {v:7,
> f:'7.000'}]}" +
> " ]" +
> " }";
>
JSP: var view = new google.visualization.DataTable(${chartData});
What I get is an error, telling me that the JSON format is invalid.
The goal is to save a hashmap to a datatable with JSON (hashmap contains a
category and a value). The above example was used as I cannot seem to build
a proper JSON format myself. But this doesn't work as well.
Hopefully someone can help me. Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/c4MMELWfEekJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.