-
Notifications
You must be signed in to change notification settings - Fork 1
/
resvsdom.php
119 lines (91 loc) · 3.01 KB
/
resvsdom.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
<?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.'ResourcesVsDayofmonth.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);
$maxmintemp=array();
$temp=array();
for ($i=0; $i<$length;$i++) {
array_push($maxmintemp, trim($data[$i][2]));
$match=0;
for ($j=0; $j<count($temp); $j++) {
if ($temp[$j]==$data[$i][0]) {
$match=1;
break;
}
}
if ($match==0) {
array_push($temp, $data[$i][0]);
}
}
$setno=$temp;
$min=0;
$max=max($maxmintemp);
?>
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['table']});
google.setOnLoadCallback(drawTable);
function drawTable() {
var data = new google.visualization.DataTable();
<?php
echo 'data.addColumn(\'number\', \'Resource ID\');'."\n";
for ($i=1; $i<=31; $i++) {
echo 'data.addColumn(\'number\', \''.$i.'\');'."\n";
}
echo 'data.addRows('.count($setno).');'."\n";
for ($i=0; $i<count($setno); $i++) {
echo 'data.setCell('.$i.', 0, '.$setno[$i].');'."\n";
}
for ($i=0; $i<count($data); $i++ ) {
echo 'data.setCell('.array_search($data[$i][0], $setno).', '.$data[$i][1].', '.trim($data[$i][2]).');'."\n";
}
?>
var table = new google.visualization.Table(document.getElementById('table_div'));
var formatter = new google.visualization.ColorFormat();
formatter.addGradientRange(<?php echo $min; ?>, <?php echo $max+1; ?>, 'transparent', 'white', 'green');
<?php
for ($i=1; $i<32; $i++) {
echo 'formatter.format(data, '.$i.');'."\n";
}
?>
table.draw(data, {
showRowNumber: false,
page: 'disable',
sort: 'disable',
allowHtml: true,
width: '100%'
});
}
</script>
</head>
<body>
<h3>Record density for each day of the week among data resources.</h3>
Data from publisher <?php echo $prov; if($dataset<>'all') { echo ', data resource '.$dataset; } ?>. The greener, the more records that fall in that day.<br>
<div id='table_div'></div>
<br><?php echo $datalink."   ".$endbutton; ?>
</body>
</html>