Redraw links without changing position of nodes

Hi,
I would like to redraw only links in my diagram without changing position of my nodes in a go.LayeredDigraphLayout.
Do we have a function to do that?
I tried with "diagram.layoutDiagram(true) and “doLayout()” of all my nodes are moving…
We use the version 1.7.

Thank you!

Laying out just links and not nodes isn’t typical behavior. Could you provide before and after screenshots/sketches to show us what you’re trying to achieve?

+1, not to hijack the thread but I believe I ran into a similar problem, I wanted to addLinkData/removeLinkData to toggle display of a subset of links without moving the nodes. I’m using layered layout for the diagram and every time I add or remove link data the nodes are moved automatically.

GoJS Layouts -- Northwoods Software should address your issue.

Another possibility: don’t add and remove links, but change their opacity between 0.0 and 1.0.

Thanks a lot!

Hi,

I have this part of diagram:

Here the result after moving node “Formule 2”:

The users move a lot of nodes, but after he finish, we want to give them the possibility to “reroute” links without move nodes (to keep the layout of the user). Now, all links linked to a node that the user moved, they are not rerouted.

Here my linkTemplate

        $(go.Link,
            {
                routing: go.Link.Normal,
                fromSpot: go.Spot.Bottom,
                toSpot: go.Spot.Top,
                cursor: 'pointer',
                corner: 5
            },
            new go.Binding('visible', '', this.elementVisibleConverter.bind(this)),
            $(go.Shape,
                {
                    isPanelMain: true,
                    strokeWidth: 4,
                    name: 'BORDER'
                },
                new go.Binding('stroke', '', this.linkColorConverter.bind(this))
            ),
            $(go.Shape,
                {
                    toArrow: 'Standard',
                    strokeWidth: 6
                })
        )

Thanks and have a nice day!

I suppose you could try setting Link.adjusting to some non-default value. I’m not sure what would work best in your app.

You’ll probably also need to customize the layout so that it explicitly sets Link.adjusting back to go.Link.None before it performs the layout and then afterwards resets Link.adjusting to your chosen value.

I forgot to give you the diagram declaration:

$(go.LayeredDigraphLayout, {
direction: 90,
columnSpacing: 10,
layerSpacing: 120,
isOngoing: false,
isInitial: true
});

Hi,
The property “adjusting” seems not working for us.
We also set the “isInitial” to false with the same result.
The only way we have finded to solve the problem is to set the routing to “AvoidsNodes”, but the performance is not enough good for our client.

We try this also:
We add a button in the app called advanced layout. So we can toggle layouts between go.LayeredDigraphLayout (advanced) and go.TreeLayout (basic). This is the initialization:

if (this.isAdvancedDisplay) {
    return $(go.LayeredDigraphLayout, {
        direction: 90,
        columnSpacing: 10,
        layerSpacing: 120,
        isOngoing: false,
        isInitial: false
    });
}
return $(go.TreeLayout, {
    arrangement: go.TreeLayout.ArrangementHorizontal,
    alignment: go.TreeLayout.AlignmentCenterChildren,
    angle: 90,
    rowSpacing: 120,
    layerSpacing: 120,
    nodeSpacing: 50,
    isRealtime: true,
    isOngoing: false,
    isInitial: false
});

But, if we toggle basic to advanced layout, the links are not “redraw”. After setting the layout, we try to add this, but nothing happens also:

this._diagram.links.each(link => {
    link.invalidateRoute();
});

And the original problem is still there with the go.LayeredDigraphLayout… If we move a node, its links can pass over other nodes. If we set the isInitial to true, nodes are moving and it’s not what we want.

I hope that I’m compréhensible!?!

If AvoidsNodes routing produces reasonable results when the user drags a node, but the overall performance of the layout is too slow with AvoidsNodes routing, then one possibility is to only turn on AvoidsNodes routing for those nodes that are being dragged.

If you find that possibility worth pursuing, you just need to override DraggingTool.doActivate. Something like:

    myDiagram.toolManager.draggingTool.doActivate = function() {
      go.DraggingTool.prototype.doActivate.call(this);
      var drags = this.draggedParts.toKeySet();
      drags.each(n => {
        if (n instanceof go.Node) {
          n.linksConnected.each(l => {
            if (!drags.contains(l)) {
              l.routing = go.Link.AvoidsNodes;
            }
          });
        }
      });
    };

No need for you to ever call invalidateRoute().

When the user changes the layout, what happens to the Layout that you return from the code that you quoted? Does it get assigned to Diagram.layout? If so, it would normally perform a layout, but you have set Layout.isInitial to false. Perhaps that is what is desired if the user loads some other model and you don’t want a layout to mess up whatever custom node positions you have saved in the model. But then you need to explicitly call Diagram.layoutDiagram(true) in order to force a re-layout.

My sample is the function getLayout in the app. It set the layout of my diagram (this._diagram.layout = getLayout())
I set isInitial to false to let the user control its layout in the diagram and to not move nodes when user toggle the layout (advanced vs basic in the app).
With the suggestion above, if I save the data (node / location) in database and leave the page, when I come back, the links are “Normal” and they can pass over other nodes. Here an example “before save” and “when I come back”:

                

Is there a way with the go.LayeredDigraphLayout to “compute” links that are manually manipulated by the user (or no matter the position of the nodes) and have the same default behavior by keeping the routing to “Normal”, like the first picture?

Thank you

Apparently you didn’t save the Link.points property using a TwoWay Binding. Many samples demonstrate this.