admin管理员组文章数量:1296858
I have a rendered Highcharts chart on a website and I need to empty it after a certain time. Now I tried that with such code but the chart doesn't empty itself/nothing changes...
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);
I also don't get any error in the Firebug console or somewhere else, just nothing happens...
I have a rendered Highcharts chart on a website and I need to empty it after a certain time. Now I tried that with such code but the chart doesn't empty itself/nothing changes...
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);
I also don't get any error in the Firebug console or somewhere else, just nothing happens...
Share Improve this question edited Aug 16, 2013 at 1:23 SheetJS 22.9k12 gold badges67 silver badges76 bronze badges asked Jun 19, 2012 at 21:44 PoruPoru 8,37022 gold badges67 silver badges90 bronze badges5 Answers
Reset to default 4A clean way to do this :
function emptyChart(chart) {
while(chart.series.length !=0) {
chart.series[0].hide();
chart.series[0].remove();
}
}
If you want your axis to disappear as well, use the "showEmpty: false" option (check xAxis.showEmpty )
I guess, you want something like this,
chart.series[0].data = [];
chart.redraw();
I had this problem already a second time and now I finally found a simple but currently only-working solution: Just create a new, empty Highchart:
function emptyChart(chart) {
chart = new Highcharts.Chart(/* chartOptions */);
}
Just a guess, but try changing to chart.series = {};
?
You can also use setData([])
http://api.highcharts./highcharts#Series.setData()
本文标签: javascriptHighchartsRedraw empty chartStack Overflow
版权声明:本文标题:javascript - Highcharts - Redraw empty chart - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741644643a2390114.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论