summaryrefslogtreecommitdiff
path: root/ebus/webapp/static/ebus.js
diff options
context:
space:
mode:
authoryvesf <yvesf-git@xapek.org>2011-07-17 16:48:18 +0200
committeryvesf <yvesf-git@xapek.org>2011-07-17 16:48:18 +0200
commitd07518ee1a41dd652c83af47e8914275d709288d (patch)
tree8298bdcd5ee905daefe050e1eb6d3ebf635d9ab6 /ebus/webapp/static/ebus.js
parent578f530ca0d0c01166b9a28fd0b2e0ab0ef750cc (diff)
downloadebus-alt-d07518ee1a41dd652c83af47e8914275d709288d.tar.gz
ebus-alt-d07518ee1a41dd652c83af47e8914275d709288d.zip
webapp: bereichsauswahl
Diffstat (limited to 'ebus/webapp/static/ebus.js')
-rw-r--r--ebus/webapp/static/ebus.js72
1 files changed, 58 insertions, 14 deletions
diff --git a/ebus/webapp/static/ebus.js b/ebus/webapp/static/ebus.js
index dc86cda..afd667f 100644
--- a/ebus/webapp/static/ebus.js
+++ b/ebus/webapp/static/ebus.js
@@ -2,37 +2,61 @@ $(document).ready(function(){
var from = Math.round(new Date().getTime()/1000) - 3*24*60*60; //86400;
var fromOverview = Math.round(new Date().getTime()/1000) - 30*24*60*60; //86400;
var to = Math.round(new Date().getTime()/1000);
- var dataset = []
+ var datasetDetail = []
var datasetOverview = [];
+ var plotOverview = null;
+ var plotDetail = null;
+
var replot = function() {
- $.plot($("#ebusgraph"),
- dataset,
- { xaxis: { mode: "time"}});
+ if (plotDetail == null) {
+ plotDetail = $.plot($("#ebusgraph"),
+ datasetDetail,
+ {
+ xaxis: { mode: "time"},
+ legend: { show : true}
+ });
+ } else {
+ plotDetail.setData(datasetDetail);
+ plotDetail.draw();
+ plotDetail.setupGrid(); // redraw legend
+ }
};
var replotOverview = function() {
- $.plot($("#overview"),
- datasetOverview,
- {
- series: {
- lines: { show: true, lineWidth: 1 },
- shadowSize: 0
- },
- xaxis: { mode: "time" },
- yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
+ if (plotOverview == null) {
+ plotOverview = $.plot($("#overview"),
+ datasetOverview,
+ { // options
+ series: {
+ lines: { show: true, lineWidth: 1 },
+ shadowSize: 0
+ },
+ xaxis: { mode: "time" },
+ yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
selection: { mode: "x" }
});
+ } else {
+ plotOverview.setData(datasetOverview);
+ plotOverview.draw();
+ }
+ plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
};
var plotSensor = function(sensorname) {
+ plotSensorDetail(sensorname);
+ plotSensorOverview(sensorname);
+ }
+ var plotSensorDetail = function(sensorname) {
$.getJSON("/sensor/"+escape(sensorname)+"/"+from+"/"+to,
function(response) {
if (response['data']) {
- dataset.push({'data':response['data'],
+ datasetDetail.push({'data':response['data'],
'label':sensorname});
replot();
} else {
alert("Fehler: " + response["error"]);
}
});
+ };
+ var plotSensorOverview = function(sensorname) {
$.getJSON("/sensor_cached/"+escape(sensorname)+"/"+fromOverview, //+"/"+to,
function(response) {
if (response['data']) {
@@ -46,6 +70,26 @@ $(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);
+ if (range_to - range_from > 4 * 24 * 60 * 60) {
+ plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
+ return;
+ } else {
+ from = range_from;
+ to = range_to;
+ }
+ sensors = [];
+ for (elem in datasetOverview) {
+ sensor = datasetDetail[elem]["label"];
+ sensors.push(sensor);
+ }
+ datasetDetail =[];
+ for (i in sensors) {
+ plotSensorDetail(sensors[i]);
+ }
+ });
plotSensor("heizkreisregler9.solarDaten.tempKollektor");
//ausreisser// plotSensor("heizkreisregler9.solarDaten.tempWarmwasserSolar");