Class: Gruff::Scatter
Overview
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN, Base::TITLE_MARGIN
Instance Attribute Summary collapse
-
#circle_radius ⇒ Object
writeonly
Attributes to allow customising the size of the points.
-
#marker_x_count ⇒ Object
writeonly
The number of vertical lines shown for reference.
-
#maximum_x_value ⇒ Object
writeonly
Maximum X Value.
-
#minimum_x_value ⇒ Object
writeonly
Minimum X Value.
-
#show_vertical_markers ⇒ Object
writeonly
Allow for vertical marker lines.
-
#stroke_width ⇒ Object
writeonly
: Float | Integer.
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
-
#data(name, x_data_points = [], y_data_points = [], color = nil) ⇒ Object
(also: #dataxy)
The first parameter is the name of the dataset.
- #disable_significant_rounding_x_axis=(_value) ⇒ Object deprecated Deprecated.
-
#enable_vertical_line_markers=(value) ⇒ Object
deprecated
Deprecated.
Please use #show_vertical_markers= instead.
-
#use_vertical_x_labels=(_value) ⇒ Object
deprecated
Deprecated.
Please use Base#label_rotation= instead.
- #x_label_margin=(_value) ⇒ Object deprecated Deprecated.
Methods inherited from Base
#add_color, #bold_title=, #draw, #font=, #font_color=, #initialize, #label_rotation=, #label_stagger_height=, #labels=, #legend_font_size=, #margins=, #marker_font_size=, #no_data_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
#circle_radius=(value) ⇒ Object (writeonly)
Attributes to allow customising the size of the points.
26 27 28 |
# File 'lib/gruff/scatter.rb', line 26 def circle_radius=(value) @circle_radius = value end |
#marker_x_count=(value) ⇒ Object
The number of vertical lines shown for reference.
23 24 25 |
# File 'lib/gruff/scatter.rb', line 23 def marker_x_count=(value) @marker_x_count = value end |
#maximum_x_value=(value) ⇒ Object (writeonly)
Maximum X Value. The value will get overwritten by the max in the datasets.
16 17 18 |
# File 'lib/gruff/scatter.rb', line 16 def maximum_x_value=(value) @maximum_x_value = value end |
#minimum_x_value=(value) ⇒ Object (writeonly)
Minimum X Value. The value will get overwritten by the min in the datasets.
20 21 22 |
# File 'lib/gruff/scatter.rb', line 20 def minimum_x_value=(value) @minimum_x_value = value end |
#show_vertical_markers=(value) ⇒ Object (writeonly)
Allow for vertical marker lines.
30 31 32 |
# File 'lib/gruff/scatter.rb', line 30 def show_vertical_markers=(value) @show_vertical_markers = value end |
#stroke_width=(value) ⇒ Object (writeonly)
: Float | Integer
27 28 29 |
# File 'lib/gruff/scatter.rb', line 27 def stroke_width=(value) @stroke_width = value end |
Instance Method Details
#data(name, x_data_points = [], y_data_points = [], color = nil) ⇒ Object Also known as: dataxy
If you want to use a preset theme, you must set it before calling #data.
The first parameter is the name of the dataset. The next two are the x and y axis data points contain in their own array in that respective order. The final parameter is the color.
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.
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/gruff/scatter.rb', line 96 def data(name, x_data_points = [], y_data_points = [], color = nil) # make sure it's an array x_data_points = Array(x_data_points) y_data_points = Array(y_data_points) raise ArgumentError, 'Data Points contain nil Value!' if x_data_points.include?(nil) || y_data_points.include?(nil) raise ArgumentError, 'x_data_points is empty!' if x_data_points.empty? raise ArgumentError, 'y_data_points is empty!' if y_data_points.empty? raise ArgumentError, 'x_data_points.length != y_data_points.length!' if x_data_points.length != y_data_points.length # Call the existing data routine for the x/y axis data store.add(name, x_data_points, y_data_points, color) end |
#disable_significant_rounding_x_axis=(_value) ⇒ Object
Allow disabling the significant rounding when labeling the X axis. This is useful when working with a small range of high values (for example, a date range of months, while seconds as units).
54 55 56 |
# File 'lib/gruff/scatter.rb', line 54 def disable_significant_rounding_x_axis=(_value) warn '#disable_significant_rounding_x_axis= is deprecated. It is no longer effective.' end |
#enable_vertical_line_markers=(value) ⇒ Object
Please use #show_vertical_markers= instead.
Allow enabling vertical lines. When you have a lot of data, they can work great.
34 35 36 37 |
# File 'lib/gruff/scatter.rb', line 34 def enable_vertical_line_markers=(value) warn '#enable_vertical_line_markers= is deprecated. Please use `show_vertical_markers` attribute instead' @show_vertical_markers = value end |
#use_vertical_x_labels=(_value) ⇒ Object
Please use Base#label_rotation= instead.
Allow using vertical labels in the X axis.
41 42 43 |
# File 'lib/gruff/scatter.rb', line 41 def use_vertical_x_labels=(_value) warn '#use_vertical_x_labels= is deprecated. It is no longer effective. Please use `#label_rotation=` instead' end |
#x_label_margin=(_value) ⇒ Object
Allow using vertical labels in the X axis (and setting the label margin).
47 48 49 |
# File 'lib/gruff/scatter.rb', line 47 def x_label_margin=(_value) warn '#x_label_margin= is deprecated. It is no longer effective.' end |