我想建立一个交互式刷新的图表。我使用 jqPlot,但通过尝试调用 replot() 或重绘来更新图形会导致巨大的浏览器内存泄漏。你知道我该如何解决吗?
function crateChart() {
var s1 = [['a',6], ['b',8], ['c',14], ['d',20]];
var s2 = [['a', 8], ['b', 12], ['c', 6], ['d', 9]];
this.plot = $.jqplot('chart', [s1, s2], {
seriesDefaults: {
renderer:$.jqplot.DonutRenderer,
rendererOptions:{
sliceMargin: 3,
startAngle: -90,
showDataLabels: true,
dataLabels: 'value'
}
}
});
}
function update () {
ChartTester.plot.series[0].data = [
['a', Math.random() * 100],
['b', Math.random() * 100],
['c', Math.random() * 100],
['d', Math.random() * 100]
];
ChartTester.plot.destroy();
$('#chart *').unbind();
$('#chart').empty();
ChartTester.plot.redraw();
}