From: Bernhard Tittelbach Date: Tue, 8 Oct 2013 04:42:08 +0000 (+0000) Subject: google line graph X-Git-Url: https://git.realraum.at/?p=svn42.git;a=commitdiff_plain;h=0fae447f152153a46e52bc6e4277f11b4b34594e google line graph --- diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index 827861f..5011b33 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -44,7 +44,7 @@ function writeGooglePlusEvents(data, elem) ghtml += '

'+item.updated.substring(0,16).replace("T"," ")+'

'; ghtml += '

'+notetxt+'

'; if (noteimgs.length>0) - { + { var bigimglimit; ghtml += ''; if (noteimgs.length > 3) @@ -145,7 +145,7 @@ function loadCalendarKiosk() $.getJSON('/shmcache/grical_realraum.json', function(data){ var calhtml = ""; $.each(calendarItemEnhancer(data), function(index, itm) { - calhtml += '
  • '+itm.when+' - '+itm.title+'
  • '+"\n"; + calhtml += '
  • '+itm.when+' - '+itm.title+'
  • '+"\n"; }); calcontainer.innerHTML=''; }); @@ -177,6 +177,28 @@ function drawGauge(targetelem, label, temp, options) { } } +function drawLineGraph(targetelem, dataarray, options) { + if (dataarray) { + var data = google.visualization.arrayToDataTable(dataarray); + // Create and draw the visualization. + if (targetelem) + { + options["width"]= targetelem.getAttribute("width"); + options["height"]=targetelem.getAttribute("height"); + new google.visualization.LineChart(targetelem).draw(data, options); + } + } +} + +function loadAndDrawSensorData() { + $.getJSON("https://realraum.at/shmcache/r3sensors.json", function(data){ + drawLineGraph(document.getElementById('tempgooglegraph'), data["TempSensorUpdate"], + {curveType: "function", title: 'Temperature Sensors', vAxis: {maxValue: 29, minValue:5}, colors: ['#FF0000','#CC0033','#660000','#CC3333'], chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ); + drawLineGraph(document.getElementById('lightgooglegraph'), data["IlluminationSensorUpdate"], + {curveType: "none", title: 'Illumination Sensors', vAxis: {maxValue: 1024, minValue:5}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ); + }); +} + function writeAnwesenheitStatus(data) { var html=""; @@ -202,7 +224,7 @@ function writeAnwesenheitStatus(data) { anwesenheit_status_frontpage.innerHTML='
    '+data.status+'
    '; } - + if (data.sensors) { if (data.sensors.temperature) @@ -251,7 +273,7 @@ function writeAnwesenheitStatus(data) }); sensorstd+=''; - } + } if (sensorstd != "") { sensorshtml=''+sensorstd+'
    '; @@ -289,7 +311,7 @@ function highlightEntry(idx, color, value) if(value == 0) { if(idx%2 == 0) $('#upnext' + idx).css('background-color', 'white'); - else + else $('#upnext' + idx).css('background-color', '#E0E0E0'); } else { $('#upnext' + idx).css('background-color', color); @@ -364,7 +386,7 @@ function reloadImg(element) $(document).ready(function() { updateAnwesenheitStatus(); - setInterval("updateAnwesenheitStatus()", 10*1000); + setInterval("updateAnwesenheitStatus()", 10*1000); if (document.getElementById("dateclock")) { updateDateClock(new Date()); @@ -384,6 +406,11 @@ $(document).ready(function() { setInterval("updateSensors()",145*1000); } + if (document.getElementById("tempgooglegraph") || document.getElementById("lightgooglegraph")) + { + loadAndDrawSensorData(); + setInterval("loadAndDrawSensorData()",145*1000); + } if (document.getElementById("gplusevents")) { loadGooglePlusEvents();