forked from Ysurac/FlightAirMap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
statistics.php
291 lines (262 loc) · 13.1 KB
/
statistics.php
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
<?php
require('require/class.Connection.php');
require('require/class.Spotter.php');
$Spotter = new Spotter();
$title = "Statistic";
require('header.php');
?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<div class="column">
<div class="info">
<h1>Statistics</h1>
</div>
<?php include('statistics-sub-menu.php'); ?>
<div class="row global-stats">
<div class="col-md-4"><span class="type">Flights</span><span><?php print number_format($Spotter->countOverallFlights()); ?></span></div>
<div class="col-md-4"><span class="type">Aircrafts</span><span><?php print number_format($Spotter->countOverallAircrafts()); ?></span></div>
<div class="col-md-4"><span class="type">Airlines</span><span><?php print number_format($Spotter->countOverallAirlines()); ?></span></div>
</div>
<div class="specific-stats">
<div class="row column">
<div class="col-md-6">
<h2>Top 10 Most Common Aircraft Type</h2>
<?php
$aircraft_array = $Spotter->countAllAircraftTypes();
print '<div id="chart1" class="chart" width="100%"></div>
<script>
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart1);
function drawChart1() {
var data = google.visualization.arrayToDataTable([
["Aircraft", "# of Times"], ';
$aircraft_data = '';
foreach($aircraft_array as $aircraft_item)
{
$aircraft_data .= '[ "'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
}
$aircraft_data = substr($aircraft_data, 0, -1);
print $aircraft_data;
print ']);
var options = {
chartArea: {"width": "80%", "height": "60%"},
height:300,
is3D: true
};
var chart = new google.visualization.PieChart(document.getElementById("chart1"));
chart.draw(data, options);
}
$(window).resize(function(){
drawChart1();
});
</script>';
?>
<div class="more">
<a href="<?php print $globalURL; ?>/statistics/aircraft" class="btn btn-default btn" role="button">See full statistic»</a>
</div>
</div>
<div class="col-md-6">
<h2>Top 10 Most Common Airline</h2>
<?php
$airline_array = $Spotter->countAllAirlines();
print '<div id="chart2" class="chart" width="100%"></div>
<script>
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart2);
function drawChart2() {
var data = google.visualization.arrayToDataTable([
["Airline", "# of Times"], ';
$airline_data = '';
foreach($airline_array as $airline_item)
{
$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
}
$airline_data = substr($airline_data, 0, -1);
print $airline_data;
print ']);
var options = {
chartArea: {"width": "80%", "height": "60%"},
height:300,
is3D: true
};
var chart = new google.visualization.PieChart(document.getElementById("chart2"));
chart.draw(data, options);
}
$(window).resize(function(){
drawChart2();
});
</script>';
?>
<div class="more">
<a href="<?php print $globalURL; ?>/statistics/airline" class="btn btn-default btn" role="button">See full statistic»</a>
</div>
</div>
</div>
<div class="row column">
<div class="col-md-6">
<h2>Top 10 Most Common Departure Airports</h2>
<?php
$airport_airport_array = $Spotter->countAllDepartureAirports();
print '<div id="chart3" class="chart" width="100%"></div>
<script>
google.load("visualization", "1", {packages:["geochart"]});
google.setOnLoadCallback(drawCharts3);
$(window).resize(function(){
drawCharts3();
});
function drawCharts3() {
var data = google.visualization.arrayToDataTable([
["Airport", "# of Times"],';
$airport_data = '';
foreach($airport_airport_array as $airport_item)
{
$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
$name = str_replace("'", "", $name);
$name = str_replace('"', "", $name);
$airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
}
$airport_data = substr($airport_data, 0, -1);
print $airport_data;
print ']);
var options = {
legend: {position: "none"},
chartArea: {"width": "80%", "height": "60%"},
height:300,
displayMode: "markers",
colors: ["#8BA9D0","#1a3151"]
};
var chart = new google.visualization.GeoChart(document.getElementById("chart3"));
chart.draw(data, options);
}
</script>';
?>
<div class="more">
<a href="<?php print $globalURL; ?>/statistics/airport-departure" class="btn btn-default btn" role="button">See full statistic»</a>
</div>
</div>
<div class="col-md-6">
<h2>Top 10 Most Common Arrival Airports</h2>
<?php
$airport_airport_array2 = $Spotter->countAllArrivalAirports();
print '<div id="chart4" class="chart" width="100%"></div>
<script>
google.load("visualization", "1", {packages:["geochart"]});
google.setOnLoadCallback(drawCharts4);
$(window).resize(function(){
drawCharts4();
});
function drawCharts4() {
var data = google.visualization.arrayToDataTable([
["Airport", "# of Times"],';
$airport_data2 = '';
foreach($airport_airport_array2 as $airport_item2)
{
$name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
$name2 = str_replace("'", "", $name2);
$name2 = str_replace('"', "", $name2);
$airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
}
$airport_data2 = substr($airport_data2, 0, -1);
print $airport_data2;
print ']);
var options = {
legend: {position: "none"},
chartArea: {"width": "80%", "height": "60%"},
height:300,
displayMode: "markers",
colors: ["#8BA9D0","#1a3151"]
};
var chart = new google.visualization.GeoChart(document.getElementById("chart4"));
chart.draw(data, options);
}
</script>';
?>
<div class="more">
<a href="<?php print $globalURL; ?>/statistics/airport-arrival" class="btn btn-default btn" role="button">See full statistic»</a>
</div>
</div>
</div>
<div class="row column">
<div class="col-md-6">
<h2>Busiest Day in the last 7 Days</h2>
<?php
$date_array = $Spotter->countAllDatesLast7Days();
print '<div id="chart5" class="chart" width="100%"></div>
<script>
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart5);
function drawChart5() {
var data = google.visualization.arrayToDataTable([
["Date", "# of Flights"], ';
$date_data = '';
foreach($date_array as $date_item)
{
$date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
}
$date_data = substr($date_data, 0, -1);
print $date_data;
print ']);
var options = {
legend: {position: "none"},
chartArea: {"width": "80%", "height": "60%"},
vAxis: {title: "# of Flights"},
hAxis: {showTextEvery: 2},
height:300,
colors: ["#1a3151"]
};
var chart = new google.visualization.AreaChart(document.getElementById("chart5"));
chart.draw(data, options);
}
$(window).resize(function(){
drawChart5();
});
</script>';
?>
<div class="more">
<a href="<?php print $globalURL; ?>/statistics/date" class="btn btn-default btn" role="button">See full statistic»</a>
</div>
</div>
<div class="col-md-6">
<h2>Busiest Time of the Day</h2>
<?php
$hour_array = $Spotter->countAllHours('hour');
print '<div id="chart6" class="chart" width="100%"></div>
<script>
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart6);
function drawChart6() {
var data = google.visualization.arrayToDataTable([
["Hour", "# of Flights"], ';
$hour_data = '';
foreach($hour_array as $hour_item)
{
$hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
}
$hour_data = substr($hour_data, 0, -1);
print $hour_data;
print ']);
var options = {
legend: {position: "none"},
chartArea: {"width": "80%", "height": "60%"},
vAxis: {title: "# of Flights"},
hAxis: {showTextEvery: 2},
height:300,
colors: ["#1a3151"]
};
var chart = new google.visualization.AreaChart(document.getElementById("chart6"));
chart.draw(data, options);
}
$(window).resize(function(){
drawChart6();
});
</script>';
?>
<div class="more">
<a href="<?php print $globalURL; ?>/statistics/time" class="btn btn-default btn" role="button">See full statistic»</a>
</div>
</div>
</div>
</div>
</div>
<?php
require('footer.php');
?>