forked from tomasholderness/PiThermServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperature_plot.htm
73 lines (68 loc) · 1.88 KB
/
temperature_plot.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
<!DOCTYPE html>
<html>
<head>
<title>PiThermServer - Plot</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 Pi NodeJS server
function getData(){
$.getJSON('./temperature_now.json', function(data) {
//alert(data.unix_time);
// Create the series
var series = chart.series[0],
shift = series.data.length > 20; // shift if the series longer than 20
// Add the point
chart.series[0].addPoint([data.temperature_record[0].unix_time, data.temperature_record[0].celsius], true, shift);
// Repeat this function call after 1 second
setTimeout(getData, 1000);
});
}
</script>
<script type="text/javascript">
// Configure the plot
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'spline',
events: {
load: getData
}
},
title: {
text: 'Raspberry Pi Temperature Plot'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxZoom: 20 * 1000,
title: {
text: 'Time (sensor called at one second intervals)',
margin: 15
}
},
yAxis: {
minPadding: 0.2,
maxPadding: 0.2,
title: {
text: 'Temperature \u00B0C',
margin: 15
}
},
series: [{
name: 'DS18B20 sensor (\u00B10.5\u00B0C)',
data: []
}]
});
});
</script>
</head>
<body>
<div id="container" style="width: 100%; height: 400px"></div>
</body>
</html>