Method: Scruffy::Layers::Pie#initialize
- Defined in:
- lib/scruffy/layers/pie.rb
#initialize(options = {}, &block) ⇒ Pie
The initialize method passes itself to the block, and since Pie is a LayerContainer, layers (pie slice) can be added just as if they were being added to Graph.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/scruffy/layers/pie.rb', line 57 def initialize( = {}, &block) super() # Allow for population of data with a block during initialization. if block block.call(self) else # Otherwise, just iterate over the points, adding the slices if @points.class == Hash @points.keys.each {|k| self.add :pie_slice, k.to_s, [@points[k]]} end if @points.class == Array @points.each {|v| self.add :pie_slice, '', [v]} end end end |