459795acdb67462cf69144a339e4726fd799edc0
[chrisu/seepark.git] / web / static / seepark_web.js
1 var chart = c3.generate({
2         bindto: '#chart',
3         transition: {
4                 duration: null
5         },
6         title: {
7                 text: 'Der See'
8         },
9         data: {
10                 url: '/data',
11                 mimeType: 'json',
12                 xs: {
13                         '0316a2193bff': '0316a2193bff_x',
14                         '0316a21383ff': '0316a21383ff_x'
15                 },
16                 names: {
17                         '0316a2193bff': 'Wassertemperatur in 4 m Tiefe',
18                         '0316a21383ff': 'Wassertemperatur in 5 m Tiefe'
19                 },
20                 xFormat: '%Y-%m-%d %H:%M:%S'
21         },
22         axis: {
23                 x: {
24                         type: 'timeseries',
25                         tick: {
26                                 format: '%Y-%m-%d %H:%M',
27                                 fit: false,
28                                 multiline: true, // broken? so →
29                                 rotate: -90
30                         }
31                 },
32                 y: {
33                         label: {
34                                 text: 'Temperatur in °C',
35                                 position: 'outer-middle'
36                         },
37                         tick: {
38                                 format: function (d) {
39                                         return d + '°';
40                                 }
41                         }
42                 }
43         },
44         zoom: {
45                 enabled: true
46         },
47         tooltip: {
48                 format: {
49                         name: function (name, ratio, id, index) {
50                                 var re = /\d m/;
51                                 var res = re.exec(name);
52                                 return res;
53                         },
54                         value: function (value, ratio, id, index) {
55                                 return value + '°';
56                         }
57                 }
58         }
59 });
60