Interface Axis<Domain>

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

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

Type Parameters

  • Domain

Methods

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

    Returns number

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

    Parameters

    • offset: number

    Returns Axis<Domain>

  • Gets the current scale underlying the axis.

    Type Parameters

    Returns A

  • Sets the scale and returns the axis.

    Parameters

    • scale: AxisScale<Domain>

      The scale to be used for axis generation.

    Returns Axis<Domain>

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

    Returns any[]

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

    Parameters

    • args: any[]

      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.

    Returns Axis<Domain>

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

    Returns ((domainValue, index) => string)

      • (domainValue, index): string
      • Parameters

        • domainValue: Domain
        • index: number

        Returns string

  • Sets the tick format function and returns the axis.

    Parameters

    • format: ((domainValue, index) => string)

      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.

        • (domainValue, index): string
        • Parameters

          • domainValue: Domain
          • index: number

          Returns string

    Returns Axis<Domain>

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

    Parameters

    • format: null

      null

    Returns Axis<Domain>

  • Get the current padding, which defaults to 3.

    Returns number

  • Set the current padding and return the axis.

    Parameters

    • padding: number

      Padding in pixels (Default is 3).

    Returns Axis<Domain>

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

    Returns number

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

    Parameters

    • size: number

      Tick size in pixels (Default is 6).

    Returns Axis<Domain>

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

    Returns number

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

    Parameters

    • size: number

      Tick size in pixels (Default is 6).

    Returns Axis<Domain>

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

    Returns number

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

    Parameters

    • size: number

      Tick size in pixels (Default is 6).

    Returns Axis<Domain>

  • Returns the current tick values, which defaults to null.

    Returns Domain[]

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

    Parameters

    • values: Iterable<Domain>

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

    Returns Axis<Domain>

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

    Parameters

    • values: null

      null

    Returns Axis<Domain>

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

    Parameters

    • count: number

      Number of ticks that should be rendered.

    • Optional specifier: string

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

    Returns Axis<Domain>

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

    Parameters

    • interval: AxisTimeInterval

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

    • Optional specifier: string

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

    Returns Axis<Domain>

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

    Parameters

    • arg0: any
    • Rest ...args: any[]

    Returns Axis<Domain>