Module: MetricFu::GchartGrapher

Included in:
Grapher
Defined in:
lib/graphs/engines/gchart.rb

Constant Summary collapse

COLORS =
%w{009999 FF7400 A60000 008500 E6399B 344AD7 00B860 D5CCB9}
GCHART_GRAPH_SIZE =

maximum permitted image size is 300000 pixels

"945x317"
NUMBER_OF_TICKS =
6

Instance Method Summary collapse

Instance Method Details

#determine_y_axis_scale(values) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/graphs/engines/gchart.rb', line 7

def determine_y_axis_scale(values)
  values.collect! {|val| val || 0.0 }
  if values.empty?
    @max_value = 10
    @yaxis = [0, 2, 4, 6, 8, 10]
  else
    @max_value = values.max + Integer(0.1 * values.max)
    portion_size = (@max_value / (NUMBER_OF_TICKS - 1).to_f).ceil
    @yaxis = []
    NUMBER_OF_TICKS.times {|n| @yaxis << Integer(portion_size * n) }
    @max_value = @yaxis.last
  end
end