我有一个渲染 Highcharts网站上的图表,我需要在一段时间后清空它。现在我尝试使用这样的代码,但图表本身没有清空/没有任何变化......
var chart = new Highcharts.Chart({
// Chart settings
});
// Some other JS
function emptyChart(chart) {
chart.series = [];
chart.redraw();
}
// Some code and a function executes this function after some time
emptyChart(chart);
我在 Firebug 控制台或其他地方也没有收到任何错误,只是什么也没发生...
最佳答案
一个干净的方法来做到这一点:
function emptyChart(chart) {
while(chart.series.length !=0) {
chart.series[0].hide();
chart.series[0].remove();
}
}
如果您也希望轴消失,请使用“showEmpty: false”选项(选中 xAxis.showEmpty)
关于javascript - Highcharts - 重绘空图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11109921/