2013-06-04 82 views
0

我有以下HighChart代码。我想通过一个对象使数据类型可用,而不是硬编码它,以便稍后我可以动态获取数据并分配给对象。请让我知道为此目的需要做出的必要更改。提前致谢。将数据动态传递给Highchart

$('#stackedChartContainer').highcharts({ 
       chart: { 
        type: 'column' 
       }, 
       title: { 
        text: '' 
       }, 
       xAxis: { 
        categories: ['IAS', 'Funding', 'Gilts', 'BuyOut'] 
       }, 
       yAxis: { 
        min: 0, 
        title: { 
         text: 'Millions' 
        }, 
        stackLabels: { 
         enabled: true, 
         style: { 
          fontWeight: 'bold', 
          color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' 
         } 
        } 
       }, 
       legend: { 
        align: 'right', 
        x: -100, 
        verticalAlign: 'top', 
        y: 20, 
        floating: true, 
        backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white', 
        borderColor: '#CCC', 
        borderWidth: 1, 
        shadow: false 
       }, 
       tooltip: { 
        formatter: function() { 
         return '<b>' + this.x + '</b><br/>' + 
         this.series.name + ': ' + this.y + '<br/>' + 
         'Total: ' + this.point.stackTotal; 
        } 
       }, 
       plotOptions: { 
        column: { 
         stacking: 'normal', 
         dataLabels: { 
          enabled: true, 
          color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white' 
         } 
        } 
       }, 
       series: [{ 
        name: 'Pensioners', 
        data: [800000000, 904080340, 961576651, 998929115] 
       }, { 
        name: 'Deferreds', 
        data: [700000000, 925466733, 1063478804, 1158224555] 
       }, { 
        name: 'Active', 
        data: [200000000, 265524863, 305739877, 333386521] 
       }] 
      }); 

回答