@types/d3-scale

  • Version 4.0.8
  • Published
  • 135 kB
  • 1 dependency
  • MIT license

Install

npm i @types/d3-scale
yarn add @types/d3-scale
pnpm add @types/d3-scale

Overview

TypeScript definitions for d3-scale

Index

Variables

Functions

Interfaces

Type Aliases

Variables

variable scaleImplicit

const scaleImplicit: { name: 'implicit' };
  • A special value for ordinal.unknown that enables implicit domain construction: unknown values are implicitly added to the domain.

Functions

function scaleBand

scaleBand: {
<Domain extends { toString(): string } = string>(
range?: Iterable<NumberValue>
): ScaleBand<Domain>;
<Domain extends { toString(): string }>(
domain: Iterable<Domain>,
range: Iterable<NumberValue>
): ScaleBand<Domain>;
};
  • Constructs a new band scale with the specified range, no padding, no rounding and center alignment. The domain defaults to the empty domain. If range is not specified, it defaults to the unit range [0, 1].

    The generic corresponds to the data type of domain elements.

    Parameter range

    A two-element array of numeric values.

  • Constructs a new band scale with the specified domain and range, no padding, no rounding and center alignment.

    The generic corresponds to the data type of domain elements.

    Parameter domain

    Array of domain values.

    Parameter range

    A two-element array of numeric values.

function scaleDiverging

scaleDiverging: {
<Output = number, Unknown = never>(
interpolator?: ((t: number) => Output) | Iterable<Output>
): ScaleDiverging<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: ((t: number) => Output) | Iterable<Output>
): ScaleDiverging<Output, Unknown>;
};
  • 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.

    Parameter interpolator

    The scale’s interpolator function or array.

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

    Parameter domain

    Array of three numeric domain values.

    Parameter interpolator

    The scale’s interpolator function or array.

function scaleDivergingLog

scaleDivergingLog: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
};
  • A diverging scale with a logarithmic transform, analogous to a log scale.

    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.

    Parameter interpolator

    The scale’s interpolator.

  • A diverging scale with a logarithmic transform, analogous to a log scale.

    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.

    Parameter domain

    Array of three numeric domain values.

    Parameter interpolator

    The scale’s interpolator.

function scaleDivergingPow

scaleDivergingPow: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
};
  • A diverging scale with a exponential transform, analogous to a power scale.

    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.

    Parameter interpolator

    The scale’s interpolator.

  • A diverging scale with a exponential transform, analogous to a power scale.

    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.

    Parameter domain

    Array of three numeric domain values.

    Parameter interpolator

    The scale’s interpolator.

function scaleDivergingSqrt

scaleDivergingSqrt: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
};
  • A diverging scale with a square-root transform, analogous to a d3.scaleSqrt.

    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.

    Parameter interpolator

    The scale’s interpolator.

  • A diverging scale with a square-root transform, analogous to a d3.scaleSqrt.

    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.

    Parameter domain

    Array of three numeric domain values.

    Parameter interpolator

    The scale’s interpolator.

function scaleDivergingSymlog

scaleDivergingSymlog: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleDiverging<Output, Unknown>;
};
  • A diverging scale with a symmetric logarithmic transform, analogous to a symlog scale.

    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.

    Parameter interpolator

    The scale’s interpolator.

  • A diverging scale with a symmetric logarithmic transform, analogous to a symlog scale.

    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.

    Parameter domain

    Array of three numeric domain values.

    Parameter interpolator

    The scale’s interpolator.

function scaleIdentity

scaleIdentity: <Unknown = never>(
range?: Iterable<NumberValue>
) => ScaleIdentity<Unknown>;
  • Constructs a new identity scale with the specified domain and range. If range is not specified, it defaults to [0, 1].

    The generic corresponds to the data type of the unknown value.

    Parameter range

    Array of range values.

function scaleLinear

scaleLinear: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScaleLinear<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleLinear<Range, Output, Unknown>;
};
  • Constructs a new continuous scale with the specified range, the default interpolator and clamping disabled. The domain defaults to [0, 1]. If range is not specified, it defaults to [0, 1].

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new continuous scale with the specified domain and range, the default interpolator and clamping disabled.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of numeric domain values.

    Parameter range

    Array of range values.

function scaleLog

scaleLog: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScaleLogarithmic<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleLogarithmic<Range, Output, Unknown>;
};
  • Constructs a new continuous scale with the specified range, the base 10, the default interpolator and clamping disabled. The domain defaults to [1, 10]. If range is not specified, it defaults to [0, 1].

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new continuous scale with the specified domain and range, the base 10, the default interpolator and clamping disabled.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of numeric domain values.

    Parameter range

    Array of range values.

function scaleOrdinal

scaleOrdinal: {
<Range>(range?: Iterable<Range>): ScaleOrdinal<string, Range>;
<Domain extends { toString(): string }, Range, Unknown = never>(
range?: Iterable<Range>
): ScaleOrdinal<Domain, Range, Unknown>;
<Domain extends { toString(): string }, Range, Unknown = never>(
domain: Iterable<Domain>,
range: Iterable<Range>
): ScaleOrdinal<Domain, Range, Unknown>;
};
  • Constructs a new ordinal scale with the specified range. The domain defaults to the empty array. If range is not specified, it defaults to the empty array; an ordinal scale always returns undefined until a non-empty range is defined.

    The generic corresponds to the data type of range elements.

    Parameter range

    An optional array of range values to initialize the scale with.

  • Constructs a new ordinal scale with the specified range. The domain defaults to the empty array. If range is not specified, it defaults to the empty array; an ordinal scale always returns undefined until a non-empty range is defined.

    The first generic corresponds to the data type of domain elements. The second generic corresponds to the data type of range elements. The third generic corresponds to the data type of the unknown value.

    Parameter range

    An optional array of range values to initialize the scale with.

  • Constructs a new ordinal scale with the specified domain and range.

    The first generic corresponds to the data type of domain elements. The second generic corresponds to the data type of range elements. The third generic corresponds to the data type of the unknown value.

    Parameter domain

    Array of domain values.

    Parameter range

    An optional array of range values to initialize the scale with.

function scalePoint

scalePoint: {
<Domain extends { toString(): string } = string>(
range?: Iterable<NumberValue>
): ScalePoint<Domain>;
<Domain extends { toString(): string }>(
domain: Iterable<Domain>,
range: Iterable<NumberValue>
): ScalePoint<Domain>;
};
  • Constructs a new point scale with the specified range, no padding, no rounding and center alignment. The domain defaults to the empty domain. If range is not specified, it defaults to the unit range [0, 1].

    The generic corresponds to the data type of domain elements.

    Parameter range

    A two-element array of numeric values.

  • Constructs a new point scale with the specified domain and range, no padding, no rounding and center alignment. The domain defaults to the empty domain.

    The generic corresponds to the data type of domain elements.

    Parameter domain

    Array of domain values.

    Parameter range

    A two-element array of numeric values.

function scalePow

scalePow: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScalePower<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScalePower<Range, Output, Unknown>;
};
  • Constructs a new continuous scale with the specified range, the exponent 1, the default interpolator and clamping disabled. The domain defaults to [0, 1]. If range is not specified, it defaults to [0, 1]. (Note that this is effectively a linear scale until you set a different exponent.)

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new continuous scale with the specified domain and range, the exponent 1, the default interpolator and clamping disabled. (Note that this is effectively a linear scale until you set a different exponent.)

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of numeric domain values.

    Parameter range

    Array of range values.

function scaleQuantile

scaleQuantile: {
<Range = number, Unknown = never>(range?: Iterable<Range>): ScaleQuantile<
Range,
Unknown
>;
<Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleQuantile<Range, Unknown>;
};
  • Constructs a new quantile scale with the specified range. The domain defaults to the empty array. If range is not specified, it defaults to the empty array. The quantile scale is invalid until both a domain and range are specified.

    The first generic corresponds to the data type of range elements. The second generic corresponds to the data type of the unknown value.

    Parameter range

    Array of range values.

  • Constructs a new quantile scale with the specified domain and range. The quantile scale is invalid until both a domain and range are specified.

    The first generic corresponds to the data type of range elements. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    Array of domain values.

    Parameter range

    Array of range values.

function scaleQuantize

scaleQuantize: {
<Range = number, Unknown = never>(range?: Iterable<Range>): ScaleQuantize<
Range,
Unknown
>;
<Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleQuantize<Range, Unknown>;
};
  • Constructs a new quantize scale with the specified range. The domain defaults to [0, 1]. If range is not specified, it defaults to [0, 1]. Thus, the default quantize scale is equivalent to the Math.round function.

    The range must be set corresponding to the type of the range elements.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the unknown value.

    Parameter range

    Array of range values.

  • Constructs a new quantize scale with the specified domain and range. Thus, the default quantize scale is equivalent to the Math.round function.

    The range must be set corresponding to the type of the range elements.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric values defining the domain.

    Parameter range

    Array of range values.

