2013-06-23 98 views
-7

我使用Highchart,我想設置數據但SetData()不適用於柱狀圖。setdata()和柱狀圖

我在這裏發現問題,談論我有同樣的問題,但我找不到解決方案。

這裏是我的代碼源:

<script src="http://code.highcharts.com/highcharts.js"></script> 
<script src="http://code.highcharts.com/modules/exporting.js"></script> 

<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> 
<input type="button" id="button" value="click" style="width:200px"> 

$(function() { 
     var x = new Highcharts.Chart({ 
      chart: { 
       type: 'column', 
       renderTo: 'container' 
      }, 
      title: { 
       text: 'Monthly Average Rainfall' 
      }, 
      subtitle: { 
       text: 'Source: WorldClimate.com' 
      }, 
      xAxis: { 
       categories: [ 
        'Jan', 
       ] 
      }, 
      yAxis: { 
       min: 0, 
       title: { 
        text: 'Rainfall (mm)' 
       } 
      }, 
      tooltip: { 
       headerFormat: '<span style="font-size:10px">{point.key}</span><table>', 
       pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' + 
        '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>', 
       footerFormat: '</table>', 
       shared: true, 
       useHTML: true 
      }, 
      plotOptions: { 
       column: { 
        pointPadding: 0.2, 
        borderWidth: 0 
       } 
      }, 
      series: [{ 
       name: 'Tokyo', 
       data: [49.9] 

      }] 
     }); 

$("#button").click(function() 
      { 
      x.series[0].setData(30); 
      } 
    ); 
    }); 

http://jsfiddle.net/foxgenki/Nf2xb/

+0

同意,並對不起 – Fox

回答

1

看來你haven't looked hard enough

$("#button").click(function() { 
    x.series[0].setData([30]); 
}); 

setData接受一個列表作爲參數,而不是數字。