1 require File.dirname(__FILE__) + '/base'
4 # A special bar graph that shows a single dataset as a set of
5 # stacked bars. The bottom bar shows the running total and
6 # the top bar shows the new value being added to the array.
8 class Gruff::AccumulatorBar < Gruff::StackedBar
11 raise(Gruff::IncorrectNumberOfDatasetsException) unless @data.length == 1
13 accumulator_array = []
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
22 data "Accumulator", accumulator_array