How to keep a node in fixed position without ignoring it in the layout?

Hello,
Is it possible to have nodes at a fixed position, but still taken into the account for the layout of other nodes and links?
The closest option I came across is ‘isLayoutPositioned=false’, but then the node will be ignored by the layout algorithm.

After some research in the forum, I assume such feature is not implemented (yet?).

My intention is to use GoJS to generate our SW architecture documentation for various projects. In each project documentation, some nodes are meant to be fixed at particular position (‘MCAL’ node shall remain at the bottom of the layout, ‘CDD’ node shall remain at the right side etc.). The user shall be able to position any node and to fix its position, but still the layout shall be affected by the node.

What is your Diagram.layout? Could you please give us some examples of what you want after the user has moved some nodes manually and a layout that might happen afterwards?

I currently use LayeredDigraphLayout.

Here is an example of having a fixed node, called “MCAL”:
Capture

Then, this node is moved manually to the “lowest position” of the SW architecture documentation:

This node should remain at this fixed position so I set isLayoutPositioned=true on it.
When the layout function is called, the node ‘CmpC’ is moved.
Capture3

I would prefer something close to this layout:
Capture4

Ah, so you don’t actually want the moved node to remain exactly where the user moved it – you want that the user has shifted the node to be in a different layer. Is that a better characterization of what you want the user to be able to do?

If so, in the case of LayeredDigraphLayout, that means overriding LayeredDigraphLayout.assignLayers to first call the super method and then update the vertexes to make sure they are in the desired layer.

No, indeed I would like the moved node (“MCAL”) to remain exactly where the user moved it (image #2).
This works nice with option ‘isLayoutPositioned=false’.
But I want the layout to keep this node into account when positioning theother nodes.
In image #3, we see node “CmpC” moved closer to other nodes whereas it should be placed at the left of “MCAL” (my example in image #4, which I made manually).

Note: I have updated the topic title to make it clearer

OK, but why shouldn’t “CmpD” also be moved to be appropriately to the left of the moved “MCAL”? And maybe something similar for “CmpB”.

Another scenario starting from the original screenshot: what if the user moves “CmpB” down to the bottom and then there’s a layout?

I really don’t have a feel for what the layout is supposed to do.

Maybe I should express the idea more precisely, instead of giving examples :-)

Let’s state my idea differently. I think the current isLayoutPositioned option is too “strong”.
A node shall have 2 options:

  • isLayoutPositioned: if false, the node is not positioned by the layout
  • isLayoutIgnored: if true, the node is not positioned AND it does not influence other nodes

Such functionality is implemented in D3 (version 3) using “.fixed” attribute. Well, I did not test it yet, but it is discussed here:

Yes, that functionality is also in GoJS in ForceDirectedLayout:
https://gojs.net/latest/api/symbols/ForceDirectedLayout.html#isFixed
https://gojs.net/latest/api/symbols/ForceDirectedVertex.html#isFixed

But not in LayeredDigraphLayout, where your idea would need significant further refinement.

Ok, thanks for the information. I will experiment with ForceDirectedLayout then.

Is it possible to have this functionality in LayeredDigraphLayout in near future?

No, for the same reason that you are unable to precisely describe what the layout should do for all situations. And even if you could, what you would want is likely different from what someone else would want.