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

ScaleLogarithmic

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.

interface ScaleLogarithmic <Range, Output, Unknown = never> extends ScaleContinuousNumeric<Range, Output, Unknown> {
base(): number;
base(base: number): this;
domain(): number[];
domain(domain: Iterable<NumberValue>): this;
interpolate(): InterpolatorFactory<any, any>;
interpolate(interpolate: InterpolatorFactory<Range, Output>): this;
interpolate<NewOutput>(interpolate: InterpolatorFactory<Range, NewOutput>): ScaleLogarithmic<Range, NewOutput, Unknown>;
nice(): this;
tickFormat(count?: number, specifier?: string): (d: NumberValue) => string;
ticks(count?: number): number[];
unknown(): UnknownReturnType<Unknown, undefined>;
unknown<NewUnknown>(value: NewUnknown): ScaleLogarithmic<Range, Output, NewUnknown>;
}

§Type Parameters

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

§Extends

§
ScaleContinuousNumeric<Range, Output, Unknown>
[src]

§Methods

§
base(): number
[src]

Returns the current base, which defaults to 10.

§
base(base: number): this
[src]

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

§
domain(): 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 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.

@param domain

Array of numeric domain values.

§
interpolate(): InterpolatorFactory<any, any>
[src]

Returns the scale’s current interpolator factory, which defaults to interpolate.

§
interpolate(interpolate: InterpolatorFactory<Range, Output>): this
[src]

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.

@param interpolate

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

§
interpolate<NewOutput>(interpolate: InterpolatorFactory<Range, NewOutput>): ScaleLogarithmic<Range, NewOutput, Unknown>
[src]

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.

@param interpolate

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

§
nice(): this
[src]

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.

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

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

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

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.

@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): ScaleLogarithmic<Range, 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.