- }
- },
- grid: {
- y: {
- show: true
- }
- },
- regions: [
- {axis: 'y', start: -999, end: 0, class: 'region-frozen'},
- {axis: 'y', start: 0, end: 25, class: 'region-ok'},
- {axis: 'y', start: 25, end: 100, class: 'region-warm'},
- {axis: 'y', start: 100, end: 999, class: 'region-boiling'}
- ]
-});
+ },
+ grid: {
+ y: {
+ show: true
+ }
+ },
+ regions: [
+ {axis: 'y', start: -999, end: 0, class: 'region-frozen'},
+ {axis: 'y', start: 0, end: 25, class: 'region-ok'},
+ {axis: 'y', start: 25, end: 100, class: 'region-warm'},
+ {axis: 'y', start: 100, end: 999, class: 'region-boiling'}
+ ]
+ });
+};
+
+function loaddays(days) {
+ chart.load({
+ url: api_base_url_sensors + beginend(days),
+ mimeType: 'json'
+ });
+}
+
+function beginend(days) {
+ var now = Date.now();
+
+ // TODO: this timezone calculation relies on the browser being in Europe/Vienna
+ var refdate = new Date(now);
+ var offset = refdate.getTimezoneOffset(); // -120 for UTC+2
+
+ var end = new Date(now - offset * 60 * 1000).toISOString().substr(0, 19); // 2018-06-13T16:52:30.995Z
+ var begin = new Date(now - days * 60*60*24 * 1000 - offset * 60 * 1000).toISOString().substr(0, 19);
+ return '&begin=' + begin + '&end=' + end;
+}
+
+dayschart('chart_water_1', 'Der See (Tag)', 1, '%H:%M');
+dayschart('chart_water_7', 'Der See (Woche)', 7, '%a %d');
+dayschart('chart_water_31', 'Der See (Monat)', 31, 'Woche %V');
+dayschart('chart_water_365', 'Der See (Jahr)', 365, '%b %Y');