my $day = (localtime ($time))[6];
my $index = ($day * 4) + $hour;
- my @data = $WeekdayCache->get ($nick) || (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0));
+ my @data = $WeekdayCache->get ($nick);
+ @data = (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) unless (@data);
$data[$index] += $chars;
$WeekdayCache->put ($nick, @data);
- @data = $WeekdayCache->get ('<TOTAL>') || (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0));
+ @data = $WeekdayCache->get ('<TOTAL>');
+ @data = (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) unless (@data);
$data[$index] += $chars;
$WeekdayCache->put ('<TOTAL>', @data);
}
my $fh = get_filehandle ();
my $max = 0;
+ my $total = 0;
my $bar_factor = 0;
for (@order)
{
my ($num, $abbr, $name) = @$_;
- my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
- $max = $sum if ($max < $sum);
+ for (my $i = 0; $i < 4; $i++)
+ {
+ $max = $data->{$abbr}[$i] if ($max < $data->{$abbr}[$i]);
+ $total += $data->{$abbr}[$i];
+ }
}
$bar_factor = $BarHeight / $max;
for (@order)
{
my ($num, $abbr, $name) = @$_;
- my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
-
- print $fh qq# <td class="bar $abbr">$sum<br />\n #;
for (my $i = 0; $i < 4; $i++)
{
my $num = $data->{$abbr}[$i];
- my $height = int (0.5 + $num * $bar_factor) || 1;
+ my $height = sprintf ("%.2f", (95 * $num / $max));
my $img = $VImages[$i];
-
- print $fh qq(<img src="$img" alt="" style="height: ${height}px;" />);
+
+ print $fh qq# <td class="bar vertical $abbr">#,
+ qq(<img src="$img" alt="" class="first last" style="height: ${height}%;" /></td>\n);
}
- print $fh "\n </td>\n";
+ }
+ print $fh qq( </tr>\n <tr class="counter">\n);
+ for (@order)
+ {
+ my ($num, $abbr, $name) = @$_;
+ my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
+ my $pct = sprintf ("%.1f", (100 * $sum / $total));
+ print $fh qq( <td colspan="4" class="counter $abbr">$pct%</td>\n);
}
print $fh qq( </tr>\n <tr class="numeration">\n);
for (@order)
{
my ($num, $abbr, $name) = @$_;
- print $fh qq( <td class="numeration $abbr">$name</td>\n);
+ print $fh qq( <td colspan="4" class="numeration $abbr">$name</td>\n);
}
print $fh " </tr>\n</table>\n\n";
}