+
+function drawGauge(targetelem, label, temp, options) {
+ var data = google.visualization.arrayToDataTable([["Label", "Value"],[label,temp]]);
+ // Create and draw the visualization.
+ if (targetelem)
+ {
+ options["width"] = targetelem.getAttribute("width");
+ options["height"] = targetelem.getAttribute("height");
+ var chart = new google.visualization.Gauge(targetelem);
+ chart.draw(data, 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', 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"}} );
+ drawLineGraph(document.getElementById('movementgooglegraph'), data["MovementSensorUpdate"],
+ {curveType: "none", title: 'Movement Sensors', vAxis: {maxValue: 10, minValue:0}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} );
+ });
+}
+