Class: Gruff::Histogram
Overview
Constant Summary
Constants inherited from Base
Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN
Instance Attribute Summary collapse
-
#bin_width ⇒ Object
writeonly
Specifies interpolation between the min and max of the set.
-
#maximum_bin ⇒ Object
writeonly
Specifies maximum value for bin.
-
#minimum_bin ⇒ Object
writeonly
Specifies minimum value for bin.
Attributes inherited from Bar
#bar_spacing, #group_spacing, #hide_labels, #label_formatting, #show_labels_for_bar_values
Attributes inherited from Base
#bold_title, #bottom_margin, #center_labels_over_point, #colors, #font_color, #has_left_labels, #hide_legend, #hide_line_markers, #hide_line_numbers, #hide_title, #label_max_size, #label_stagger_height, #label_truncation_style, #labels, #left_margin, #legend_at_bottom, #legend_box_size, #legend_font_size, #legend_margin, #marker_color, #marker_font_size, #marker_shadow_color, #maximum_value, #minimum_value, #no_data_message, #right_margin, #sort, #sorted_drawing, #title, #title_font, #title_font_size, #title_margin, #top_margin, #use_data_label, #x_axis_increment, #x_axis_label, #y_axis_increment, #y_axis_label
Instance Method Summary collapse
- #data(name, data_points = [], color = nil) ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ Histogram
constructor
A new instance of Histogram.
Methods inherited from Bar
Methods inherited from Base
#add_color, #font=, #margins=, #replace_colors, #theme=, #theme_37signals, #theme_greyscale, #theme_keynote, #theme_odeo, #theme_pastel, #theme_rails_keynote, #to_blob, #to_image, #write
Constructor Details
#initialize ⇒ Histogram
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
39 40 41 |
# File 'lib/gruff/histogram.rb', line 39 def data(name, data_points = [], color = nil) @data << [name, data_points, color] end |
#draw ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gruff/histogram.rb', line 43 def draw @data.each do |(name, data_points, color)| bins, freqs = HistogramArray.new(data_points).histogram(bin_width: @bin_width, min: @minimum_bin, max: @maximum_bin) bins.each_with_index do |bin, index| @labels[index] = bin end store.add(name, freqs, color) end super end |