increment minimum marker position
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 7 Dec 2022 20:17:28 +0000 (21:17 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 12 Dec 2022 22:03:10 +0000 (23:03 +0100)
First value corresponds to before the leftmost character.
Transpose to make it visible if significant (i.e. not expected 0).

barcat
t/t2264-minmax_percent.out
t/t2265-percentile_markers.out

diff --git a/barcat b/barcat
index 753e323a0ebe376109d38f4e5f3d444334e3eb92..efb631f248964c7714c4852ae6883c1668681a25 100755 (executable)
--- 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;
                }
        }
 
index 0ad153ce1b6db12a588a30cc96bc69c47915d2f0..7126c7a06514f91178631851f4db7ed9d56513e5 100644 (file)
@@ -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           (--------------
index 80888d6ceed309dd96c73c5ec47586f920de1613..5258fc8e0856c9614ea59200c8292b9480820751 100644 (file)
@@ -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