From 94c475154436950768e3686fa7030ee5fdb23e4e Mon Sep 17 00:00:00 2001 From: octo Date: Sat, 23 Apr 2005 06:36:58 +0000 Subject: [PATCH] Use relative scaling in the main table --- lib/Onis/Plugins/Core.pm | 62 +++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/lib/Onis/Plugins/Core.pm b/lib/Onis/Plugins/Core.pm index fb68973..6babaed 100644 --- a/lib/Onis/Plugins/Core.pm +++ b/lib/Onis/Plugins/Core.pm @@ -693,18 +693,21 @@ EOF } if ($DISPLAY_LINES ne 'NONE') { + my $span = $DISPLAY_LINES eq 'BOTH' ? ' colspan="2"' : ''; $trans = translate ('Number of Lines'); - print $fh " $trans\n"; + print $fh " $trans\n"; } if ($DISPLAY_WORDS ne 'NONE') { + my $span = $DISPLAY_WORDS eq 'BOTH' ? ' colspan="2"' : ''; $trans = translate ('Number of Words'); - print $fh " $trans\n"; + print $fh " $trans\n"; } if ($DISPLAY_CHARS ne 'NONE') { + my $span = $DISPLAY_CHARS eq 'BOTH' ? ' colspan="2"' : ''; $trans = translate ('Number of Characters'); - print $fh " $trans\n"; + print $fh " $trans\n"; } if ($DISPLAY_TIMES) { @@ -808,50 +811,44 @@ EOF if ($DISPLAY_LINES ne 'NONE') { - print $fh qq# #; - if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'BAR')) + if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'NUMBER')) { - my $code = bar ($max_lines, $NickData->{$nick}{'lines'}); - print $fh $code; + my $num = $NickData->{$nick}{'lines_total'}; + print $fh qq( $num\n); } - print $fh ' ' if ($DISPLAY_LINES eq 'BOTH'); - if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'NUMBER')) + if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'BAR')) { - print $fh $NickData->{$nick}{'lines_total'}; + my $code = bar ($max_lines, $NickData->{$nick}{'lines'}); + print $fh qq( $code\n); } - print $fh "\n"; } if ($DISPLAY_WORDS ne 'NONE') { - print $fh qq# #; - if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'BAR')) + if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'NUMBER')) { - my $code = bar ($max_words, $NickData->{$nick}{'words'}); - print $fh $code; + my $num = $NickData->{$nick}{'words_total'}; + print $fh qq( $num\n); } - print $fh ' ' if ($DISPLAY_WORDS eq 'BOTH'); - if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'NUMBER')) + if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'BAR')) { - print $fh $NickData->{$nick}{'words_total'}; + my $code = bar ($max_words, $NickData->{$nick}{'words'}); + print $fh qq( $code\n); } - print $fh "\n"; } if ($DISPLAY_CHARS ne 'NONE') { - print $fh qq# #; - if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'BAR')) + if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'NUMBER')) { - my $code = bar ($max_chars, $NickData->{$nick}{'chars'}); - print $fh $code; + my $num = $NickData->{$nick}{'chars_total'}; + print $fh qq( $num\n); } - print $fh ' ' if ($DISPLAY_CHARS eq 'BOTH'); - if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'NUMBER')) + if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'BAR')) { - print $fh $NickData->{$nick}{'chars_total'}; + my $code = bar ($max_chars, $NickData->{$nick}{'chars'}); + print $fh qq( $code\n); } - print $fh "\n"; } if ($DISPLAY_TIMES) @@ -958,21 +955,16 @@ sub bar confess () unless (ref ($source) eq 'ARRAY'); # BAR_WIDTH is a least 10 - my $max_width = $BAR_WIDTH - 4; - my $factor = 1; my $retval = ''; my $i; my $j; - if (!$max_num) { return ($retval); } - $factor = $max_width / $max_num; - for ($i = 0; $i < 4; $i++) { my $sum = 0; - my $width = 1; my $img = $H_IMAGES[$i]; + my $width; for ($j = 0; $j < 6; $j++) { @@ -980,9 +972,9 @@ sub bar $sum += $source->[$hour]; } - $width += int (0.5 + ($sum * $factor)); + $width = sprintf ("%.2f", 95 * $sum / $max_num); - $retval .= qq#$sum); -- 2.11.0