Sha256: 39c1cee6aa118459c00ef76a2dd257a7481da1f870d7a478f9ec301669c3ef0e

Contents?: true

Size: 709 Bytes

Versions: 22

Compression:

Stored size: 709 Bytes

Contents

require File.dirname(__FILE__) + '/base'

##
# 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.

class Gruff::AccumulatorBar < Gruff::StackedBar

  def draw
    raise(Gruff::IncorrectNumberOfDatasetsException) unless @data.length == 1
    
    accumulator_array = []
    index = 0

    increment_array = @data.first[DATA_VALUES_INDEX].inject([]) {|memo, value| 
        memo << ((index > 0) ? (value + memo.max) : value)
        accumulator_array << memo[index] - value
        index += 1
        memo
      }
    data "Accumulator", accumulator_array
    
    super
  end

end

Version data entries

22 entries across 22 versions & 10 rubygems

Version Path
jslade-gruff-0.3.5 lib/gruff/accumulator_bar.rb
schapht-gruff-0.3.5 lib/gruff/accumulator_bar.rb
topfunky-gruff-0.3.2 lib/gruff/accumulator_bar.rb
topfunky-gruff-0.3.3 lib/gruff/accumulator_bar.rb
topfunky-gruff-0.3.5 lib/gruff/accumulator_bar.rb
umang-gruff-0.3.6 lib/gruff/accumulator_bar.rb
woodhull-gruff-0.3.5 lib/gruff/accumulator_bar.rb
gruff-0.3.7 lib/gruff/accumulator_bar.rb
fhs-gruff-0.3.6.2 lib/gruff/accumulator_bar.rb
pfsc_gruff-0.3.6 lib/gruff/accumulator_bar.rb
pfsc-gruff-0.3.6 lib/gruff/accumulator_bar.rb
teejayvanslyke-gruff-0.4.1 lib/gruff/accumulator_bar.rb
teejayvanslyke-gruff-0.4.0 lib/gruff/accumulator_bar.rb
teejayvanslyke-gruff-0.3.8 lib/gruff/accumulator_bar.rb
teejayvanslyke-gruff-0.3.6 lib/gruff/accumulator_bar.rb
gruff-0.3.6 lib/gruff/accumulator_bar.rb
gruff-0.3.0 lib/gruff/accumulator_bar.rb
gruff-0.2.9 lib/gruff/accumulator_bar.rb
gruff-0.2.8 lib/gruff/accumulator_bar.rb
gruff-0.3.3 lib/gruff/accumulator_bar.rb