File: stacked_mixin.rb

package info (click to toggle)
ruby-gruff 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 852 kB
  • sloc: ruby: 4,929; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

module Gruff::Base::StackedMixin
  # Used by StackedBar and child classes.
  #
  # tsal: moved from Base 03 FEB 2007
  DATA_VALUES_INDEX = Gruff::Base::DATA_VALUES_INDEX
  def get_maximum_by_stack
    # Get sum of each stack
    max_hash = {}
    @data.each do |data_set|
      data_set[DATA_VALUES_INDEX].each_with_index do |data_point, i|
        max_hash[i] = 0.0 unless max_hash[i]
        max_hash[i] += data_point.to_f
      end
    end
  
    # @maximum_value = 0
    max_hash.keys.each do |key|
      @maximum_value = max_hash[key] if max_hash[key] > @maximum_value
    end
    @minimum_value = 0
  end
end