Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts datetime starting on wrong day

I have a php outputting a chart as Javascript, it all displays properly, however, the datetime function on the x-axis isin't starting on the correct date.

I have set the graph like this:

xAxis: {
    title:{
        text: 'Day',
        style: {
           color: '#666666',
           fontSize: '12px',
           fontWeight: 'normal'
        }
    },
    type: 'datetime',
    dateTimeLabelFormats: {
        day: '%e.%b'   
    },
    showFirstLabel: false
},

Then at the series data level:

series: [{
    name: 'Office', 
    zIndex: '1',
    data: [0, 0, 0, 0, 0, 0, 1.8, 17.67, 17.66, 74.8, 62.45, 71.21, 67.75, 22.28, 16.61, 16.26, 71.79, 72.85, 56.52, 48.68, 47.01, 0, 0, 33.8, 62.72, 40.28, 9.99, 26.06, 8.85, 9.46, ],
    pointStart: Date.UTC(2012, 7, 14),  
    pointInterval: 24 * 3600 * 1000 //one day
}]

So this is clearly set to daily, and to start on the 14th of July 2012. However, when the graph displays, it starts on todays date.

Any help is greatly appreciated.

like image 496
Seán McCabe Avatar asked Dec 26 '22 19:12

Seán McCabe


1 Answers

try

pointStart: Date.UTC(2012, 6, 14), 

for July - JS months start at 0

like image 79
mplungjan Avatar answered Dec 29 '22 10:12

mplungjan