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").' - '._("Top 10 Races Number of Participants");
8 if (!isset($filter_name)) $filter_name = '';
9 $year = filter_input(INPUT_GET
,'year',FILTER_SANITIZE_NUMBER_INT
);
10 $month = filter_input(INPUT_GET
,'month',FILTER_SANITIZE_NUMBER_INT
);
12 require_once('header.php');
13 include('statistics-sub-menu.php');
14 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
15 print '<script type="text/javascript" src="'.$globalURL.'/js/d3pie.min.js"></script>';
16 print '<div class="info">
17 <h1>'._("Top 10 Races Number of Participants").'</h1>
19 <p>'._("Below are the <strong>Top 10</strong> races with the most number of participants.").'</p>';
21 $race_array = $Marine->countAllCaptainsByRaces(true,$filter_name,$year,$month);
22 print '<div id="chart" class="chart" width="100%"></div><script>';
24 foreach($race_array as $race_item)
26 $race_data .= '["'.$race_item['marine_race_name'].' ('.$race_item['marine_race_id'].')",'.$race_item['marine_captain_count'].'],';
28 $race_data = substr($race_data, 0, -1);
29 print 'var series = ['.$race_data.'];';
30 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);';
31 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
32 print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
33 print 'var marinetype = 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":"60%"},"data":{"sortOrder":"value-desc","content":';
35 print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3,"format":"value"},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#98e8e3","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
38 if (!empty($race_array))
40 print '<div class="table-responsive">';
41 print '<table class="common-type table-striped">';
44 print '<th>'._("Race Name").'</th>';
45 print '<th>'._("# of captains").'</th>';
49 foreach($race_array as $race_item)
52 print '<td><strong>'.$i.'</strong></td>';
54 print $race_item['marine_race_name'].' ('.$race_item['marine_race_id'].')</a>';
57 print $race_item['marine_captain_count'];
66 require_once('footer.php');