-
Notifications
You must be signed in to change notification settings - Fork 1
/
humidity.js
executable file
·95 lines (80 loc) · 1.8 KB
/
humidity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//Humidity
$(function () {
var seriesOptions = [],
yAxisOptions = [],
seriesCounter = 0,
names = ['InsideH', 'OutsideH'],
colors = Highcharts.getOptions().colors;
$.each(names, function(i, name) {
$.getJSON('wsdata.php?sensor='+ name.toLowerCase() +'&stationid='+STATIONID, function(data) {
seriesOptions[i] = {
name: name,
data: data
};
// As we're loading the data asynchronously, we don't know what order it will arrive. So
// we keep a counter and create the chart when all the data is loaded.
seriesCounter++;
if (seriesCounter == names.length) {
createChart();
}
});
});
// create the chart when all data is loaded
function createChart() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
$('#humidity').highcharts('StockChart', {
chart: {
type: 'line'
},
legend: {
enabled: true,
align: 'right',
backgroundColor: 'white',
borderColor: 'black',
borderWidth: 2,
layout: 'vertical',
verticalAlign: 'top',
y: 100,
shadow: true
},
rangeSelector : {
inputEnabled: $('#humidity').width() > 480,
buttons : [{
type : 'day',
count : 1,
text : '1D'
}, {
type : 'week',
count : 1,
text : '1W'
}, {
type: 'all',
text: 'All'
}],
selected : 0
},
xAxis: {
type: 'datetime',
},
yAxis: {
title: {
text: "%"
}
},
title : {
text : 'Humidity (%)'
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
series: seriesOptions
});
}
});