A sparkline is a graph of successive values laid out horizontally
where the height of the line is proportional to the values in succession.



Task

Use the following series of Unicode characters to create a program
that takes a series of numbers separated by one or more whitespace or comma characters
and generates a sparkline-type bar graph of the values on a single line of output.

The eight characters: '▁▂▃▄▅▆▇█'

(Unicode values U+2581 through U+2588).

Use your program to show sparklines for the following input,
here on this page:

 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
 1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5 
(note the mix of separators in this second case)!
Notes
 
 A space is not part of the generated sparkline.
 The sparkline may be accompanied by simple statistics of the data such as its range.
 A suggestion emerging in later discussion (see Discussion page) is that the bounds between bins should ideally be set to yield the following results for two particular edge cases:
 "0, 1, 19, 20" -> ▁▁██
 (Aiming to use just two spark levels)
 "0, 999, 4000, 4999, 7000, 7999" -> ▁▁▅▅██
 (Aiming to use just three spark levels)
 It may be helpful to include these cases in output tests.
 You may find that the unicode sparklines on this page are rendered less noisily by Google Chrome than by Firefox or Safari.


/* NetRexx */
options replace format comments java crossref symbols nobinary
 
runSample(arg)
return
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method sparkline(spark) private static
  spark = spark.changestr(',', ' ')
  bars = '\u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588'
  barK = bars.words()
  nmin = spark.word(1)
  nmax = nmin
  -- get min & max values
  loop iw = 1 to spark.words()
    nval = spark.word(iw)
    nmin = nval.min(nmin)
    nmax = nval.max(nmax)
    end iw
  range = nmax - nmin + 1
  slope = ''
  loop iw = 1 to spark.words()    
    point = Math.ceil((spark.word(iw) - nmin + 1) / range * barK)
    slope = slope || bars.word(point)
    end iw
  return slope nmin nmax range
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
  -- sample data setup
  parse arg vals
  sparks = 0
  sparks[0] = 0
  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.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5'
    end
  else do
    loop until vals = ''
      -- split input on a ! character
      parse vals lst '!' vals
      si = sparks[0] + 1; sparks[0] = si; sparks[si] = lst
      end
    end
  -- run the samples
  loop si = 1 to sparks[0]
    vals = sparks[si]
    parse sparkline(vals) slope .
    say 'Input:        ' vals
    say 'Sparkline:    ' slope
    say
    end si
 
  return
 