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

Axis

Interface defining an axis generator. The generic is the type of the axis domain.

interface Axis <Domain> {
(context: Selection<SVGSVGElement, any, any, any> | Selection<SVGGElement, any, any, any>): void;
(context: TransitionLike<SVGSVGElement, any> | TransitionLike<SVGGElement, any>): void;
offset(): number;
offset(offset: number): this;
scale<A extends AxisScale<Domain>>(): A;
scale(scale: AxisScale<Domain>): this;
tickArguments(): any[];
tickArguments(args: [number]): this;
tickArguments(args: [number, string]): this;
tickArguments(args: [AxisTimeInterval]): this;
tickArguments(args: [AxisTimeInterval, string]): this;
tickArguments(args: any[]): this;
tickFormat(): ((domainValue: Domain, index: number) => string) | null;
tickFormat(format: (domainValue: Domain, index: number) => string): this;
tickFormat(format: null): this;
tickPadding(): number;
tickPadding(padding: number): this;
ticks(count: number, specifier?: string): this;
ticks(interval: AxisTimeInterval, specifier?: string): this;
ticks(arg0: any, ...args: any[]): this;
tickSize(): number;
tickSize(size: number): this;
tickSizeInner(): number;
tickSizeInner(size: number): this;
tickSizeOuter(): number;
tickSizeOuter(size: number): this;
tickValues(): Domain[] | null;
tickValues(values: Domain[]): this;
tickValues(values: null): this;
}

§Type Parameters

§
Domain
[src]

§Call Signatures

§
(context: Selection<SVGSVGElement, any, any, any> | Selection<SVGGElement, any, any, any>): void
[src]

Render the axis to the given context.

§
(context: TransitionLike<SVGSVGElement, any> | TransitionLike<SVGGElement, any>): void
[src]

Render the axis to the given context.

§Methods

§
offset(): number
[src]

Returns the current offset which defaults to 0 on devices with a devicePixelRatio greater than 1, and 0.5px otherwise. This default offset ensures crisp edges on low-resolution devices.

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

Sets the offset to the specified value in pixels and returns the axis. Defaults to 0 on devices with a devicePixelRatio greater than 1, and 0.5px otherwise. This default offset ensures crisp edges on low-resolution devices.

§
scale<A extends AxisScale<Domain>>(): A
[src]

Gets the current scale underlying the axis.

§
scale(scale: AxisScale<Domain>): this
[src]

Sets the scale and returns the axis.

@param scale

The scale to be used for axis generation.

§
tickArguments(): any[]
[src]

Get an array containing the currently set arguments to be passed into scale.ticks and scale.tickFormat, which defaults to the empty array.

§
tickArguments(args: [number]): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.

This method has no effect if the scale does not implement scale.ticks, as with band and point scales. To set the tick values explicitly, use axis.tickValues. To set the tick format explicitly, use axis.tickFormat.

See also axis.ticks.

@param args

An array containing a single element representing the count, i.e. number of ticks to be rendered.

§
tickArguments(args: [number, string]): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.

This method has no effect if the scale does not implement scale.ticks, as with band and point scales. To set the tick values explicitly, use axis.tickValues. To set the tick format explicitly, use axis.tickFormat.

See also axis.ticks.

@param args

An array containing two elements. The first element represents the count, i.e. number of ticks to be rendered. The second element is a string representing the format specifier to customize how the tick values are formatted.

§
tickArguments(args: [AxisTimeInterval]): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. Use with a TIME SCALE ONLY.

See also axis.ticks.

@param args

An array containing a single element representing a time interval used to generate date-based ticks. This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15).

§
tickArguments(args: [AxisTimeInterval, string]): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. Use with a TIME SCALE ONLY.

See also axis.ticks.

@param args

An array containing two elements. The first element represents a time interval used to generate date-based ticks. This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15). The second element is a string representing the format specifier to customize how the tick values are formatted.

§
tickArguments(args: any[]): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.

This method has no effect if the scale does not implement scale.ticks, as with band and point scales. To set the tick values explicitly, use axis.tickValues. To set the tick format explicitly, use axis.tickFormat.

See also axis.ticks.

