]> ToastFreeware Gitweb - chrisu/seepark.git/blobdiff - web/static/seepark_web.js
add buttons for day/week/month/year, + css and a js function
[chrisu/seepark.git] / web / static / seepark_web.js
index 93f5d4967cd0526b2bb364d81852e31b6160e51b..73e9ac2f4492bd165f22fd539f929214fdea180f 100644 (file)
@@ -7,7 +7,7 @@ var chart = c3.generate({
                text: 'Der See'
        },
        data: {
                text: 'Der See'
        },
        data: {
-               url: '/data',
+               url: '/data/', // redirects to /data/1
                mimeType: 'json',
                xs: {
                        '0316a2193bff': '0316a2193bff_x',
                mimeType: 'json',
                xs: {
                        '0316a2193bff': '0316a2193bff_x',
@@ -42,7 +42,22 @@ var chart = c3.generate({
                }
        },
        zoom: {
                }
        },
        zoom: {
-               enabled: true
+               enabled: true,
+               onzoomend: function (domain) {
+                       // UNIX epoch
+                       var start = domain[0].getTime()/1000;
+                       var end   = domain[1].getTime()/1000;
+                       var duration = end- start;
+                       // duration is now the diff of the "viewport in seconds"
+                       // and now we could try and load more/less data
+                       // this works but doesn't make sense :)
+                       /*
+                       chart.load({
+                               url: '/data/7',
+                               mimeType: 'json'
+                       });
+                       */
+               }
        },
        tooltip: {
                format: {
        },
        tooltip: {
                format: {
@@ -63,9 +78,15 @@ var chart = c3.generate({
        },
        regions: [
                {axis: 'y', start: -999, end:   0, class: 'region-frozen'},
        },
        regions: [
                {axis: 'y', start: -999, end:   0, class: 'region-frozen'},
-               {axis: 'y', start:    1, end:  25, class: 'region-ok'},
-               {axis: 'y', start:   26, end:  99, class: 'region-warm'},
-               {axis: 'y', start:   99, end: 999, class: 'region-boiling'}
+               {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: '/data/' + days,
+               mimeType: 'json'
+       });
+}