-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathstatistics-type.php
69 lines (64 loc) · 3.07 KB
/
statistics-type.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
<?php
require_once('require/class.Connection.php');
require_once('require/class.Marine.php');
require_once('require/class.Language.php');
$Marine = new Marine();
$title = _("Statistics").' - '._("Most common Vessel Type");
$type = 'marine';
if (!isset($filter_name)) $filter_name = '';
$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
require_once('header.php');
include('statistics-sub-menu.php');
print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
print '<script type="text/javascript" src="'.$globalURL.'/js/d3pie.min.js"></script>';
print '<div class="info">
<h1>'._("Most common vessel Type").'</h1>
</div>
<p>'._("Below are the <strong>Top 10</strong> most common vessel types.").'</p>';
$type_array = $Marine->countAllMarineTypes(true,0,'',$filter_name,$year,$month);
print '<div id="chart" class="chart" width="100%"></div><script>';
$type_data = '';
foreach($type_array as $type_item)
{
$type_data .= '["'.$type_item['marine_type'].'",'.$type_item['marine_type_count'].'],';
}
$type_data = substr($type_data, 0, -1);
print 'var series = ['.$type_data.'];';
print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
print 'var aircraftype = new d3pie("chart",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"80%"},"data":{"sortOrder":"value-desc","content":';
print 'dataset';
print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
print '</script>';
if (!empty($type_array))
{
print '<div class="table-responsive">';
print '<table class="common-type table-striped">';
print '<thead>';
print '<th></th>';
print '<th>'._("Type").'</th>';
print '<th>'._("# of times").'</th>';
print '</thead>';
print '<tbody>';
$i = 1;
foreach($type_array as $type_item)
{
print '<tr>';
print '<td><strong>'.$i.'</strong></td>';
print '<td>';
print '<a href="'.$globalURL.'/marine/type/'.$type_item['marine_type_id'].'">'.$type_item['marine_type'].'</a>';
print '</td>';
print '<td>';
print $type_item['marine_type_count'];
print '</td>';
print '</tr>';
$i++;
}
print '<tbody>';
print '</table>';
print '</div>';
}
require_once('footer.php');
?>