Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Use Epoch Time With Highcharts Series Data?

Tags:

highcharts

I'm trying use epoch time dates in my series data. The array looks like this:

data:[ [1324857600,205.4],[1324771200,208.7],[1324684800,205.4]. . .]

The points display fine, but the date labels on the x-axis and tooltip are all set to 16 Jan 1970 (the beginning of epoch time!).

If I do a bunch of string-fu I can produce an array that looks like this:

 data:[ [Date.UTC(2011, 11, 26),247.7],[Date.UTC(2011, 11, 25),245.5] . . .]

When I do it this way the date labels on the x-axis are correct.

I've tried using the dateTimeLabelFormat option and it formats the date correctly - it's just that when I try to use millisecond values all I get is 16 Jan 70.

Any ideas? I'd rather work with milliseconds than jump through all the hoops to produce "Date.UTC(2011, 11, 26)."

Thanks!

like image 820
jacoulter Avatar asked Dec 27 '11 20:12

jacoulter


1 Answers

Found the answer on the Highsoft forum.

I need to multiply the epoch time values by 1000 to get the proper millisecond values for Highcharts.

Works great!

like image 156
jacoulter Avatar answered Sep 30 '22 07:09

jacoulter