如何使用Highcharts系列数据使用纪元时间? [英] How To Use Epoch Time With Highcharts Series Data?

查看:66
本文介绍了如何使用Highcharts系列数据使用纪元时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的系列数据中使用纪元时间日期。数组看起来像这样:

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

点显示正常,但x轴和工具提示上的日期标签均已设置到1970年1月16日(开始的时代!)。

如果我做了一堆string-fu,我可以生成一个如下所示的数组:

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

当我这样做时,x轴上的日期标签是正确的。 p>

我试过使用dateTimeLabelFormat选项,它正确地格式化日期 - 只是当我尝试使用毫秒值时,我得到的是1月16日70。



有什么想法?我宁愿用毫秒工作,而不是跳过所有的环节来生成Date.UTC(2011,11,26)。
$ b $ p

谢谢!

解决方案

在Highsoft论坛上找到答案。
$ b 我需要乘以纪元时间值为1000,以获得适合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!

解决方案

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!

这篇关于如何使用Highcharts系列数据使用纪元时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