Reputation: 339
I've been using HighCharts a lot in the past, but I don't remember how to render this kind of chart, with HighStocks:
I have a JSON like this:
[
{
timestamp: 'Sun Aug 16 2015 10:00:00 GMT+1000 (AEST)',
run: 2,
rest: 3
},
{
timestamp: 'Sun Aug 16 2015 10:01:00 GMT+1000 (AEST)',
run: 4,
rest: 1
},
{
timestamp: 'Sun Aug 16 2015 10:02:00 GMT+1000 (AEST)',
run: 2,
rest: 1
},
]
I would like to have a chart with two columns (run and rest) per timestamp. With HighStocks, so I can define my own scale with the mouse.
How can I write this in the chart configuration ?
Upvotes: 1
Views: 185
Reputation: 2136
To use Highstocks, you need to pass your date in milliseconds. So you can use (supposing we are looping through your JSON array):
var d = new Date(json[i].timestamp);
Then your series will have the format:
[d.getTime(), json[i].rest]
You can see a working JSFiddle here, which takes your json array as data.
Upvotes: 1