| Class | Gruff::AccumulatorBar |
| In: |
lib/gruff/accumulator_bar.rb
|
| Parent: | Gruff::StackedBar |
A special bar graph that shows a single dataset as a set of stacked bars. The bottom bar shows the running total and the top bar shows the new value being added to the array.
# File lib/gruff/accumulator_bar.rb, line 10
10: def draw
11: raise(Gruff::IncorrectNumberOfDatasetsException) unless @data.length == 1
12:
13: accumulator_array = []
14: index = 0
15:
16: increment_array = @data.first[DATA_VALUES_INDEX].inject([]) {|memo, value|
17: memo << ((index > 0) ? (value + memo.max) : value)
18: accumulator_array << memo[index] - value
19: index += 1
20: memo
21: }
22: data "Accumulator", accumulator_array
23:
24: super
25: end