Charting library that does not cause memory leak when updating chart

爷,独闯天下 提交于 2020-01-01 10:16:50

问题


I want to build a page with interactively refreshing charts based on the data that is being fetched from the server asynchronously using AJAX. I really like jqPlot, but when trying to update the graph periodically (by calling replot(), without page refresh), it causes a huge browser memory leak. It seems to be a well known issue occurring on all major browsers.

I haven't tried Flot and protovis, but quick googling reveals that they seem to have the same problems.

Are you aware of any JavaScript charting library that does not introduce memory leak after several updates of the chart?


回答1:


You could take a look at Highcharts. A quick googling doesn't seem to indicate that memory leaks are much of an issue.




回答2:


to avoid jqPlot memory leak you have to remove binding and destry your chart:

var chart;

function yourTimedFunction(data) {
    if (chart) 
    {
        $('#chartDiv *').unbind(); // iexplorer
        chart.destroy();
    }
    chart = $.jqplot('chartDiv', ............. ); 
}


来源:https://stackoverflow.com/questions/5291049/charting-library-that-does-not-cause-memory-leak-when-updating-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!