+ },
+ 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 (x) {
+ // TODO: format datetime into something readable
+ return x;
+ }
+ }
+ },
+ 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(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'
+ });