Sha256: f3379a91a5d5115ac5a4323ead5ce625eea9a11c85045f7d4887645d7d55e8de

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module MetricFu
  module GchartGrapher
    COLORS = %w{009999 FF7400 A60000 008500 E6399B 344AD7 00B860 D5CCB9}
    GCHART_GRAPH_SIZE = "945x317" # maximum permitted image size is 300000 pixels

    NUMBER_OF_TICKS = 6
    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
  end

  class Grapher
    include MetricFu::GchartGrapher

    def self.require_graphing_gem
      require 'gchart' if MetricFu.graph_engine == :gchart
    rescue LoadError
      mf_log "#"*99 + "\n" +
           "If you want to use google charts for graphing, you'll need to install the googlecharts rubygem." +
           "\n" + "#"*99
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metric_fu-4.2.1 lib/metric_fu/reporting/graphs/engines/gchart.rb