Class: Scruffy::Layers::Scatter

Inherits:
Base
  • Object
show all
Includes:
Helpers::Marker
Defined in:
lib/scruffy/layers/scatter.rb

Overview

Scruffy::Layers::Line

Author

Mat Schaffer

Date

March 20th, 2007

Simple scatter graph

Instance Attribute Summary

Attributes inherited from Base

#color, #complexity, #height, #max_value, #min_value, #opacity, #options, #points, #preferred_color, #relevant_data, #title, #width

Instance Method Summary collapse

Methods included from Helpers::Marker

#each_marker

Methods inherited from Base

#bottom_key, #bottom_value, #initialize, #legend_data, #relevant_data?, #render, #sum_values, #top_key, #top_value

Constructor Details

This class inherits a constructor from Scruffy::Layers::Base

Instance Method Details

#draw(svg, coords, options = {}) ⇒ Object

Renders scatter graph.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scruffy/layers/scatter.rb', line 13

def draw(svg, coords, options={})
  
  options.merge!(@options)
  
  if options[:shadow]
    svg.g(:class => 'shadow', :transform => "translate(#{relative(0.5)}, #{relative(0.5)})") {
      coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last + relative(0.9), :r => relative(2), 
                                        :style => "stroke-width: #{relative(2)}; stroke: black; opacity: 0.35;" ) }
    }
  end

  coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last, :r => relative(2), 
                                    :style => "stroke-width: #{relative(2)}; stroke: #{color.to_s}; fill: #{color.to_s}" ) }
end