2013-05-09 283 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