如何解读 HighStock 的时间线

How to interpret Timelien for HighStock

我正在使用 HighChart 的 HighStock API。

演示:

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/stock/demo/compare/

在 x 轴上制作时间轴。 但是图表的数据 JSON 数据具有以下键: 例如。对于 AAPL:

?(/* AAPL historical OHLC data from the Google Finance API */
[
/* Dec 2008 */
[1229472000000,12.74],
[1229558400000,12.78],
[1229644800000,12.86],
[1229904000000,12.25],
[1229990400000,12.34],
[1230076800000,12.15],
[1230249600000,12.26],
[1230508800000,12.37],
[1230595200000,12.33],
[1230681600000,12.19],

所有 1229.... 值如何与 Date/Time 相关?我的意思是

1232582400000

关于 22. January 2009???

我的数据格式如下 Java:

2015-12-10 15:27 

我应该如何在 HighChart 中使用它们 API?

您看到的数字时间戳“1232582400000”是 javascript 时间戳。我相信这是以毫秒为单位的 UNIX 纪元时间(纪元时间乘以 1000)。您可以通过多种方式将人类可读的时间值转换为 javascript 时间。如果您有年、月、日、小时和秒,则基本示例是让您的数据系列使用 Date.UTC():

[Date.UTC(year, month, day, hour, minute), yValue]

"Unix time (also known as POSIX time or Epoch time) is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds."

(source)