function scaleRadial

scaleRadial: {
<Range = number, Unknown = never>(range?: Iterable<Range>): ScaleRadial<
Range,
Range,
Unknown
>;
<Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleRadial<Range, Range, Unknown>;
};
  • Constructs a new radial scale with the specified range. The domain defaults to [0, 1].

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the unknown value.

    The range must be set in accordance with the range element type.

    Parameter range

    Iterable of range values.

  • Constructs a new radial scale with the specified domain and range.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the unknown value.

    The range must be set in accordance with the range element type.

    Parameter domain

    Iterable of numeric domain values.

    Parameter range

    Iterable of range values.

function scaleSequential

scaleSequential: {
<Output = number, Unknown = never>(
interpolator?: ((t: number) => Output) | Iterable<Output>
): ScaleSequential<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: ((t: number) => Output) | Iterable<Output>
): ScaleSequential<Output, Unknown>;
};
  • Constructs a new sequential scale with the specified interpolator function or array. The domain defaults to [0, 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 minimum value and 1 represents the maximum value.

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

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter interpolator

    The interpolator function or array to be used with the scale.

  • Constructs a new sequential 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 minimum value and 1 represents the maximum value.

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

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric domain values.

    Parameter interpolator

    The interpolator function or array to be used with the scale.

function scaleSequentialLog

scaleSequentialLog: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleSequential<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleSequential<Output, Unknown>;
};
  • A sequential scale with a logarithmic transform, analogous to a log scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter interpolator

    The interpolator function to be used with the scale.

  • A sequential scale with a logarithmic transform, analogous to a log scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric domain values.

    Parameter interpolator

    The interpolator function to be used with the scale.

function scaleSequentialPow

scaleSequentialPow: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleSequential<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleSequential<Output, Unknown>;
};
  • A sequential scale with a exponential transform, analogous to a power scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter interpolator

    The interpolator function to be used with the scale.

  • A sequential scale with a exponential transform, analogous to a power scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric domain values.

    Parameter interpolator

    The interpolator function to be used with the scale.

function scaleSequentialQuantile

scaleSequentialQuantile: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleSequentialQuantile<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleSequentialQuantile<Output, Unknown>;
};
  • A sequential scale using a p-quantile transform, analogous to a quantile scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter interpolator

    The interpolator function to be used with the scale.

  • A sequential scale using a p-quantile transform, analogous to a quantile scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric domain values.

    Parameter interpolator

    The interpolator function to be used with the scale.

function scaleSequentialSqrt

scaleSequentialSqrt: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleSequential<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleSequential<Output, Unknown>;
};
  • A sequential scale with a square-root transform, analogous to a d3.scaleSqrt.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second third generic corresponds to the data type of the unknown value.

    Parameter interpolator

    The interpolator function to be used with the scale.

  • A sequential scale with a square-root transform, analogous to a d3.scaleSqrt.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric domain values.

    Parameter interpolator

    The interpolator function to be used with the scale.

function scaleSequentialSymlog

scaleSequentialSymlog: {
<Output = number, Unknown = never>(
interpolator?: (t: number) => Output
): ScaleSequential<Output, Unknown>;
<Output, Unknown = never>(
domain: Iterable<NumberValue>,
interpolator: (t: number) => Output
): ScaleSequential<Output, Unknown>;
};
  • A sequential scale with a symmetric logarithmic transform, analogous to a symlog scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter interpolator

    The interpolator function to be used with the scale.

  • A sequential scale with a symmetric logarithmic transform, analogous to a symlog scale.

    The first generic corresponds to the data type of the output of the interpolator underlying the scale. The second generic corresponds to the data type of the unknown value.

    Parameter domain

    A two-element array of numeric domain values.

    Parameter interpolator

    The interpolator function to be used with the scale.

function scaleSqrt

scaleSqrt: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScalePower<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScalePower<Range, Output, Unknown>;
};
  • Constructs a new continuous power scale with the specified range, the exponent 0.5, the default interpolator and clamping disabled. The domain defaults to [0, 1]. If range is not specified, it defaults to [0, 1]. This is a convenience method equivalent to d3.scalePow().exponent(0.5).

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new continuous power scale with the specified domain and range, the exponent 0.5, the default interpolator and clamping disabled. This is a convenience method equivalent to d3.scalePow().exponent(0.5).

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of numeric domain values.

    Parameter range

    Array of range values.

function scaleSymlog

scaleSymlog: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScaleSymLog<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleSymLog<Range, Output, Unknown>;
};
  • Constructs a new continuous scale with the specified range, the constant 1, the default interpolator and clamping disabled. The domain defaults to [0, 1]. If range is not specified, it defaults to [0, 1].

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new continuous scale with the specified domain and range, the constant 1, the default interpolator and clamping disabled.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of numeric domain values.

    Parameter range

    Array of range values.

function scaleThreshold

scaleThreshold: {
<
Domain extends string | number | Date = number,
Range = number,
Unknown = never
>(
range?: Iterable<Range>
): ScaleThreshold<Domain, Range, Unknown>;
<Domain extends string | number | Date, Range, Unknown = never>(
domain: Iterable<Domain>,
range: Iterable<Range>
): ScaleThreshold<Domain, Range, Unknown>;
};
  • Constructs a new threshold scale with the specified range. The domain defaults to [0.5]. If range is not specified, it defaults to [0, 1]. Thus, the default threshold scale is equivalent to the Math.round function for numbers; for example threshold(0.49) returns 0, and threshold(0.51) returns 1.

    The first generic corresponds to the data type of domain values. The second generic corresponds to the data type of range values. The third generic corresponds to the data type of the unknown value.

    Parameter range

    Array of range values.

  • Constructs a new threshold scale with the specified domain and range. Thus, the default threshold scale is equivalent to the Math.round function for numbers; for example threshold(0.49) returns 0, and threshold(0.51) returns 1.

    The first generic corresponds to the data type of domain values. The second generic corresponds to the data type of range values. The third generic corresponds to the data type of the unknown value.

    Parameter domain

    Array of domain values.

    Parameter range

    Array of range values.

function scaleTime

scaleTime: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScaleTime<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue | Date>,
range: Iterable<Range>
): ScaleTime<Range, Output, Unknown>;
};
  • Constructs a new time scale with the specified range, the default interpolator and clamping disabled. The domain defaults to [2000-01-01, 2000-01-02]. If range is not specified, it defaults to [0, 1].

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new time scale with the specified domain and range, the default interpolator and clamping disabled.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of temporal domain values. Numeric values will be coerced to dates.

    Parameter range

    Array of range values.

function scaleUtc

scaleUtc: {
<Range = number, Output = Range, Unknown = never>(
range?: Iterable<Range>
): ScaleTime<Range, Output, Unknown>;
<Range, Output = Range, Unknown = never>(
domain: Iterable<NumberValue>,
range: Iterable<Range>
): ScaleTime<Range, Output, Unknown>;
};
  • Constructs a new time scale using Coordinated Universal Time (UTC) with the specified range, the default interpolator and clamping disabled. The domain defaults to [2000-01-01, 2000-01-02]. If range is not specified, it defaults to [0, 1].

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter range

    Array of range values.

  • Constructs a new time scale using Coordinated Universal Time (UTC) with the specified domain and range, the default interpolator and clamping disabled.

    The first generic corresponds to the data type of the range elements. The second generic corresponds to the data type of the output elements generated by the scale. The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

    The range must be set in accordance with the range element type.

    The interpolator factory may be set using the interpolate(...) method of the scale.

    Parameter domain

    Array of temporal domain values. Numeric values will be coerced to dates.

    Parameter range

    Array of range values.

function tickFormat

tickFormat: (
start: number,
stop: number,
count: number,
specifier?: string
) => (d: NumberValue) => string;
  • Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values, as determined by d3.tickStep.

    Parameter start

    Start

    Parameter stop

    Stop

    Parameter count

    Approximate number of ticks to be used when calculating precision for the number format function.

    Parameter specifier

    An optional specifier allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. If specifier uses the format type s, the scale will return a SI-prefix format based on the larger absolute value of start and stop. If the specifier already specifies a precision, this method is equivalent to locale.format.

Interfaces

interface InterpolatorFactory

interface InterpolatorFactory<T, U> {}
  • An Interpolator factory returns an interpolator function.

    The first generic corresponds to the data type of the interpolation boundaries. The second generic corresponds to the data type of the return type of the interpolator.

call signature

(a: T, b: T): (t: number) => U;
  • Construct a new interpolator function, based on the provided interpolation boundaries.

    Parameter a

    Start boundary of the interpolation interval.

    Parameter b

    End boundary of the interpolation interval.

interface ScaleBand

