|
1
|
|
|
<?php |
|
2
|
|
|
require_once('require/class.Connection.php'); |
|
3
|
|
|
require_once('require/class.Marine.php'); |
|
4
|
|
|
require_once('require/class.Language.php'); |
|
5
|
|
|
$Marine = new Marine(); |
|
6
|
|
|
$title = _("Statistics").' - '._("Most common Vessel Type"); |
|
7
|
|
|
|
|
8
|
|
|
$type = 'marine'; |
|
9
|
|
|
if (!isset($filter_name)) $filter_name = ''; |
|
10
|
|
|
$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
11
|
|
|
$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
12
|
|
|
|
|
13
|
|
|
require_once('header.php'); |
|
14
|
|
|
|
|
15
|
|
|
include('statistics-sub-menu.php'); |
|
16
|
|
|
print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
|
17
|
|
|
print '<script type="text/javascript" src="'.$globalURL.'/js/d3pie.min.js"></script>'; |
|
18
|
|
|
print '<div class="info"> |
|
19
|
|
|
<h1>'._("Most common vessel Type").'</h1> |
|
20
|
|
|
</div> |
|
21
|
|
|
<p>'._("Below are the <strong>Top 10</strong> most common vessel types.").'</p>'; |
|
22
|
|
|
|
|
23
|
|
|
$type_array = $Marine->countAllMarineTypes(true,0,'',$filter_name,$year,$month); |
|
|
|
|
|
|
24
|
|
|
print '<div id="chart" class="chart" width="100%"></div><script>'; |
|
25
|
|
|
$type_data = ''; |
|
26
|
|
|
foreach($type_array as $type_item) |
|
27
|
|
|
{ |
|
28
|
|
|
$type_data .= '["'.$type_item['marine_type'].'",'.$type_item['marine_type_count'].'],'; |
|
29
|
|
|
} |
|
30
|
|
|
$type_data = substr($type_data, 0, -1); |
|
31
|
|
|
print 'var series = ['.$type_data.'];'; |
|
32
|
|
|
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);'; |
|
33
|
|
|
print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
34
|
|
|
print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
35
|
|
|
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":'; |
|
36
|
|
|
print 'dataset'; |
|
37
|
|
|
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}}});'; |
|
38
|
|
|
print '</script>'; |
|
39
|
|
|
|
|
40
|
|
|
if (!empty($type_array)) |
|
41
|
|
|
{ |
|
42
|
|
|
print '<div class="table-responsive">'; |
|
43
|
|
|
print '<table class="common-type table-striped">'; |
|
44
|
|
|
print '<thead>'; |
|
45
|
|
|
print '<th></th>'; |
|
46
|
|
|
print '<th>'._("Type").'</th>'; |
|
47
|
|
|
print '<th>'._("# of times").'</th>'; |
|
48
|
|
|
print '</thead>'; |
|
49
|
|
|
print '<tbody>'; |
|
50
|
|
|
$i = 1; |
|
51
|
|
|
foreach($type_array as $type_item) |
|
52
|
|
|
{ |
|
53
|
|
|
print '<tr>'; |
|
54
|
|
|
print '<td><strong>'.$i.'</strong></td>'; |
|
55
|
|
|
print '<td>'; |
|
56
|
|
|
print '<a href="'.$globalURL.'/marine/type/'.$type_item['marine_type_id'].'">'.$type_item['marine_type'].'</a>'; |
|
57
|
|
|
print '</td>'; |
|
58
|
|
|
print '<td>'; |
|
59
|
|
|
print $type_item['marine_type_count']; |
|
60
|
|
|
print '</td>'; |
|
61
|
|
|
print '</tr>'; |
|
62
|
|
|
$i++; |
|
63
|
|
|
} |
|
64
|
|
|
print '<tbody>'; |
|
65
|
|
|
print '</table>'; |
|
66
|
|
|
print '</div>'; |
|
67
|
|
|
} |
|
68
|
|
|
require_once('footer.php'); |
|
69
|
|
|
?> |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: