]> ToastFreeware Gitweb - chrisu/seepark.git/blobdiff - web/static/seepark_web.js
tooltip: 2 decimal places are enough
[chrisu/seepark.git] / web / static / seepark_web.js
index eedcb44b51de04ba48d21dcbeda7a9722de216a7..f5f2f6a413fe4c0e87f33f2355402518fe5894f1 100644 (file)
@@ -47,16 +47,13 @@ var chart = c3.generate({
                        // UNIX epoch
                        var start = domain[0].getTime()/1000;
                        var end   = domain[1].getTime()/1000;
-                       var duration = end- start;
+                       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'
-                       });
-                       */
+                       // FIXME
+                       var days = Math.round(duration / 86400 / 2);
+                       if (days > 0) {
+                               loaddays(days);
+                       }
                }
        },
        tooltip: {
@@ -67,7 +64,7 @@ var chart = c3.generate({
                                return res;
                        },
                        value: function (value, ratio, id, index) {
-                               return value + '°';
+                               return value.toFixed(2) + '°';
                        }
                }
        },
@@ -84,3 +81,9 @@ var chart = c3.generate({
        ]
 });
 
+function loaddays(days) {
+       chart.load({
+               url: '/data/' + days,
+               mimeType: 'json'
+       });
+}