interface ScaleBand<Domain extends { toString(): string }> {}
  • Band scales are like ordinal scales except the output range is continuous and numeric. Discrete output values are automatically computed by the scale by dividing the continuous range into uniform bands. Band scales are typically used for bar charts with an ordinal or categorical dimension. The unknown value of a band scale is effectively undefined: they do not allow implicit domain construction.

    The generic corresponds to the data type of domain elements.

method align

align: { (): number; (align: number): this };
  • Returns the current alignment which defaults to 0.5.

  • Sets the alignment to the specified value which must be in the range [0, 1].

    The default is 0.5.

    The alignment determines how any leftover unused space in the range is distributed. A value of 0.5 indicates that the outer patter should be equally distributed before the first band and after the last band; i.e., the bands should be centered within the range. A value of 0 or 1 may be used to shift the bands to one side, say to position them adjacent to an axis.

    Parameter align

    Value for alignment setting in [0, 1] interval.

method bandwidth

bandwidth: () => number;
  • Returns the width of each band.

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): Domain[]; (domain: Iterable<Domain>): this };
  • Returns to scale's current domain

  • Sets the domain to the specified array of values. The first element in domain will be mapped to the first band, the second domain value to the second band, and so on. Domain values are stored internally in an InternMap from primitive value to index; the resulting index is then used to determine the band. Thus, a band scale’s values must be coercible to a primitive value, and the primitive domain value uniquely identifies the corresponding band.

    Parameter domain

    Array of domain values.

method padding

padding: { (): number; (padding: number): this };
  • Returns the inner padding.

  • A convenience method for setting the inner and outer padding to the same padding value.

    Parameter padding

    Value for inner and outer padding in [0, 1] interval.

method paddingInner

paddingInner: { (): number; (padding: number): this };
  • Returns the current inner padding which defaults to 0.

  • Sets the inner padding to the specified value which must be in the range [0, 1]. The inner padding determines the ratio of the range that is reserved for blank space between bands.

    The default setting is 0.

    Parameter padding

    Value for inner padding in [0, 1] interval.

method paddingOuter

paddingOuter: { (): number; (padding: number): this };
  • Returns the current outer padding which defaults to 0.

  • Sets the outer padding to the specified value which must be in the range [0, 1]. The outer padding determines the ratio of the range that is reserved for blank space before the first band and after the last band.

    The default setting is 0.

    Parameter padding

    Value for outer padding in [0, 1] interval.

method range

range: { (): [number, number]; (range: Iterable<NumberValue>): this };
  • Returns the scale’s current range, which defaults to [0, 1].

  • Sets the scale’s range to the specified two-element array of numbers. If the elements in the given array are not numbers, they will be coerced to numbers. The default range is [0, 1].

    Parameter range

    A two-element array of numeric values.

method rangeRound

rangeRound: (range: Iterable<NumberValue>) => this;
  • Sets the scale’s range to the specified two-element array of numbers while also enabling rounding. If the elements in the given array are not numbers, they will be coerced to numbers.

    Rounding is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles.

    Parameter range

    A two-element array of numeric values.

method round

round: { (): boolean; (round: boolean): this };
  • Returns the current rounding status for the scale: enabled (= true) or disabled (= false).

  • Enables or disables rounding accordingly. If rounding is enabled, the start and stop of each band will be integers. Rounding is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles. Note that if the width of the domain is not a multiple of the cardinality of the range, there may be leftover unused space, even without padding! Use band.align to specify how the leftover space is distributed.

    Parameter round

    Enable rounding (= true), disable rounding (= false).

method step

step: () => number;
  • Returns the distance between the starts of adjacent bands.

call signature

(x: Domain): number | undefined;
  • Given a value in the input domain, returns the start of the corresponding band derived from the output range. If the given value is not in the scale’s domain, returns undefined.

    Parameter x

    A value from the domain.

interface ScaleContinuousNumeric

interface ScaleContinuousNumeric<Range, Output, Unknown = never> {}
  • A helper interface for a continuous scale defined over a numeric domain.

method clamp

clamp: { (): boolean; (clamp: boolean): this };
  • Returns whether or not the scale currently clamps values to within the range.

  • Enables or disables clamping, respectively. If clamping is disabled and the scale is passed a value outside the domain, the scale may return a value outside the range through extrapolation.

    If clamping is enabled, the return value of the scale is always within the scale’s range. Clamping similarly applies to the "invert" method.

    Parameter clamp

    A flag to enable (true) or disable (false) clamping.

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): number[]; (domain: Iterable<NumberValue>): this };
  • Returns a copy of the scale’s current domain.

  • Sets the scale’s domain to the specified array of numbers. The array must contain two or more elements. If the elements in the given array are not numbers, they will be coerced to numbers

    Although continuous scales typically have two values each in their domain and range, specifying more than two values produces a piecewise scale.

    Internally, a piecewise scale performs a binary search for the range interpolator corresponding to the given domain value. Thus, the domain must be in ascending or descending order. If the domain and range have different lengths N and M, only the first min(N,M) elements in each are observed.

    Parameter domain

    Array of numeric domain values.

method invert

invert: (value: NumberValue) => number;
  • Given a value from the range, returns the corresponding value from the domain. Inversion is useful for interaction, say to determine the data value corresponding to the position of the mouse.

    If the given value is outside the range, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the domain.

    IMPORTANT: This method is only supported if the range is numeric. If the range is not numeric, returns NaN.

    For a valid value y in the range, continuous(continuous.invert(y)) approximately equals y; similarly, for a valid value x in the domain, continuous.invert(continuous(x)) approximately equals x. The scale and its inverse may not be exact due to the limitations of floating point precision.

    Parameter value

    A numeric value from the range.

method nice

nice: (count?: number) => this;
  • Extends the domain so that it starts and ends on nice round values. This method typically modifies the scale’s domain, and may only extend the bounds to the nearest round value. An optional tick count argument allows greater control over the step size used to extend the bounds, guaranteeing that the returned ticks will exactly cover the domain. Nicing is useful if the domain is computed from data, say using extent, and may be irregular. For example, for a domain of [0.201479…, 0.996679…], a nice domain might be [0.2, 1.0]. If the domain has more than two values, nicing the domain only affects the first and last value.

    Nicing a scale only modifies the current domain; it does not automatically nice domains that are subsequently set using continuous.domain. You must re-nice the scale after setting the new domain, if desired.

    Parameter count

    An optional number of ticks expected to be used.

method range

range: { (): Range[]; (range: Iterable<Range>): this };
  • Returns a copy of the scale’s current range.

  • Sets the scale’s range to the specified array of values.

    The array must contain two or more elements. Unlike the domain, elements in the given array need not be numbers; any value that is supported by the underlying interpolator will work, though note that numeric ranges are required for invert.

    Parameter range

    Array of range values.

method rangeRound

rangeRound: (range: Iterable<NumberValue>) => this;
  • Sets the scale’s range to the specified array of values while also setting the scale’s interpolator to interpolateRound.

    The rounding interpolator is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles. Note that this interpolator can only be used with numeric ranges.

    The array must contain two or more elements. Unlike the domain, elements in the given array need not be numbers; any value that is supported by the underlying interpolator will work, though note that numeric ranges are required for invert.

    Parameter range

    Array of range values.

method tickFormat

tickFormat: (count?: number, specifier?: string) => (d: NumberValue) => string;
  • Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values. The specified count should have the same value as the count that is used to generate the tick values.

    Parameter count

    Approximate number of ticks to be used when calculating precision for the number format function.

    Parameter specifier

    An optional valid format specifier string which allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. If specifier uses the format type "s", the scale will return a SI-prefix format based on the largest value in the domain. If the specifier already specifies a precision, this method is equivalent to locale.format.

method ticks

ticks: (count?: number) => number[];
  • Returns approximately count representative values from the scale’s domain.

    If count is not specified, it defaults to 10.

    The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data. The specified count is only a hint; the scale may return more or fewer values depending on the domain. See also d3-array’s ticks.

    Parameter count

    Optional approximate number of ticks to be returned. If count is not specified, it defaults to 10.

call signature

(value: NumberValue): Output | Unknown;
  • Given a value from the domain, returns the corresponding value from the range, subject to interpolation, if any.

    If the given value is outside the domain, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the range.

    Note: The interpolation function applied by the scale may change the output type from the range type as part of the interpolation.

    Parameter value

    A numeric value from the domain.

interface ScaleDiverging

interface ScaleDiverging<Output, Unknown = never> {}
  • Diverging scales, like sequential scales, are similar to continuous scales in that they map a continuous, numeric input domain to a continuous output range. However, unlike continuous scales, the input domain and output range of a diverging scale always has exactly three elements, and the output range is typically specified as an interpolator rather than an array of values. These scales do not expose invert and interpolate methods.

    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.

method clamp

