Interface Link<This, LinkDatum, NodeDatum>

A link generator for a Cartesian coordinate system. The link shape generates a smooth cubic Bézier curve from a source point to a target point. The tangents of the curve at the start and end are either vertical, horizontal.

The first generic corresponds to the type of the "this" context within which the link generator and its accessor functions will be invoked.

The second generic corresponds to the datum type of the link object for which the link is to be generated.

The third generic corresponds to the datum type of the source/target node contained in the link object.

interface Link {
    context(): CanvasRenderingContext2D;
    context(context): Link<This, LinkDatum, NodeDatum>;
    source(): ((this, d, ...args) => NodeDatum);
    source(source): Link<This, LinkDatum, NodeDatum>;
    target(): ((this, d, ...args) => NodeDatum);
    target(target): Link<This, LinkDatum, NodeDatum>;
    x(): ((this, node, ...args) => number);
    x(x): Link<This, LinkDatum, NodeDatum>;
    y(): ((this, node, ...args) => number);
    y(y): Link<This, LinkDatum, NodeDatum>;
    (this, d, ...args): string;
    (this, d, ...args): void;
}

Type Parameters

  • This

  • LinkDatum

  • NodeDatum

  • Generates a link for the given arguments.

    IMPORTANT: If the rendering context of the link generator is null, then the link is returned as a path data string.

    The "this" context within which this function is invoked, will be the context within which the accessor methods of the generator are invoked. All arguments passed into this function, will be passed to the accessor functions of the generator.

    Parameters

    • this: This
    • d: LinkDatum

      The datum for which the link is to be generated.

    • Rest ...args: any[]

    Returns string

  • Generates an link for the given arguments.

    IMPORTANT: If the link generator has been configured with a rendering context, then the link is rendered to this context as a sequence of path method calls and this function returns void.

    The "this" context within which this function is invoked, will be the context within which the accessor methods of the generator are invoked. All arguments passed into this function, will be passed to the accessor functions of the generator.

    Parameters

    • this: This
    • d: LinkDatum

      The datum for which the link is to be generated.

    • Rest ...args: any[]

    Returns void

Methods

  • Returns the current source node accessor function. The default source accessor function returns a two element array [x, y].

    Returns ((this, d, ...args) => NodeDatum)

      • (this, d, ...args): NodeDatum
      • Returns the current source node accessor function. The default source accessor function returns a two element array [x, y].

        Parameters

        • this: This
        • d: LinkDatum
        • Rest ...args: any[]

        Returns NodeDatum

  • Sets the source accessor to the specified function and returns this link generator.

    Parameters

    • source: ((this, d, ...args) => NodeDatum)

      Source node accessor function. The accessor function is invoked in the same "this" context as the generator was invoked in and receives the same arguments that were passed into the link generator. The default target accessor function returns a two element array [x, y].

        • (this, d, ...args): NodeDatum
        • Parameters

          • this: This
          • d: LinkDatum
          • Rest ...args: any[]

          Returns NodeDatum

    Returns Link<This, LinkDatum, NodeDatum>

  • Returns the current target node accessor function. The default target accessor function returns a two element array [x, y].

    Returns ((this, d, ...args) => NodeDatum)

      • (this, d, ...args): NodeDatum
      • Returns the current target node accessor function. The default target accessor function returns a two element array [x, y].

        Parameters

        • this: This
        • d: LinkDatum
        • Rest ...args: any[]

        Returns NodeDatum

  • Sets the target accessor to the specified function and returns this link generator.

    Parameters

    • target: ((this, d, ...args) => NodeDatum)

      Target node accessor function. The accessor function is invoked in the same "this" context as the generator was invoked in and receives the same arguments that were passed into the link generator. The default target accessor function returns a two element array [x, y].

        • (this, d, ...args): NodeDatum
        • Parameters

          • this: This
          • d: LinkDatum
          • Rest ...args: any[]

          Returns NodeDatum

    Returns Link<This, LinkDatum, NodeDatum>

  • Returns the current x-accessor, which defaults to a function accepting an number array as its argument an returning the first element of the array.

    Returns ((this, node, ...args) => number)

      • (this, node, ...args): number
      • Returns the current x-accessor, which defaults to a function accepting an number array as its argument an returning the first element of the array.

        Parameters

        • this: This
        • node: NodeDatum
        • Rest ...args: any[]

        Returns number

  • Sets the x-accessor to the specified function and returns this link generator.

    Parameters

    • x: ((this, node, ...args) => number)

      x-coordinate accessor function. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as its first argument a node object followed by all additional arguments that were passed into the link generator.

        • (this, node, ...args): number
        • Parameters

          • this: This
          • node: NodeDatum
          • Rest ...args: any[]

          Returns number

    Returns Link<This, LinkDatum, NodeDatum>

  • Returns the current y-accessor, which defaults to a function accepting an number array as its argument an returning the second element of the array.

    Returns ((this, node, ...args) => number)

      • (this, node, ...args): number
      • Returns the current y-accessor, which defaults to a function accepting an number array as its argument an returning the second element of the array.

        Parameters

        • this: This
        • node: NodeDatum
        • Rest ...args: any[]

        Returns number

  • Sets the y-accessor to the specified function and returns this link generator.

    Parameters

    • y: ((this, node, ...args) => number)

      y-coordinate accessor function. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as its first argument a node object followed by all additional arguments that were passed into the link generator.

        • (this, node, ...args): number
        • Parameters

          • this: This
          • node: NodeDatum
          • Rest ...args: any[]

          Returns number

    Returns Link<This, LinkDatum, NodeDatum>