Class: Gruff::Spider

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

Overview

Experimental!!! See also the Net graph.

Submitted by Kevin Clark glu.ttono.us/

Constant Summary

Constants inherited from Base

Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN, Base::THOUSAND_SEPARATOR

Instance Attribute Summary collapse

Attributes inherited from Base

#additional_line_values, #bold_title, #bottom_margin, #center_labels_over_point, #colors, #font, #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_count, #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

Methods inherited from Base

#add_color, #data, #margins=, #replace_colors, #theme=, #theme_37signals, #theme_greyscale, #theme_keynote, #theme_odeo, #theme_pastel, #theme_rails_keynote, #to_blob, #write

Constructor Details

#initialize(max_value, target_width = 800) ⇒ Spider

Returns a new instance of Spider.



23
24
25
26
27
28
# File 'lib/gruff/spider.rb', line 23

def initialize(max_value, target_width = 800)
  super(target_width)
  @max_value = max_value
  @hide_legend = true
  @rotation = 0
end

Instance Attribute Details

#hide_axesObject

Returns the value of attribute hide_axes.



11
12
13
# File 'lib/gruff/spider.rb', line 11

def hide_axes
  @hide_axes
end

#hide_textObject

Hide all text.



10
11
12
# File 'lib/gruff/spider.rb', line 10

def hide_text
  @hide_text
end

#rotationObject

Returns the value of attribute rotation.



13
14
15
# File 'lib/gruff/spider.rb', line 13

def rotation
  @rotation
end

#transparent_backgroundObject

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

#drawObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gruff/spider.rb', line 30

def draw
  @hide_line_markers = true

  super

  return unless data_given?

  # Setup basic positioning
  radius = @graph_height / 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

  additive_angle = (2 * Math::PI) / store.length

  # Draw axes
  draw_axes(center_x, center_y, radius, additive_angle) unless hide_axes

  # Draw polygon
  draw_polygon(center_x, center_y, additive_angle)

  Gruff::Renderer.finish
end