@param args

An array with arguments suitable for the scale to be used for tick generation.

§
tickFormat(): ((domainValue: Domain, index: number) => string) | null
[src]

Returns the currently set tick format function, which defaults to null.

§
tickFormat(format: (domainValue: Domain, index: number) => string): this
[src]

Sets the tick format function and returns the axis.

@param format

A function mapping a value from the axis Domain to a formatted string for display purposes. When invoked, the format function is also passed a second argument representing the zero-based index of the tick label in the array of generated tick labels.

§
tickFormat(format: null): this
[src]

Reset the tick format function. A null format indicates that the scale’s default formatter should be used, which is generated by calling scale.tickFormat. In this case, the arguments specified by axis.tickArguments are likewise passed to scale.tickFormat.

@param format

null

§
tickPadding(): number
[src]

Get the current padding, which defaults to 3.

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

Set the current padding and return the axis.

@param padding

Padding in pixels (Default is 3).

§
ticks(count: number, specifier?: string): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.

This method has no effect if the scale does not implement scale.ticks, as with band and point scales.

This method is also a convenience function for axis.tickArguments.

@param count

Number of ticks that should be rendered.

@param specifier

An optional format specifier to customize how the tick values are formatted.

§
ticks(interval: AxisTimeInterval, specifier?: string): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. Use with a TIME SCALE ONLY.

This method is also a convenience function for axis.tickArguments.

@param interval

A time interval used to generate date-based ticks. This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15).

@param specifier

An optional format specifier to customize how the tick values are formatted.

§
ticks(arg0: any, ...args: any[]): this
[src]

Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.

The meaning of the arguments depends on the axis’ scale type: most commonly, the arguments are a suggested count for the number of ticks (or a time interval for time scales), and an optional format specifier to customize how the tick values are formatted.

This method has no effect if the scale does not implement scale.ticks, as with band and point scales.

To set the tick values explicitly, use axis.tickValues. To set the tick format explicitly, use axis.tickFormat.

This method is also a convenience function for axis.tickArguments.

§
tickSize(): number
[src]

Get the current inner tick size, which defaults to 6.

§
tickSize(size: number): this
[src]

Set the inner and outer tick size to the specified value and return the axis.

@param size

Tick size in pixels (Default is 6).

§
tickSizeInner(): number
[src]

Get the current inner tick size, which defaults to 6. The inner tick size controls the length of the tick lines, offset from the native position of the axis.

§
tickSizeInner(size: number): this
[src]

Set the inner tick size to the specified value and return the axis. The inner tick size controls the length of the tick lines, offset from the native position of the axis.

@param size

Tick size in pixels (Default is 6).

§
tickSizeOuter(): number
[src]

Get the current outer tick size, which defaults to 6. The outer tick size controls the length of the square ends of the domain path, offset from the native position of the axis. Thus, the “outer ticks” are not actually ticks but part of the domain path, and their position is determined by the associated scale’s domain extent. Thus, outer ticks may overlap with the first or last inner tick. An outer tick size of 0 suppresses the square ends of the domain path, instead producing a straight line.

§
tickSizeOuter(size: number): this
[src]

Set the current outer tick size and return the axis. The outer tick size controls the length of the square ends of the domain path, offset from the native position of the axis. Thus, the “outer ticks” are not actually ticks but part of the domain path, and their position is determined by the associated scale’s domain extent. Thus, outer ticks may overlap with the first or last inner tick. An outer tick size of 0 suppresses the square ends of the domain path, instead producing a straight line.

@param size

Tick size in pixels (Default is 6).

§
tickValues(): Domain[] | null
[src]

Returns the current tick values, which defaults to null.

§
tickValues(values: Domain[]): this
[src]

Specified values to be used for ticks rather than using the scale’s automatic tick generator. The explicit tick values take precedent over the tick arguments set by axis.tickArguments. However, any tick arguments will still be passed to the scale’s tickFormat function if a tick format is not also set.

@param values

An array with values from the Domain of the scale underlying the axis.

§
tickValues(values: null): this
[src]

Clears any previously-set explicit tick values and reverts back to the scale’s tick generator.

@param values

null