-
Notifications
You must be signed in to change notification settings - Fork 1
/
recspercountry.php
106 lines (78 loc) · 2.89 KB
/
recspercountry.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
<?php
// BIDDSAT - BIoDiversity DataSet Assessment Tool
// Copyright (C) 2012 Javier Otegui
// This file is part of BIDDSAT.
// BIDDSAT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// BIDDSAT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with BIDDSAT. If not, see <http://www.gnu.org/licenses/>.
// Contact: javier.otegui@gmail.com
include 'header.php';
$filename=$path.'RecordsByCountry.txt';
$datalink = checkFile($filename, $db, $prov, $dataset);
$file=file($filename);
$data=array();
foreach($file as $line) {
$temparray=explode("\t", $line);
array_push($data, $temparray);
}
array_shift($data);
$length=count($data);
$temp=array();
for ($i=0; $i<$length;$i++) {
array_push($temp, trim($data[$i][2]));
}
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart", "table"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Country');
data.addColumn('number', 'Records');
<?php
echo 'data.addRows('.$length.');';
for ($i=0; $i<$length; $i++) {
echo 'data.setValue('.$i.', 0,\''.$data[$i][0].'\');';
echo 'data.setValue('.$i.', 1,'.$data[$i][1].');';
}
?>
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 750, height: 600, title: 'Records per country for publisher <?php echo $prov; if($dataset<>'all') { echo ', data resource '.$dataset; } ?>'});
var tableData = new google.visualization.DataTable();
tableData.addColumn('string', 'Country');
tableData.addColumn('number', 'Records');
<?php
echo 'tableData.addRows('.$length.');'."\n";
for ($i=0; $i<$length; $i++) {
echo 'tableData.setValue('.$i.', 0, \''.$data[$i][0].'\');'."\n";
echo 'tableData.setValue('.$i.', 1, '.trim($data[$i][1]).');'."\n";
}
?>
var tableChart = new google.visualization.Table(document.getElementById('table_div'));
tableChart.draw(tableData, {
page: 'enable',
pageSize: 20,
width: 250,
title: 'Records per country for publisher <?php echo $prov; ?>'
});
}
</script>
</head>
<body>
<table><tr>
<td><div id="chart_div"></div></td>
<td><div id="table_div"></div></td>
</tr></table>
<br><?php echo $datalink."   ".$endbutton; ?>
</body>
</html>