GoJS API
/ to search
    Preparing search index...

    Class AvoidsLinksRouter

    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.

    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.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get avoidsNodes(): boolean

      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.

      Returns boolean

    • get diagram(): Diagram

      Gets or sets the Diagram this router is associated with. Routers cannot be shared.

      Returns Diagram

    • get epsilonDistance(): number

      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.

      Returns number

    • get ignoreContainingGroups(): boolean

      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.

      Returns boolean

    • get isEnabled(): boolean

      Gets or sets whether this router is enabled.

      Returns boolean

    • get isRealtime(): boolean

      Gets or sets whether this router runs during real-time operations, such as dragging or resizing. The default is true.

      Returns boolean

    • get iterations(): number

      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.

      Returns number

    • get linkSpacing(): number

      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.

      Returns number

    • get name(): string

      Gets or sets the name of this router.

      Returns string

    Methods

    • If this router has been added to a diagram, calling this method will ensure the Diagram re-runs all routing.

      The router should call this method when setting properties that might require the router to re-run when values change.

      Returns void