X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/blobdiff_plain/28d193ff34844a996984f5276713ddd1d0a7f264..32289b0c8cb2b0d0ae9436fdad60238ea68f87f5:/web/static/seepark_web.js diff --git a/web/static/seepark_web.js b/web/static/seepark_web.js index 9ac4f44..4ee570f 100644 --- a/web/static/seepark_web.js +++ b/web/static/seepark_web.js @@ -13,16 +13,27 @@ function dayschart(element, title, days, xtickformat) { '0416a1bab9ff': '0416a1bab9ff_x' }, names: { - '0416a1ac66ff': 'Wassertemperatur in 50 cm Tiefe', - '0516a207a4ff': 'Wassertemperatur in 1 m Tiefe', - '0416a1bab9ff': 'Wassertemperatur in 2 m Tiefe' + '0416a1ac66ff': 'Wassertemperatur 30cm Tiefe', + '0516a207a4ff': 'Wassertemperatur 50cm Tiefe', + '0416a1bab9ff': 'Wassertemperatur 1m Tiefe' }, xFormat: '%Y-%m-%d %H:%M:%S', colors: { '0416a1ac66ff': 'lightskyblue', '0516a207a4ff': 'royalblue', '0416a1bab9ff': 'midnightblue' + }, + /* + xSort: false, + order: function (a, b) { + // gets 2 x objects. seems to be a "sort function" for js's sort() + // -1: a before b etc. + // only handle cases that appear in the wild + // console.log("a.id", a.id, "b.id", b.id); + if (a.id == '0416a1ac66ff') {return -1}; + if (a.id == '0416a1bab9ff') {return 1}; } + */ }; } else { chartdata = { @@ -98,7 +109,7 @@ function dayschart(element, title, days, xtickformat) { name: function (name, ratio, id, index) { var prefix = ''; if (element.substr(0, 7) == 'chart_w') { - var re = /\d+ c?m/; + var re = /\d+ ?c?m/; prefix = 'Wasser '; } else { var re = /Luft/; @@ -109,9 +120,15 @@ function dayschart(element, title, days, xtickformat) { value: function (value, ratio, id, index) { return value.toFixed(2) + '°'; }, - title: function (x) { - // TODO: format datetime into something readable - return x; + title: function (datetime) { + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString + options = { + weekday: 'short', + year: 'numeric', month: 'numeric', day: 'numeric', + hour: 'numeric', minute: 'numeric', second: 'numeric', + timeZone: 'Europe/Vienna', timeZoneName: 'short' + }; + return datetime.toLocaleString('de-AT', options); } } },