-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDiagramm.html
More file actions
454 lines (387 loc) · 17.8 KB
/
Diagramm.html
File metadata and controls
454 lines (387 loc) · 17.8 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Air Quality Egg Münster</title>
<link rel="shortcut icon" href="bilder/egg1.png" type="image/x-icon" />
<meta name="description" content="Luftqualitätsdaten Muenster">
<meta name="keywords" content="Air Quality Egg">
<meta name="viewport" content="target-densitydpi=480px, width=1000px, user-scalable=yes">
<meta http-equiv="X-UA-Compatible" content="IE=edge"><!--Order IE to use the best available compatibility-Microsoft Standard-->
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="libraries_diagram/RGraph/libraries/RGraph.common.core.js">
</script>
<script src="libraries_diagram/RGraph/libraries/RGraph.line.js">
</script>
<script src="libraries_diagram/RGraph/libraries/RGraph.bar.js">
</script>
<script src="libraries_diagram/RGraph/libraries/RGraph.common.key.js">
</script>
<script src="libraries_diagram/jquery-1.9.1.js" type="text/javascript">
</script>
<script src="libraries_diagram/RGraph/libraries/RGraph.common.dynamic.js">
</script>
<script src="libraries_diagram/RGraph/libraries/RGraph.drawing.circle.js">
</script>
</head>
<body>
<div id="main">
<div id="header">
<div id="banner">
<div id="Willkommen">
<h1>Semvis Air</h1>
<h6>System zur Erfassung,Modellierung und Visualisierung von Luftqualitätsdaten</h6>
</div><!--close welcome-->
</div><!--close banner-->
</div><!--close header-->
<div id="menubar">
<ul id="menu">
<li class="current">
<a href="Diagramm.html">Diagramm</a>
</li>
<li>
<a href="Karte.php">Zurück zur Kartenansicht</a>
</li>
<li>
<a href="Hilfe.html">Hilfe</a>
</li>
</ul>
</div><!--close menubar-->
<div id="site_content">
<div class="sidebar_container">
<div class="sidebar">
<div class="sidebar_item">
<h2>Diagramm</h2>
<form name='selectpara' id="selectpara">
<input type="radio" name="Parameter" onclick="(chooseTemperature())"> Temperatur<br>
<input type="radio" name="Parameter" onclick="(chooseO3())"> Ozon<br>
<input type="radio" name="Parameter" onclick="(chooseCO())"> Kohlenstoffmonoxid<br>
<input type="radio" name="Parameter" onclick="(chooseNO2())"> Stickstoffdioxid<br>
<input type="radio" name="Parameter" onclick="(chooseHumidity())"> Luftfeuchtigkeit<br>
</form>
<br>
<p id='parameter'>Maßeinheit</p><span style="margin-left: 225px"><a class="tooltip">?<span class="classic">Um eine
Messung im Diagramm anzuzeigen, wählen und markieren Sie bitte den jeweiligen Kreis</span></a></span>
</div><!--Close-item-->
</div><!--Close-sidebar-->
<div class="sidebar">
<div class="sidebar_item">
<p id='time'></p>
<h2>Tag</h2>
<form name='selectday' id="selectday">
<input type="radio" name="Parameter" onclick="(chooseDay(6))"> <span id="day6"></span><br>
<input type="radio" name="Parameter" onclick="(chooseDay(5))"> <span id="day5"></span><br>
<input type="radio" name="Parameter" onclick="(chooseDay(4))"> <span id="day4"></span><br>
<input type="radio" name="Parameter" onclick="(chooseDay(3))"> <span id="day3"></span><br>
<input type="radio" name="Parameter" onclick="(chooseDay(2))"> <span id="day2"></span><br>
<input type="radio" name="Parameter" onclick="(chooseDay(1))"> <span id="day1"></span><br>
<input type="radio" name="Parameter" onclick="(chooseDay(0))" checked="checked"> <span id="day0"></span> (heute)
</form><span style="margin-left: 225px"><a class="tooltip">?<span class="classic">Wenn Sie die Werte vergangener Tage
einsehen möchten, wählen und markieren Sie bitte den zum jeweiligen Datum dazugehörigen Kreis</span></a></span>
</div><!--Close-item-->
<div class="sidebar_item">
<h2>Rohdaten XML</h2>
<div id="rawdata" onclick="(getXML1())">AQE 1</div>
<div id="rawdata" onclick="(getXML2())">AQE 2</div>
<div id="rawdata" onclick="(getXML3())">AQE 3</div>
</div><!--Close-item-->
</div><!--Close-sidebar-->
</div><!--Close-sidebar_container-->
<div id="diagram">
<canvas id="canvas1" width="710" height="420">[No canvas support]</canvas>
</div>
<script>
function getXML1(){
xmlPath1 = 'http://giv-geosoft2c.uni-muenster.de:8080/XML/rest/XML/' + sensorId1 + '/' + selectedPara + '/' + yearBegin + '-' + monthBegin + '-' + dateBegin + '%200:0:0/' + yearEnd + '-' + monthEnd + '-' + dateEnd + '%200:0:0';
window.open(xmlPath1);
}
function getXML2(){
xmlPath2 = 'http://giv-geosoft2c.uni-muenster.de:8080/XML/rest/XML/' + sensorId2 + '/' + selectedPara + '/' + yearBegin + '-' + monthBegin + '-' + dateBegin + '%200:0:0/' + yearEnd + '-' + monthEnd + '-' + dateEnd + '%200:0:0';
window.open(xmlPath2);
}
function getXML3(){
xmlPath3 = 'http://giv-geosoft2c.uni-muenster.de:8080/XML/rest/XML/' + sensorId3 + '/' + selectedPara + '/' + yearBegin + '-' + monthBegin + '-' + dateBegin + '%200:0:0/' + yearEnd + '-' + monthEnd + '-' + dateEnd + '%200:0:0';
window.open(xmlPath3);
}
</script>
<script>
var sensorId1 = 0;
var sensorId2 = 0;
var sensorId3 = 0;
var name1 = ' ';
var name2 = ' ';
var name3 = ' ';
var bool1 = [];
var bool2 = [];
var bool3 = [];
var selectedPara;
var circle;
var time = [];
path = location.href;
pathPara = path.split('?');
if (pathPara.length > 0){ //at least one egg selected
pathPara = pathPara[1];
eggId = pathPara.split('&');
getId1 = eggId.slice(0,1);
getId1 = getId1.toString();
sensorId1 = getId1.slice(4);
if (eggId.length > 1){ //more than one egg selected
getId2 = eggId.slice(1,2);
getId2 = getId2.toString();
sensorId2 = getId2.slice(4);
if (eggId.length > 2){ //more than two eggs selected
getId3 = eggId.slice(2,3);
getId3 = getId3.toString();
sensorId3 = getId3.slice(4);
}
}
}
//get Names for the legend
phpLocation2 = 'http://giv-geosoft2c.uni-muenster.de/getEggNames.php?id1=' + sensorId1 + '&id2=' + sensorId2 + '&id3=' + sensorId3;
$.ajax({
type: "GET",
url: phpLocation2,
dataType: "script",
success: function(){}
});
//choose the day of the displayed measurements
function chooseDay(n)
{
timeBegin = writeCorrectDates(n);
timeBeginArray = timeBegin.split(".");
dateBegin = timeBeginArray[0];
monthBegin = timeBeginArray[1];
yearBegin = timeBeginArray[2];
timeEnd = writeCorrectDates(n-1);
timeEndArray = timeEnd.split(".");
dateEnd = timeEndArray[0];
monthEnd = timeEndArray[1];
yearEnd = timeEndArray[2];
egg1 = [0];
egg2 = [0];
egg3 = [0];
fullDay = ['','2 Uhr','4 Uhr','6 Uhr','8 Uhr','10 Uhr','12 Uhr','14 Uhr','16 Uhr','18 Uhr','20 Uhr','22 Uhr','24 Uhr',];
//adjusting x-axis labels, for the current day which has not 24 hours of measurement values
timeNow = new Date();
hourNow = timeNow.getHours();
partDay = ['','2 Uhr','4 Uhr','6 Uhr','8 Uhr','10 Uhr','12 Uhr','14 Uhr','16 Uhr','18 Uhr','20 Uhr','22 Uhr','24 Uhr',];
hour1 = hourNow / 2 + 1;
hour2 = Math.floor(hour1);
partDay.length = hour2;
if (n == 0) time = partDay;
else time = fullDay;
switch(selectedPara)
{
case 'temperature':
chooseTemperature();
break;
case 'ozon':
chooseO3();
break;
case 'co':
chooseCO();
break;
case 'no2':
chooseNO2();
break;
case 'humidity':
chooseHumidity();
break;
}
}
chooseDay(0);
//At loading the page: Draw empty diagram
drawDiagram(egg1, egg2, egg3, bool1, bool2, bool3);
//Date of the radio buttons: Instead of "yesterday", "day before yesterday" etc.
for (var x = 0; x < 7; x++) document.getElementById('day' + x).innerHTML = writeCorrectDates(x);
function testLeapYear(x){
if (x%400 == 0) return true;
if (x%4 == 0 && x%100 != 0) return true;
else return false;
}
function writeCorrectDates(n)
{
var d = new Date();
var currentDay = d.getDate();
var currentMonth = d.getMonth() + 1;
var currentYear = d.getFullYear();
var correctDay = (currentDay-n + '.' + (currentMonth) + '.' + currentYear);
//Preventing negative days and months
if (currentDay-n < 1){
var minusDays = n - currentDay;
var previousMonth = currentMonth-1;
if (previousMonth < 1) previousMonth = 12;
var previousMonthLength;
if (previousMonth == 1 || previousMonth == 3 || previousMonth == 5 || previousMonth == 7 || previousMonth == 8 || previousMonth == 10 || previousMonth == 12)
previousMonthLength = 31;
else if (previousMonth == 4 || previousMonth == 6 || previousMonth == 9 || previousMonth == 11)
previousMonthLength = 30;
else if (testLeapYear(currentYear) == true)
previousMonthLength = 29;
else previousMonthLength = 28;
correctDay = (previousMonthLength-minusDays + '.' + (previousMonth) + '.' + currentYear);
}
return correctDay;
}
//Main function for drawing all diagrams
function drawDiagram(egg1, egg2, egg3, bool1, bool2, bool3)
{
var line = new RGraph.Line('canvas1', [0],[0],[0]);
line.Set('chart.ylabels', false);
if (selectedPara == 'temperature') line.Set('chart.xaxispos', 'center');
else line.Set('chart.xaxispos', 'bottom');
line.Set('colors', ['red', 'limegreen', 'blue']);
line.Set('chart.key', [name1, name2, name3]);
line.Set('chart.key.position', 'gutter');
line.Set('chart.background.grid.autofit.numvlines', 24);
line.Set('chart.background.grid.autofit.numhlines', 8);
line.Set('chart.gutter.left', 50);
line.Set('chart.numxticks',1);
line.Draw();
var line1 = new RGraph.Line('canvas1', [egg1, egg2, egg3]);
if (selectedPara == 'temperature') line1.Set('chart.xaxispos', 'center');
else line1.Set('chart.xaxispos', 'bottom');
line1.Set('colors', ['red', 'rgba(0,0,0,0)', 'rgba(0,0,0,0)']);
line1.Set('chart.gutter.left', 50);
line1.Set('chart.labels', time);
line1.Set('chart.ylabels.count', 5);
line1.Set('chart.background.grid.vlines', false);
line1.Set('chart.background.grid.hlines', false);
line1.Set('chart.numxticks',1);
line1.Draw();
var line2 = new RGraph.Line('canvas1', [egg2, egg1, egg3]);
if (selectedPara == 'temperature') line2.Set('chart.xaxispos', 'center');
else line2.Set('chart.xaxispos', 'bottom');
line2.Set('colors', ['limegreen', 'rgba(0,0,0,0)', 'rgba(0,0,0,0)']);
line2.Set('chart.gutter.left', 50);
line2.Set('chart.ylabels', false);
line2.Set('chart.background.grid.vlines', false);
line2.Set('chart.background.grid.hlines', false);
line2.Set('chart.noaxes',true);
line2.Set('chart.numxticks',1);
line2.Draw();
var line3 = new RGraph.Line('canvas1', [egg3, egg1, egg2]);
if (selectedPara == 'temperature') line3.Set('chart.xaxispos', 'center');
else line3.Set('chart.xaxispos', 'bottom');
line3.Set('colors', ['blue', 'rgba(0,0,0,0)', 'rgba(0,0,0,0)']);
line3.Set('chart.gutter.left', 50);
line3.Set('chart.ylabels', false);
line3.Set('chart.background.grid.vlines', false);
line3.Set('chart.background.grid.hlines', false);
line3.Set('chart.noaxes',true);
line3.Set('chart.numxticks',1);
line3.Draw();
//Mark measurement errors with circles
for (i=0;i<bool1.length;i++){
if (bool1[i]==1) {
circle = new RGraph.Drawing.Circle('canvas1',line1.coords[i][0],line1.coords[i][1],5)
circle.Set('chart.strokestyle', 'black')
circle.Set('chart.fillstyle', 'rgba(255,255,0,0)')
circle.Set('chart.linewidth', 1)
circle.Draw();
}
}
for (i=0;i<bool2.length;i++){
if (bool2[i]==1) {
circle = new RGraph.Drawing.Circle('canvas1',line2.coords[i][0],line2.coords[i][1],5)
circle.Set('chart.strokestyle', 'black')
circle.Set('chart.fillstyle', 'rgba(255,255,0,0)')
circle.Set('chart.linewidth', 1)
circle.Draw();
}
}
for (i=0;i<bool3.length;i++){
if (bool3[i]==1) {
circle = new RGraph.Drawing.Circle('canvas1',line3.coords[i][0],line3.coords[i][1],5)
circle.Set('chart.strokestyle', 'black')
circle.Set('chart.fillstyle', 'rgba(255,255,0,0)')
circle.Set('chart.linewidth', 1)
circle.Draw();
}
}
}
//Remove previous diagram from the canvas
function clearCanvas()
{
var c = document.getElementById("canvas1");
var context = c.getContext('2d');
context.rect(-10,0,750,500);
context.fillStyle='white';
context.fill();
}
//Choose parameter
function chooseTemperature()
{
selectedPara = 'temperature';
egg1 = [0];
egg2 = [0];
egg3 = [0];
callPHP();
clearCanvas();
document.getElementById('parameter').innerHTML='Temperatur in °C';
}
function chooseO3()
{
selectedPara = 'ozon';
egg1 = [0];
egg2 = [0];
egg3 = [0];
callPHP();
clearCanvas();
document.getElementById('parameter').innerHTML='Ozon in Parts per Million';
}
function chooseCO()
{
selectedPara = 'co';
egg1 = [0];
egg2 = [0];
egg3 = [0];
callPHP();
clearCanvas();
document.getElementById('parameter').innerHTML='Kohlenstoffmonoxid in Parts per Million';
}
function chooseNO2()
{
selectedPara = 'no2';
egg1 = [0];
egg2 = [0];
egg3 = [0];
callPHP();
clearCanvas();
document.getElementById('parameter').innerHTML='Stickstoffdioxid in Parts per Million';
}
function chooseHumidity()
{
selectedPara = 'humidity';
egg1 = [0];
egg2 = [0];
egg3 = [0];
callPHP();
clearCanvas();
document.getElementById('parameter').innerHTML='Luftfeuchtigkeit in Prozent';
}
//Default: Empty diagram
var egg1 = [0];
var egg2 = [0];
var egg3 = [0];
//function for requesting data from the database with PHP and drawing the diagram
function callPHP(){
//Access to real data from Cosm
phpLocation = 'http://giv-geosoft2c.uni-muenster.de/requestData.php?dateBegin=' + dateBegin + '&monthBegin=' + monthBegin + '&yearBegin=' + yearBegin + '&dateEnd=' + dateEnd + '&monthEnd=' + monthEnd + '&yearEnd=' + yearEnd + '&selectedPara=' + selectedPara + '&sensorId1=' + sensorId1 + '&sensorId2=' + sensorId2 + '&sensorId3=' + sensorId3;
//Access to test database
//phpLocation = 'http://giv-geosoft2c.uni-muenster.de/requestDataTest.php?selectedPara=' + selectedPara;
$.ajax({
type: "GET",
url: phpLocation,
dataType: "script",
success: function(){
RGraph.ObjectRegistry.Clear();
drawDiagram(egg1, egg2, egg3, bool1, bool2, bool3);
}
});
}
</script>
</div><!--Close-side_content-->
</div><!--Close_Main=-->
</body>
</html>