Class Gruff::Spider
In: lib/gruff/spider.rb
Parent: Gruff::Base

Experimental!!! See also the Net graph.

Submitted by Kevin Clark glu.ttono.us/

Methods

Attributes

hide_axes  [RW] 
hide_text  [R]  Hide all text
transparent_background  [R] 

Public Class methods

[Source]

# 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

Public Instance methods

[Source]

# 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

[Source]

# File lib/gruff/spider.rb, line 19
  def hide_text=(value)
    @hide_title = @hide_text = value
  end

[Source]

# File lib/gruff/spider.rb, line 14
  def transparent_background=(value)
    @transparent_background = value
    @base_image = render_transparent_background if value
  end

[Validate]