I redraw the chart based on new data every second and it works and looks great, but I notice that it increases memory, like using 1 MB every second. Any way to fix this? I notice that if I only have static diagrams, then the memory is stabilized, but as soon as I add a constant redraw (to update the data), the memory usage never stops.
At first I thought it was because every time I created a new instance of the diagram, so I change the code, so every time it redraws the same instance, but it did not help at all.
Does anyone know how to fix this? Do I need to reset the old chart first?
google.setOnLoadCallback(test); var chart; var chartOptions; var chartCreate; function test() { chart = new google.visualization.DataTable(); chart.addColumn('string', 'Lorem'); chart.addColumn('number', 'Ipsum'); chart.addRows([ ['', 0] ]); chartOptions = {}; chartCreate = new google.visualization.LineChart(document.getElementById('chartDiv')); chartCreate.draw(chart, chartOptions); ]); } function test2() { chart.removeRows(0, 5); for (var i = 0; i < dataSpaceArray.length; ++i) { chart.addRow([dataTimeArray[i], dataSpaceArray[i], dataSpeedArray[i]]); } chartCreate.draw(chart, chartOptions); } setTimeout(test2,1000)
source share