2011-06-06 118 views
0

如何在j軸對象上顯示我的x軸上的日期;Highcharts顯示日期軸(毫秒)

[ 
    [ 
     634420512000000000, 
     100000 
    ], 
    [ 
     634421376000000000, 
     100086 
    ], 
    [ 
     634422240000000000, 
     100171 
    ], 
    [ 
     634423104000000000, 
     100257 
    ] 
] 

我的日期以毫秒爲單位。我把xAxis設置成這樣;

xAxis: { 
    title: { 
     text: 'Time' 
    }, 
    type: 'datetime' 
} 

由於

回答

1

原來我是從1/1/1970

於是久違蜱,而不是毫秒...

Dim dt1970 As DateTime = New DateTime("1970", "1", "1") 
Dim d As DateTime = row("myDateFromDB") 
Dim span As TimeSpan = d - dt1970 

Dim milli as long = span.TotalMilliseconds 
0

Highcharts接受數據三個主要格式:

  • 一個簡單的陣列(例如[1, 2, 3]
  • x的數組的數組,y對(例如[[x, y], [x2, y2]]
  • 點對象列表

有關這些格式的更多詳細信息,請參見in the highcharts documentation。不過,就你而言,它應該很容易。只要做下面的事情。

var data = []; //assume data is the array you've listed in your question 

var chart = new Highcharts.chart({ 
    xAxis: { 
     title: { 
      text: 'Time' 
     }, 
     type: 'datetime' 
    }, 
    series: [{ 
     data: data 
    }] 
});