Class: Gruff::Spider
Overview
Experimental!!! See also the Net graph.
Submitted by Kevin Clark glu.ttono.us/
Constant Summary
Constants inherited from Base
Base::DATA_COLOR_INDEX, Base::DATA_LABEL_INDEX, Base::DATA_VALUES_INDEX, Base::DEBUG, Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN, Base::THOUSAND_SEPARATOR
Instance Attribute Summary collapse
-
#hide_axes ⇒ Object
Returns the value of attribute hide_axes.
-
#hide_text ⇒ Object
Hide all text.
-
#transparent_background ⇒ Object
Returns the value of attribute transparent_background.
Attributes inherited from Base
#additional_line_values, #bottom_margin, #center_labels_over_point, #colors, #font, #font_color, #has_left_labels, #hide_legend, #hide_line_markers, #hide_line_numbers, #hide_title, #labels, #left_margin, #legend_box_size, #legend_font_size, #legend_margin, #marker_color, #marker_count, #marker_font_size, #maximum_value, #minimum_value, #no_data_message, #right_margin, #sort, #stacked, #title, #title_font_size, #title_margin, #top_margin, #x_axis_label, #y_axis_increment, #y_axis_label
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(max_value, target_width = 800) ⇒ Spider
constructor
A new instance of Spider.
Methods inherited from Base
#add_color, #data, #initialize_ivars, #margins=, #replace_colors, #theme=, #theme_37signals, #theme_greyscale, #theme_keynote, #theme_odeo, #theme_pastel, #theme_rails_keynote, #to_blob, #write
Methods included from Deprecated
#graph_height, #graph_left, #graph_top, #graph_width, #scale_measurements, #total_height
Constructor Details
#initialize(max_value, target_width = 800) ⇒ Spider
Returns a new instance of Spider.
23 24 25 26 27 |
# File 'lib/gruff/spider.rb', line 23 def initialize(max_value, target_width = 800) super(target_width) @max_value = max_value @hide_legend = true; end |
Instance Attribute Details
#hide_axes ⇒ Object
Returns the value of attribute hide_axes.
11 12 13 |
# File 'lib/gruff/spider.rb', line 11 def hide_axes @hide_axes end |
#hide_text ⇒ Object
Hide all text
10 11 12 |
# File 'lib/gruff/spider.rb', line 10 def hide_text @hide_text end |
#transparent_background ⇒ Object
Returns the value of attribute transparent_background.
12 13 14 |
# File 'lib/gruff/spider.rb', line 12 def transparent_background @transparent_background end |
Instance Method Details
#draw ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gruff/spider.rb', line 29 def draw @hide_line_markers = true super return unless @has_data # Setup basic positioning diameter = @graph_height radius = @graph_height / 2.0 top_x = @graph_left + (@graph_width - diameter) / 2.0 center_x = @graph_left + (@graph_width / 2.0) center_y = @graph_top + (@graph_height / 2.0) - 25 # Move graph up a bit @unit_length = radius / @max_value total_sum = sums_for_spider prev_degrees = 0.0 additive_angle = (2 * Math::PI)/ @data.size current_angle = 0.0 # Draw axes draw_axes(center_x, center_y, radius, additive_angle) unless hide_axes # Draw polygon draw_polygon(center_x, center_y, additive_angle) @d.draw(@base_image) end |