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

ScaleQuantize

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.

interface ScaleQuantize <Range, Unknown = never> {
(value: NumberValue): Range | Unknown;
copy(): this;
domain(): [number, number];
domain(domain: Iterable<NumberValue>): this;
invertExtent(value: Range): [number, number];
nice(count?: number): this;
range(): Range[];
range(range: Iterable<Range>): this;
thresholds(): number[];
tickFormat(count?: number, specifier?: string): (d: NumberValue) => string;
ticks(count?: number): number[];
unknown(): UnknownReturnType<Unknown, undefined>;
unknown<NewUnknown>(value: NewUnknown): ScaleQuantize<Range, NewUnknown>;
}

§Type Parameters

§
Range
[src]
§
Unknown = never
[src]

§Call Signatures

§
(value: NumberValue): 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(): [number, number]
[src]

Returns the scale’s current domain.

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

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.

@param domain

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

§
invertExtent(value: Range): [number, number]
[src]

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

@param value

A value from the range.

§
nice(count?: number): this
[src]

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.

@param count

An optional number of ticks expected to be used.

§
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. The array may contain any number of discrete values.

@param range

Array of range values.

§
thresholds(): number[]
[src]

Returns the array of computed thresholds within the domain.

§
tickFormat(count?: number, specifier?: string): (d: NumberValue) => string
[src]

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.

@param count

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

@param 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.

§
ticks(count?: number): number[]
[src]

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.

@param count

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

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

Returns the current unknown value, which defaults to undefined.

§
unknown<NewUnknown>(value: NewUnknown): ScaleQuantize<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.