Link recalculates its route when the visibility of the node changes

Hi,

By example

When I change the link route
and hide the node (node.visible = false) and then show it (node.visible = true),
the link route will be recalculated.
Is there a way to change this behavior?

function hideSelected() {
myDiagram.startTransaction(“hideSelected”);
myDiagram.selection.each(node => {
if (node instanceof go.Node){
node.visible = false;
}
});
myDiagram.commitTransaction(“hideSelected”);
}

function showAll() {
myDiagram.startTransaction(“showAll”);
myDiagram.nodes.each(function(node) {
node.visible = true;
});
myDiagram.commitTransaction(“showAll”);
}

You could save those link routes and restore them after making the node visible. There are some implementation complications, though.

Or you could make the node’s and links’ GraphObject.opacity zero. This is what I recommend. You probably also want to set Part.selectable and GraphObject.pickable to false, depending on the reason for hiding the node and connected links.

Thanks, I’m satisfied with the second solution

I have another problem:
When I hide a link that goes through another link, white gaps appear
Do you know how to fix it?

First, I hope you already understand that the reason for having gaps there normally is due to Link.curve having been set to go.Link.JumpGap.

But the functionality for deciding whether or not to insert a “jump” into the geometry of a link path doesn’t consider the opacity of the link or link path.

What happens when you make the link not visible instead of setting opacity to zero?

There is no difference.
The white gaps remain whether link.visible=false or link.opacity=0
Is there a way to fix it?

I can finally remove: curve: go.Link.JumpGap

Hmmm, that’s interesting. We’ll need to investigate what the right behavior should be.

But yes, if you don’t need Link.JumpGap or Link.JumpOver, don’t use it.

I think this will be fixed in v2.3.4, which should be coming out next week.