diff options
author | Ebus-at-dockstar <ebus@dockstar> | 2013-02-25 18:21:49 +0100 |
---|---|---|
committer | Ebus-at-dockstar <ebus@dockstar> | 2013-02-25 18:21:49 +0100 |
commit | 13222c58142aa6b3bdf50525a250a81c4ab52d55 (patch) | |
tree | fde396c8cff36a944019f9615274c947400daff5 /ebus/webhdf/static/src | |
parent | 37e334d24a099e5367597ee18ac0c6d5ae2fba32 (diff) | |
download | ebus-alt-13222c58142aa6b3bdf50525a250a81c4ab52d55.tar.gz ebus-alt-13222c58142aa6b3bdf50525a250a81c4ab52d55.zip |
web hdf server
Diffstat (limited to 'ebus/webhdf/static/src')
-rw-r--r-- | ebus/webhdf/static/src/ebus.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/ebus/webhdf/static/src/ebus.js b/ebus/webhdf/static/src/ebus.js index 7667b71..ce37557 100644 --- a/ebus/webhdf/static/src/ebus.js +++ b/ebus/webhdf/static/src/ebus.js @@ -1,15 +1,19 @@ var d = new Object(); -d.sec = 1; +d.ms = 1; +d.sec = 1000 * d.ms; d.min = 60 * d.sec; d.hour = 60 * d.min; d.day = 24 * d.hour; d.week = 7 * d.day; d.month = 30.5 * d.day; - +d.now = new Date().getTime(); + +function int(n) { return Math.round(n); }; + $(document).ready(function(){ - var from = Math.round(new Date().getTime()/1000) - 2*d.day; - var fromOverview = Math.round(new Date().getTime()/1000) - 15*d.day; - var to = Math.round(new Date().getTime()/1000); + var from = d.now - 5*d.day; + var fromOverview = d.now - 30*d.day; + var to = d.now; var datasetDetail = [] var datasetOverview = []; var plotOverview = null; @@ -33,19 +37,13 @@ $(document).ready(function(){ return sensorConfigFound; } var replot = function() { - if (plotDetail == null) { plotDetail = $.plot($("#ebusgraph"), datasetDetail, { - xaxis: { mode: "time"}, + xaxis: { mode: "time", min: from, max:to }, yaxis: { min: -16, max: 100 }, legend: { show : true} }); - } else { - plotDetail.setData(datasetDetail); - plotDetail.draw(); - plotDetail.setupGrid(); // redraw legend - } }; var replotOverview = function() { if (plotOverview == null) { @@ -56,7 +54,7 @@ $(document).ready(function(){ lines: { show: true, lineWidth: 1 }, shadowSize: 0 }, - xaxis: { mode: "time" }, + xaxis: { mode: "time", min: fromOverview, max: d.now }, yaxis: { ticks: [], min: -26, max: 100, autoscaleMargin: 0.1 }, legend: { show: false }, selection: { mode: "x" } @@ -65,7 +63,7 @@ $(document).ready(function(){ plotOverview.setData(datasetOverview); plotOverview.draw(); } - plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true); + plotOverview.setSelection({xaxis: {'from': from, 'to': to}}, true); }; var plotSensor = function(sensorConfig) { plotSensorDetail(sensorConfig); @@ -76,20 +74,20 @@ $(document).ready(function(){ unplotSensorOverview(sensorname); }; var tzFix = function(d) { - return d - new Date().getTimezoneOffset() * 60 * 1000; + return d; //return d - new Date().getTimezoneOffset() * 60 * 1000; } var plotSensorDetail = function(sensorConfig) { - $.getJSON("sensor/"+escape(sensorConfig.sensorname)+"/"+from+"/"+to, + $.getJSON("sensor/"+escape(sensorConfig.sensorname)+"/"+int(from/1000)+"/"+int(to/1000), function(response) { - if (response['data']) { + if (!response.error) { response.data = response.data.map(function(d) { return [ tzFix(d[0]), d[1] ]; }); datasetDetail.push({'data':response['data'], 'label':sensorConfig.sensorname, 'color':sensorConfig.color}); replot(); } else { - alert("Fehler: " + response["error"]); + console.log("Fehler: " + response["error"]); } }); }; @@ -105,9 +103,9 @@ $(document).ready(function(){ }; var plotSensorOverview = function(sensorConfig) { - $.getJSON("avg/"+escape(sensorConfig.sensorname)+"/"+fromOverview, + $.getJSON("avg/"+escape(sensorConfig.sensorname)+"/"+int(fromOverview/1000), function(response) { - if (response['data']) { + if (!response.error) { response.data = response.data.map(function(d) { return [ tzFix(d[0]), d[1] ]; }); datasetOverview.push({'data':response['data'], 'label':sensorConfig.sensorname, @@ -130,11 +128,12 @@ $(document).ready(function(){ } $("#overview").bind("plotselected", function (event, ranges) { - range_from = Math.round(ranges.xaxis.from / 1000); - range_to = Math.round(ranges.xaxis.to / 1000); + range_from = Math.round(ranges.xaxis.from); + range_to = Math.round(ranges.xaxis.to); // max selection range - if (range_to - range_from > d.month/2) { - plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true); + if (range_to - range_from > d.month) { + // reset selection + plotOverview.setSelection({xaxis: {'from': from, 'to': to}}, true); return; } else { from = range_from; @@ -177,3 +176,4 @@ $(document).ready(function(){ } }); }); + |