forked from tomasholderness/PiThermServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperature_log.htm
106 lines (100 loc) · 3.64 KB
/
temperature_log.htm
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
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head>
<title>PiThermServer - Plot of logged temperature</title>
<meta name="description" content="Plot of temperature from DS18B20 sensor connected to Raspberry Pi">
<meta name="author" content="Tom Holderness">
<meta name="version" content="0.1">
<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="http://code.highcharts.com/highcharts.js" type="text/javascript"></script>
<script type="text/javascript">
var chart; // global chart variable
// Get data from server in JSON format (query time series when sensor was outside).
function getData(){
$.getJSON('/temperature_query.json?num_obs=-1&start_date=2013-01-23T16:00', function(data){
var series = {
id: 'series',
name: 'DS18B20 sensor (\u00B10.5\u00B0C)',
type: 'area',
data: []
};
var i = 0;
// Iterate JSON data series and add to plot
while (data.temperature_record[0][i])
{
series.data.push([data.temperature_record[0][i].unix_time, data.temperature_record[0][i].celsius]);
i++;
}
chart.addSeries(series);
});
}
</script>
<script type="text/javascript">
// Configure the plot
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
//type: 'spline',
zoomType: 'x',
spaceRight: 20,
events: {load: getData()}
},
title: {
text: 'Plot of temperatures from Raspberry Pi logger'},
subtitle: {
text: 'Click and drag in the plot area to zoom in',
align: 'right',
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxZoom: 20 * 1000,
title: {
text: 'Time',
margin: 15
}},
yAxis: {
minPadding: 0.2,
maxPadding: 0.2,
showFirstLabel: false,
title: {
text: 'Temperature \u00B0C',
margin: 15
}},
plotOptions: {
area: {
fillColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, 'rgba(2,0,0,0)'],
]
},
lineWidth: 1,
marker: {
enabled: false,
states: {
hover: {
enabled: true,
radius: 5
}
}
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
},
},
})
});
</script>
</head>
<body>
<div id="container" style="width: 100%; height: 400px"></div>
</body>
</html>