]> ToastFreeware Gitweb - chrisu/seepark.git/blobdiff - web/static/seepark_web.js
loaddays: wrap .flush in a setTimeout
[chrisu/seepark.git] / web / static / seepark_web.js
index fdc5377087f223bf257cd134ed73471d2f22a8db..7e727a1f0927b31351122c6f2a8c00f9ac289e77 100644 (file)
@@ -67,7 +67,6 @@ function dayschart(element, title, days, xtickformat) {
                        chart.resize({
                                width: getwidth(element)
                        });
-                       // chart.flush();
                },
                transition: {
                        duration: null
@@ -149,6 +148,9 @@ function dayschart(element, title, days, xtickformat) {
                grid: {
                        y: {
                                show: true
+                       },
+                       x: {
+                               show: true
                        }
                },
                regions: [
@@ -159,6 +161,9 @@ function dayschart(element, title, days, xtickformat) {
                ]
        });
 
+       // workaround for unrendered dots
+       setTimeout(function () { chart.flush(); }, 5000);
+
        // reload data in charts
        setInterval(
                function() {
@@ -173,14 +178,17 @@ function loaddays(chart, element, days) {
        if (element.substr(0, 7) == 'chart_w') {
                chart.load({
                        url: api_base_url_sensors + beginend(days),
-                       mimeType: 'json'
+                       mimeType: 'json',
+                       unload: true
                });
        } else {
                chart.load({
                        url: api_base_url_weather + beginend(days),
-                       mimeType: 'json'
+                       mimeType: 'json',
+                       unload: true
                });
-       }
+       };
+       setTimeout(function () { chart.flush(); }, 5000);
 }
 
 function beginend(days) {
@@ -220,7 +228,7 @@ setInterval(
                        .then((resp) => resp.json())
                        .then(function(data) {
                                airvalue.innerText = data['value'].toFixed(1);
-                               airtime.innerText  = strftime('%Y-%m-%d H:%M', new Date(data['timestamp']));
+                               airtime.innerText  = strftime('%Y-%m-%d %H:%M', new Date(data['timestamp']));
                        })
                        .catch(function(error) {
                                console.log(error);
@@ -229,7 +237,7 @@ setInterval(
                        .then((resp) => resp.json())
                        .then(function(data) {
                                watervalue.innerText = data['value'].toFixed(1);
-                               watertime.innerText  = strftime('%Y-%m-%d H:%M', new Date(data['timestamp']));
+                               watertime.innerText  = strftime('%Y-%m-%d %H:%M', new Date(data['timestamp']));
                        })
                        .catch(function(error) {
                                console.log(error);