From b05fa01a14831903c8c41a14a12ec68c55bde579 Mon Sep 17 00:00:00 2001 From: marc Date: Mon, 25 Jul 2011 23:37:42 +0200 Subject: =?UTF-8?q?Add=20custom=20color=20support,=20detail=20scale=20from?= =?UTF-8?q?=20-10=20to=20100=C2=B0C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebus/webapp/static/src/ebus.js | 58 +++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'ebus/webapp/static/src') diff --git a/ebus/webapp/static/src/ebus.js b/ebus/webapp/static/src/ebus.js index ad98d91..ae6ab29 100644 --- a/ebus/webapp/static/src/ebus.js +++ b/ebus/webapp/static/src/ebus.js @@ -7,18 +7,32 @@ $(document).ready(function(){ var plotOverview = null; var plotDetail = null; var indexFound = null; - var sensorList = [{"sensorname":"heizkreisregler9.solarDaten.tempKollektor","show":true}, - {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur","show":true}, - {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar","show":false}, - {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur","show":true}, - {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur","show":true}]; + var sensorList = [{"sensorname":"heizkreisregler9.solarDaten.tempKollektor","show":true, "color":"#f30000"}, + {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur","show":true, "color":"#283074"}, + {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar","show":false, "color":"#f0ff4c"}, + {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur","show":true, "color":"#84b500"}, + {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur","show":true, "color":"#48b4ff"}]; + var pickSensorConfig = function(sensorname) { + $.each(sensorList, function(i,sensorconfig) { + var sensor_found; + if (sensorconfig.sensorname == sensorname) { + sensorconfig_found = sensorconfig; + return false; + } else { + sensorconfig_found = false; + } + }); + return sensorconfig_found; + } var replot = function() { if (plotDetail == null) { plotDetail = $.plot($("#ebusgraph"), datasetDetail, { xaxis: { mode: "time"}, + yaxis: { min: -10, max: 100 }, legend: { show : true} + }); } else { plotDetail.setData(datasetDetail); @@ -46,20 +60,21 @@ $(document).ready(function(){ } plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true); }; - var plotSensor = function(sensorname) { - plotSensorDetail(sensorname); - plotSensorOverview(sensorname); + var plotSensor = function(sensorconfig) { + plotSensorDetail(sensorconfig); + plotSensorOverview(sensorconfig); }; var unplotSensor = function(sensorname) { unplotSensorDetail(sensorname); unplotSensorOverview(sensorname); }; - var plotSensorDetail = function(sensorname) { - $.getJSON("sensor/"+escape(sensorname)+"/"+from+"/"+to, + var plotSensorDetail = function(sensorconfig) { + $.getJSON("sensor/"+escape(sensorconfig.sensorname)+"/"+from+"/"+to, function(response) { if (response['data']) { datasetDetail.push({'data':response['data'], - 'label':sensorname}); + 'label':sensorconfig.sensorname, + 'color':sensorconfig.color}); replot(); } else { alert("Fehler: " + response["error"]); @@ -77,12 +92,13 @@ $(document).ready(function(){ }); }; - var plotSensorOverview = function(sensorname) { - $.getJSON("sensor_cached/"+escape(sensorname)+"/"+fromOverview, //+"/"+to, + var plotSensorOverview = function(sensorconfig) { + $.getJSON("sensor_cached/"+escape(sensorconfig.sensorname)+"/"+fromOverview, //+"/"+to, function(response) { if (response['data']) { datasetOverview.push({'data':response['data'], - 'label':sensorname}); + 'label':sensorconfig.sensorname, + 'color':sensorconfig.color}); replotOverview(); } else { alert("Overview Fehler: " + response["error"]); @@ -122,17 +138,17 @@ $(document).ready(function(){ } }); - $.each(sensorList, function(i,sensorname) { - var pickerDiv = $("
").attr("id","pick_"+sensorname.sensorname.replace(/\./g,"_")) + $.each(sensorList, function(i,sensorconfig) { + var pickerDiv = $("
").attr("id","pick_"+sensorconfig.sensorname.replace(/\./g,"_")) .addClass("picker") .appendTo("#sensorpicker"); var pickerCheckbox = $("").attr("type","checkbox") .appendTo(pickerDiv); - $(pickerDiv).append(sensorname.sensorname); - if (sensorname.show) { + $(pickerDiv).append(sensorconfig.sensorname); + if (sensorconfig.show) { //Plot - plotSensor(sensorname.sensorname); + plotSensor(sensorconfig); $(pickerCheckbox).attr("checked","checked"); } }); @@ -141,8 +157,8 @@ $(document).ready(function(){ $('.picker input').click( function() { var sensorname = $(this).parent().attr("id").replace("pick_","").replace(/_/g,"."); - if ($(this).is(":checked")) { - plotSensor(sensorname); + if ($(this).is(":checked")) { + plotSensor(pickSensorConfig(sensorname)); } else { unplotSensor(sensorname); } -- cgit v1.2.1