Sparkline in unicode: Difference between revisions
Content deleted Content added
Add NetRexx implementation |
m →{{header|NetRexx}}: Handle both commas & spaces as delimiters |
||
Line 248: | Line 248: | ||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
method sparkline(spark) private static |
method sparkline(spark) private static |
||
spark = spark.changestr(',', ' ') |
|||
bars = '\u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588' |
bars = '\u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588' |
||
barK = bars.words() |
barK = bars.words() |
||
Line 274: | Line 275: | ||
if vals = '' then do |
if vals = '' then do |
||
si = sparks[0] + 1; sparks[0] = si; sparks[si] = 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 |
si = sparks[0] + 1; sparks[0] = si; sparks[si] = 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 |
||
si = sparks[0] + 1; sparks[0] = si; sparks[si] = 1.5 0.5 3.5 2.5 5.5 4.5 7.5 6.5 |
si = sparks[0] + 1; sparks[0] = si; sparks[si] = '1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5' |
||
end |
end |
||
else do |
else do |
||
loop until vals = '' |
loop until vals = '' |
||
-- split input on a | character |
|||
parse vals lst '|' vals |
|||
si = sparks[0] + 1; sparks[0] = si; sparks[si] = lst |
si = sparks[0] + 1; sparks[0] = si; sparks[si] = lst |
||
end |
end |
||
Line 284: | Line 286: | ||
-- run the samples |
-- run the samples |
||
loop si = 1 to sparks[0] |
loop si = 1 to sparks[0] |
||
vals = sparks[si] |
|||
parse sparkline(vals) slope . |
|||
say 'Input: ' |
say 'Input: ' vals |
||
say 'Sparkline: ' slope |
say 'Sparkline: ' slope |
||
say |
|||
end si |
end si |
||
Line 295: | Line 299: | ||
Input: 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 |
Input: 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 |
||
Sparkline: ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁ |
Sparkline: ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁ |
||
Input: 1.5 0.5 3.5 2.5 5.5 4.5 7.5 6.5 |
Input: 1.5 0.5 3.5 2.5 5.5 4.5 7.5 6.5 |
||
Sparkline: ▂▁▄▃▆▅█▇ |
Sparkline: ▂▁▄▃▆▅█▇ |