Class: Rubyvis::Layout::Grid

Inherits:
Rubyvis::Layout show all
Defined in:
lib/rubyvis/layout/grid.rb

Instance Attribute Summary collapse

Attributes inherited from Panel

#_canvas, #children, #root

Attributes inherited from Mark

#_properties, #binds, #child_index, #parent, #proto, #root, #scale, #scene, #target

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rubyvis::Layout

Arc, Cluster, Grid, Hierarchy, Horizon, Indent, Matrix, Network, Pack, Partition, Stack, Tree, Treemap, attr_accessor_dsl, #build_properties, #layout_build_implied, #layout_build_properties

Methods inherited from Panel

#add, #anchor, #bind, #build_instance, #children_inspect, #panel_build_implied, #to_svg, #type

Methods inherited from Bar

#type, #width

Methods inherited from Mark

#add, #anchor, #area, attr_accessor_dsl, #bar, #bind, #build, #build_instance, #build_properties, #context, #context_apply, #context_clear, #cousin, #delete_index, #dot, #event, #execute, #first, #image, index, #index, index=, #index=, #index_defined?, #instance, #instances, #label, #last, #layout_arc, #layout_cluster, #layout_grid, #layout_horizon, #layout_indent, #layout_matrix, #layout_pack, #layout_partition, #layout_partition_fill, #layout_stack, #layout_tree, #layout_treemap, #line, #margin, #mark_anchor, #mark_bind, #mark_build_implied, #mark_build_instance, #mark_build_properties, #mark_extend, mark_method, #panel, #properties, properties, property_method, #property_value, #render, #rule, scene, scene=, #sibling, stack, stack=, #type, #wedge

Constructor Details

#initializeGrid

Returns a new instance of Grid.



49
50
51
52
# File 'lib/rubyvis/layout/grid.rb', line 49

def initialize
  super
  @cell=_cell
end

Instance Attribute Details

#_gridObject

Returns the value of attribute _grid.



46
47
48
# File 'lib/rubyvis/layout/grid.rb', line 46

def _grid
  @_grid
end

#cellObject

Returns the value of attribute cell.



47
48
49
# File 'lib/rubyvis/layout/grid.rb', line 47

def cell
  @cell
end

Class Method Details

.defaultsObject



85
86
87
88
89
# File 'lib/rubyvis/layout/grid.rb', line 85

def self.defaults
  Rubyvis::Layout::Grid.new.mark_extend(Rubyvis::Layout.defaults).
    rows(1).
    cols(1)
end

Instance Method Details

#build_implied(s) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rubyvis/layout/grid.rb', line 90

def build_implied(s)
  layout_build_implied(s)
  r=s.rows
  c=s.cols
  r=Rubyvis.transpose(c) if c.is_a? Array
  if r.is_a? Array
    s._grid=Rubyvis.blend(r)
    s.rows=r.size
    s.cols=r[0] ? r[0].size : 0
  else
    s._grid=Rubyvis.repeat([s.data],r*c)
  end
end

#rowsObject

:attr: cols

The number of columns. This property can also be specified as the data in column-major order; in this case, the cols property is implicitly set to the length of the array, and the rows property is set to the length of the first element in the array.



84
# File 'lib/rubyvis/layout/grid.rb', line 84

attr_accessor_dsl :rows, :cols