Class: Gruff::Histogram

Inherits:
Bar show all
Defined in:
lib/gruff/histogram.rb

Overview

Here’s how to set up a Gruff::Histogram.

g = Gruff::Histogram.new
g.title = 'Histogram Graph'
g.minimum_bin = 10
g.bin_width = 20
g.data :A, [10, 10, 20, 30, 40, 40, 40, 40, 40, 40, 50, 10, 10, 10]
g.data :B, [100, 100, 100, 100, 90, 90, 80, 30, 30, 30, 30, 30]
g.write('histogram.png')

Constant Summary

Constants inherited from Base

Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN

Instance Attribute Summary collapse

Attributes inherited from Bar

#bar_spacing, #group_spacing, #hide_labels, #label_formatting, #show_labels_for_bar_values

Attributes inherited from Base

#bottom_margin, #colors, #hide_legend, #hide_line_markers, #hide_line_numbers, #hide_title, #label_margin, #label_max_size, #label_truncation_style, #left_margin, #legend_at_bottom, #legend_box_size, #legend_margin, #marker_color, #marker_shadow_color, #maximum_value, #minimum_value, #no_data_message, #right_margin, #sort, #sorted_drawing, #title_margin, #top_margin, #x_axis_increment, #x_axis_label_format, #y_axis_increment, #y_axis_label_format

Instance Method Summary collapse

Methods inherited from Bar

#spacing_factor=

Methods inherited from Base

#add_color, #bold_title=, #draw, #font=, #font_color=, #label_rotation=, #label_stagger_height=, #labels=, #legend_font_size=, #margins=, #marker_font_size=, #replace_colors, #theme=, #theme_37signals, #theme_greyscale, #theme_keynote, #theme_odeo, #theme_pastel, #theme_rails_keynote, #title=, #title_font=, #title_font_size=, #to_blob, #to_image, #transparent_background=, #write

Constructor Details

#initializeHistogram

Returns a new instance of Histogram.



26
27
28
29
# File 'lib/gruff/histogram.rb', line 26

def initialize(*)
  super
  @data = []
end

Instance Attribute Details

#bin_width=(value) ⇒ Object (writeonly)

Specifies interpolation between the min and max of the set. Default is 10.



18
19
20
# File 'lib/gruff/histogram.rb', line 18

def bin_width=(value)
  @bin_width = value
end

#maximum_bin=(value) ⇒ Object (writeonly)

Specifies maximum value for bin.



24
25
26
# File 'lib/gruff/histogram.rb', line 24

def maximum_bin=(value)
  @maximum_bin = value
end

#minimum_bin=(value) ⇒ Object (writeonly)

Specifies minimum value for bin.



21
22
23
# File 'lib/gruff/histogram.rb', line 21

def minimum_bin=(value)
  @minimum_bin = value
end

Instance Method Details

#data(name, data_points = [], color = nil) ⇒ Object



31
32
33
# File 'lib/gruff/histogram.rb', line 31

def data(name, data_points = [], color = nil)
  @data << [name, Array(data_points), color]
end