Reputation: 10010
Is it possible to update a Morris chart dynamically? I know setData()
will update the data, but I want to update the settings. Namely, the user being able to select if a bar chart is stacked or not.
I have tried:
bChart.stacked = true;
bChart.setData(response);
... because setData()
will redraw. I also tried bChart.redraw();
. There was no change.
Any ideas welcome.
Upvotes: 2
Views: 7486
Reputation: 5849
You were 90% there. You would need to set bChart.options.stacked
to true;
then do bChart.redraw();
.
Therefore, the code for toggling stacked bars is the following (if you are using jQuery):
jQuery(function($) {
$('#stacked').on('change', function() {
bChart.options.stacked = $(this).is(':checked');
bChart.redraw();
});
});
Providing that the checkbox toggling this option has a #stacked
ID.
Upvotes: 5