indicate average value in bar
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 4 Sep 2019 14:57:08 +0000 (16:57 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 5 Sep 2019 03:11:33 +0000 (05:11 +0200)
graph

diff --git a/graph b/graph
index 83a3a880adaeab4cde199de30081bdb5a92e5125..b53ac6a8496e2f1f46886ab21cc39a7bc6bc6c78 100755 (executable)
--- a/graph
+++ b/graph
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use 5.014;
 use warnings;
-use List::Util qw( max );
+use List::Util qw( max sum );
 
 my $width = $ENV{COLUMNS} || 80;
 
@@ -15,6 +15,7 @@ my $size   = ($width - $lenval - $len) / $order[0];  # bar multiplication
 
 sub orderpos { ($order[$_[0]] + $order[$_[0] + .5]) / 2 * $size }
 my @barmark;
+$barmark[ sum(@values) / @values * $size ] = '=';  # average
 $barmark[ orderpos($#order / 2) ] = '+';  # mean
 defined and $_ = "\e[36m$_\e[0m" for @barmark;