clamp: { (): boolean; (clamp: boolean): this };
  • Returns whether or not the scale currently clamps values to within the range.

  • Enables or disables clamping, respectively. If clamping is disabled and the scale is passed a value outside the domain, the scale may return a value outside the range through extrapolation.

    If clamping is enabled, the return value of the scale is always within the interpolator scale’s range.

    Parameter clamp

    A flag to enable (true) or disable (false) clamping.

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): [number, number, number]; (domain: Iterable<NumberValue>): this };
  • Returns a copy of the scale’s current domain.

  • Sets the scale’s domain to the specified array of numbers. The domain must be numeric and must contain exactly three values. The default domain is [0, 0.5, 1]. If the elements in the given array are not numbers, they will be coerced to numbers

    Parameter domain

    Array of three numeric domain values.

method interpolator

interpolator: {
(): (t: number) => Output;
(interpolator?: (t: number) => Output): this;
};
  • Returns the scale’s current interpolator.

  • Sets the scale’s interpolator to the specified function.

    Parameter interpolator

    The scale’s interpolator.

method range

range: { (): () => [Output, Output, Output]; (range: Iterable<Output>): this };
  • See continuous.range.

  • See continuous.range. The given two-element array is converted to an interpolator function using d3.interpolate and d3.piecewise.

    Parameter range

    Range values.

method rangeRound

rangeRound: (range: Iterable<NumberValue>) => this;
  • See continuous.rangeRound. If range is specified, implicitly uses d3.interpolateRound as the interpolator.

    Parameter range

    Range values.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScaleDiverging<Output, NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

call signature

(value: NumberValue): Output | Unknown;
  • Given a value from the domain, returns the corresponding value subject to interpolation.

    If the given value is outside the domain, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the range.

    Parameter value

    A numeric value from the domain.

interface ScaleIdentity

interface ScaleIdentity<Unknown = never> {}
  • Identity scales are a special case of linear scales where the domain and range are identical; the scale and its invert method are thus the identity function. These scales are occasionally useful when working with pixel coordinates, say in conjunction with an axis.

    The generic corresponds to the data type of the unknown value.

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): number[]; (domain: Iterable<NumberValue>): this };
  • Returns a copy of the scale’s current domain.

  • Sets the scale’s domain to the specified array of numbers. The array must contain two or more elements. If the elements in the given array are not numbers, they will be coerced to numbers

    Although continuous scales typically have two values each in their domain and range, specifying more than two values produces a piecewise scale.

    Internally, a piecewise scale performs a binary search for the range interpolator corresponding to the given domain value. Thus, the domain must be in ascending or descending order. If the domain and range have different lengths N and M, only the first min(N,M) elements in each are observed.

    Parameter domain

    Array of numeric domain values.

method invert

invert: (value: NumberValue) => number;
  • Given a value from the range, returns the corresponding value from the domain. Inversion is useful for interaction, say to determine the data value corresponding to the position of the mouse.

    If the given value is outside the range, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the domain.

    IMPORTANT: This method is only supported if the range is numeric. If the range is not numeric, returns NaN.

    For a valid value y in the range, continuous(continuous.invert(y)) approximately equals y; similarly, for a valid value x in the domain, continuous.invert(continuous(x)) approximately equals x. The scale and its inverse may not be exact due to the limitations of floating point precision.

    Parameter value

    A numeric value from the range.

method nice

nice: (count?: number) => this;
  • Extends the domain so that it starts and ends on nice round values. This method typically modifies the scale’s domain, and may only extend the bounds to the nearest round value. An optional tick count argument allows greater control over the step size used to extend the bounds, guaranteeing that the returned ticks will exactly cover the domain. Nicing is useful if the domain is computed from data, say using extent, and may be irregular. For example, for a domain of [0.201479…, 0.996679…], a nice domain might be [0.2, 1.0]. If the domain has more than two values, nicing the domain only affects the first and last value.

    Nicing a scale only modifies the current domain; it does not automatically nice domains that are subsequently set using continuous.domain. You must re-nice the scale after setting the new domain, if desired.

    Parameter count

    An optional number of ticks expected to be used.

method range

range: { (): number[]; (range: Iterable<NumberValue>): this };
  • Returns a copy of the scale’s current range.

  • Sets the scale’s range to the specified array of values.

    The array must contain two or more elements. Unlike the domain, elements in the given array need not be numbers; any value that is supported by the underlying interpolator will work, though note that numeric ranges are required for invert.

    Parameter range

    Array of range values.

method tickFormat

tickFormat: (count?: number, specifier?: string) => (d: NumberValue) => string;
  • Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values. The specified count should have the same value as the count that is used to generate the tick values.

    Parameter count

    Approximate number of ticks to be used when calculating precision for the number format function.

    Parameter specifier

    An optional valid format specifier string which allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. If specifier uses the format type "s", the scale will return a SI-prefix format based on the largest value in the domain. If the specifier already specifies a precision, this method is equivalent to locale.format.

method ticks

ticks: (count?: number) => number[];
  • Returns approximately count representative values from the scale’s domain.

    If count is not specified, it defaults to 10.

    The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data. The specified count is only a hint; the scale may return more or fewer values depending on the domain. See also d3-array’s ticks.

    Parameter count

    Optional approximate number of ticks to be returned. If count is not specified, it defaults to 10.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScaleIdentity<NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

call signature

(value: NumberValue): number | Unknown;
  • Given a value from the domain, returns the corresponding value from the range, subject to interpolation, if any.

    If the given value is outside the domain, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the range.

    Note: The interpolation function applied by the scale may change the output type from the range type as part of the interpolation.

    Parameter value

    A numeric value from the domain.

interface ScaleLinear

interface ScaleLinear<Range, Output, Unknown = never>
extends ScaleContinuousNumeric<Range, Output, Unknown> {}
  • A linear continuous scale defined over a numeric domain.

    Continuous scales map a continuous, quantitative input domain to a continuous output range. Each range value y can be expressed as a function of the domain value x: y = mx + b.

    If the range is also numeric, the mapping may be inverted.

    Note that the data types of the range and output of the scale must be compatible with the interpolator applied by the scale.

    The first generic corresponds to the data type of the range elements.

    The second generic corresponds to the data type of the output elements generated by the scale.

    The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

method interpolate

interpolate: {
(): InterpolatorFactory<any, any>;
(interpolate: InterpolatorFactory<Range, Output>): this;
<NewOutput>(interpolate: InterpolatorFactory<Range, NewOutput>): ScaleLinear<
Range,
NewOutput,
Unknown
>;
};
  • Returns the scale’s current interpolator factory, which defaults to interpolate.

  • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

    Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

    As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

    Parameter interpolate

    An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

  • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

    Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

    As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

    The generic "NewOutput" can be used to change the scale to have a different output element type corresponding to the new interpolation factory.

    Parameter interpolate

    An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScaleLinear<Range, Output, NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

interface ScaleLogarithmic

interface ScaleLogarithmic<Range, Output, Unknown = never>
extends ScaleContinuousNumeric<Range, Output, Unknown> {}
  • A continuous logarithmic scale defined over a numeric domain.

    Continuous scales map a continuous, quantitative input domain to a continuous output range.

    The mapping to the range value y can be expressed as a function of the domain value x: y = m log(x) + b.

    As log(0) = -∞, a log scale domain must be strictly-positive or strictly-negative; the domain must not include or cross zero. A log scale with a positive domain has a well-defined behavior for positive values, and a log scale with a negative domain has a well-defined behavior for negative values. (For a negative domain, input and output values are implicitly multiplied by -1.) The behavior of the scale is undefined if you pass a negative value to a log scale with a positive domain or vice versa.

    If the range is also numeric, the mapping may be inverted.

    Note that the data types of the range and output of the scale must be compatible with the interpolator applied by the scale.

    The first generic corresponds to the data type of the range elements.

    The second generic corresponds to the data type of the output elements generated by the scale.

    The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

method base

base: { (): number; (base: number): this };
  • Returns the current base, which defaults to 10.

  • Sets the base for this logarithmic scale to the specified value.

method domain

domain: { (): number[]; (domain: Iterable<NumberValue>): this };
  • Returns a copy of the scale’s current domain.

  • Sets the scale’s domain to the specified array of numbers. The array must contain two or more elements. If the elements in the given array are not numbers, they will be coerced to numbers

    As log(0) = -∞, a log scale domain must be strictly-positive or strictly-negative; the domain must not include or cross zero. A log scale with a positive domain has a well-defined behavior for positive values, and a log scale with a negative domain has a well-defined behavior for negative values. (For a negative domain, input and output values are implicitly multiplied by -1.) The behavior of the scale is undefined if you pass a negative value to a log scale with a positive domain or vice versa.

    Although continuous scales typically have two values each in their domain and range, specifying more than two values produces a piecewise scale.

    Internally, a piecewise scale performs a binary search for the range interpolator corresponding to the given domain value. Thus, the domain must be in ascending or descending order. If the domain and range have different lengths N and M, only the first min(N,M) elements in each are observed.

    Parameter domain

    Array of numeric domain values.

