-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
168 lines (137 loc) · 5.33 KB
/
test.html
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<link rel="shortcut icon" href="images/profilepic.jpg">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script><title>Tom Licha</title>
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
.navbar {
margin-bottom: 0;
border-radius: 0;
}
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
.row.content {height: 450px}
/* Set gray background color and 100% height */
.sidenav {
padding-top: 20px;
background-color: #f1f1f1;
height: 100%;
}
/* Set black background color, white text and some padding */
footer {
background-color: #555;
color: white;
padding: 15px;
}
/* On small screens, set height to 'auto' for sidenav and grid */
@media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto;}
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>
<button type="submit" onclick="UserAction()">Search</button>
<script>
var csv
function UserAction(){
$.ajax({
url: 'https://84.7.38.34:443/collections/aze',
success: function(data){
//process the JSON data etc
console.log(data[1]["date"]);
alert((data[1]["date"]));
csv = ConvertToCSV(data,["date","temperature","humidité","id\n"])
console.log(csv);
afficherGraphe(csv, options,"graph");
}
})
}
function ConvertToCSV(objArray,headers) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var str = '';
str+=headers;
for (var i = 0; i < array.length; i++) {
var line = '';
for (var index in array[i]) {
if (line != '') line += ','
line += array[i][index];
}
str += line + '\r\n';
}
return str;
}
var afficherGraphe = function(csvfile, options, id_graphe) {
g = new Dygraph(
// containing div
document.getElementById(id_graphe),
// CSV or path to a CSV file.
csvfile,
//Options
options
);
};
var options = {
animatedZooms :true,
title : 'Température et Humidité ambiante',
titleHeight : 30,
labelsGMT: true,
ylabel : "valeur mesurée (°C et %)",
y2label:"seuils d'alerte",
labelsSeparateLines :true,
xlabel : "date de la mesure",
legend:'follow',
fillGraph: true,
fillAlpha: 0.5,
labelsDivStyles: {'textAlign': 'right'},
colors : ['#86BBEE','#5FBA7D','#FF0000','#FF0000'],
"series": {
"alerte humidité": {
"fillAlpha":0
},
"alerte température": {
"fillAlpha":0
},
"Humidité %": {
"connectSeparatedPoints":true
},
"Température °C": {
"connectSeparatedPoints":true
},
},
};
</script>
<div class="container-fluid">
<div id="graph" style="height:320px; margin-top: 10px;"></div>
</div>
</body>
</HTML>