]> ToastFreeware Gitweb - chrisu/seepark.git/blobdiff - web/static/seepark_web.js
js: make points on line chart smaller
[chrisu/seepark.git] / web / static / seepark_web.js
index 1390cd73c41673add19c40b66c8f9c0698874fff..9b24b60d96570aec342e6ea6f675b421ba3cfea1 100644 (file)
@@ -49,6 +49,9 @@ function dayschart(element, title, days, xtickformat) {
                        text: title
                },
                data: chartdata,
                        text: title
                },
                data: chartdata,
+               point: {
+                       r: 1.5 // default 2.5
+               },
                axis: {
                        x: {
                                type: 'timeseries',
                axis: {
                        x: {
                                type: 'timeseries',
@@ -88,10 +91,17 @@ function dayschart(element, title, days, xtickformat) {
                },
                tooltip: {
                        format: {
                },
                tooltip: {
                        format: {
+                               // TODO: maybe move to top
                                name: function (name, ratio, id, index) {
                                name: function (name, ratio, id, index) {
-                                       var re = /\d m/;
-                                       var res = re.exec(name);
-                                       return res;
+                                       var prefix = '';
+                                       if (element.substr(0, 7) == 'chart_w') {
+                                               var re = /\d m/;
+                                               prefix = 'Wasser ';
+                                       } else {
+                                               var re = /Luft/;
+                                       };
+                                       var result = re.exec(name);
+                                       return prefix + result;
                                },
                                value: function (value, ratio, id, index) {
                                        return value.toFixed(2) + '°';
                                },
                                value: function (value, ratio, id, index) {
                                        return value.toFixed(2) + '°';
@@ -125,17 +135,22 @@ function loaddays(days) {
 
 function beginend(days) {
        var now = Date.now();
 
 function beginend(days) {
        var now = Date.now();
-       var end = new Date(now).toISOString().substr(0, 19); // 2018-06-13T16:52:30.995Z
-       var begin = new Date(now - days * 60*60*24 * 1000).toISOString().substr(0, 19);
+
+       // 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');
        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 %d');
+dayschart('chart_water_365', 'Der See (Jahr)',  365, '%b %Y');
 
 dayschart('chart_air_1',     'Die Luft (Tag)',     1, '%H:%M');
 dayschart('chart_air_7',     'Die Luft (Woche)',   7, '%a %d');
 dayschart('chart_air_31',    'Die Luft (Monat)',  31, 'Woche %V');
 
 dayschart('chart_air_1',     'Die Luft (Tag)',     1, '%H:%M');
 dayschart('chart_air_7',     'Die Luft (Woche)',   7, '%a %d');
 dayschart('chart_air_31',    'Die Luft (Monat)',  31, 'Woche %V');
-dayschart('chart_air_365',   'Die Luft (Jahr)',  365, '%b %d');
+dayschart('chart_air_365',   'Die Luft (Jahr)',  365, '%b %Y');