method interpolate

interpolate: {
(): InterpolatorFactory<any, any>;
(interpolate: InterpolatorFactory<Range, Output>): this;
<NewOutput>(
interpolate: InterpolatorFactory<Range, NewOutput>
): ScaleLogarithmic<Range, NewOutput, Unknown>;
};
  • Returns the scale’s current interpolator factory, which defaults to interpolate.

  • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

    Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

    As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

    Parameter interpolate

    An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

  • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

    Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

    As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

    The generic "NewOutput" can be used to change the scale to have a different output element type corresponding to the new interpolation factory.

    Parameter interpolate

    An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

method nice

nice: () => this;
  • Extends the domain to integer powers of base. For example, for a domain of [0.201479…, 0.996679…], and base 10, the nice domain is [0.1, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.

    Nicing a scale only modifies the current domain; it does not automatically nice domains that are subsequently set using continuous.domain. You must re-nice the scale after setting the new domain, if desired.

method tickFormat

tickFormat: (count?: number, specifier?: string) => (d: NumberValue) => string;
  • Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values.

    The specified count typically has the same value as the count that is used to generate the tick values. If there are too many ticks, the formatter may return the empty string for some of the tick labels; however, note that the ticks are still shown. To disable filtering, specify a count of Infinity. When specifying a count, you may also provide a format specifier or format function. For example, to get a tick formatter that will display 20 ticks of a currency, say log.tickFormat(20, "$,f"). If the specifier does not have a defined precision, the precision will be set automatically by the scale, returning the appropriate format. This provides a convenient way of specifying a format whose precision will be automatically set by the scale.

    Parameter count

    Approximate number of ticks to be used when calculating precision for the number format function.

    Parameter specifier

    An optional valid format specifier string which allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. For example, to get a tick formatter that will display 20 ticks of a currency, say log.tickFormat(20, "$,f"). If the specifier does not have a defined precision, the precision will be set automatically by the scale, returning the appropriate format. This provides a convenient way of specifying a format whose precision will be automatically set by the scale.

method ticks

ticks: (count?: number) => number[];
  • Returns approximately count representative values from the scale’s domain.

    If count is not specified, it defaults to 10.

    If the base is an integer, the returned ticks are uniformly spaced within each integer power of base; otherwise, one tick per power of base is returned. The returned ticks are guaranteed to be within the extent of the domain. If the orders of magnitude in the domain is greater than count, then at most one tick per power is returned. Otherwise, the tick values are unfiltered, but note that you can use log.tickFormat to filter the display of tick labels.

    Parameter count

    Optional approximate number of ticks to be returned. If count is not specified, it defaults to 10.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScaleLogarithmic<Range, Output, NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

interface ScaleOrdinal

interface ScaleOrdinal<
Domain extends { toString(): string },
Range,
Unknown = never
> {}
  • Unlike continuous scales, ordinal scales have a discrete domain and range. For example, an ordinal scale might map a set of named categories to a set of colors, or determine the horizontal positions of columns in a column chart.

    The first element in the domain will be mapped to the first element in range, the second domain value to the second range value, and so on. If there are fewer elements in the range than in the domain, the scale will reuse values from the start of the range.

    The first generic corresponds to the data type of domain values. The second generic corresponds to the data type of range values. The third generic corresponds to the data type of the unknown value.

method copy

copy: () => this;
  • Returns an exact copy of this ordinal scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): Domain[]; (domain: Iterable<Domain>): this };
  • Returns the scale's current domain.

  • Sets the domain to the specified array of values.

    The first element in domain will be mapped to the first element in the range, the second domain value to the second range value, and so on.

    Domain values are stored internally in an InternMap from primitive value to index; the resulting index is then used to retrieve a value from the range. Thus, an ordinal scale’s values must be coercible to a primitive value, and the primitive domain value uniquely identifies the corresponding range value.

    Setting the domain on an ordinal scale is optional if the unknown value is implicit (the default). In this case, the domain will be inferred implicitly from usage by assigning each unique value passed to the scale a new value from the range. Note that an explicit domain is recommended to ensure deterministic behavior, as inferring the domain from usage will be dependent on ordering.

    Parameter domain

    Array of domain values.

method range

range: { (): Range[]; (range: Iterable<Range>): this };
  • Returns the scale's current range.

  • Sets the range of the ordinal scale to the specified array of values.

    The first element in the domain will be mapped to the first element in range, the second domain value to the second range value, and so on.

    If there are fewer elements in the range than in the domain, the scale will reuse values from the start of the range.

    Parameter range

    Array of range values.

method unknown

unknown: {
(): UnknownReturnType<Unknown, { name: 'implicit' }>;
<NewUnknown>(value: NewUnknown): NewUnknown extends { name: 'implicit' }
? ScaleOrdinal<Domain, Range, never>
: ScaleOrdinal<Domain, Range, NewUnknown>;
};
  • Returns the current unknown value, which defaults to "implicit".

  • Sets the output value of the scale for unknown input values and returns this scale. The implicit value enables implicit domain construction. scaleImplicit can be used as a convenience to set the implicit value.

    Parameter value

    Unknown value to be used or scaleImplicit to set implicit scale generation.

call signature

(x: Domain): Range | Unknown;
  • Given a value in the input domain, returns the corresponding value in the output range. If the given value is not in the scale’s domain, returns the unknown; or, if the unknown value is implicit (the default), then the value is implicitly added to the domain and the next-available value in the range is assigned to value, such that this and subsequent invocations of the scale given the same input value return the same output value.

    Parameter x

    A value from the domain.

interface ScalePoint

interface ScalePoint<Domain extends { toString(): string }> {}
  • Point scales are a variant of band scales with the bandwidth fixed to zero. Point scales are typically used for scatterplots with an ordinal or categorical dimension. The unknown value of a point scale is always undefined: they do not allow implicit domain construction.

    The generic corresponds to the data type of domain elements.

method align

align: { (): number; (align: number): this };
  • Returns the current alignment which defaults to 0.5.

  • Sets the alignment to the specified value which must be in the range [0, 1].

    The alignment determines how any leftover unused space in the range is distributed. A value of 0.5 indicates that the leftover space should be equally distributed before the first point and after the last point; i.e., the points should be centered within the range. A value of 0 or 1 may be used to shift the points to one side, say to position them adjacent to an axis.

    The default value is 0.5.

    Parameter align

    Value for alignment setting in [0, 1] interval.

method bandwidth

bandwidth: () => number;
  • Return 0.

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): Domain[]; (domain: Iterable<Domain>): this };
  • Returns the scale's current domain.

  • Sets the domain to the specified array of values. The first element in domain will be mapped to the first point, the second domain value to the second point, and so on. Domain values are stored internally in an InternMap from primitive value to index; the resulting index is then used to determine the point. Thus, a point scale’s values must be coercible to a primitive value, and the primitive domain value uniquely identifies the corresponding point.

    Parameter domain

    Array of domain values.

method padding

padding: { (): number; (padding: number): this };
  • Returns the current outer padding which defaults to 0. The outer padding determines the ratio of the range that is reserved for blank space before the first point and after the last point.

  • Sets the outer padding to the specified value which must be in the range [0, 1]. The outer padding determines the ratio of the range that is reserved for blank space before the first point and after the last point.

    The default is 0.

    Parameter padding

    Value for outer padding in [0, 1] interval.

method range

range: { (): [number, number]; (range: Iterable<NumberValue>): this };
  • Returns the scale’s current range, which defaults to [0, 1].

  • Sets the scale’s range to the specified two-element array of numbers. If the elements in the given array are not numbers, they will be coerced to numbers. The default range is [0, 1].

    Parameter range

    A two-element array of numeric values.

method rangeRound

rangeRound: (range: Iterable<NumberValue>) => this;
  • Sets the scale’s range to the specified two-element array of numbers while also enabling rounding. If the elements in the given array are not numbers, they will be coerced to numbers.

    Rounding is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles.

    Parameter range

    A two-element array of numeric values.

method round

round: { (): boolean; (round: boolean): this };
  • Returns the current rounding status for the scale: enabled (= true) or disabled (= false).

  • Enables or disables rounding accordingly. If rounding is enabled, the position of each point will be integers. Rounding is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles. Note that if the width of the domain is not a multiple of the cardinality of the range, there may be leftover unused space, even without padding! Use point.align to specify how the leftover space is distributed.

    Parameter round

    Enable rounding (= true), disable rounding (= false).

method step

step: () => number;
  • Returns the distance between the starts of adjacent points.

call signature

(x: Domain): number | undefined;
  • Given a value in the input domain, returns the corresponding point derived from the output range. If the given value is not in the scale’s domain, returns undefined.

    Parameter x

    A value from the domain.

