Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

ScaleDiverging

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.

interface ScaleDiverging <Output, Unknown = never> {
(value: NumberValue): Output | Unknown;
clamp(): boolean;
clamp(clamp: boolean): this;
copy(): this;
domain(): [number, number, number];
domain(domain: Iterable<NumberValue>): this;
interpolator(): (t: number) => Output;
interpolator(interpolator?: (t: number) => Output): this;
range(): () => [Output, Output, Output];
range(range: Iterable<Output>): this;
rangeRound(range: Iterable<NumberValue>): this;
unknown(): UnknownReturnType<Unknown, undefined>;
unknown<NewUnknown>(value: NewUnknown): ScaleDiverging<Output, NewUnknown>;
}

§Type Parameters

§
Output
[src]
§
Unknown = never
[src]

§Call Signatures

§
(value: NumberValue): Output | Unknown
[src]

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.

§Methods

§
clamp(): boolean
[src]

Returns whether or not the scale currently clamps values to within the range.

§
clamp(clamp: boolean): this
[src]

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.

@param clamp

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

§
copy(): this
[src]

Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

§
domain(): [number, number, number]
[src]

Returns a copy of the scale’s current domain.

§
domain(domain: Iterable<NumberValue>): this
[src]

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

@param domain

Array of three numeric domain values.

§
interpolator(): (t: number) => Output
[src]

Returns the scale’s current interpolator.

§
interpolator(interpolator?: (t: number) => Output): this
[src]

Sets the scale’s interpolator to the specified function.

@param interpolator

The scale’s interpolator.

§
range(): () => [Output, Output, Output]
[src]

See continuous.range.

§
range(range: Iterable<Output>): this
[src]

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

@param range

Range values.

§
rangeRound(range: Iterable<NumberValue>): this
[src]

See continuous.rangeRound. If range is specified, implicitly uses d3.interpolateRound as the interpolator.

@param range

Range values.

§
unknown(): UnknownReturnType<Unknown, undefined>
[src]

Returns the current unknown value, which defaults to undefined.

§
unknown<NewUnknown>(value: NewUnknown): ScaleDiverging<Output, NewUnknown>
[src]

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

@param value

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