Class: Scruffy::Layers::Average
- Defined in:
- lib/scruffy/layers/average.rb
Overview
Scruffy::Layers::Average
- Author
-
Brasten Sager
- Date
-
August 7th, 2006
An ‘average’ graph. This graph iterates through all the layers and averages all the data at each point, then draws a thick, translucent, shadowy line graph indicating the average values.
This only looks decent in SVG mode. ImageMagick doesn’t retain the transparency for some reason, creating a massive black line. Any help resolving this would be useful.
Instance Attribute Summary collapse
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
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
Render average graph.
-
#initialize(options = {}) ⇒ Average
constructor
Returns new Average graph.
Methods inherited from Base
#bottom_key, #bottom_value, #legend_data, #relevant_data?, #render, #sum_values, #top_key, #top_value
Constructor Details
#initialize(options = {}) ⇒ Average
Returns new Average graph.
18 19 20 21 22 23 24 25 |
# File 'lib/scruffy/layers/average.rb', line 18 def initialize( = {}) # Set self's relevant_data to false. Otherwise we get stuck in a # recursive loop. super(.merge({:relevant_data => false})) # The usual :points argument is actually layers for Average, name it as such @layers = [:points] end |
Instance Attribute Details
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
15 16 17 |
# File 'lib/scruffy/layers/average.rb', line 15 def layers @layers end |
Instance Method Details
#draw(svg, coords, options = {}) ⇒ Object
Render average graph.
28 29 30 31 |
# File 'lib/scruffy/layers/average.rb', line 28 def draw(svg, coords, = {}) svg.polyline( :points => coords.join(' '), :fill => 'none', :stroke => 'black', 'stroke-width' => relative(5), 'opacity' => '0.4') end |