2013-05-09 206 views
0

我有這種情節,我得到的數據形式爲JSON格式的MSSQL表,但日期時間軸標籤只顯示一個點。 JSON中的日期時間格式是epoc格式[1325397600000,1325484000000,1325570400000,1325656800000,1325743200000,1325829600000]。highcharts中的日期時間軸標籤

可能是什麼問題?

這裏是我使用的代碼:

$(document).ready(function() { 
     var options = { 
      chart: { 
       renderTo: 'container', 
       type: 'line', 
       marginRight: 130, 
       marginBottom: 60 
      }, 
      title: { 
       text: 'Pressure and Temperature', 
       x: -20 //center 
      }, 
      subtitle: { 
       text: '', 
       x: -20 
      }, 
      xAxis: { 
       categories: [] 
    type: 'datetime', 



      }, 
      yAxis: { 
       title: { 
        text: 'Temperature ' 
       }, 
       plotLines: [{ 
        value: 0, 
        width: 1, 
        color: '#808080' 
       }] 
      }, 
      tooltip: { 
       formatter: function() { 
         return '<b>'+ this.series.name +'</b><br/>'+ 
         this.x +': '+ this.y; 
       } 
      }, 
      legend: { 
       layout: 'vertical', 
       align: 'right', 
       verticalAlign: 'top', 
       x: -10, 
       y: 100, 
       borderWidth: 0 
      }, 
      series: [] 

     } 

     $.getJSON("data3.php", function(json) { 
      options.xAxis.categories = json[0]['data']; 
      options.series[0] = json[1]; 
    options.series[1] = json[2]; 
      chart = new Highcharts.Chart(options); 

     }); 
    }); 
+0

您可以與樣本數據的爵士小提琴,將重現你得到了同樣的問題 – Strikers 2013-05-10 06:56:29

回答

0

在這些線路:

options.series[0] = json[1]; 
options.series[1] = json[2]; 

您嘗試添加兩個系列,但基於您的JSON它meanas您嘗試引用系列中的一點,換句話說就是你的構造方式:

options.series[0] = 1325397600000; 
options.series[1] = 1325484000000; 

我建議熟悉正確的系列str (包括數據數組)。

http://docs.highcharts.com/#preprocessing