2013-02-14 111 views
1

我正在嘗試創建向下鑽取Highcharts列圖。只要數據是硬編碼的,我就可以使用這些示例並使其工作。我也可以從我的MySQL數據庫中獲取數據的例子。Highcharts:列向下鑽取:JSON

我需要知道的是如何在系列中調用。

實施例:

/// This needs to be data from the MySQL (a total sum) of X-data 
name = 'Browser brands', 
data = [{ 
y: 55.11, 
color: colors[0], 
////// this drill down needs the a breakdown of the data 
drilldown: { 
name: 'MSIE versions', 
categories: ['MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'], 
data: [10.85, 7.35, 33.06, 2.81], 
color: colors[0] 
} 
///////// I need another drill that will show a breakdown of the data again 
} 
/// This needs to be data from the MySQL (a total sum) of y-data 
name = 'Browser brands', 
data = [{ 
y: 55.11, 
color: colors[0], 
////// this drill down needs the a breakdown of the data 
drilldown: { 
name: 'MSIE versions', 
categories: ['MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'], 
data: [10.85, 7.35, 33.06, 2.81], 
color: colors[0] 
} 
///////// I need another drill that will show a breakdown of the data again 
} 

所以理論上如何可以有一個圖表的一個第一系列示出了總的X,Y,Z 被點擊時或者,它顯示了一個突破該數據的下降,當任何一個下一列被點擊時,再次顯示數據的進一步分解。

我知道有多個MySQL查詢,多個數組。我只是不明白如何調用它們所需

+0

您是否需要多次下鑽?看例子:http://jsfiddle.net/NULTY/390/(第一列) – 2013-02-14 12:09:32

+0

謝謝你的回覆。這開始有所幫助。除了我需要的每個數據點都是從MySQL中提取的數據。我不確定如何發出呼叫來獲取信息。我知道如果它只是一個包含所有數據的圖表,我會這樣做... $。getJSON(「data.php」,function(json){ – Mike 2013-02-14 13:35:10

回答

1

時看看這一部分:

click: function() { 
       var drilldown = this.drilldown; 
       if (drilldown) { // drill down 

        this.series.chart.setTitle({ 
         text: drilldown.name 
        }); 

        setChart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color, drilldown.level); 
       } else { // restore 
        setChart(name, categories, data, null, level); 
       } 
       } 

只需使用$ .getJSON()那裏,和內部的$ .getJSON()使用setChart ()方法與來自AJAX的數據。像這樣(未測試):

click: function() { 
       var drilldown = this.drilldown; 
       if (drilldown) { // drill down 
        var chart = this.series.chart; 
        $.getJSON(...., function(data){ 
         chart.setTitle({ 
          text: data.name 
         }); 
         setChart(data.name, data.categories, data.data, data.color, data.level); 
        }); 
       } else { // restore 
        setChart(name, categories, data, null, level); 
       } 
       }