Class: Gruff::Box

Inherits:
Base
  • Object
show all
Defined in:
lib/gruff/box.rb

Overview

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

g = Gruff::Box.new
g.data "A", [2, 3, 5, 6, 8, 10, 11, 15, 17, 20, 28, 29, 33, 34, 45, 46, 49, 61]
g.data "B", [3, 4, 34, 35, 38, 39, 45, 60, 61, 69, 80, 130]
g.data "C", [4, 40, 41, 46, 57, 64, 77, 76, 79, 78, 99, 153]
g.write("box_plot.png")

Constant Summary

Constants inherited from Base

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

Instance Attribute Summary collapse

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 Base

#add_color, #bold_title=, #data, #draw, #font=, #font_color=, #initialize, #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

This class inherits a constructor from Gruff::Base

Instance Attribute Details

#fill_opacity=(value) ⇒ Object (writeonly)

Specifies the filling opacity in area graph. Default is 0.2.



14
15
16
# File 'lib/gruff/box.rb', line 14

def fill_opacity=(value)
  @fill_opacity = value
end

#stroke_width=(value) ⇒ Object (writeonly)

Specifies the stroke width in line. Default is 3.0.



17
18
19
# File 'lib/gruff/box.rb', line 17

def stroke_width=(value)
  @stroke_width = value
end

Instance Method Details

#spacing_factor=(space_percent) ⇒ Object

Can be used to adjust the spaces between the bars. Accepts values between 0.00 and 1.00 where 0.00 means no spacing at all and 1 means that each bars’ width is nearly 0 (so each bar is a simple line with no x dimension).

Default value is 0.8.

Raises:

  • (ArgumentError)


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

def spacing_factor=(space_percent)
  raise ArgumentError, 'spacing_factor must be between 0.00 and 1.00' if (space_percent < 0) || (space_percent > 1)

  @spacing_factor = (1 - space_percent)
end