TreeLayout
layout.TreeLayout is a class, which provides layout algorithm for tree-like graphs.
To learn more, check out the learn section.
constructor​
constructor(options: TreeLayout.Options);
The layout.TreeLayout constructor options parameter has following properties:
attributeNames​
[optional] An object that maps element attributes accepted by the layout to user defined attribute names. Useful for resolving conflicts when an attribute is already in use by the application logic. e.g Setting { siblingRank: 'index' } will make the layout look for the index attribute instead of siblingRank when trying to figure out the order of siblings.
direction​
[optional] The default direction of the layout. It can be set to one of the following values: 'L', 'R', 'T', 'B' (for left-to-right, right-to-left, top-to-bottom and bottom-to-top layouts) or diagonal variants 'TL', 'TR','BL', 'BR' (for top-left, top-right, bottom-left and bottom-right). Defaults to 'R'.
filter()​
(children: dia.Element[], parent: dia.Element | null, opt: { [key: string]: any }, treeLayout: layout.TreeLayout) => dia.Element[];
[optional] A callback which runs for every single parent element in the graph and returns an array of elements to be laid out.
Parameters:
childrenis an array of siblingsparentis the parent of thechildrenornull, whenchildrenare rootsoptis the option object passed tolayout()method when calling the layout.treeLayoutis the layout instance, for context.
firstChildGap​
[optional] The distance between the first sibling and its parent. It's applicable only for diagonal layouts ('TL', 'TR','BL', 'BR'). Defaults to 20.
graph​
The JointJS graph object on which you want to perform the layout.
parentGap​
[optional] The distance between a parent element and its children. Defaults to 20.
siblingGap​
[optional] The distance between siblings. Defaults to 20.
symmetrical​
[optional] Enabling this layout option ensures that the distance between children is the same. This feature only works either in the horizontal or vertical direction.
updateAttributes()​
(layoutArea: TreeLayout.LayoutArea, root: dia.Element, rootLink: dia.Link, opt: { [key: string]: any }, treeLayout: layout.TreeLayout) => void
[optional] A function responsible for updating attributes of the current root and the associated link.
updatePosition()​
(element: dia.Element, position: dia.Point, opt?: { [key: string]: any }, treeLayout: layout.TreeLayout) => void
[optional] A function responsible for setting the resulting position on the elements. It calls element.set('position', position, opt); by default.