Reputation: 165
I am trying to reset data in a stacked chart on a button click in highcharts Here is my work so far
It is not working
Can you please help with this one? thanks.
Just to clarify I took the help of below two examples
http://www.highcharts.com/demo/column-stacked
Edit on button works for simple graphs, however I could not make it work for stacked columns.
Upvotes: 0
Views: 8317
Reputation: 5367
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/
Upvotes: 2
Reputation: 2282
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
Upvotes: 6