user1530249
user1530249

Reputation: 1057

Using HighCharts setData for multiple variables?

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/

Upvotes: 1

Views: 11581

Answers (1)

Nils
Nils

Reputation: 2071

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/

Upvotes: 6

Related Questions