From: Mischa POSLAWSKY Date: Wed, 7 Dec 2022 20:17:28 +0000 (+0100) Subject: increment minimum marker position X-Git-Tag: v1.10~9 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/ab6a6188c897d3467a9677dc4a539feedecb30a9 increment minimum marker position First value corresponds to before the leftmost character. Transpose to make it visible if significant (i.e. not expected 0). --- diff --git a/barcat b/barcat index 753e323..efb631f 100755 --- a/barcat +++ b/barcat @@ -287,6 +287,7 @@ my @barmark; if ($opt{markers} and $size > 0) { for my $markspec (split /\h/, $opt{markers}) { my ($char, $func) = split //, $markspec, 2; + my $increment = $func =~ s/[+]\z//; my @pos = eval { if ($func eq 'avg') { return sum(@order) / @order; @@ -321,7 +322,8 @@ if ($opt{markers} and $size > 0) { $pos -= $minval; $pos &&= log $pos if $opt{log}; $pos >= 0 or next; - color(36) for $barmark[$pos / $range * $size] = $char; + $increment ||= $minval && !$pos; + color(36) for $barmark[$pos / $range * $size + $increment] = $char; } } diff --git a/t/t2264-minmax_percent.out b/t/t2264-minmax_percent.out index 0ad153c..7126c7a 100644 --- a/t/t2264-minmax_percent.out +++ b/t/t2264-minmax_percent.out @@ -1,4 +1,4 @@ -barcat --markers=')0v (100v' input/ascii.txt # TODO position before marker character +barcat --markers=')0v (100v' input/ascii.txt 123e-6 micro (--------------------- .1 long line (---------------------) -1 (-------------- diff --git a/t/t2265-percentile_markers.out b/t/t2265-percentile_markers.out index 80888d6..5258fc8 100644 --- a/t/t2265-percentile_markers.out +++ b/t/t2265-percentile_markers.out @@ -1,6 +1,6 @@ -barcat --graph-format=─ --markers='550v 00v 11v 999v ^100v' input/ascii.txt -123e-6 micro ──9──────────5──────── - .1 long line ──9──────────5────────1 - -1 ──9──────────5─ - -2 ──9──── +barcat --graph-format=─ --markers='550v 11v 00v 999v 0100v' input/ascii.txt +123e-6 micro 0─9──────────5──────── + .1 long line 0─9──────────5────────0 + -1 0─9──────────5─ + -2 0─9──── -3