Make links run parallel, instead of on top of each other

I have a digram that is using LayeredDigraphLayout, with additional configuration where some nodes are placed to the bottom of the chart. The diagram may consists of a high number of nodes, each with multiple links going in and out of them. Please see a visual example below.

My question would be if it is possible to ensure that the links always run in paralell and never on top of each other (like on the screenshot).

I’m using the following config for links:

  • routing: go.Link.Orthogonal
  • curve: go.Link.JumpGap
  • midAngle: 30
  • toEndSegmentLength: 50
  • fromEndSegmentLength: 150

One way of reducing the overlapping segments would be to vary the fromEndSegmentLength and toEndSegmentLength for each of the ports of a node and the Link.curviness for each Link.

The Dynamic Ports sample, Dynamic Ports, demonstrates this with a custom Link class the overrides the Link.computeEndSegmentLength and Link.computeCurviness methods. Alas that class is implemented very specifically for that sample, but perhaps you could do something similar, but simpler. I guess it depends on how you have implemented ports in your nodes.

Alternatively you could bind GraphObject.fromEndSegmentLength and GraphObject.toEndSegmentLength on the ports and Link.curviness on the links and assign values programmatically.