Keep position when the node expanding

I am trying to create a collapsible and expandable diagram. I have set the isLayoutPositioned and isTreeLink of the link (marked as r) to false. The issue I am facing is that when I expand a node, the positions of the left and right nodes automatically change (P1), but I want the nodes to maintain their positions (P2). How can I solve this issue?


If node 9 is expanded, do you want the subtree to overlap with any other subtrees expanded from nodes to its left?

I don’t want that, but the current diagram already ensures that only one node will be expanded. If node 9 is clicked to expand, node 8 will automatically collapse.

Oh, OK. Would expanding node 53 collapse node 52?

How are the nodes 8, 9, 145 et al. being laid out?

Yes, expanding node 53 will collapse node 52, and I want nodes 8, 9, and 145 to keep positions.

Sorry, it’s been busy here. I’ll produce a sample as soon as I have some free time.

Take your time, I look forward to seeing the sample. Thank you!

Here you go: Binary Tree Layout and Expanding Collapses Other Nodes

As always, the complete source code is in the page itself.

Sorry, the implemented diagram is not a binary tree. The nodes in the second layer should be children of the first layer.

Ah, OK. The code that I gave you shows how you can define the expanding function to first collapse the sibling nodes, although the graph structure that you have is different than in that sample.

That would be some new work. Once you purchase a license, we’ll promise to make such a sample for you.