Reputation: 4473
I'm working with this simple chart:
https://jsfiddle.net/w7uyghqn/2/
My dates are in the format: Date(1447793679000)
, which translates correctly to Thu Aug 11 2016 10:26:59 GMT-0400 (EDT)
.
var seriesOptions = [
{
"data":[
[Date(1447793679000), 7.8494623656],
[Date(1450913358000), 5.4140127389],
[Date(1460475392000), 6.015037594],
[Date(1460648544000), 3.75],
[Date(1460753244000), 2.1015761821],
[Date(1460985174000), 3.0141843972],
[Date(1460988174000), 5.2264808362],
[Date(1461874589000), 1.5100671141]
],
"name":"Product 1"
},
{
"data":[
[Date(1450729647000), 2.9850746269],
[Date(1452184898000), 4.1666666667],
[Date(1454616863000), 4.1749502982],
[Date(1455206741000), 2.6717557252],
[Date(1458062356000), 2.4],
[Date(1459868909000), 3.8461538462],
[Date(1459882015000), 3.3955857385],
[Date(1459968893000), 4.1832669323],
[Date(1460574864000), 4.973357016],
[Date(1460665314000), 5.2032520325]
],
"name":"Product 2"
}
]
However, as you can see on the x-axis, this is all Jan 1st 1970. Can anyone spot what's wrong?
I've tried so many different formats and I'm totally tearing my hair out.
Upvotes: 2
Views: 2909
Reputation: 3721
As jlbriggs said in the comments, you can simply remove the Date()
function and use the actual number which will automatically be interpreted by HighCharts as the number of milliseconds since January 1, 1970 because you told it that the xAxis.type
is datetime
.
I modified your JSFiddle and fixed the problem so you can see it: Working JSFiddle
var seriesOptions = [
{
"data":[
[1447793679000, 7.8494623656],
[1450913358000, 5.4140127389],
[1460475392000, 6.015037594],
[1460648544000, 3.75],
[1460753244000, 2.1015761821],
[1460985174000, 3.0141843972],
[1460988174000, 5.2264808362],
[1461874589000, 1.5100671141]
],
"name":"Product 1"
},{
"data":[
[1450729647000, 2.9850746269],
[1452184898000, 4.1666666667],
[1454616863000, 4.1749502982],
[1455206741000, 2.6717557252],
[1458062356000, 2.4],
[1459868909000, 3.8461538462],
[1459882015000, 3.3955857385],
[1459968893000, 4.1832669323],
[1460574864000, 4.973357016],
[1460665314000, 5.2032520325]
],
"name":"Product 2"
}
]
Upvotes: 2