I\'m redrawing the chart based on new data each second, and it works and looks great, but I notice it increase memory like 1 MB usage each second. Any way to fix this? I notice
I've solved this by globaly store the chart. Before draw the chart, you need to check if chart has been instantiated. If not, create the new chart object else call clearChart() method before draw it. Like this:
//Store all chart objects in a global array to avoid memory leak
var charts = [];
function drawChart(chartName, element, data, chartOptions) {
if (charts[chartName] === undefined || charts[chartName] === null) {
charts[chartName] = new google.visualization.LineChart(group);
} else {
charts[chartName].clearChart();
}
charts[chartName].draw(dataTable, chartOptions);
}