Interface LineRadial<Datum>

The radial line generator produces a spline or polyline, as in a line chart.

A radial line generator is equivalent to the standard Cartesian line generator, except the x and y accessors are replaced with angle and radius accessors. Radial lines are always positioned relative to ⟨0,0⟩; use a transform (see: SVG, Canvas) to change the origin.

The generic refers to the data type of an element in the input array passed into the line generator.

interface LineRadial {
    angle(): ((d, index, data) => number);
    angle(angle): LineRadial<Datum>;
    angle(angle): LineRadial<Datum>;
    context(): CanvasRenderingContext2D;
    context(context): LineRadial<Datum>;
    curve(): CurveFactory | CurveFactoryLineOnly;
    curve<C>(): C;
    curve(curve): LineRadial<Datum>;
    defined(): ((d, index, data) => boolean);
    defined(defined): LineRadial<Datum>;
    defined(defined): LineRadial<Datum>;
    radius(): ((d, index, data) => number);
    radius(radius): LineRadial<Datum>;
    radius(radius): LineRadial<Datum>;
    (data): string;
    (data): void;
}

Type Parameters

  • Datum

  • Generates a radial line for the given array of data. Depending on this radial line generator’s associated curve, the given input data may need to be sorted by x-value before being passed to the line generator.

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

    Parameters

    • data: Datum[] | Iterable<Datum>

      Array of data elements.

    Returns string

  • Generates a radial line for the given array of data. Depending on this radial line generator’s associated curve, the given input data may need to be sorted by x-value before being passed to the radial line generator.

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

    Parameters

    • data: Datum[] | Iterable<Datum>

      Array of data elements.

    Returns void

Methods

  • Returns the current angle accessor function, which defaults to a function returning first element of a two-element array of numbers.

    Returns ((d, index, data) => number)

      • (d, index, data): number
      • Returns the current angle accessor function, which defaults to a function returning first element of a two-element array of numbers.

        Parameters

        • d: Datum
        • index: number
        • data: Datum[]

        Returns number

  • Sets the angle accessor to the specified number and returns this radial line generator.

    Parameters

    • angle: number

      A constant angle value in radians, with 0 at -y (12 o’clock).

    Returns LineRadial<Datum>

  • Sets the angle accessor to the specified function and returns this radial line generator.

    When a radial line is generated, the angle accessor will be invoked for each defined element in the input data array.

    The default angle accessor assumes that the input data are two-element arrays of numbers. If your data are in a different format, or if you wish to transform the data before rendering, then you should specify a custom accessor.

    Parameters

    • angle: ((d, index, data) => number)

      An angle accessor function which returns the angle value in radians, with 0 at -y (12 o’clock). The angle accessor will be invoked for each defined element in the input data array, being passed the element d, the index i, and the array data as three arguments.

        • (d, index, data): number
        • Parameters

          • d: Datum
          • index: number
          • data: Datum[]

          Returns number

    Returns LineRadial<Datum>

  • Returns the current curve factory, which defaults to curveLinear.

    Returns CurveFactory | CurveFactoryLineOnly

  • Returns the current curve factory, which defaults to curveLinear.

    The generic allows to cast the curve factory to a specific type, if known.

    Type Parameters

    Returns C

  • Sets the curve factory and returns this radial line generator.

    Note that curveMonotoneX or curveMonotoneY are not recommended for radial lines because they assume that the data is monotonic in x or y, which is typically untrue of radial lines.

    Parameters

    Returns LineRadial<Datum>

  • Returns the current defined accessor, which defaults to a function returning a constant boolean value of true.

    Returns ((d, index, data) => boolean)

      • (d, index, data): boolean
      • Returns the current defined accessor, which defaults to a function returning a constant boolean value of true.

        Parameters

        • d: Datum
        • index: number
        • data: Datum[]

        Returns boolean

  • Sets the defined accessor to the specified boolean and returns this radial line generator.

    The default accessor for defined returns a constant boolean value of true, thus assumes that the input data is always defined.

    When a radial line is generated, the defined accessor will be invoked for each element in the input data array, being passed the element d, the index i, and the array data as three arguments. If the given element is defined (i.e., if the defined accessor returns a truthy value for this element), the angle and radius accessors will subsequently be evaluated and the point will be added to the current radial line segment. Otherwise, the element will be skipped, the current radial line segment will be ended, and a new radial line segment will be generated for the next defined point. As a result, the generated radial line may have several discrete segments.

    Note that if a radial line segment consists of only a single point, it may appear invisible unless rendered with rounded or square line caps. In addition, some curves such as curveCardinalOpen only render a visible segment if it contains multiple points.

    Parameters

    • defined: boolean

      A boolean constant.

    Returns LineRadial<Datum>

  • Sets the defined accessor to the specified function and returns this radial line generator.

    The default accessor for defined returns a constant boolean value of true, thus assumes that the input data is always defined.

    When a radial line is generated, the defined accessor will be invoked for each element in the input data array, being passed the element d, the index i, and the array data as three arguments. If the given element is defined (i.e., if the defined accessor returns a truthy value for this element), the angle and radius accessors will subsequently be evaluated and the point will be added to the current radial line segment. Otherwise, the element will be skipped, the current radial line segment will be ended, and a new radial line segment will be generated for the next defined point. As a result, the generated radial line may have several discrete segments.

    Note that if a radial line segment consists of only a single point, it may appear invisible unless rendered with rounded or square line caps. In addition, some curves such as curveCardinalOpen only render a visible segment if it contains multiple points.

    Parameters

    • defined: ((d, index, data) => boolean)

      An accessor function which returns a boolean value. The accessor will be invoked for each defined element in the input data array, being passed the element d, the index i, and the array data as three arguments.

        • (d, index, data): boolean
        • Parameters

          • d: Datum
          • index: number
          • data: Datum[]

          Returns boolean

    Returns LineRadial<Datum>

  • Returns the current radius accessor function, which defaults to a function returning second element of a two-element array of numbers.

    Returns ((d, index, data) => number)

      • (d, index, data): number
      • Returns the current radius accessor function, which defaults to a function returning second element of a two-element array of numbers.

        Parameters

        • d: Datum
        • index: number
        • data: Datum[]

        Returns number

  • Sets the radius accessor to the specified number and returns this radial line generator.

    Parameters

    • radius: number

      A constant radius value.

    Returns LineRadial<Datum>

  • Sets the radius accessor to the specified function and returns this radial line generator.

    When a radial line is generated, the radius accessor will be invoked for each defined element in the input data array.

    The default radius accessor assumes that the input data are two-element arrays of numbers. If your data are in a different format, or if you wish to transform the data before rendering, then you should specify a custom accessor.

    Parameters

    • radius: ((d, index, data) => number)

      A radius accessor function which returns the radius value. The radius accessor will be invoked for each defined element in the input data array, being passed the element d, the index i, and the array data as three arguments.

        • (d, index, data): number
        • Parameters

          • d: Datum
          • index: number
          • data: Datum[]

          Returns number

    Returns LineRadial<Datum>