Reputation: 485
Just trying to plot some data via highcharts and getting some weird results.
Its 'almost' right but not quite.
I'm plotting price changes over time and have this data coming from a db. I'm turning it into the series of data and then trying to plot.
The strange thing is, highcharts are showing data into the future and plotting November 2015!!!!
I cannot see this in the date anywhere.
Please help!
Here is a snippet from the code:
{
type: 'line',
name: 'Competitor 6',
data: [
[Date.UTC(2015, 10, 22), 91],
]
}
This plots on the Graph as the 22nd November 2015.
Full example file is here: https://www.dropbox.com/s/auhoe00gcsizu1g/stackexchange_example.html?dl=0
Its too long to post in here!
Thanks
Alex
Upvotes: 1
Views: 54
Reputation: 128771
For array purposes, month numbers in JavaScript start at 0 (January) and go up to 11 (December).
Here you're passing in a month of 10
which in JavaScript ends up as November.
new Date(Date.UTC(2015, 10, 22))
-> "Sun Nov 22 2015 00:00:00 GMT+0000 (GMT Standard Time)"
If you're wanting this to be October, you're going to have to pass in 9
instead:
new Date(Date.UTC(2015, 9, 22))
-> "Thu Oct 22 2015 01:00:00 GMT+0000 (GMT Standard Time)"
Here's a relevant question here if you want some further reading: Why does the month argument range from 0 to 11 in JavaScript's Date constructor?
Upvotes: 1