-7

我使用 Highchart,我想要设置数据,但 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/

4

1 回答 1

1

看来你还不够努力

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

setData接受列表作为参数,而不是数字。

于 2013-06-23T09:45:08.353 回答