Using HighCharts setData for multiple variables?

本小妞迷上赌 提交于 2019-12-23 03:04:07

问题


High Charts API http://api.highcharts.com/highcharts#Series.setData()

javascript

....

        $('#button').click(function() {
            chart.series[0].setData(   //How can I use this method to add the data?                  
                    ['Firefox',   55.0],
                    ['IE',       16.8],
                    ['Safari',    7.5],
                    ['Opera',     7.2],
                    ['Others',   0.7]
 );

See full code and example on jfiddle http://jsfiddle.net/bK7fh/


回答1:


You forgot that set data takes an array of data, not lots of arrays.

Here is an example:

$('#button').click(function () {
        chart.series[0].setData([
            ['Firefox', 55.0],
            ['IE', 16.8],
            ['Safari', 7.5],
            ['Opera', 7.2],
            ['Others', 0.7]
        ]);
 });

Here is your fiddle, and working: http://jsfiddle.net/bK7fh/2/



来源:https://stackoverflow.com/questions/14417601/using-highcharts-setdata-for-multiple-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!