Sha256: 6938d638e56d1790fea7bddbea908d75e0cf4045ba9d92511a01aa13c3fd1427

Contents?: true

Size: 553 Bytes

Versions: 18

Compression:

Stored size: 553 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 Gruffy::AccumulatorBar < Gruffy::StackedBar
  def draw
    raise(Gruffy::IncorrectNumberOfDatasetsException) unless @data.length == 1

    accum_array = @data.first[DATA_VALUES_INDEX][0..-2].inject([0]) { |a, v| a << a.last + v}
    data 'Accumulator', accum_array
    set_colors
    @data.reverse!
    super
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
gruffy-1.2.3 lib/gruffy/accumulator_bar.rb
gruffy-1.2.2 lib/gruffy/accumulator_bar.rb
gruffy-1.2.1 lib/gruffy/accumulator_bar.rb
gruffy-1.2.0 lib/gruffy/accumulator_bar.rb
gruffy-1.1.0 lib/gruffy/accumulator_bar.rb
gruffy-1.0.4 lib/gruffy/accumulator_bar.rb
gruffy-1.0.3 lib/gruffy/accumulator_bar.rb
gruffy-1.0.2 lib/gruffy/accumulator_bar.rb
gruffy-1.0.1 lib/gruffy/accumulator_bar.rb
gruffy-1.0.0 lib/gruffy/accumulator_bar.rb
gruffy-0.1.2 lib/gruffy/accumulator_bar.rb
gruffy-0.1.1 lib/gruffy/accumulator_bar.rb
gruffy-0.1.0 lib/gruffy/accumulator_bar.rb
gruffy-0.0.7 lib/gruffy/accumulator_bar.rb
gruffy-0.0.6 lib/gruffy/accumulator_bar.rb
gruffy-0.0.5 lib/gruffy/accumulator_bar.rb
gruffy-0.0.4 lib/gruffy/accumulator_bar.rb
gruffy-0.0.3 lib/gruffy/accumulator_bar.rb