@types/d3-axis

  • Version 3.0.1
  • Published
  • 16.1 kB
  • 1 dependency
  • MIT license

Install

npm i @types/d3-axis
yarn add @types/d3-axis
pnpm add @types/d3-axis

Overview

TypeScript definitions for D3JS d3-axis module

Index

Functions

function axisBottom

axisBottom: <Domain extends AxisDomain>(
scale: AxisScale<Domain>
) => Axis<Domain>;
  • Constructs a new bottom-oriented axis generator for the given scale, with empty tick arguments, a tick size of 6 and padding of 3. In this orientation, ticks are drawn below the horizontal domain path.

    Parameter scale

    The scale to be used for axis generation.

function axisLeft

axisLeft: <Domain extends AxisDomain>(scale: AxisScale<Domain>) => Axis<Domain>;
  • Constructs a new left-oriented axis generator for the given scale, with empty tick arguments, a tick size of 6 and padding of 3. In this orientation, ticks are drawn to the left of the vertical domain path.

    Parameter scale

    The scale to be used for axis generation.

function axisRight

axisRight: <Domain extends AxisDomain>(scale: AxisScale<Domain>) => Axis<Domain>;
  • Constructs a new right-oriented axis generator for the given scale, with empty tick arguments, a tick size of 6 and padding of 3. In this orientation, ticks are drawn to the right of the vertical domain path.

    Parameter scale

    The scale to be used for axis generation.

function axisTop

axisTop: <Domain extends AxisDomain>(scale: AxisScale<Domain>) => Axis<Domain>;
  • Constructs a new top-oriented axis generator for the given scale, with empty tick arguments, a tick size of 6 and padding of 3. In this orientation, ticks are drawn above the horizontal domain path.

    Parameter scale

    The scale to be used for axis generation.

Interfaces

interface Axis

interface Axis<Domain> {}
  • Interface defining an axis generator. The generic is the type of the axis domain.

method offset

offset: { (): number; (offset: number): this };
  • 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.

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

method scale

scale: { <A extends AxisScale<Domain>>(): A; (scale: AxisScale<Domain>): this };
  • Gets the current scale underlying the axis.

  • Sets the scale and returns the axis.

    Parameter scale

    The scale to be used for axis generation.

method tickArguments

tickArguments: { (): any[]; (args: any[]): this };
  • Get an array containing the currently set arguments to be passed into scale.ticks and scale.tickFormat, which defaults to the empty array.

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

    Parameter args

    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.

method tickFormat

tickFormat: {
(): (domainValue: Domain, index: number) => string;
(format: (domainValue: Domain, index: number) => string): this;
(format: null): this;
};
  • Returns the currently set tick format function, which defaults to null.

  • Sets the tick format function and returns the axis.

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

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

    Parameter format

    null

method tickPadding

tickPadding: { (): number; (padding: number): this };
  • Get the current padding, which defaults to 3.

  • Set the current padding and return the axis.

    Parameter padding

    Padding in pixels (Default is 3).

method ticks

ticks: {
(count: number, specifier?: string): this;
(interval: AxisTimeInterval, specifier?: string): this;
(arg0: any, ...args: any[]): this;
};
  • 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.

    Parameter count

    Number of ticks that should be rendered.

    Parameter specifier

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

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

    Parameter 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).

    Parameter specifier

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

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

method tickSize

tickSize: { (): number; (size: number): this };
  • Get the current inner tick size, which defaults to 6.

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

    Parameter size

    Tick size in pixels (Default is 6).

method tickSizeInner

tickSizeInner: { (): number; (size: number): this };
  • 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.

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

    Parameter size

    Tick size in pixels (Default is 6).

method tickSizeOuter

tickSizeOuter: { (): number; (size: number): this };
  • 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.

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

    Parameter size

    Tick size in pixels (Default is 6).

method tickValues

tickValues: {
(): Domain[] | null;
(values: Iterable<Domain>): this;
(values: null): this;
};
  • Returns the current tick values, which defaults to null.

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

    Parameter values

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

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

    Parameter values

    null

call signature

(
context:
| Selection<SVGSVGElement, any, any, any>
| Selection<SVGGElement, any, any, any>
| TransitionLike<SVGSVGElement, any>
| TransitionLike<SVGGElement, any>
): void;
  • Render the axis to the given context.

    Parameter context

    A selection of or a transition defined on SVG containers (either SVG or G elements).

interface AxisScale

interface AxisScale<Domain> {}
  • A helper interface to which a scale passed into axis must conform (at a minimum) for axis to use the scale without error.

method bandwidth

bandwidth: () => number;

    method copy

    copy: () => this;

      method domain

      domain: () => Domain[];

        method range

        range: () => number[];

          call signature

          (x: Domain): number | undefined;

            interface AxisTimeInterval

            interface AxisTimeInterval {}
            • A helper interface to describe the minimal contract to be met by a time interval which can be passed into the Axis.ticks(...) or Axis.tickArguments(...) methods when creating time series axes. Under normal circumstances the argument will be of type TimeInterval or CountableTimeInterval as defined in d3-time. NB: This helper interface has been created to avoid tight coupling of d3-axis to d3-time at the level of definition files. I.e. d3-time is not a dependency of d3-axis in the D3 Javascript implementation. This minimal contract is based on an analysis of how d3-axis passes a time interval argument into a time scale, if a time scale was set using Axis.scale(...). And in turn on how a time scale uses the time interval when creating ticks from it.

            method range

            range: (start: Date, stop: Date, step?: number) => Date[];

              Type Aliases

              type AxisContainerElement

              type AxisContainerElement = SVGSVGElement | SVGGElement;
              • A helper type to alias elements which can serve as a container for an axis.

              type AxisDomain

              type AxisDomain = number | string | Date | { valueOf(): number };
              • A helper type to alias elements which can serve as a domain for an axis.

              Package Files (1)

              Dependencies (1)

              Dev Dependencies (0)

              No dev dependencies.

              Peer Dependencies (0)

              No peer dependencies.

              Badge

              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/d3-axis.

              • Markdown
                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/d3-axis)
              • HTML
                <a href="https://www.jsdocs.io/package/@types/d3-axis"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>