且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Highcharts:使用相同的div使用不同的系列数据多次加载图表

更新时间:2023-01-04 17:52:32

由于您使用的是jQuery,您是否尝试过按照以下步骤清空容器div,然后重绘图表?

Since you're using jQuery, have you tried simply emptying the container div as follows before redrawing the chart?

$('#container').html();

这也许会更有益,因为chart.destroy()在您的情况下似乎不起作用.

Perhaps this would be more beneficial since chart.destroy() doesn't seem to be working in your case.

来自 http://api.jquery.com/html/#html2 :

使用.html()设置元素的内容时,该元素中的所有内容都将被新内容完全替换.此外,在用新内容替换子元素之前,jQuery从子元素中删除了其他构造,例如数据和事件处理程序.

When .html() is used to set an element's content, any content that was in that element is completely replaced by the new content. Additionally, jQuery removes other constructs such as data and event handlers from child elements before replacing those elements with the new content.