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

ScaleThreshold

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.

interface ScaleThreshold <Domain extends number | string | Date, Range, Unknown = never> {
(value: Domain): Range | Unknown;
copy(): this;
domain(): Domain[];
domain(domain: Iterable<Domain>): this;
invertExtent(value: Range): [Domain | undefined, Domain | undefined];
range(): Range[];
range(range: Iterable<Range>): this;
unknown(): UnknownReturnType<Unknown, undefined>;
unknown<NewUnknown>(value: NewUnknown): ScaleThreshold<Domain, Range, NewUnknown>;
}

§Type Parameters

§
Domain extends number | string | Date
[src]
§
Range
[src]
§
Unknown = never
[src]

§Call Signatures

§
(value: Domain): Range | Unknown
[src]

Given a value in the input domain, returns the corresponding value in the output range.

§Methods

§
copy(): this
[src]

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

§
domain(): Domain[]
[src]

Returns the scale’s current domain.

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

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.

@param domain

Array of domain values.

§
invertExtent(value: Range): [Domain | undefined, Domain | undefined]
[src]

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.

@param value

A range value.

§
range(): Range[]
[src]

Returns the scale’s current range.

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

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.

@param range

Array of range values.

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

Returns the current unknown value, which defaults to undefined.

§
unknown<NewUnknown>(value: NewUnknown): ScaleThreshold<Domain, Range, 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.