I'm trying to write a Java method that will return a string representing a
JSON object, that will be consumed by Google Charts javascript. The JSON
object should look like this:
{
cols: [
{id: 'date', label: 'Date', type: 'string'},
{id: 'activeCampaigns', label: 'Active Campaigns', type: 'number'}
],
rows: [
{c:[{v: new Date(2014, 6, 22), f: '2/28/08'}, {v: 393}]},
{c:[{v: new Date(2014, 6, 22), f: '2/28/08'}, {v: 393}]}
]
}
So far I have:
DataTable data = new DataTable();
ArrayList<ColumnDescription> cols = new ArrayList<ColumnDescription>();
cols.add(new ColumnDescription("summary", ValueType.DATE, "Date"));
cols.add(new ColumnDescription("activeCampaigns", ValueType.NUMBER,
"Active Campaigns"));
data.addColumns(cols);
But how do I add a row with a date in it?
try {
data.addRowFromValues(*/* WHAT GOES HERE??? /**);
} catch (TypeMismatchException e) {
System.out.println("Invalid type!");
}
So far I can only find documentation with strings and numbers.
--
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/d/optout.