2013-03-26 38 views
0

我是新來的Highcharts,我已經喜歡它。 我做了一些使用json,php en mysql的柱形圖(給出的例子)。 現在我想使用json製作帶有列和行的圖表。 有人可以告訴我如何做到這一點?通過使用json_encode()在PHP http://docs.highcharts.com/#preprocessing-data-from-a-database 高柱圖與列和行使用JSON

  • 返回數組作爲JSON,然後用它在Highcharts:

    $(function() { 
    var chart; 
    $(document).ready(function() { 
        $.getJSON("DataKwhDagCum.php", function(json) {  
         chart = new Highcharts.Chart({ 
          chart: { 
           renderTo: 'container', 
           type: 'column', 
           marginRight: 130, 
           marginBottom: 25 
          }, 
          title: { 
           text: 'In (Enexis) vs Out (Zonnestroom)', 
           x: -20 //center 
          }, 
          subtitle: { 
           text: '', 
           x: -20 
          }, 
          xAxis: { 
           categories: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20','21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'] 
          }, 
          yAxis: { 
           title: { 
            text: 'Amount' 
           }, 
           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: json 
         }); 
        }); 
    
    }); 
    
    }); 
    
  • +1

    您應該首先開始編碼,然後我們會在您遇到問題時解救您:D – fedorqui 2013-03-26 15:44:17

    +0

    您卡在哪裏?你能描述你未能達到你要找的結果嗎? – Shog9 2013-03-27 23:29:02

    回答

    0

    你可以用兩種方式

    • 使用PHP和腳本在同一個文件。