Class: Gruff::Candlestick
Overview
Here’s how to set up a Gruff::Candlestick.
g = Gruff::Candlestick.new
g.data low: 79.30, high: 93.10, open: 79.44, close: 91.20
g.data low: 89.14, high: 106.42, open: 91.28, close: 106.26
g.data low: 107.89, high: 131.00, open: 108.20, close: 129.04
g.data low: 103.10, high: 137.98, open: 132.76, close: 115.81
g.write("candlestick.png")
Constant Summary
Constants inherited from Base
Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN
Instance Attribute Summary collapse
-
#down_color ⇒ Object
writeonly
Specifies the color with down bar.
-
#fill_opacity ⇒ Object
writeonly
Specifies the filling opacity in area graph.
-
#show_vertical_markers ⇒ Object
writeonly
Allow for vertical marker lines.
-
#stroke_width ⇒ Object
writeonly
Specifies the stroke width in line.
-
#up_color ⇒ Object
writeonly
Specifies the color with up bar.
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(low:, high:, open:, close:) ⇒ Object
-
#sort=(_value) ⇒ Object
The sort feature is not supported in this graph.
-
#sorted_drawing=(_value) ⇒ Object
The sort feature is not supported in this graph.
-
#spacing_factor=(space_percent) ⇒ Object
Can be used to adjust the spaces between the bars.
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=, #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
#down_color=(value) ⇒ Object (writeonly)
Specifies the color with down bar. Default is ‘#eb5242’.
27 28 29 |
# File 'lib/gruff/candlestick.rb', line 27 def down_color=(value) @down_color = value end |
#fill_opacity=(value) ⇒ Object (writeonly)
Specifies the filling opacity in area graph. Default is 0.4
.
18 19 20 |
# File 'lib/gruff/candlestick.rb', line 18 def fill_opacity=(value) @fill_opacity = value end |
#show_vertical_markers=(value) ⇒ Object (writeonly)
Allow for vertical marker lines.
15 16 17 |
# File 'lib/gruff/candlestick.rb', line 15 def show_vertical_markers=(value) @show_vertical_markers = value end |
#stroke_width=(value) ⇒ Object (writeonly)
Specifies the stroke width in line. Default is 2.0
.
21 22 23 |
# File 'lib/gruff/candlestick.rb', line 21 def stroke_width=(value) @stroke_width = value end |
#up_color=(value) ⇒ Object (writeonly)
Specifies the color with up bar. Default is ‘#579773’.
24 25 26 |
# File 'lib/gruff/candlestick.rb', line 24 def up_color=(value) @up_color = value end |
Instance Method Details
#data(low:, high:, open:, close:) ⇒ Object
51 52 53 |
# File 'lib/gruff/candlestick.rb', line 51 def data(low:, high:, open:, close:) super('', [low, high, open, close]) end |
#sort=(_value) ⇒ Object
The sort feature is not supported in this graph.
42 43 44 |
# File 'lib/gruff/candlestick.rb', line 42 def sort=(_value) raise 'Not support #sort= in Gruff::Candlestick' end |
#sorted_drawing=(_value) ⇒ Object
The sort feature is not supported in this graph.
47 48 49 |
# File 'lib/gruff/candlestick.rb', line 47 def sorted_drawing=(_value) raise 'Not support #sorted_drawing= in Gruff::Candlestick' end |
#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.9
.
35 36 37 38 39 |
# File 'lib/gruff/candlestick.rb', line 35 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 |