0
votes

I am trying to reset data in a stacked chart on a button click in highcharts Here is my work so far

http://jsfiddle.net/N9WJ9/1/

It is not working

Can you please help with this one? thanks.

Just to clarify I took the help of below two examples

http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/highcharts/members/series-setdata/

http://www.highcharts.com/demo/column-stacked

Edit on button works for simple graphs, however I could not make it work for stacked columns.

2

2 Answers

2
votes

For that you are going to have to re-draw the HighChart or initialize the Object again.

 $('#button').click(function() {
    $("#container").empty(); 

    options.series = [];
    options.series.push({
        name: 'Test',
        data: [10, 10, 10, 10, 10]
    });
    options.series.push({
        name: 'Test2',
        data: [5, 5, 5, 5, 5]
    });
    options.series.push({
        name: 'Test3',
        data: [4, 4, 4, 4, 4]
    });
    chart = new Highcharts.Chart(options);
});

http://jsfiddle.net/dane/YUa3R/34/

6
votes

Use the following code in button click:

chart.series[0].setData([10, 10, 10, 10, 10]);
   chart.series[1].setData([5, 5, 5, 5, 5]);
   chart.series[2].setData([4, 4, 4, 4, 4]);

Check out this FIDDLE