问题
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