Node without parents in TreeLayout


I’m using the TreeLayout and in my diagram, some nodes does not have any parent.
Currently, these nodes are at the first level, but I’d like to put them at the last level (like the LayeredDigraphLayout diagram).

Is it possible to have this behavior with the TreeLayout?

Now, I have this:

But I would like to have this:

Here my declaration:

$(go.TreeLayout, {
    angle: 90,
    alignment: go.TreeLayout.AlignmentCenterChildren,
    arrangement: go.TreeLayout.ArrangementHorizontal,
    layerSpacing: 200,
    nodeSpacing: 50,
    isRealtime: false,
    isOngoing: false,
    isInitial: true,
    layerStyle: go.TreeLayout.LayerUniform,
    treeStyle: go.TreeLayout.StyleLayered,
    compaction: go.TreeLayout.CompactionNone


Thank you

That would not be easy to do in a general fashion. It is possible to assign nodes to be in certain layers, but you need to know ahead of time which layer you’d want to use for each node.

Are you only concerned about singleton nodes? If so, there might be a special case solution for you.

Hmmm, I suppose you could layout each tree separately and then move them next to each other so that their last layers are all aligned. Would that be acceptable?

I try to optimize space for our larger diagrams.
Can we know the number of layers in the diagram to put these nodes under the last layer (create a new layer for them)

Or can we put them over the first layer?

After reflection, I believe that just down the nodes without parent will be insufficient and inefficient

Thanks for your time!

So I still do not understand what you want. A sketch or screenshot of a nontrivial example would be useful.

I would to set nodes without parent under the nodes “Child x”. Something like this:

Or put the nodes “Without Parent x” over the node “Root”.

I think that I could save a lot of space…

Thanks for your help

[EDIT – BorderLayout has been subsumed by the ArrangingLayout extension in v2.1.23.]

You can use ArrangingLayout to do what you want.
An example usage is at: Arranging Layout of the Class Hierarchy
The layout is defined at:
Documentation is at: ArrangingLayout | GoJS API

You will want to set ArrangingLayout.primaryLayout to be an instance of TreeLayout. By default singleton nodes will automatically be arranged by a GridLayout along the bottom of the document.

I will try it.