header option to prepend value scale
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 18 Sep 2019 21:17:07 +0000 (23:17 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 24 Sep 2019 00:08:51 +0000 (02:08 +0200)
Single top line to indicate minimum and maximum values, similar to scale in
common-lisp vspark <https://github.com/tkych/cl-spark>.

barcat
t/t0002-usage_-h_|wc_-l.out
t/t1901-technicolor_-cs_--header.in [moved from t/t1901-technicolor_-cs.in with 100% similarity]
t/t1901-technicolor_-cs_--header.out [moved from t/t1901-technicolor_-cs.out with 96% similarity]

diff --git a/barcat b/barcat
index db0aefa23fb370051399b502954972f388f39281..268c993db3a76b223e04114c6506489b727e5c25 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -42,6 +42,7 @@ GetOptions(\%opt,
                        " (range expected)\n"
                );
        },
+       'header!',
        'markers|m=s',
        'graph-format=s' => sub {
                $opt{'graph-format'} = substr $_[1], 0, 1;
@@ -192,6 +193,8 @@ sub sival {
        );
 }
 
+say sprintf '%*s-+%*s-+', $lenval, $minval, $size * ($maxval - $minval) - 3, $maxval if $opt{header};
+
 while ($nr <= $#lines) {
        $nr >= $opt{hidemax} and last if defined $opt{hidemax};
        my $val = $values[$nr];
@@ -294,6 +297,10 @@ A string can indicate the starting position of a value
 or capture the numbers itself,
 for example I<-f'(\d+)'> for the first digits anywhere.
 
+=item --header
+
+Prepend a chart axis with minimum and maximum values labeled.
+
 =item -H, --human-readable
 
 Format values using SI unit prefixes,
index f04c001f3f7fd5d290d0264b4a2c35f7b159ac42..e85087affded170efcbc6f9672a6fc671d839ed0 100644 (file)
@@ -1 +1 @@
-29
+31
similarity index 96%
rename from t/t1901-technicolor_-cs.out
rename to t/t1901-technicolor_-cs_--header.out
index 20485574eba67377417e6f1da01afba693fe3785..e1d4a415618443e9bc78d54c68962fbfb442226e 100644 (file)
@@ -1,3 +1,4 @@
+         -3-+                  2-+
 \e[31m         -3\e[0m       
 \e[90m     -2.449\e[0m       --
 \e[90m         -2\e[0m       ----