2013-05-20 136 views
0

我是新來的使用highcharts和工作的例子。 我在高樓裏顯示一些數據時遇到問題。Highcharts - 不同顯示月份

這裏是我的系列數據(的var_dump)

'series_data' => string '[ 
{name:'Inmobi',data:[ 
    [Date.UTC(2013, 05, 01),311328],[Date.UTC(2013, 05, 02),363780], 
    [Date.UTC(2013, 05, 03),364062],[Date.UTC(2013, 05, 04),283128], 
    [Date.UTC(2013, 05, 05),322608]] }, 
{name:'Buzz City',data:[ 
    [Date.UTC(2013, 05, 01),363216],[Date.UTC(2013, 05, 02),404670], 
    [Date.UTC(2013, 05, 03),370783],[Date.UTC(2013, 05, 04),459942], 
    [Date.UTC(2013, 05, 05),569499]] }]' 

當顯示highcharts,當月轉移到六月(應該是五月)。 https://www.dropbox.com/s/girftyfs8a71n9k/highcharts.jpg

我想知道是什麼問題。

這裏是highcharts渲染腳本

<script language="javascript"> 
var chart_type = 'column'; 
var series_data = <?=$series_data?>; 

    var chart; 
    chart = new Highcharts.Chart({ 
     chart: { 
      renderTo: 'site_statistics', 
     type: chart_type 
     }, 
     title: { 
      text: 'Ad Spend', 
      x: -20 //center 
     }, 
     xAxis: { 
      title: { 
       text: 'Date ' 
      }, 
     type: 'datetime', 
      dateTimeLabelFormats: { 
       minute: '%H:%M', 
       hour: '%H:%M', 
       day: '%e %b', 
       week: '%e %b', 
       month: '%b \'%y', 
       year: '%Y' 
     }, 
     tickInterval: 24 * 3600 * 1000 
     }, 
     yAxis: { 
      title: { 
       text: 'Cost ' 
      }, 
      plotLines: [{ 
       value: 0, 
       width: 1, 
       color: '#808080' 
      }] 
     }, 
     tooltip: { 
      formatter: function() { 
        return '<b>'+ this.series.name +'</b><br/>'+ 
        Highcharts.dateFormat('%a %d %b',this.x) +': '+ accounting.formatMoney(this.y, "Rp", 0, ".", "") +''; 
      } 
     }, 
     credits: { 
      enabled: false 
     }, 
     series: series_data 
    }); 

我高度讚賞的任何幫助。

問候

+0

可能是你需要減去1個月因爲JS數組開始0 –

回答

1

這是正確的,因爲在Highcharts個月的名稱默認情況下開始從0到11 從0-一月到十二月11-。

enter image description here

所以對於月份可能你應該寫4,而不是5