Stop links with no port from ending at the same point

Hi

When I have a number of links with no port specified going to the same node, these can link to the node at the same point. When possible I’d like to avoid this situation and link at a different point instead.

This is what currently happens

This is what I’d like

Do I need to add this functionality myself by extending the Link class? Or is it configurable somewhere? It appears LayeredDigraphLayout may do what I want, but I don’t want the node layout features that provides

What’s wrong with specifying the toSpot to be Spot.LeftSide, either on the node’s port element or on the Link itself?

The links can be going in any direction. Should Spot.AllSides achieve what I’m after?

But I just tried using Spot.LeftSide and the links did stay connected on the left hand side but they always connected to the centre of the side of the node. Presumably you wouldn’t expect that?

You aren’t using a Diagram.layout, are you?

Yes, try using Spot.AllSides.

No, we’re just using go.Layout

Edit - Actually we do use our own custom layout when we have lanes but don’t for other diagram types. I’ll see what happens with no layout vs with a layout

I was wondering if your Diagram.layout were assigning Link.fromSpot or Link.toSpot, which would cause whatever spot values you had chosen on the ports or on the links to be ignored.

That’s the case for TreeLayout and LayeredDigraphLayout. You can disable that behavior by setting TreeLayout.setsPortSpot and TreeLayout.setsChildPortSpot to false or LayeredDigraphLayout.setsPortSpots to false.

But if you have a completely custom layout, I cannot know what routing that does.

No, our lanes layout is used purely for laying out the lanes. If Spot.AllSides should work, I’ll start ripping things out of our code until it does start working then I’ll have more idea of what’s causing the problem

Search for “Spot.AllSides” in the samples and in the documentation for examples where it is used, so you can be more comfortable about “ripping things out of our code”.

OK, I think I understand the problem now. We have 12 ports on the node and if none are used, the node is used as the port. So we set the linkFromPortIdProperty and linkToPortIdProperty properties. If I remove those property assignments the links no longer merge together with Spot.AllSides set. I’m guessing if ports are being used, the fromSpot and toSpot properties are ignored?

The fromSpot and toSpot apply to every port element.

You need to decide whether your nodes should have one big port or many small ones. I suspect the former is the better decision in your case, but I might not know all of the behaviors that you are expecting to implement.

Our main aim is to work similarly to our desktop tool, which by default lays out the link in the best way it can but allows the user to drag the link to a different port. So we’ve got 12 small ports and the node also acts as a port. Other than this particular problem, this approach seems to be working OK?

Make sure the one big port also has a portId. It is customary to assign it the default port id, the empty string.

Then make sure all of the link data in the model specify the port id for both ends.

Bingo! The links with no associated small ports were being set to “0” rather than “”. Changing that made the links stop merging. Thanks, do you have a tip jar?