Function scaleDiverging

  • Constructs a new diverging scale with the specified interpolator function or array. The domain defaults to [0, 0.5, 1]. If interpolator is not specified, it defaults to the identity function. When the scale is applied, the interpolator will be invoked with a value typically in the range [0, 1], where 0 represents the extreme negative value, 0.5 represents the neutral value, and 1 represents the extreme positive value.

    If interpolator is an array, it represents the scale’s three-element output range and is converted to an interpolator function using d3.interpolate and d3.piecewise.

    The first generic corresponds to the data type of the interpolator return type. The second generic corresponds to the data type of the unknown value.

    Type Parameters

    • Output = number

    • Unknown = never

    Parameters

    • Optional interpolator: ((t) => Output) | Iterable<Output>

      The scale’s interpolator function or array.

    Returns ScaleDiverging<Output, Unknown>

  • Constructs a new diverging scale with the specified domain and interpolator function or array. When the scale is applied, the interpolator will be invoked with a value typically in the range [0, 1], where 0 represents the extreme negative value, 0.5 represents the neutral value, and 1 represents the extreme positive value.

    If interpolator is an array, it represents the scale’s three-element output range and is converted to an interpolator function using d3.interpolate and d3.piecewise.

    The first generic corresponds to the data type of the interpolator return type. The second generic corresponds to the data type of the unknown value.

    Type Parameters

    • Output

    • Unknown = never

    Parameters

    • domain: Iterable<NumberValue>

      Array of three numeric domain values.

    • interpolator: ((t) => Output) | Iterable<Output>

      The scale’s interpolator function or array.

    Returns ScaleDiverging<Output, Unknown>