Class: Rubyvis::Layout::Indent
Overview
Implements a hierarchical layout using the indent algorithm. This layout implements a node-link diagram where the nodes are presented in preorder traversal, and nodes are indented based on their depth from the root. This technique is used ubiquitously by operating systems to represent file directories; although it requires much vertical space, indented trees allow efficient interactive exploration of trees to find a specific node. In addition they allow rapid scanning of node labels, and multivariate data such as file sizes can be displayed adjacent to the hierarchy.
<p>The indent layout can be configured using the depth
and breadth
properties, which control the increments in pixel space for each indent and row in the layout. This layout does not support multiple orientations; the root node is rendered in the top-left, while breadth
is a vertical offset from the top, and depth
is a horizontal offset from the left.
<p>For more details on how to use this layout, see Rubyvis::Layout::Hierarchy
Instance Attribute Summary
Attributes inherited from Network
#_id, #link, #node, #node_label
Attributes inherited from Panel
Attributes inherited from Mark
#_properties, #binds, #child_index, #parent, #proto, #root, #scale, #scene, #target
Class Method Summary collapse
-
.defaults ⇒ Object
Default properties for indent layouts.
Instance Method Summary collapse
- #build_implied(s) ⇒ Object
-
#depth ⇒ Object
:attr: breadth The vertical offset between nodes; defaults to 15.
-
#initialize ⇒ Indent
constructor
Constructs a new, empty indent layout.
Methods inherited from Hierarchy
#hierarchy_build_implied, #links
Methods inherited from Network
#_link, #_node, #_node_label, #build_properties, #network_build_implied, #nodes, #reset
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
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
#initialize ⇒ Indent
Constructs a new, empty indent layout. Layouts are not typically constructed directly; instead, they are added to an existing panel via Rubyvis::Mark.add
30 31 32 33 |
# File 'lib/rubyvis/layout/indent.rb', line 30 def initialize super @link.interpolate("step-after") end |
Class Method Details
Instance Method Details
#build_implied(s) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/rubyvis/layout/indent.rb', line 69 def build_implied(s) return nil if hierarchy_build_implied(s) nodes = s.nodes @bspace = s.breadth @dspace = s.depth @ax = 0 @ay = 0 position(nodes[0], 1, 1) end |
#depth ⇒ Object
:attr: breadth The vertical offset between nodes; defaults to 15.
45 |
# File 'lib/rubyvis/layout/indent.rb', line 45 attr_accessor_dsl :depth, :breadth |