google / google-visualization-issues

288 stars 35 forks source link

convert dates internally #460

Open orwant opened 9 years ago

orwant commented 9 years ago
Did you consider when converting a JSON to a DataTable to convert date strings internally
to a JS date object?

To allow something like:
var dt = new google.visualization.DataTable({{
  cols: [{id: 'C', label: 'C-label', type: 'date'}],
2009-04-04T22:55:16.0000000-04:00
  rows: [{c:[{v: '2008-1-28T00:31:26', f: '2/28/08 12:31 AM'}]},
         {c:[{v: '2008-2-30T00:31:26', f: '3/30/08 12:31 AM'}]},
         {c:[{v: '2008-3-30T00:31:26', f: '4/30/08 12:31 AM'}]}
        ]
});

I know it is not a strictly valid JSON if I want dates, but since the type of the column
is set to 'date' we know we need them.
The server returns a JSON as a strings, and I have to iterate first on all the data
to convert them to the date object or use a generic reviver while parsing.

For big dataset that would help.

Original issue reported on code.google.com by mic@beebole.com on 2010-11-18 17:09:36

orwant commented 9 years ago
sorry for the 2009-04-04T22:55:16.0000000-04:00 in the middle, it is an error

Original issue reported on code.google.com by mic@beebole.com on 2010-11-18 17:11:10