[英]Highcharts - Redraw/Resize chart after destroying legend?
I am building several charts on the fly on some of them I remove the legend using chart.legend.destroy(). 我正在动态建立一些图表,其中一些图表是使用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.
我已经尝试了chart.reflow()和chart.redraw,但是这些图表本身不会“调整”并保持相同的大小,就像图例仍在其中一样。
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. 您可以销毁图例,但Highcharts不会意识到需要为丢失的图例重新进行调整。 So, you need to set it's display to
false
. 因此,您需要将其显示设置为
false
。 But now Highcharts doesn't realize it's dirty
so it won't redraw. 但是现在Highcharts并没有意识到它
dirty
因此不会重绘。 So... 所以...
var chart = Highcharts.charts[0];
chart.legend.destroy();
chart.legend.display = false;
chart.isDirtyBox = true;
chart.redraw();
You can call setSize like in the example: 您可以像示例中那样调用setSize:
if(legend.display) {
chart.setSize(600,400);
legend.group.hide();
legend.display = false;
} else {
chart.setSize(500,400);
legend.group.show();
legend.display = true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.