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

The area generator produces an area, as in an area chart. An area is defined by two bounding lines, either splines or polylines. Typically, the two lines share the same x-values (x0 = x1), differing only in y-value (y0 and y1); most commonly, y0 is defined as a constant representing zero. The first line (the topline) is defined by x1 and y1 and is rendered first; the second line (the baseline) is defined by x0 and y0 and is rendered second, with the points in reverse order. With a curveLinear curve, this produces a clockwise polygon.

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

Type parameters

  • Datum

Hierarchy

  • Area

Callable

  • __call(data: Datum[]): string | null
  • __call(data: Datum[]): void
  • Generates an area for the given array of data. Depending on this area generator’s associated curve, the given input data may need to be sorted by x-value before being passed to the area generator.

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

    Parameters

    • data: Datum[]

      Array of data elements.

    Returns string | null

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

    IMPORTANT: If the area generator has been configured with a rendering context, then the area 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

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 area generator.

    If the context is not null, then the generated area 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 area generator.

    A path data string representing the generated area 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

  • 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 area 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 area generator.

    The default accessor for defined returns a constant boolean value of true, thus assumes that the input data is always defined. When an area 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 x0, x1, y0 and y1 accessors will subsequently be evaluated and the point will be added to the current area segment. Otherwise, the element will be skipped, the current area segment will be ended, and a new area segment will be generated for the next defined point. As a result, the generated area may have several discrete segments.

    Note that if an area 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 area generator.

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

    The default accessor for defined returns a constant boolean value of true, thus assumes that the input data is always defined. When an area 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 x0, x1, y0 and y1 accessors will subsequently be evaluated and the point will be added to the current area segment. Otherwise, the element will be skipped, the current area segment will be ended, and a new area segment will be generated for the next defined point. As a result, the generated area may have several discrete segments.

    Note that if an area 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

lineX0

  • lineX0(): Line<Datum>
  • Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x0-accessor, and the line’s y-accessor is this area’s y0-accessor.

    Returns Line<Datum>

lineX1

  • lineX1(): Line<Datum>
  • Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x1-accessor, and the line’s y-accessor is this area’s y0-accessor.

    Returns Line<Datum>

lineY0

  • lineY0(): Line<Datum>
  • Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x0-accessor, and the line’s y-accessor is this area’s y0-accessor.

    Returns Line<Datum>

lineY1

  • lineY1(): Line<Datum>
  • Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x0-accessor, and the line’s y-accessor is this area’s y1-accessor.

    Returns Line<Datum>

x

  • x(): function
  • x(x: number)
  • x(x: function)
  • Returns the current x0 accessor. The default x0 accessor is a function returning the 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 x0 to a constant number x and x1 to null and returns this area generator.

    Setting x1 to null indicates that the previously-computed x0 value should be reused for the x1 value.

    Parameters

    • x: number

      A constant value to be used for x0.

  • Sets x0 to the specified function x and x1 to null and returns this area generator.

    The default x0 accessor assumes that the input data are two-element arrays of numbers and returns the first element. 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

      An accessor function returning a value to be used for x0. 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[]): number
        • Parameters

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

          Returns number

x0

  • x0(): function
  • x0(x: number)
  • x0(x: function)
  • Returns the current x0 accessor. The default x0 accessor is a function returning the 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 x0 to a constant number and returns this area generator.

    Parameters

    • x: number

      A constant value.

  • Sets x0 to the specified function and returns this area generator.

    The default x0 accessor assumes that the input data are two-element arrays of numbers and returns the first element. 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

      An accessor function returning a value to be used for x0. 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[]): number
        • Parameters

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

          Returns number

x1

  • x1(): function | null
  • x1(x: null)
  • x1(x: number)
  • x1(x: function)
  • Returns the current x1 accessor, which defaults to null, indicating that the previously-computed x0 value should be reused for the x1 value.

    Returns function | null

  • Sets x1 to null and returns this area generator.

    Setting x1 to null indicates that the previously-computed x0 value should be reused for the x1 value.

    Parameters

    • x: null

      null.

  • Sets x1 to a constant number and returns this area generator.

    Parameters

    • x: number

      A constant value.

  • Sets x1 to the specified function and returns this area generator.

    The default x1 accessor is null, indicating that the previously-computed x0 value should be reused for the x1 value. 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

      An accessor function returning a value to be used for x1. 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[]): number
        • Parameters

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

          Returns number

y

  • y(): function
  • y(y: number)
  • y(y: function)
  • Returns the current y0 accessor. The default y0 accessor is a function returning a constant value of zero.

    Returns function

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

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

        Returns number

  • Sets y0 to a constant number y and y1 to null and returns this area generator.

    Setting y1 to null indicates that the previously-computed y0 value should be reused for the y1 value.

    Parameters

    • y: number

      A constant value to be used for y0.

  • Sets y0 to the accessor function y and y1 to null and returns this area generator.

    The default y0 accessor returns a constant value of zero. 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

      An accessor function returning a value to be used for y0. 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[]): number
        • Parameters

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

          Returns number

y0

  • y0(): function
  • y0(y: number)
  • y0(y: function)
  • Returns the current y0 accessor. The default y0 accessor is a function a constant value of zero.

    Returns function

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

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

        Returns number

  • Sets y0 to a constant number and returns this area generator.

    Parameters

    • y: number

      A constant value.

  • Sets y0 to the specified function and returns this area generator.

    The default y0 accessor is a function which returns a constant value of zero. 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

      An accessor function returning a value to be used for y0. 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[]): number
        • Parameters

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

          Returns number

y1

  • y1(): function | null
  • y1(y: null)
  • y1(y: number)
  • y1(y: function)
  • Returns the current y1 accessor or null. The default y1 accessor is a function returning the second element of a two-element array of numbers.

    If the y1 accessor is null, the previously-computed y0 value is reused for the y1 value.

    Returns function | null

  • Sets y1 to null and returns this area generator.

    Setting y1 to null indicates that the previously-computed y0 value should be reused for the y1 value.

    Parameters

    • y: null

      null.

  • Sets y1 to a constant number and returns this area generator.

    Parameters

    • y: number

      A constant value.

  • Sets y1 to the specified function and returns this area generator.

    The default y1 accessor assumes that the input data are two-element arrays of numbers and returns the second element. 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

      An accessor function returning a value to be used for y1. 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[]): 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