X-Git-Url: http://git.shiar.nl/barcat.git/blobdiff_plain/ef0556b2123644377182a9f43a4b2a753cb571a6..4644846ee87e7e9eaa30ec40d679d0e02afd8d14:/graph diff --git a/graph b/graph index d317df5..ab51d08 100755 --- a/graph +++ b/graph @@ -8,7 +8,10 @@ use open qw( :std :utf8 ); our $VERSION = '1.02'; use Getopt::Long '2.33', qw( :config gnu_getopt ); -sub podexit { require Pod::Usage; Pod::Usage::pod2usage(-exitval => 0, @_) } +sub podexit { + require Pod::Usage; + Pod::Usage::pod2usage(-exitval => 0, -perldocopt => '-oman', @_); +} GetOptions(\my %opt, 'color|c!', 'follow|f:i', @@ -54,6 +57,8 @@ $SIG{INT} = 'DEFAULT'; sub show_lines { +state $nr = 0; + my @order = sort { $b <=> $a } grep { length } @values; my $maxval = $order[0]; my $minval = min $order[-1], 0; @@ -72,9 +77,21 @@ if ($opt{markers} // 1 and $size > 0) { $barmark[ orderpos($#order / 2) ] = '+'; # mean $barmark[ -$minval * $size ] = '|' if $minval < 0; # zero defined and $opt{color} and $_ = "\e[36m$_\e[0m" for @barmark; + + state $lastmax = $maxval; + if ($maxval > $lastmax) { + print ' ' x ($lenval + $len); + printf "\e[90m" if $opt{color}; + printf '%-*s', + ($lastmax - $minval) * $size + .5, + '-' x (($values[$nr - 1] - $minval) * $size); + print "\e[92m" if $opt{color}; + say '+' x (($maxval - $lastmax - $minval) * $size + .5); + print "\e[0m" if $opt{color}; + $lastmax = $maxval; + } } -state $nr = 0; while ($nr <= $#lines) { my $val = $values[$nr]; if (length $val) {