From: Bernhard Tittelbach Date: Wed, 9 Oct 2013 02:56:13 +0000 (+0000) Subject: possibly save some memory X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=06ab21d9e0c65a3f9ea14682ed06ff1ac6fe13cd;p=svn42.git possibly save some memory --- diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index 420e5af..ef1e420 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -164,7 +164,7 @@ function loadCalendarMainPage() }); } - +var gauges = {} function drawGauge(targetelem, label, temp, options) { var data = google.visualization.arrayToDataTable([["Label", "Value"],[label,temp]]); // Create and draw the visualization. @@ -172,11 +172,14 @@ function drawGauge(targetelem, label, temp, options) { { options["width"] = targetelem.getAttribute("width"); options["height"] = targetelem.getAttribute("height"); - var chart = new google.visualization.Gauge(targetelem); - chart.draw(data, options); + if (!gauges.hasOwnProperty(targetelem.id)) { + gauges[targetelem.id] = new google.visualization.Gauge(targetelem); + } + gauges[targetelem.id].draw(data, options); } } +var linecharts = {} function drawLineGraph(targetelem, dataarray, options) { if (dataarray) { var data = google.visualization.arrayToDataTable(dataarray); @@ -185,7 +188,10 @@ function drawLineGraph(targetelem, dataarray, options) { { options["width"]= targetelem.getAttribute("width"); options["height"]=targetelem.getAttribute("height"); - new google.visualization.LineChart(targetelem).draw(data, options); + if (!linecharts.hasOwnProperty(targetelem.id)) { + linecharts[targetelem.id] = new google.visualization.LineChart(targetelem); + } + linecharts[targetelem.id].draw(data, options); } } }