Using a JSON post call, I can format the data set to return ['2009/07/12 12:34:56, 100'] but dygraphs documentations says
[ new Date("2009/07/12"), 100] (Taken from here)
This is very unfortunate, I cannot send a date object since there will be automatic conversions. I'm working with around 2 million data, and it is very slow to for-loop [new Date('2009/07/12 12:34:56), 100'] 2 million times. The efficiency will be much greater if taken straight from a JSON call.
Is there anyway to plot dates without client side modifications?/ straight from a JSON call?
You can't transmit Dates as JSON, since they're not supported in the JSON spec.
An alternative would be to transmit milliseconds since epoch, which is how dygraphs represents these values internally. You'll have to manually set the various x-axis options if you do this. See this fiddle:
g = new Dygraph(document.getElementById('graph'),
[[1247382000000, 10],
[1247468400000, 20],
[1247554800000, 30]],
{
labels: ['Date', 'Value'],
axes: {
x: {
valueFormatter: Dygraph.dateString_,
axisLabelFormatter: Dygraph.dateAxisFormatter,
ticker: Dygraph.dateTicker
}
}
});