we have air temperature charts!
authorgregor herrmann <gregor@toastfreeware.priv.at>
Thu, 2 Aug 2018 11:11:24 +0000 (13:11 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Thu, 2 Aug 2018 11:11:24 +0000 (13:11 +0200)
web/static/seepark_web.js
web/templates/seepark_web.html

index 71c9862..1390cd7 100644 (file)
@@ -1,6 +1,42 @@
 var api_base_url_sensors = '/api/1/sensor/type/Wassertemperatur?mode=consolidated&format=c3';
+var api_base_url_weather = '/api/1/openweathermap/city/3319578?mode=consolidated&format=c3';
 
 function dayschart(element, title, days, xtickformat) {
+       var chartdata;
+       if (element.substr(0, 7) == 'chart_w') {
+               chartdata = {
+                               url: api_base_url_sensors + beginend(days),
+                               mimeType: 'json',
+                               xs: {
+                                       '0316a2193bff': '0316a2193bff_x',
+                                       '0316a21383ff': '0316a21383ff_x'
+                               },
+                               names: {
+                                       '0316a2193bff': 'Wassertemperatur in 4 m Tiefe',
+                                       '0316a21383ff': 'Wassertemperatur in 5 m Tiefe'
+                               },
+                               xFormat: '%Y-%m-%d %H:%M:%S',
+                               colors: {
+                                       '0316a2193bff': 'lightblue',
+                                       '0316a21383ff': 'darkblue'
+                               }
+               };
+       } else {
+               chartdata = {
+                               url: api_base_url_weather + beginend(days),
+                               mimeType: 'json',
+                               xs: {
+                                       '3319578': '3319578_x'
+                               },
+                               names: {
+                                       '3319578': 'Lufttemperatur in Obsteig'
+                               },
+                               xFormat: '%Y-%m-%d %H:%M:%S',
+                               colors: {
+                                       '3319578': 'red'
+                               }
+               };
+       };
        var chart = c3.generate({
                bindto: '#' + element,
                size: {
@@ -12,23 +48,7 @@ function dayschart(element, title, days, xtickformat) {
                title: {
                        text: title
                },
-               data: {
-                       url: api_base_url_sensors + beginend(days),
-                       mimeType: 'json',
-                       xs: {
-                               '0316a2193bff': '0316a2193bff_x',
-                               '0316a21383ff': '0316a21383ff_x'
-                       },
-                       names: {
-                               '0316a2193bff': 'Wassertemperatur in 4 m Tiefe',
-                               '0316a21383ff': 'Wassertemperatur in 5 m Tiefe'
-                       },
-                       xFormat: '%Y-%m-%d %H:%M:%S',
-                       colors: {
-                               '0316a2193bff': 'lightblue',
-                               '0316a21383ff': 'darkblue'
-                       }
-               },
+               data: chartdata,
                axis: {
                        x: {
                                type: 'timeseries',
@@ -94,7 +114,7 @@ function dayschart(element, title, days, xtickformat) {
                        {axis: 'y', start:  100, end: 999, class: 'region-boiling'}
                ]
        });
-       };
+};
 
 function loaddays(days) {
        chart.load({
@@ -114,3 +134,8 @@ 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_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');
index 562c526..3eae133 100644 (file)
                <div id="chart_water_31"></div>
                <div id="chart_water_365"></div>
 
+               <h2>Die Luft</h2>
+               <div id="chart_air_1"></div>
+               <div id="chart_air_7"></div>
+               <div id="chart_air_31"></div>
+               <div id="chart_air_365"></div>
 
                <!-- openweathermap widget -->
                <div id="openweathermap-widget-15"></div>