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

ScaleBand

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.

interface ScaleBand <Domain extends {
toString(): string;
}
>
{
(x: Domain): number | undefined;
align(): number;
align(align: number): this;
bandwidth(): number;
copy(): this;
domain(): Domain[];
domain(domain: Iterable<Domain>): this;
padding(): number;
padding(padding: number): this;
paddingInner(): number;
paddingInner(padding: number): this;
paddingOuter(): number;
paddingOuter(padding: number): this;
range(): [number, number];
range(range: Iterable<NumberValue>): this;
rangeRound(range: Iterable<NumberValue>): this;
round(): boolean;
round(round: boolean): this;
step(): number;
}

§Type Parameters

§
Domain extends {
toString(): string;
}
[src]

§Call Signatures

§
(x: Domain): number | undefined
[src]

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.

§Methods

§
align(): number
[src]

Returns the current alignment which defaults to 0.5.

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

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.

@param align

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

§
bandwidth(): number
[src]

Returns the width of each band.

§
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 to scale's current domain

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

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 a map from stringified value to index; the resulting index is then used to determine the band. Thus, a band scale’s values must be coercible to a string, and the stringified version of the domain value uniquely identifies the corresponding band.

@param domain

Array of domain values.

§
padding(): number
[src]

Returns the inner padding.

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

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

@param padding

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

§
paddingInner(): number
[src]

Returns the current inner padding which defaults to 0.

§
paddingInner(padding: number): this
[src]

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.

@param padding

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

§
paddingOuter(): number
[src]

Returns the current outer padding which defaults to 0.

§
paddingOuter(padding: number): this
[src]

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.

@param padding

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

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

Returns the scale’s current range, which defaults to [0, 1].

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

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

@param range

A two-element array of numeric values.

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

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.

@param range

A two-element array of numeric values.

§
round(): boolean
[src]

Returns the current rounding status for the scale: enabled (= true) or disabled (= false).

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

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.

@param round

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

§
step(): number
[src]

Returns the distance between the starts of adjacent bands.