X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/blobdiff_plain/e4c8650daecb46af4933a59a3e7f5f9f8d617ac2..179bfba13289a427e9e68448f09a247f034a1bcc:/web/static/seepark_web.js?ds=inline diff --git a/web/static/seepark_web.js b/web/static/seepark_web.js index 149d659..0bda800 100644 --- a/web/static/seepark_web.js +++ b/web/static/seepark_web.js @@ -7,7 +7,7 @@ var chart = c3.generate({ text: 'Der See' }, data: { - url: '/data', + url: '/data/', // redirects to /data/1 mimeType: 'json', xs: { '0316a2193bff': '0316a2193bff_x', @@ -42,7 +42,19 @@ var chart = c3.generate({ } }, 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" + // FIXME + var days = Math.round(duration / 86400 / 2); + if (days > 0) { + loaddays(days); + } + } }, tooltip: { format: { @@ -60,6 +72,18 @@ var chart = c3.generate({ y: { show: true } - } + }, + regions: [ + {axis: 'y', start: -999, end: 0, class: 'region-frozen'}, + {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' + }); +}