blob: f92032818450468c1fd8ef0ffbbc80b90336e87a (
plain)
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
|
<table class="miniplot"><tr>
% for my $major (@major) {
<td><div class="graph">
<ul>
% my $i = 0;
% for my $minor (@minor) {
% my $percent = int( 100 * ($data->{$major}{$minor} || 0) / $max );
<li class="c<% ($i % 6) + 1%>" style="width: <% $barwidth %>%;
left: <% $baroffset + $each * $i %>%;
height: <% $percent %>%;"><div class="data"><% $minor %>: <% $percent %>%</div></li>
% $i++;
% }
</ul>
</div></td>
% }
</tr><tr>
% for my $major (@major) {
<th class="legend"><% $major %></th>
% }
</tr>
</table>
<table class="miniplot"><tr>
% my $i = 0;
% for my $minor (@minor) {
<th><span class="demoblock c<% ($i++ % 6) + 1 %>"></span> <% $minor %></th>
% }
</tr>
</table>
<%args>
$data
$major => undef
$minor => undef
</%args>
<%init>
my $max = 1;
my %minor;
for my $major (keys %{$data}) {
for (keys %{$data->{$major}}) {
$minor{$_}++;
$max = $data->{$major}{$_} if $data->{$major}{$_} > $max;
}
}
my @major = $major ? @{$major} : sort keys %{$data};
my @minor = $minor ? @{$minor} : sort keys %minor;
return unless @minor and @major;
my $each = int( (100 / @minor) );
my $barwidth = int( (100 / @minor) * (3/4) );
my $baroffset = int( (100 / @minor) * (1/8) );
</%init>
|