format tooltip names depending on water/air
authorgregor herrmann <gregor@toastfreeware.priv.at>
Thu, 2 Aug 2018 11:23:40 +0000 (13:23 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Thu, 2 Aug 2018 11:23:40 +0000 (13:23 +0200)
web/static/seepark_web.js

index e663296..816b6a5 100644 (file)
@@ -88,10 +88,17 @@ function dayschart(element, title, days, xtickformat) {
                },
                tooltip: {
                        format: {
+                               // TODO: maybe move to top
                                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) + '°';