X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/blobdiff_plain/0fada4574744180c793908a27a2fa1e27b656675..105e2625c0cacd63414fa47979f882672f633e35:/web/static/seepark_web.js diff --git a/web/static/seepark_web.js b/web/static/seepark_web.js index e30d414..73e9ac2 100644 --- a/web/static/seepark_web.js +++ b/web/static/seepark_web.js @@ -1,10 +1,13 @@ var chart = c3.generate({ bindto: '#chart', + transition: { + duration: null + }, title: { - text: 'Temperaturen' + text: 'Der See' }, data: { - url: '/data', + url: '/data/', // redirects to /data/1 mimeType: 'json', xs: { '0316a2193bff': '0316a2193bff_x', @@ -20,18 +23,41 @@ var chart = c3.generate({ x: { type: 'timeseries', tick: { - format: '%Y-%m-%d %H:%M:%S' + format: '%Y-%m-%d %H:%M', + fit: false, + multiline: true, // broken? so → + rotate: -90 } }, y: { label: { - text: '°C', + text: 'Temperatur in °C', position: 'outer-middle' + }, + tick: { + format: function (d) { + return d + '°'; + } } } }, 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: { @@ -39,8 +65,28 @@ var chart = c3.generate({ var re = /\d m/; var res = re.exec(name); return res; + }, + value: function (value, ratio, id, index) { + return value + '°'; } } - } + }, + grid: { + 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' + }); +}