full distribution over sparkline indicators
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 6 Nov 2022 14:04:05 +0000 (15:04 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 7 Nov 2022 00:46:55 +0000 (01:46 +0100)
No unexpected min/max exceptions.

barcat
t/t2100-sparkwave_--spark.out
t/t2103-spark-lines_--spark_-w9.out
t/t2105-spark_ascii_-a_--spark.out
t/t2111-spark_unicode_--spark=-·•O.out
t/t2180-spark_combined_--spark=012345_-cs_--maxval=1_-L17.out

diff --git a/barcat b/barcat
index 095ee93c5ac9080dbff1408ebf8afb8af8068f0a..077bae022e42e0cc88347f6bd4ff5168e71e2914 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -55,7 +55,7 @@ GetOptions(\%opt,
        },
        'spark:s' => sub {
                $opt{spark} = [split //,
-                       $_[1] || ($opt{ascii} ? ' ..oOO' : ' ▁▂▃▄▅▆▇█')
+                       $_[1] || ($opt{ascii} ? ' .oO' : ' ▁▂▃▄▅▆▇█')
                ];
        },
        'palette=s' => sub {
@@ -285,10 +285,9 @@ while ($nr <= $limit) {
                say '' if $opt{width} and $nr and $nr % $opt{width} == 0;
                print color($color), $opt{spark}->[
                        !$val || !$#{$opt{spark}} ? 0 : # blank
-                       $val == $order[0] ? -1 : # max
-                       $val == $order[-1] ? 1 : # min
-                       $#{$opt{spark}} < 3 ? 1 :
-                       $rel * ($#{$opt{spark}} - 3) + 2.5
+                       $#{$opt{spark}} < 2 ? 1 :
+                       $val >= $order[0] ? -1 :
+                       $rel * ($#{$opt{spark}} - 1e-14) + 1
                ];
                next;
        }
@@ -532,12 +531,9 @@ or I<greys> and I<fire256> for 256-color variants.
 
 Replace lines by I<sparklines>,
 single characters corresponding to input values.
-A specified sequence of unicode characters will be used for
 Of a specified sequence of unicode characters,
 the first one will be used for non-values,
-the last one for the maximum,
-the second (if any) for the minimum,
-and any remaining will be distributed over the range of values.
+the remainder will be distributed over the range of values.
 Unspecified, block fill glyphs U+2581-2588 will be used.
 
 =item -s, --stat
index 67f49518950123ab4c99765c7eae7a00519e88ee..70f8cf12cb07653e4c0e5ccbb5915f3005bfd34e 100644 (file)
@@ -1 +1 @@
-��▇▇█▇▇▇▇▇▆▆▆▆▅▅▅▄▄▄▃▃▃▃▂▂▂▂▂▁▂▂▂▂▂▃▃▃▃▄▄▄▅▅▅▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▆▆▆▆▅▅▅▄▄▄▄▃▃▃▃▂▂▂▂▂▂▂▂▂▂▃▃▃▃▄▄▄▅▅▅▅▆▆▆▆▇
+��████████▇▇▇▆▆▅▅▄▄▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▃▄▄▅▅▆▆▇▇▇████████████▇▇▆▆▅▅▄▄▃▃▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▃▄▄▅▅▆▆▆▇▇██
index cde9902b2dff0ece62ef7d2c482434fefe1577ef..01ea973ab7a2df16aeba1146c1433e49d2b470a2 100644 (file)
@@ -1,12 +1,12 @@
-��▇▇█▇▇▇▇▇
-��▆▆▆▅▅▅▄▄
-��▃▃▃▃▂▂▂▂
-��▁▂▂▂▂▂▃▃
-��▃▄▄▄▅▅▅
-��▆▆▆▇▇▇▇▇
-��▇▇▇▇▆▆▆
-��▅▅▄▄▄▄▃▃
-��▃▂▂▂▂▂▂▂
-��▂▂▃▃▃▃▄
-▄▅▅��▅▆▆▆▆
-�
+��████████
+��▇▇▆▆▅▅▄▄
+��▃▂▂▂▁▁▁▁
+��▁▁▁▁▁▁▂▂
+��▃▃▄▄▅▅▆
+��▇▇██████
+��█████▇▇
+��▅▅▄▄▃▃▃▂
+��▁▁▁▁▁▁▁▁
+��▁▁▁▂▂▃▃
+▄▅▅��▆▆▇▇█
+�
index eddad81dbcce4c80f0676ad68fc2bece77127c5b..771c1a8ad3105178cfc9ebd0bc8af31e1978e92f 100644 (file)
@@ -1 +1 @@
-OOOOOOOOOOOOoooooooo.................ooooooooOOOOOOOOOOOOOOOOOooooooooo................oooooooooOOOO
+OOOOOOOOOOOOOoooooo...................ooooooOOOOOOOOOOOOOOOOOOOOooooo....................oooooOOOOOO
index 54d2883e71d84ae71e48fa678b92883d66797f0e..854d335f2f6130c8f9904932562363004a56303a 100644 (file)
@@ -1 +1 @@
•••-••••••••O-••-
··•-•••••••OO-O·-
index 85a14465bac38380f29fa845b0afe17debb71c04..777e01533e930666e176bdcc7cddb247590e6827 100644 (file)
@@ -1,2 +1,2 @@
-\e[31m1\e[90m2\e[90m3\e[90m3\e[90m0\e[90m4\e[90m4\e[90m3\e[90m4\e[90m4\e[90m3\e[90m4\e[32m4\e[32m50\e[32m4\e[90m3\e[0m
+\e[31m1\e[90m1\e[90m2\e[90m3\e[90m0\e[90m4\e[90m4\e[90m4\e[90m4\e[90m4\e[90m3\e[90m4\e[32m5\e[32m50\e[32m5\e[90m2\e[0m
 -7.459 of \e[1m-7.459\e[0m total in 16 values over 18 lines (\e[31m-3\e[0m min, \e[36m-0.47\e[0m avg, \e[32m2\e[0m max)