Skip to content Skip to sidebar Skip to footer

Highcharts: Set Regular Intervals On Xaxis

I have a series of data values over time (determined by a count). Data is provided at n minute intervals (count x interval); typically the data will be 96 x 15 (96 15minute interva

Solution 1:

If the axis is of type datetime then the chart will render them the best way it sees fit. If you don't like the way they are rendered, you can control the datetime formats of the chart using dateTimeLabelFormats like you are already doing.

Based on the datetime span of the data at the time the chart will pick one of the following default formats:

second:'%H:%M:%S',minute:'%H:%M',hour:'%H:%M',day:'%e. %b',week:'%e. %b',month:'%b \'%y',year:'%Y'

If you want to force them all to the Hour and Minute no matter what the range is then set them as follows:

second:'%H:%M',minute:'%H:%M',hour:'%H:%M',day:'%H:%M',week:'%H:%M',month:'%H:%M',year:'%H:%M'

To control the interval of the dates shown use tickInterval. Since your axis is of type datetime you will have to use milliseconds as the unit for your tickInterval. So, a 1 hour tickinterval in milliseconds is 3600000. If you want it to be 2 hours then use 7200000.

Solution 2:

Rough guess here is that you do not include a time in your series. If your xAxis is datetime you need to somehow provide that to HighCharts. For example you series should look like:

[[timeInJSTime1, 15999.999999999996],
 [timeInJSTime2, 14999.999999999996],
 ....
]

Post a Comment for "Highcharts: Set Regular Intervals On Xaxis"