diff options
author | marc <you@example.com> | 2011-08-01 17:38:14 +0200 |
---|---|---|
committer | marc <you@example.com> | 2011-08-01 17:38:14 +0200 |
commit | 0ad590fcb3c4749335716ad1d16442a3fef2bb32 (patch) | |
tree | 9c8d7f3691167b69b9df4434a644e039e268c2eb /ebus | |
parent | a4b207ae33a42cde29239789d6d47ae5fcd2b634 (diff) | |
download | ebus-alt-0ad590fcb3c4749335716ad1d16442a3fef2bb32.tar.gz ebus-alt-0ad590fcb3c4749335716ad1d16442a3fef2bb32.zip |
Fixed problems with custom color
Diffstat (limited to 'ebus')
-rw-r--r-- | ebus/webapp/static/src/ebus.js | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/ebus/webapp/static/src/ebus.js b/ebus/webapp/static/src/ebus.js index ad98d91..ba14f51 100644 --- a/ebus/webapp/static/src/ebus.js +++ b/ebus/webapp/static/src/ebus.js @@ -7,17 +7,29 @@ $(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 sensorConfigList = [{"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) { + var SensorConfigFound; + $.each(sensorConfigList, function(i,sensorConfig) { + if (sensorConfig.sensorname == sensorname) { + sensorConfigFound = sensorConfig; + return false; + } + }); + return sensorConfigFound; + } var replot = function() { if (plotDetail == null) { plotDetail = $.plot($("#ebusgraph"), datasetDetail, { xaxis: { mode: "time"}, + yaxis: { min: -10, max: 100 }, legend: { show : true} }); } else { @@ -46,20 +58,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 +90,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"]); @@ -118,21 +132,21 @@ $(document).ready(function(){ } datasetDetail =[]; for (i in sensors) { - plotSensorDetail(sensors[i]); + plotSensorDetail(pickSensorConfig(sensors[i])); } }); - $.each(sensorList, function(i,sensorname) { - var pickerDiv = $("<div>").attr("id","pick_"+sensorname.sensorname.replace(/\./g,"_")) + $.each(sensorConfigList, function(i,sensorConfig) { + var pickerDiv = $("<div>").attr("id","pick_"+sensorConfig.sensorname.replace(/\./g,"_")) .addClass("picker") .appendTo("#sensorpicker"); var pickerCheckbox = $("<input>").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"); } }); @@ -142,7 +156,7 @@ $(document).ready(function(){ $('.picker input').click( function() { var sensorname = $(this).parent().attr("id").replace("pick_","").replace(/_/g,"."); if ($(this).is(":checked")) { - plotSensor(sensorname); + plotSensor(pickSensorConfig(sensorname)); } else { unplotSensor(sensorname); } |