WebCola
Options
All
  • Public
  • Public/Protected
  • All
Menu

The line generator produces a spline or polyline, as in a line chart. Lines also appear in many other visualization types, such as the links in hierarchical edge bundling.

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

Type parameters

  • Datum

Hierarchy

  • Line

Callable

  • __call(data: Datum[]): string | null
  • __call(data: Datum[]): void
  • Generates a line for the given array of data. Depending on this 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 line generator is null, then the line is returned as a path data string.

    Parameters

    • data: Datum[]

      Array of data elements.

    Returns string | null

  • Generates a line for the given array of data. Depending on this 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 line generator has been configured with a rendering context, then the line is rendered to this context as a sequence of path method calls and this function returns void.

    Parameters

    • data: Datum[]

      Array of data elements.

    Returns void

Index

Methods

Methods

context

  • context(): CanvasRenderingContext2D | null
  • context(context: CanvasRenderingContext2D)
  • context(context: null)
  • Returns the current rendering context, which defaults to null.

    Returns CanvasRenderingContext2D | null

  • Sets the rendering context and returns this line generator.

    If the context is not null, then the generated line is rendered to this context as a sequence of path method calls.

    Parameters

    • context: CanvasRenderingContext2D

      The rendering context.

  • Sets the rendering context to null and returns this line generator.

    A path data string representing the generated line will be returned when the generator is invoked with data.

    Parameters

    • context: null

      null, to remove rendering context.

curve

  • 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 specifc type, if known.

    Type parameters

    Returns C

  • Sets the curve factory and returns this line generator.

    Parameters

defined

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

    Returns function

      • (d: Datum, index: number, data: Datum[]): boolean
      • Parameters

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

        Returns boolean

  • Sets the defined accessor to the specified boolean and returns this 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 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 x and y accessors will subsequently be evaluated and the point will be added to the current line segment. Otherwise, the element will be skipped, the current line segment will be ended, and a new line segment will be generated for the next defined point. As a result, the generated line may have several discrete segments.

    Note that if a 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

  • Sets the defined accessor to the specified function and returns this 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 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 x and y accessors will subsequently be evaluated and the point will be added to the current line segment. Otherwise, the element will be skipped, the current line segment will be ended, and a new line segment will be generated for the next defined point. As a result, the generated line may have several discrete segments.

    Note that if a 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: function

      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: Datum, index: number, data: Datum[]): boolean
        • Parameters

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

          Returns boolean

x

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

    Returns function

      • (d: Datum, index: number, data: Datum[]): number
      • Parameters

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

        Returns number

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

    Parameters

    • x: number

      A constant x-coordinate value.

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

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

    The default x 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

    • x: function

      A coordinate accessor function which returns the x-coordinate value. The x 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: Datum, index: number, data: Datum[]): number
        • Parameters

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

          Returns number

y

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

    Returns function

      • (d: Datum, index: number, data: Datum[]): number
      • Parameters

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

        Returns number

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

    Parameters

    • y: number

      A constant y-coordinate value.

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

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

    The default y 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

    • y: function

      A coordinate accessor function which returns the y-coordinate value. The y 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: Datum, index: number, data: Datum[]): number
        • Parameters

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

          Returns number

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc