+ */
+ },
+ tooltip: {
+ format: {
+ // TODO: maybe move to top
+ name: function (name, ratio, id, index) {
+ var prefix = '';
+ if (element.substr(0, 7) == 'chart_w') {
+ var re = /\d+ ?c?m/;
+ prefix = 'Wasser ';
+ } else {
+ var re = /Luft/;
+ };
+ var result = re.exec(name);
+ return prefix + result;
+ },
+ value: function (value, ratio, id, index) {
+ return value.toFixed(2) + '°';
+ },
+ 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);
+ }
+ }
+ },
+ 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'}
+ ]
+ });
+
+ // reload data in charts
+ // TODO: this is basically the same as the unused loaddays function below
+ setInterval(
+ function() {
+ if (element.substr(0, 7) == 'chart_w') {
+ console.log("water");
+ chart.load({
+ url: api_base_url_sensors + beginend(days),
+ mimeType: 'json'
+ });
+ chart.flush();
+ } else {
+ console.log("air");
+ chart.load({
+ url: api_base_url_weather + beginend(days),
+ mimeType: 'json'
+ });
+ chart.flush();
+ }
+ },
+ refresh_interval
+ );
+};
+
+function loaddays(chart, element, days) {
+ // TODO: maybe move to top or factor out somehow
+ if (element.substr(0, 7) == 'chart_w') {
+ chart.load({
+ url: api_base_url_sensors + beginend(days),
+ mimeType: 'json'
+ });
+ } else {
+ chart.load({
+ url: api_base_url_weather + beginend(days),
+ mimeType: 'json'
+ });