A layout that arranges nodes in a tree either left-to-right or top-to-bottom.
var display = new thinkmap.display.Display(document.getElementById('mydiv'));
var tree = new thinkmap.graph.Tree();
tree.root(tree.createNode({label:"Root Node"}))
.add(tree.createEdge(tree.root(),tree.createNode({label:"Child 1"})))
.add(tree.createEdge(tree.root(),tree.createNode({label:"Child 2"})));
display.add(tree);
display.template('edge').as(thinkmap.display.edgestyle.linear());
thinkmap.layout.tree(display).tree(tree).spacing(200).layout();
Sets (or gets) the axis that this layout will layout the tree on. Use "x" for left-to-right, or "y" for top-to-bottom. The default is "x".
If called with zero arguments, returns the current value of "axis".
Sets (or gets) the rectangle that will be used as the bounding box of each node.
This is either a thinkmap.geom.Rectangle, or a function returns a rectangle.
The default is a function that calls display.bbox(node).
If called with zero arguments, returns the current value of bbox.
Returns the last transition created calling the layout method.
This will be null if the layout() method was never called.
Sets (or gets) the duration (in milliseconds) of the transition that will be used for animating the layout.
If called with zero arguments, returns the current value of duration
Sets (or gets) the easing function of the transition that will be used for animating the layout.
If called with zero arguments, returns the current value of easing
Applies this layout to the configured display. By default, this creates and returns an animated selection that is configured to apply the layout in the default way.
If you wish to customize how the layout is applied, you have two choices:
an optional function to apply the layout to
a transitioned display selection (or a regular Display Selection if an apply function was passed)
Sets (or gets) the margin that will be maintained between siblings (or cousins) in the tree. This is either a number, or a function that takes the two nodes and returns a number.
If called with zero arguments, returns the current value of margin.
Sets (or gets) the point where the root of the tree will be placed. The default is 0,0 This is either a thinkmap.geom.Point, or a function returns a point.
If called with zero arguments, returns the current value of position.
Sets (or gets) the sorting function that will be used to sort child nodes. The function is passed two nodes and must return -1 if the first is less than the second, 0 if they are equal, or 1 if the second is greater than the first.
If called with zero arguments, returns the current value of sort
Sets (or gets) the spacing that will be maintained between parents and their children in the tree. This is either a number, or a function that takes the two nodes and returns a number.
If called with zero arguments, returns the current value of spacing.
Gets the target position of the given node given the last layout state of this tree layout.
Sets (or gets) the tree that this layout will layout.
If called with zero arguments, returns the current value of tree.
Enables or disables this layout.
If called with zero arguments, returns true if this layout is enabled.
true to enable this layout
this layout, or a boolean if called with zero arguments.