Class AvoidsLinksRouter

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

Hierarchy

A custom Router that will cause overlapping segments of Orthogonal or AvoidsNodes links to be routed in parallel, while minimizing resulting crossings between links.

The maximum distance that resulting sets of links will be spread apart is given by AvoidsLinksRouter.linkSpacing.

By default the router will reduce the space between parallel segments to prevent them from overlapping nearby Nodes, however this behavior can be disabled by setting AvoidsLinksRouter.avoidsNodes to false. If that property is set to false, then all modified sets of links will be at a distance of exactly AvoidsLinksRouter.linkSpacing, even if this causes some of the links to overlap a nearby Node.

Typical setup:

  myDiagram.routers.add(new AvoidsLinksRouter());

If you want to experiment with this extension, try the AvoidsLinksRouter sample.

Index

Constructors

Accessors

  • Gets or sets whether the AvoidsLinksRouter should reduce spacing between separated Links to avoid overlap with nearby Nodes. If avoidsNodes is false, all separated links will have a distance of exactly linkSpacing, even if this causes them to cross over a nearby Node.

    The default value is true.

  • Gets or sets the minimum distance between links for them to be considered "overlapping" and be separated by AvoidsLinksRouter. Large values of this parameter compared to linkSpacing can make the resulting groups of segments less evenly-spaced, so it is recommended to use a small value for this parameter - ideally a small fraction of linkSpacing.

    The default value is 0.5.

  • Gets or sets whether the router will run only once on the top-level Diagram, considering all links regardless of their containing group.

    If false, the router will instead separately route the top-level links against links in each Group, which is more efficient but may have undefined results when links route in and out of nested Groups.

    The default value is false.

  • Gets or sets the number of times the AvoidsLinksRouter will run iteratively. In the vast majority of cases, one iteration should be enough and this parameter should not need to be modified. Multiple iterations may be useful when numerous links coincide, particularly when they are close to Nodes with avoidsNodes set to true.

    The default value is 1.

  • Gets or sets the desired distance between Links that are separated by AvoidsLinksRouter. If avoidsNodes is true, this value is the maximum allowed distance between such links, but the distance could be smaller to avoid overlapping Nodes.

    The default value is 4.

Methods

  • Adjust segments of all links in the Diagram to prevent overlap.

    Parameters

    Returns void