interface ScalePower

interface ScalePower<Range, Output, Unknown = never>
extends ScaleContinuousNumeric<Range, Output, Unknown> {}
  • A continuous power scale defined over a numeric domain.

    Continuous scales map a continuous, quantitative input domain to a continuous output range.

    Each range value y can be expressed as a function of the domain value x: y = mx^k + b, where k is the exponent value. Power scales also support negative domain values, in which case the input value and the resulting output value are multiplied by -1.

    If the range is also numeric, the mapping may be inverted.

    Note that the data types of the range and output of the scale must be compatible with the interpolator applied by the scale.

    The first generic corresponds to the data type of the range elements.

    The second generic corresponds to the data type of the output elements generated by the scale.

    The third generic corresponds to the data type of the unknown value.

    If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

method exponent

exponent: { (): number; (exponent: number): this };
  • If exponent is not specified, returns the current exponent, which defaults to 1. (Note that this is effectively a linear scale until you set a different exponent.)

  • Sets the current exponent to the given numeric value. (Note that this is effectively a linear scale until you set a different exponent.)

method interpolate

interpolate: {
(): InterpolatorFactory<any, any>;
(interpolate: InterpolatorFactory<Range, Output>): this;
<NewOutput>(interpolate: InterpolatorFactory<Range, NewOutput>): ScalePower<
Range,
NewOutput,
Unknown
>;
};
  • Returns the scale’s current interpolator factory, which defaults to interpolate.

  • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

    Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

    As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

    Parameter interpolate

    An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

  • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

    Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

    As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

    The generic "NewOutput" can be used to change the scale to have a different output element type corresponding to the new interpolation factory.

    Parameter interpolate

    An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScalePower<Range, Output, NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

interface ScaleQuantile

interface ScaleQuantile<Range, Unknown = never> {}
  • Quantile scales map a sampled input domain to a discrete range. The domain is considered continuous and thus the scale will accept any reasonable input value; however, the domain is specified as a discrete set of sample values. The number of values in (the cardinality of) the output range determines the number of quantiles that will be computed from the domain. To compute the quantiles, the domain is sorted, and treated as a population of discrete values; see d3-array’s quantile.

    The first generic corresponds to the data type of range elements.

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

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): number[]; (domain: Iterable<NumberValue>): this };
  • Returns the scale’s current domain.

  • Sets the domain of the quantile scale to the specified set of discrete numeric values. The array must not be empty, and must contain at least one numeric value; NaN, null and undefined values are ignored and not considered part of the sample population.

    If the elements in the given array are not numbers, they will be coerced to numbers. A copy of the input array is sorted and stored internally.

    Parameter domain

    Array of domain values.

method invertExtent

invertExtent: (value: Range) => [number, number];
  • Returns the extent of values in the domain [x0, x1] for the corresponding value in the range: the inverse of quantile. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

    Parameter value

    A value from the range.

method quantiles

quantiles: () => number[];
  • Returns the quantile thresholds. If the range contains n discrete values, the returned array will contain n - 1 thresholds. Values less than the first threshold are considered in the first quantile; values greater than or equal to the first threshold but less than the second threshold are in the second quantile, and so on. Internally, the thresholds array is used with bisect to find the output quantile associated with the given input value.

method range

range: { (): Range[]; (range: Iterable<Range>): this };
  • Returns the current range.

  • Sets the discrete values in the range. The array must not be empty. The number of values in (the cardinality, or length, of) the range array determines the number of quantiles that are computed.

    For example, to compute quartiles, range must be an array of four elements such as [0, 1, 2, 3].

    Parameter range

    Array of range values.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScaleQuantile<Range, NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

call signature

(value: NumberValue): Range | Unknown;
  • Given a value in the input domain, returns the corresponding value in the output range.

    Parameter value

    A numeric value in the input domain.

interface ScaleQuantize

interface ScaleQuantize<Range, Unknown = never> {}
  • Quantize scales are similar to linear scales, except they use a discrete rather than continuous range. The continuous input domain is divided into uniform segments based on the number of values in (i.e., the cardinality of) the output range.

    Each range value y can be expressed as a quantized linear function of the domain value x: y = m round(x) + b.

    The first generic corresponds to the data type of the range elements.

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

method copy

copy: () => this;
  • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

method domain

domain: { (): [number, number]; (domain: Iterable<NumberValue>): this };
  • Returns the scale’s current domain.

  • Sets the scale’s domain to the specified two-element array of numbers. If the elements in the given array are not numbers, they will be coerced to numbers.

    Parameter domain

    A two-element array of numeric values defining the domain.

method invertExtent

invertExtent: (value: Range) => [number, number];
  • Returns the extent of values in the domain [x0, x1] for the corresponding value in the range: the inverse of quantize. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

    If an invalid range value is entered, returns [NaN, NaN].

    Parameter value

    A value from the range.

method nice

nice: (count?: number) => this;
  • Extends the domain so that it starts and ends on nice round values. This method typically modifies the scale’s domain, and may only extend the bounds to the nearest round value.

    Nicing is useful if the domain is computed from data, say using extent, and may be irregular. For example, for a domain of [0.201479…, 0.996679…], a nice domain might be [0.2, 1.0].

    Nicing a scale only modifies the current domain; it does not automatically nice domains that are subsequently set using continuous.domain. You must re-nice the scale after setting the new domain, if desired.

    Parameter count

    An optional number of ticks expected to be used.

method range

range: { (): Range[]; (range: Iterable<Range>): this };
  • Returns the scale’s current range.

  • Sets the scale’s range to the specified array of values. The array may contain any number of discrete values.

    Parameter range

    Array of range values.

method thresholds

thresholds: () => number[];
  • Returns the array of computed thresholds within the domain.

method tickFormat

tickFormat: (count?: number, specifier?: string) => (d: NumberValue) => string;
  • Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values. The specified count should have the same value as the count that is used to generate the tick values.

    Parameter count

    Approximate number of ticks to be used when calculating precision for the number format function.

    Parameter specifier

    An optional valid format specifier string which allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. If specifier uses the format type "s", the scale will return a SI-prefix format based on the largest value in the domain. If the specifier already specifies a precision, this method is equivalent to locale.format.

method ticks

ticks: (count?: number) => number[];
  • Returns approximately count representative values from the scale’s domain.

    If count is not specified, it defaults to 10.

    The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data. The specified count is only a hint; the scale may return more or fewer values depending on the domain. See also d3-array’s ticks.

    Parameter count

    Optional approximate number of ticks to be returned. If count is not specified, it defaults to 10.

method unknown

unknown: {
(): UnknownReturnType<Unknown, undefined>;
<NewUnknown>(value: NewUnknown): ScaleQuantize<Range, NewUnknown>;
};
  • Returns the current unknown value, which defaults to undefined.

  • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

    Parameter value

    The output value of the scale for undefined (or NaN) input values.

call signature

(value: NumberValue): Range | Unknown;
  • Given a value in the input domain, returns the corresponding value in the output range.

interface ScaleRadial

