-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode2_temp.js
89 lines (80 loc) · 2.28 KB
/
node2_temp.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
$(function() {
var x_values = [];
var y_values = [];
var switch1 = true;
$.get('graph_temp2.php', function(data) {
data = data.split('/');
for (var i in data)
{
if (switch1 == true)
{
var ts = data[i];
x_values.push(ts);
switch1 = false;
}
else
{
y_values.push(parseFloat(data[i]));
switch1 = true;
}
}
x_values.pop();
$('#chart').highcharts({
chart : {
type : 'spline'
},
title : {
text : 'Node 2 Temperature'
},
subtitle : {
text : 'IoT based Precision Farming'
},
xAxis : {
title : {
text : 'Time'
},
categories : x_values
},
yAxis : {
title : {
text : 'Temperature'
},
labels : {
formatter : function() {
return this.value + ' C'
}
}
},
tooltip : {
crosshairs : true,
shared : true,
valueSuffix : ''
},
plotOptions : {
spline : {
marker : {
radius : 4,
lineColor : '#666666',
lineWidth : 1
}
}
},
series : [{
name : 'Temperature',
data : y_values
}]
});
});
});
function timeConverter(UNIX_timestamp){
var a = new Date(UNIX_timestamp * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes() < 10 ? '0' + a.getMinutes() : a.getMinutes();
var sec = a.getSeconds() < 10 ? '0' + a.getSeconds() : a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
return time;
}