Class: Scruffy::Layers::Line
Overview
Scruffy::Layers::Line
- Author
-
Brasten Sager
- Date
-
August 7th, 2006
Line graph.
Instance Attribute Summary
Attributes inherited from Base
#color, #complexity, #height, #max_value, #min_value, #opacity, #options, #outline, #points, #preferred_color, #preferred_outline, #relevant_data, #title, #width
Instance Method Summary collapse
-
#draw(svg, coords, options = {}) ⇒ Object
Renders line graph.
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 line graph.
Options: See initialize()
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scruffy/layers/line.rb', line 14 def draw(svg, coords, ={}) # Include options provided when the object was created .merge!(@options) stroke_width = ([:relativestroke]) ? relative([:stroke_width]) : [:stroke_width] style = ([:style]) ? [:style] : '' if [:shadow] svg.g(:class => 'shadow', :transform => "translate(#{relative(0.5)}, #{relative(0.5)})") { svg.polyline( :points => stringify_coords(coords).join(' '), :fill => 'transparent', :stroke => 'black', 'stroke-width' => stroke_width, :style => 'fill-opacity: 0; stroke-opacity: 0.35' ) if [:dots] coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last + relative(0.9), :r => stroke_width, :style => "stroke-width: #{stroke_width}; stroke: black; opacity: 0.35;" ) } end } end svg.polyline( :points => stringify_coords(coords).join(' '), :fill => 'none', :stroke => @color.to_s, 'stroke-width' => stroke_width, :style => style ) if [:dots] coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last, :r => stroke_width, :style => "stroke-width: #{stroke_width}; stroke: #{color.to_s}; fill: #{color.to_s}" ) } end end |