I want to select some nodes and make them tree-layout.
Have any API to do that?
Or I need to implement it myself
The literal answer to your question is:
myDiagram.layout.doLayout(myDiagram.selection)
But I think you would want to include all links between the selected nodes, even if the links were not selected. So I would initialize a Set with the selected Parts and then add any unselected Links that connect two Nodes that are selected.
Thank you,
I mean that the diagram’s layout isn’t “go.TreeLayout”,but i want to make some nodes tree-layout.
This is my solution,is there a better way?
function makeTreeLayout() {
const diagram = getDiagram()
if (diagram.selection) {
const tempLayout = diagram.layout
// make is go.GraphObject.make
diagram.layout = make(go.TreeLayout, { angle: 90, arrangement: go.TreeLayout.ArrangementFixedRoots })
diagram.layout.doLayout(diagram.selection)
diagram.layout = tempLayout
}
}
Don’t set Diagram.layout.
The Mind Map sample, Mind Map, does what I think you want. Look at the context menu command and various calls to layoutAngle
.