Visual Tree of another Diagram
This sample shows the actual visual tree of a running Diagram. The Diagram that we inspect is named "myDiagramDiv" and initially contains two simple Nodes and two Links. The Diagram below it is named "myVisualTree" and shows the visual tree of "myDiagramDiv".
You can also try selecting, copying, and deleting parts in myDiagram and then click on "Draw Visual Tree" again to see how the visual tree in myDiagram changes.
The traverseVisualTree function is what walks the visual tree of "myDiagramDiv" and constructs the corresponding Nodes and Links used in "myVisualTree". The text for each Node in "myVisualTree" is data-bound to the actual Diagram/Layer/Part/GraphObject object. That object is converted to a text string by using the toString method.
See also the Visual Tree Using Groups sample, to show the same visual tree using nested groups. For more uses of the TreeLayout, see the DOM Tree and Class Hierarchy Tree samples.
GoJS Features in this sample
Tree Layout
This predefined layout is used for placing Nodes of a tree-structured graph in layers (rows or columns). For discussion and examples of the most commonly used properties of the TreeLayout, see the learn Trees page. More information can be found in the GoJS learn pages.