How to manually control nodes to display in one side of the tree in SideTreeLayout

%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200116181027

I have a SideTreeLayout like this, and I have to make the A(or B or C) node to the left or right of the tree(decided by the data that returned from the server)

How to manually control these nodes to display in one side(left or right) of the tree in SideTreeLayout?

If the SideTreeLayout can’t make it, are there any other solutions to solve this problem?

Any advice would be appreciated, thank u.

You are talking about the customized TreeLayout in https://gojs.net/latest/samples/orgChartAssistants.html, aren’t you?

Its idea is to make use of https://gojs.net/latest/api/symbols/TreeLayout.html#static-AlignmentBus. It positions all org chart “assistants” alternating left and right. It then adds a dummy vertex if needed to make sure there are an even number of assistant vertexes, so that the final vertex, which is a dummy substitute vertex acting as the real parent vertex for all of the non-assistant children, can be positioned straight below the original parent vertex and below all of the assistants.

So you will need to adapt the SideTreeLayout.makeNetwork override method so that it figures out how many assistants need to go on the left side and how many need to go on the right side. Then it needs to add dummy vertexes so that the numbers are equal for both sides. But crucially you need to alternate adding the edges to the assistant vertexes (including any dummies) so that you add an edge to a vertex on the left and then you add an edge to a vertex on the right. Repeat until all edges to assistants (including dummies) have been added. Then continue with the code to create and add the substitute vertex (and edge to that) for all of the normal children.

Yes, that is what I wanted.

Let me try first. Thank u very much!