Reputation: 975
I am building several charts on the fly on some of them I remove the legend using chart.legend.destroy(). I have tried chart.reflow() and chart.redraw but the charts do not "refit" themselves and stay the same size as if the legend was still there.
Upvotes: 0
Views: 2773
Reputation: 37578
You can call setSize like in the example:
if(legend.display) {
chart.setSize(600,400);
legend.group.hide();
legend.display = false;
} else {
chart.setSize(500,400);
legend.group.show();
legend.display = true;
}
Upvotes: 0
Reputation: 108512
This is a little convoluted.
You can destroy the legend but Highcharts doesn't recognize that it needs to re-adjust for a missing legend. So, you need to set it's display to false
. But now Highcharts doesn't realize it's dirty
so it won't redraw. So...
var chart = Highcharts.charts[0];
chart.legend.destroy();
chart.legend.display = false;
chart.isDirtyBox = true;
chart.redraw();
See example here.
Upvotes: 1