lib/gruff/base.rb
# Parameters are an array where the first element is the name of the dataset
# and the value is an array of values to plot.
#
# Can be called multiple times with different datasets for a multi-valued
# graph.
#
# If the color argument is nil, the next color from the default theme will
# be used.
#
# NOTE: If you want to use a preset theme, you must set it before calling
# data().
#
# Example:
#   data("Bart S.", [95, 45, 78, 89, 88, 76], '#ffcc00')
Parameters are an array where the first element is the name of the dataset
and the value is an array of values to plot.

Can be called multiple times with different datasets for a multi-valued
graph.

If the color argument is nil, the next color from the default theme will
be used.

If you want to use a preset theme, you must set it before calling
data().


Parameters are an array where the first element is the name of the dataset and the value is an array of values to plot . Can be called multiple times with different datasets for a multi - valued graph . If the color argument is nil the next color from the default theme will be used . If you want to use a preset theme you must set it before calling data () .
def data(name, data_points=[], color=nil)
      data_points = Array(data_points) 
      @data << [name, data_points, (color || increment_color)]
      @column_count = (data_points.length > @column_count) ? data_points.length : @column_count
      data_points.each_with_index do |data_point, index|
        next if data_point.nil?
        if @maximum_value.nil? && @minimum_value.nil?
          @maximum_value = @minimum_value = data_point
        end
        @maximum_value = larger_than_max?(data_point) ? data_point : @maximum_value
        @has_data = true if @maximum_value > 0
        @minimum_value = less_than_min?(data_point) ? data_point : @minimum_value
        @has_data = true if @minimum_value < 0
      end
    end
def data ( name , data_points = [ ] , color = nil ) data_points = Array ( data_points ) @data << [ name , data_points , ( color || increment_color ) ] @column_count = ( data_points . length > @column_count ) ? data_points . length : @column_count data_points . each_with_index do | data_point , index | next if data_point . nil? if @maximum_value . nil? && @minimum_value . nil? @maximum_value = @minimum_value = data_point end @maximum_value = larger_than_max? ( data_point ) ? data_point : @maximum_value @has_data = true if @maximum_value > 0 @minimum_value = less_than_min? ( data_point ) ? data_point : @minimum_value @has_data = true if @minimum_value < 0 end end
Parameters are an array where the first element is the name of the dataset
and the value is an array of values to plot.
Parameters are an array where the first element is the name of the dataset and the value is an array of values to plot .
# make sure it's an array # Set column count if this is larger than previous counts # Pre-normalize # Setup max/min so spread starts at the low end of the data points # TODO Doesn't work with stacked bar graphs # Original: @maximum_value = larger_than_max?(data_point, index) ? max(data_point, index) : @maximum_value
name
<not_specific>
data_points
<not_specific>
color
<not_specific>