From 06ab21d9e0c65a3f9ea14682ed06ff1ac6fe13cd Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Wed, 9 Oct 2013 02:56:13 +0000 Subject: [PATCH] possibly save some memory --- raspberry-kiosk/kiosk.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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); } } } -- 1.7.10.4