Class: Scruffy::Components::Graphs
- Defined in:
- lib/scruffy/components/graphs.rb
Overview
Component for displaying Graphs layers.
Is passed all graph layers from the Graph object.
(This may change as the capability for Graph filtering and such fills out.)
Constant Summary collapse
- STACKED_OPACITY =
0.85
Instance Attribute Summary
Attributes inherited from Base
#id, #options, #position, #size, #visible
Instance Method Summary collapse
Methods inherited from Base
#initialize, #process, #render
Constructor Details
This class inherits a constructor from Scruffy::Components::Base
Instance Method Details
#draw(svg, bounds, options = {}) ⇒ Object
12 13 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 |
# File 'lib/scruffy/components/graphs.rb', line 12 def draw(svg, bounds, ={}) # If Graph is limited to a category, reject layers outside of it's scope. applicable_layers = [:layers].reject do |l| if @options[:only] (l.[:category].nil? && l.[:categories].nil?) || (!l.[:category].nil? && l.[:category] != @options[:only]) || (!l.[:categories].nil? && !l.[:categories].include?(@options[:only])) else false end end applicable_layers.each_with_index do |layer, idx| = {} [:index] = idx [:min_value] = [:min_value] [:max_value] = [:max_value] [:complexity] = [:complexity] [:size] = [bounds[:width], bounds[:height]] [:color] = layer.preferred_color || layer.color || [:theme].next_color [:opacity] = opacity_for(idx) [:theme] = [:theme] svg.g(:id => "component_#{id}_graph_#{idx}", :class => 'graph_layer') { layer.render(svg, ) } end # applicable_layers end |