interface ScaleRadial<Range, Output, Unknown = never>
extends ScaleContinuousNumeric<Range, Output, Unknown> {}

    method unknown

    unknown: {
    (): UnknownReturnType<Unknown, undefined>;
    <NewUnknown>(value: NewUnknown): ScaleRadial<Range, Output, NewUnknown>;
    };
    • Returns the current unknown value, which defaults to undefined.

    • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

      Parameter value

      The output value of the scale for undefined (or NaN) input values.

    interface ScaleSequential

    interface ScaleSequential<Output, Unknown = never>
    extends ScaleSequentialBase<Output, Unknown> {}

      method interpolator

      interpolator: {
      (): (t: number) => Output;
      (interpolator: (t: number) => Output): this;
      <NewOutput>(interpolator: (t: number) => NewOutput): ScaleSequential<
      NewOutput,
      Unknown
      >;
      };
      • Returns the current interpolator underlying the scale.

      • Sets the scale’s interpolator to the specified function.

        Parameter interpolator

        An interpolator function mapping a value from the [0, 1] interval to an output value.

      • Sets the scale’s interpolator to the specified function.

        The generic corresponds to a the new output type of the scale. The output type of the scale is determined by the output type of the interpolator function.

        Parameter interpolator

        An interpolator function mapping a value from the [0, 1] interval to an output value.

      method unknown

      unknown: {
      (): UnknownReturnType<Unknown, undefined>;
      <NewUnknown>(value: NewUnknown): ScaleSequential<Output, NewUnknown>;
      };
      • Returns the current unknown value, which defaults to undefined.

      • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

        Parameter value

        The output value of the scale for undefined (or NaN) input values.

      interface ScaleSequentialBase

      interface ScaleSequentialBase<Output, Unknown = never> {}
      • Sequential scales are similar to continuous scales in that they map a continuous, numeric input domain to a continuous output range. However, unlike continuous scales, the input domain and output range of a sequential scale always has exactly two elements, and the output range is typically specified as an interpolator rather than an array of values. These scales do not expose invert and interpolate methods.

        The first generic corresponds to the data type of the output of the interpolator underlying the scale.

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

      method clamp

      clamp: { (): boolean; (clamp: boolean): this };
      • Returns whether or not the scale currently clamps values to within the range.

      • Enables or disables clamping, respectively. If clamping is disabled and the scale is passed a value outside the domain, the scale may return a value outside the range through extrapolation.

        If clamping is enabled, the return value of the scale is always within the scale’s range. Clamping similarly applies to the "invert" method.

        Parameter clamp

        A flag to enable (true) or disable (false) clamping.

      method copy

      copy: () => this;
      • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

      method domain

      domain: { (): [number, number]; (domain: Iterable<NumberValue>): this };
      • Returns a copy of the scale’s current domain.

      • Sets the scale’s domain to the specified array of numbers. The array must contain exactly two elements. If the elements in the given array are not numbers, they will be coerced to numbers

        Parameter domain

        A two-element array of numeric domain values.

      method range

      range: { (): () => [Output, Output]; (range: Iterable<Output>): this };
      • See continuous.range.

      • See continuous.range. The given two-element array is converted to an interpolator function using d3.interpolate.

        Parameter range

        Range values.

      method rangeRound

      rangeRound: (range: Iterable<NumberValue>) => this;
      • See continuous.rangeRound. If range is specified, implicitly uses d3.interpolateRound as the interpolator.

        Parameter range

        Range values.

      call signature

      (value: NumberValue): Output | Unknown;
      • Given a value from the domain, returns the corresponding value from the output range, subject to interpolation.

        If the given value is outside the domain, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the range.

        Parameter value

        A numeric value from the domain.

      interface ScaleSequentialQuantile

      interface ScaleSequentialQuantile<Output, Unknown = never>
      extends ScaleSequentialBase<Output, Unknown> {}

        method interpolator

        interpolator: {
        (): (t: number) => Output;
        (interpolator: (t: number) => Output): this;
        <NewOutput>(interpolator: (t: number) => NewOutput): ScaleSequentialQuantile<
        NewOutput,
        Unknown
        >;
        };
        • Returns the current interpolator underlying the scale.

        • Sets the scale’s interpolator to the specified function.

          Parameter interpolator

          An interpolator function mapping a value from the [0, 1] interval to an output value.

        • Sets the scale’s interpolator to the specified function.

          The generic corresponds to a the new output type of the scale. The output type of the scale is determined by the output type of the interpolator function.

          Parameter interpolator

          An interpolator function mapping a value from the [0, 1] interval to an output value.

        method quantiles

        quantiles: () => number[];
        • Returns an array of n + 1 quantiles. For example, if n = 4, returns an array of five numbers: the minimum value, the first quartile, the median, the third quartile, and the maximum.

        method unknown

        unknown: {
        (): UnknownReturnType<Unknown, undefined>;
        <NewUnknown>(value: NewUnknown): ScaleSequentialQuantile<Output, NewUnknown>;
        };
        • Returns the current unknown value, which defaults to undefined.

        • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

          Parameter value

          The output value of the scale for undefined (or NaN) input values.

        interface ScaleSymLog

        interface ScaleSymLog<Range, Output, Unknown = never>
        extends ScaleContinuousNumeric<Range, Output, Unknown> {}
        • A bi-symmetric log transformation for wide-range data by Webber scale defined over a numeric domain.

          Continuous scales map a continuous, quantitative input domain to a continuous output range.

          See “A bi-symmetric log transformation for wide-range data” by Webber for more

          If the range is also numeric, the mapping may be inverted.

          Note that the data types of the range and output of the scale must be compatible with the interpolator applied by the scale.

          The first generic corresponds to the data type of the range elements.

          The second generic corresponds to the data type of the output elements generated by the scale.

          The third generic corresponds to the data type of the unknown value.

          If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

        method constant

        constant: { (): number; (constant: number): this };
        • Returns the current constant, which defaults to 1.

        • Sets the symlog constant to the specified number and returns this scale; otherwise returns the current value of the symlog constant, which defaults to 1. See “A bi-symmetric log transformation for wide-range data” by Webber for more.

        method tickFormat

        tickFormat: (count?: number, specifier?: string) => (d: NumberValue) => string;
        • Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values.

          The specified count typically has the same value as the count that is used to generate the tick values. If there are too many ticks, the formatter may return the empty string for some of the tick labels; however, note that the ticks are still shown. To disable filtering, specify a count of Infinity. When specifying a count, you may also provide a format specifier or format function. For example, to get a tick formatter that will display 20 ticks of a currency, say log.tickFormat(20, "$,f"). If the specifier does not have a defined precision, the precision will be set automatically by the scale, returning the appropriate format. This provides a convenient way of specifying a format whose precision will be automatically set by the scale.

          Parameter count

          Approximate number of ticks to be used when calculating precision for the number format function.

          Parameter specifier

          An optional valid format specifier string which allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. For example, to get a tick formatter that will display 20 ticks of a currency, say log.tickFormat(20, "$,f"). If the specifier does not have a defined precision, the precision will be set automatically by the scale, returning the appropriate format. This provides a convenient way of specifying a format whose precision will be automatically set by the scale.

        method unknown

        unknown: {
        (): UnknownReturnType<Unknown, undefined>;
        <NewUnknown>(value: NewUnknown): ScaleSymLog<Range, Output, NewUnknown>;
        };
        • Returns the current unknown value, which defaults to undefined.

        • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

          Parameter value

          The output value of the scale for undefined (or NaN) input values.

        interface ScaleThreshold

        interface ScaleThreshold<
        Domain extends number | string | Date,
        Range,
        Unknown = never
        > {}
        • Threshold scales are similar to quantize scales, except they allow you to map arbitrary subsets of the domain to discrete values in the range. The input domain is still continuous, and divided into slices based on a set of threshold values.

          If the number of values in the scale’s range is N+1, the number of values in the scale’s domain must be N. If there are fewer than N elements in the domain, the additional values in the range are ignored. If there are more than N elements in the domain, the scale may return undefined for some inputs.

          The first generic corresponds to the data type of domain values. The second generic corresponds to the data type of range values. The third generic corresponds to the data type of the unknown value.

        method copy

        copy: () => this;
        • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

        method domain

        domain: { (): Domain[]; (domain: Iterable<Domain>): this };
        • Returns the scale’s current domain.

        • Sets the scale’s domain to the specified array of values. The values must be in sorted ascending order, or the behavior of the scale is undefined. The values are typically numbers, but any naturally ordered values (such as strings) will work; a threshold scale can be used to encode any type that is ordered. If the number of values in the scale’s range is N+1, the number of values in the scale’s domain must be N. If there are fewer than N elements in the domain, the additional values in the range are ignored. If there are more than N elements in the domain, the scale may return undefined for some inputs.

          Parameter domain

          Array of domain values.

        method invertExtent

        invertExtent: (value: Range) => [Domain | undefined, Domain | undefined];
        • Returns the extent of values in the domain [x0, x1] for the corresponding value in the range, representing the inverse mapping from range to domain. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

          Parameter value

          A range value.

        method range

        range: { (): Range[]; (range: Iterable<Range>): this };
        • Returns the scale’s current range.

        • Sets the scale’s range to the specified array of values. If the number of values in the scale’s domain is N, the number of values in the scale’s range must be N+1. If there are fewer than N+1 elements in the range, the scale may return undefined for some inputs. If there are more than N+1 elements in the range, the additional values are ignored.

          Parameter range

          Array of range values.

        method unknown

        unknown: {
        (): UnknownReturnType<Unknown, undefined>;
        <NewUnknown>(value: NewUnknown): ScaleThreshold<Domain, Range, NewUnknown>;
        };
        • Returns the current unknown value, which defaults to undefined.

        • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

          Parameter value

          The output value of the scale for undefined (or NaN) input values.

        call signature

        (value: Domain): Range | Unknown;
        • Given a value in the input domain, returns the corresponding value in the output range.

          Parameter value

          A domain value.

        interface ScaleTime

        interface ScaleTime<Range, Output, Unknown = never> {}
        • A linear scale defined over a temporal domain.

          Time scales implement ticks based on calendar intervals, taking the pain out of generating axes for temporal domains.

          If the range is numeric, the mapping may be inverted to return a date.

          Note that the data types of the range and output of the scale must be compatible with the interpolator applied by the scale.

          The first generic corresponds to the data type of the range elements.

          The second generic corresponds to the data type of the output elements generated by the scale.

          The third generic corresponds to the data type of the unknown value.

          If range element and output element type differ, the interpolator factory used with the scale must match this behavior and convert the interpolated range element to a corresponding output element.

        method clamp

        clamp: { (): boolean; (clamp: boolean): this };
        • Returns whether or not the scale currently clamps values to within the range.

        • Enables or disables clamping, respectively. If clamping is disabled and the scale is passed a value outside the domain, the scale may return a value outside the range through extrapolation.

          If clamping is enabled, the return value of the scale is always within the scale’s range. Clamping similarly applies to the "invert" method.

          Parameter clamp

          A flag to enable (true) or disable (false) clamping.

        method copy

        copy: () => this;
        • Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

        method domain

        domain: { (): Date[]; (domain: Iterable<NumberValue | Date>): this };
        • Returns a copy of the scale’s current domain.

        • Sets the scale’s domain to the specified array of temporal domain values. The array must contain two or more elements. If the elements in the given array are not dates, they will be coerced to dates.

          Although continuous scales typically have two values each in their domain and range, specifying more than two values produces a piecewise scale.

          Internally, a piecewise scale performs a binary search for the range interpolator corresponding to the given domain value. Thus, the domain must be in ascending or descending order. If the domain and range have different lengths N and M, only the first min(N,M) elements in each are observed.

          Parameter domain

          Array of temporal domain values. Numeric values will be coerced to dates.

        method interpolate

        interpolate: {
        (): InterpolatorFactory<any, any>;
        (interpolate: InterpolatorFactory<Range, Output>): this;
        <NewOutput>(interpolate: InterpolatorFactory<Range, NewOutput>): ScaleTime<
        Range,
        NewOutput,
        Unknown
        >;
        };
        • Returns the scale’s current interpolator factory, which defaults to interpolate.

        • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

          Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

          As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

          Parameter interpolate

          An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

        • Sets the scale’s range interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter t in [0, 1] to the corresponding value in the range.

          Note: the default interpolator may reuse return values. For example, if the range values are objects, then the value interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, this is typically acceptable (and desirable for performance); however, if you need to store the scale’s return value, you must specify your own interpolator or make a copy as appropriate.

          As part of the interpolation process the interpolated value from the range may be converted to a corresponding output value.

          The generic "NewOutput" can be used to change the scale to have a different output element type corresponding to the new interpolation factory.

          Parameter interpolate

          An interpolation factory. The generics for Range and Output of the scale must correspond to the interpolation factory applied to the scale.

        method invert

        invert: (value: NumberValue) => Date;
        • Given a value from the range, returns the corresponding value from the domain. Inversion is useful for interaction, say to determine the data value corresponding to the position of the mouse.

          If the given value is outside the range, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the domain.

          IMPORTANT: This method is only supported if the range is numeric. If the range is not numeric, returns Invalid Date.

          For a valid value y in the range, time(time.invert(y)) equals y; similarly, for a valid value x in the domain, time.invert(time(x)) equals x. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

          Parameter value

          A numeric value from the range.

        method nice

        nice: { (count?: number): this; (interval: CountableTimeInterval): this };
        • Extends the domain so that it starts and ends on nice round values. This method typically modifies the scale’s domain, and may only extend the bounds to the nearest round value.

          An optional count argument allows greater control over the step size used to extend the bounds, guaranteeing that the returned ticks will exactly cover the domain.

          Nicing is useful if the domain is computed from data, say using extent, and may be irregular. For example, for a domain of [2009-07-13T00:02, 2009-07-13T23:48], the nice domain is [2009-07-13, 2009-07-14]. If the domain has more than two values, nicing the domain only affects the first and last value.

          Parameter count

          Expected number of ticks.

        • Extends the domain so that it starts and ends on nice round values. This method typically modifies the scale’s domain, and may only extend the bounds to the nearest round value.

          A time interval may be specified to explicitly set the ticks. If an interval is specified, an optional step may also be specified to skip some ticks. For example, time.nice(d3.timeSecond.every(10)) will extend the domain to an even ten seconds (0, 10, 20, etc.). See time.ticks and interval.every for further detail.

          Nicing is useful if the domain is computed from data, say using extent, and may be irregular. For example, for a domain of [2009-07-13T00:02, 2009-07-13T23:48], the nice domain is [2009-07-13, 2009-07-14]. If the domain has more than two values, nicing the domain only affects the first and last value.

          Parameter interval

          A time interval to specify the expected ticks.

        method range

        range: { (): Range[]; (range: Iterable<Range>): this };
        • Returns a copy of the scale’s current range.

        • Sets the scale’s range to the specified array of values.

          The array must contain two or more elements. Unlike the domain, elements in the given array need not be temporal domain values; any value that is supported by the underlying interpolator will work, though note that numeric ranges are required for invert.

          Parameter range

          Array of range values.

        method rangeRound

        rangeRound: (range: Iterable<NumberValue>) => this;
        • Sets the scale’s range to the specified array of values while also setting the scale’s interpolator to interpolateRound.

          The rounding interpolator is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles. Note that this interpolator can only be used with numeric ranges.

          The array must contain two or more elements. Unlike the domain, elements in the given array need not be temporal domain values; any value that is supported by the underlying interpolator will work, though note that numeric ranges are required for invert.

          Parameter range

          Array of range values.

        method tickFormat

        tickFormat: {
        (count?: number, specifier?: string): (d: Date) => string;
        (interval: TimeInterval, specifier?: string): (d: Date) => string;
        };
        • Returns a time format function suitable for displaying tick values.

          The default multi-scale time format chooses a human-readable representation based on the specified date as follows:

          - %Y - for year boundaries, such as 2011. - %B - for month boundaries, such as February. - %b %d - for week boundaries, such as Feb 06. - %a %d - for day boundaries, such as Mon 07. - %I %p - for hour boundaries, such as 01 AM. - %I:%M - for minute boundaries, such as 01:23. - :%S - for second boundaries, such as :45. - .%L - milliseconds for all other times, such as .012.

          Although somewhat unusual, this default behavior has the benefit of providing both local and global context: for example, formatting a sequence of ticks as [11 PM, Mon 07, 01 AM] reveals information about hours, dates, and day simultaneously, rather than just the hours [11 PM, 12 AM, 01 AM].

          The specified count is currently ignored, but is accepted for consistency with other scales such as continuous.tickFormat.

          Parameter count

          Expected number of ticks. (Currently ignored)

          Parameter specifier

          An optional valid date format specifier string (see d3-time-format).

        • Returns a time format function suitable for displaying tick values.

          The specified time interval is currently ignored, but is accepted for consistency with other scales such as continuous.tickFormat.

          Parameter interval

          A time interval to specify the expected ticks. (Currently ignored)

          Parameter specifier

          An optional valid date format specifier string (see d3-time-format).

        method ticks

        ticks: { (count?: number): Date[]; (interval: TimeInterval): Date[] };
        • Returns representative dates from the scale’s domain. The returned tick values are uniformly-spaced (mostly), have sensible values (such as every day at midnight), and are guaranteed to be within the extent of the domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data.

          An optional count may be specified to affect how many ticks are generated. If count is not specified, it defaults to 10. The specified count is only a hint; the scale may return more or fewer values depending on the domain.

          Parameter count

          Expected number of ticks.

        • Returns representative dates from the scale’s domain. The returned tick values are uniformly-spaced (mostly), have sensible values (such as every day at midnight), and are guaranteed to be within the extent of the domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data.

          The specified time interval controls the ticks generated and returned. To prune the generated ticks for a given time interval, use interval.every(...) or interval.filter(...).

          Parameter interval

          A time interval to specify the expected ticks.

        method unknown

        unknown: {
        (): UnknownReturnType<Unknown, undefined>;
        <NewUnknown>(value: NewUnknown): ScaleTime<Range, Output, NewUnknown>;
        };
        • Returns the current unknown value, which defaults to undefined.

        • Sets the output value of the scale for undefined (or NaN) input values and returns this scale.

          Parameter value

          The output value of the scale for undefined (or NaN) input values.

        call signature

        (value: Date | NumberValue): Output | Unknown;
        • Given a value from the domain, returns the corresponding value from the range, subject to interpolation, if any.

          If the given value is outside the domain, and clamping is not enabled, the mapping may be extrapolated such that the returned value is outside the range.

          Note: The interpolation function applied by the scale may change the output type from the range type as part of the interpolation.

          Parameter value

          A temporal value from the domain. If the value is not a Date, it will be coerced to Date.

        Type Aliases

        type NumberValue

        type NumberValue = number | { valueOf(): number };

          type UnknownReturnType

          type UnknownReturnType<Unknown, DefaultUnknown> = [Unknown] extends [never]
          ? DefaultUnknown
          : Unknown;

            Package Files (1)

            Dependencies (1)

            Dev Dependencies (0)

            No dev dependencies.

            Peer Dependencies (0)

            No peer dependencies.

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/d3-scale.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/d3-scale)
            • HTML
              <a href="https://www.jsdocs.io/package/@types/d3-scale"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>