spark
spark copied to clipboard
the last bar is always one number wide
Data 0 1 19 20
should print ▁▁██ but prints ▁▁▇█
The problem is the number 7 in your character index calculation. A working formula for the index is int( 8 * (n-min)/(max-min) )
with n==max
special-cased to give 7.
See also https://rosettacode.org/wiki/Talk:Sparkline_in_unicode#Most_of_these_are_buggy