-var chart = c3.generate({
- bindto: '#chart',
- title: {
- text: 'Seepark'
- },
- data: {
- url: '/data',
- mimeType: 'json',
- xs: {
- 'water_temperature': 'water_temperature_x',
- 'air_temperature': 'air_temperature_x'
+var api_base_url = '/api/1/sensor/type/Wassertemperatur?mode=consolidated&format=c3';
+
+function dayschart(element, interval, days) {
+ var chart = c3.generate({
+ bindto: element,
+ transition: {
+ duration: null
+ },
+ title: {
+ text: 'Der See (' + interval + ')'
+ },
+ data: {
+ url: api_base_url + beginend(days),
+ mimeType: 'json',
+ xs: {
+ '0316a2193bff': '0316a2193bff_x',
+ '0316a21383ff': '0316a21383ff_x'
+ },
+ names: {
+ '0316a2193bff': 'Wassertemperatur in 4 m Tiefe',
+ '0316a21383ff': 'Wassertemperatur in 5 m Tiefe'
+ },
+ xFormat: '%Y-%m-%d %H:%M:%S',
+ colors: {
+ '0316a2193bff': 'lightblue',
+ '0316a21383ff': 'darkblue'
+ }
+ },
+ axis: {
+ x: {
+ type: 'timeseries',
+ tick: {
+ format: '%Y-%m-%d %H:%M',
+ fit: false,
+ multiline: true, // broken? so →
+ rotate: -90
+ }
+ },
+ y: {
+ label: {
+ text: 'Temperatur in °C',
+ position: 'outer-middle'
+ },
+ tick: {
+ format: function (d) {
+ return d.toFixed(1) + '°';
+ }
+ }
+ }