Misplaced links after doLayout

Running gojs 2.0 on ubuntu.

I’ve modified the ContinuousForceDirectedLayout example as follows: when a node is clicked, the layouter switches and for each node an n.move() is performed relative to the clicked node:

if (!clickedNode) {
// now perform the normal layout
go.ForceDirectedLayout.prototype.doLayout.call(this, coll);
} else {
this.diagram.nodes.each(function(n) {
var pt = new go.Point(…);

The move is performed OK, but a lot of the links between the nodes do not point to the middle of a node, but are ‘misplaced’: the are connected to the correct node, but point to an arbitrary point inside the node.


could you advise me how to fix this?

Where is that code defined? When is it called?

I’m guessing that you need to perform all of those moves within a single transaction.

The code is defined inside the


override, as copied from the examples pages. It behaves like the example when clickedNode is not set.
I accidentally forgot to include the transaction in this post; the real code more looks like this:

 else {
   this.diagram.nodes.each(function(n) {
        var pt = new go.Point(…);

so the introduction of a transaction doesn’t help.
The re-layout is activated by a call to


I just tried modifying the InteractiveForce sample, changing the override of doLayout to check a global variable and either do the super call or to call move on each not-isSelected node to shift them towards larger X and Y values.

The unselected nodes moved correctly, the selected nodes did not move, and the links were re-routed correctly.

So I don’t know what you are doing differently.

I will try and make a small example that shows the behaviour, and present that to you. Stay tuned…

In trying to come up with a minimal example I found the cause of the problem.
For some reason (I cannot recall) the link definition has the following attributes:

 curve: go.Link.Bezier,
 adjusting: go.Link.Stretch,
 reshapable: true

removing the last two lines (not useful for my app anyway) solved the problem.
Thanks for the support, anyway.