From e707723250d46cf03faf7537532d1c1f4b046cb7 Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Thu, 26 Dec 2019 19:58:53 +0100 Subject: [PATCH] modify graph --- snippets/graph2.html | 57 +++++++++++++++++++++++++++++++++++++++----- snippets/scales.html | 10 ++++---- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/snippets/graph2.html b/snippets/graph2.html index 7547072..2109579 100644 --- a/snippets/graph2.html +++ b/snippets/graph2.html @@ -17,27 +17,27 @@
- + - + - + - + - + @@ -51,6 +51,8 @@ $(function() { var start = moment({hour: 0}); var end = moment(); + var s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); + var s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); console.log("XXX: "+start.format()); @@ -63,6 +65,36 @@ $(function() { reloadGraph(s_start,s_end); } + $('#btn_w').on("click", function() { + if (urlParams.toString().indexOf("property=w") == -1) { + location.href = location.href.replace(/property=w|property=t|property=p|property=h|property=vp/, 'property=w'); + } + }); + + $('#btn_t').on("click", function() { + if (urlParams.toString().indexOf("property=t") == -1) { + location.href = location.href.replace(/property=w|property=t|property=p|property=h|property=vp/, 'property=t'); + } + }); + + $('#btn_h').on("click", function() { + if (urlParams.toString().indexOf("property=h") == -1) { + location.href = location.href.replace(/property=w|property=t|property=p|property=h|property=vp/, 'property=h'); + } + }); + + $('#btn_p').on("click", function() { + if (urlParams.toString().indexOf("property=p") == -1) { + location.href = location.href.replace(/property=w|property=t|property=p|property=h|property=vp/, 'property=p'); + } + }); + + $('#btn_vp').on("click", function() { + if (urlParams.toString().indexOf("property=vp") == -1) { + location.href = location.href.replace(/property=w|property=t|property=p|property=h|property=vp/, 'property=vp'); + } + }); + $('#reportrange').daterangepicker({ startDate: start, endDate: end, @@ -131,6 +163,7 @@ function reloadGraph(start, stop) { range = "" range = range + "&start=" + start; range = range + "&stop=" + stop; + alert(sPageURL); $.getJSON('https://mini-beieli.ch/metrics?' + sPageURL + range, function(mydata) { chart.updateSeries([{ data: mydata @@ -163,22 +196,27 @@ $('#reportrange span').html(moment(start).format('D. MMMM YYYY') + ' - ' + momen var sPageURL = window.location.search.substring(1); var label; if (sPageURL.search("property=t") > -1) { + $("#btn_t").addClass("is-success"); label = 'Temperatur'; minfunc = function(min) { if (min > 0) { return 0 } else { return min } } maxfunc = function(max) { return max + 5 } } else if (sPageURL.search("property=vp") > -1) { + $("#btn_vp").addClass("is-success"); label = 'Akkuladung'; minfunc = function(min) { return 0 } maxfunc = function(max) { return 100 } } else if (sPageURL.search("property=w") > -1) { + $("#btn_w").addClass("is-success"); label = 'Gewicht'; - minfunc = function(min) { if (min < 5000000) { return min - 2000 } else { return min - 1000 } } + minfunc = function(min) { if (min > 40000) { return min - 2000 } else { return 0 } } maxfunc = function(max) { return max + 2000 } } else if (sPageURL.search("property=h") > -1) { + $("#btn_h").addClass("is-success"); label = 'Luftfeuchtigkeit'; minfunc = function(min) { return 0 } maxfunc = function(max) { return 100 } } else if (sPageURL.search("property=p") > -1) { + $("#btn_p").addClass("is-success"); label = 'Luftdruck'; minfunc = function(min) { return 900 } maxfunc = function(max) { return 1060 } @@ -197,6 +235,13 @@ $.getJSON('https://mini-beieli.ch/metrics?' + sPageURL + range, function(mydata) stroke: { curve: 'smooth' }, + title: { + text: urlParams.get('alias'), + align: 'center', + style: { + fontSize: '32px' + } + }, xaxis: { type: "datetime", labels: { diff --git a/snippets/scales.html b/snippets/scales.html index 813382f..525d80f 100644 --- a/snippets/scales.html +++ b/snippets/scales.html @@ -76,7 +76,7 @@ Device ID: