format strings picked a bit randomly for now, following the temperature
charts at https://info.comodo.priv.at/webcam/
might make more sense and fun with real values …
var api_base_url = '/api/1/sensor/type/Wassertemperatur?mode=consolidated&format=c3';
var api_base_url = '/api/1/sensor/type/Wassertemperatur?mode=consolidated&format=c3';
-function dayschart(element, interval, days) {
+function dayschart(element, interval, days, xtickformat) {
var chart = c3.generate({
bindto: '#' + element,
size: {
var chart = c3.generate({
bindto: '#' + element,
size: {
x: {
type: 'timeseries',
tick: {
x: {
type: 'timeseries',
tick: {
- format: '%Y-%m-%d %H:%M',
fit: false,
multiline: true, // broken? so →
rotate: -90
fit: false,
multiline: true, // broken? so →
rotate: -90
},
value: function (value, ratio, id, index) {
return value.toFixed(2) + '°';
},
value: function (value, ratio, id, index) {
return value.toFixed(2) + '°';
+ },
+ title: function (x) {
+ // TODO: format datetime into something readable
+ return x;
return '&begin=' + begin + '&end=' + end;
}
return '&begin=' + begin + '&end=' + end;
}
-dayschart('chart1', 'Tag', 1);
-dayschart('chart7', 'Woche', 7);
-dayschart('chart31', 'Monat', 31);
-dayschart('chart365', 'Jahr', 365);
+dayschart('chart1', 'Tag', 1, '%H:%M');
+dayschart('chart7', 'Woche', 7, '%a %d');
+dayschart('chart31', 'Monat', 31, 'Woche %V');
+dayschart('chart365', 'Jahr', 365, '%b %d');