admin管理员组

文章数量:1312741

High Charts API .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 /

High Charts API http://api.highcharts./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/bK7fh/

Share Improve this question asked Jan 19, 2013 at 18:47 user1530249user1530249 1,0573 gold badges19 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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/bK7fh/2/

本文标签: javascriptUsing HighCharts setData for multiple variablesStack Overflow