Links not following toSpot and fromSpot on connector port shape


I have nodes that are using connector ports placed RightCenter with shapes that only have toSpot or fromSpot values defined as go.Spot.Right. However, it looks like these properties are being ignored, as seen here:

In the For Each node, the link is pointing to the top of the port. In the If node, the link is coming out of the bottom of the port.

In this example where the For Each node does not have a child, the toSpot property is honored:


We are using v2.1.4 on a browser.

Please let me know any information I am missing and I will do my best to provide answers.

What Diagram.layout do you have? I’m wondering if the layout is automatically setting each Link’s Link.fromSpot and Link.toSpot, unless you tell it not to: TreeLayout.setsPortSpot, TreeLayout.setsChildPortSpot, LayeredDigraphLayout.setsPortSpots, ForceDirectedLayout.setsPortSpots

We are using the TreeLayout. Thanks Walter, that was it!


I do have a follow-up question though. In the docs for setsPortsSpot it says:

The default value is true – this may modify the spot of the port of this node, the parent, if the node has only a single port.

Don’t our nodes here have more than one port? Why are the ports still being modified?

I don’t know what your templates are, but I don’t see why you would want more than one port per node.

I think I am misunderstanding the meaning of “node” here. I thought a node would be like a For Each node, which in my head has three ports: the input, output, and returning loop input. Are we referring to the connector port as a “node” instead?

A “port” is a GraphObject that supports identifiable connection points for a Node. That is for the purpose of syntactic and semantic distinction of link connections.

fromSpot and toSpot control where on a port a link connection point should be.

Yes, by “node” I meant an instance of Node. Your “For Each” thing is a node. Whether it has more than the one default port whose identifier is the empty string, depends entirely on how the node template is defined. Does it set or bind any GraphObject.portId to a non-empty string?

It isn’t clear to me that your node templates need to have anything besides the default port. I would think you would want to have links coming out the side of a node or into the side of a node based on the link’s specific qualities. In your case that’s probably because you want links that “loop back” to go “around” nodes. But you don’t need to use port objects for that – just set or bind the Link.fromSpot and Link.toSpot. Which is something that could be done by the automatic layout, if that is its responsibility. I don’t know how you have customized your TreeLayout.