Skip to content

Axis options

Type: AxisOptions

AxisOptions is a union of:

  • LinearAxisOptions
  • TimeAxisOptions
  • CategoricalAxisOptions

The following options are available on all axis types unless noted otherwise.

Type: string
Default: none

Label of the axis. Is used by the tooltip too.

Type: boolean
Default: true

Whether the label should be rendered next to the axis. If false, the label will still be rendered in the tooltip.

Type: "linear" | "time" | "categorical"
Required

Axis type. Selects the underlying scale and which of the options below apply.

Type: string
Required

The key of the data that should be mapped to the axis.

Type: unknown[]
Default: none

The domain of the axis. For concrete axis types, this is narrowed (see below).

Type: boolean
Default: none

Whether grid lines should be shown. Grid lines are hidden unless you set this to true.

Applies to: linear, time. Also ignored for time axes in bar charts, because those are rendered as categorical axes.

Type: string
Default: none

Format string for the axis ticks. Either a D3 format string or a time format string. Depending on the type of the scale.

Applies to: linear, time.

Type: AxisUnit
Default: [null, null] (no prefix or suffix)

Unit (prefix, suffix) for the rendered ticks. A tuple of [prefix, suffix]. E.g. for a currency format, the prefix could be $ and the suffix could be CHF. The units are applied after tickFormat.

Type: string
Default: none

Format string for values that are displayed in an extended format. E.g. when the value is displayed in a tooltip.

Applies to: linear, time.

Type: AxisUnit
Default: none (falls back to tickUnit)

Unit (prefix, suffix) for values that are displayed in an extended format. E.g. in the tooltip. A tuple of [prefix, suffix]. The units are applied after extendedFormat. If not set, the tickUnit is used for the extended format as well.


Type: LinearAxisOptions

Type: "linear"
Required

Type: boolean
Default: true

Whether the axis should include zero in the domain. Has no effect when the domain is set or when the data has values that are smaller than zero.

Type: [number, number]
Default: none

Fixed numeric domain.


Type: TimeAxisOptions

Type: "time"
Required

Type: [string, string]
Default: none

Fixed time domain boundaries.

Type: "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year"
Default: none

Minimal interval for the ticks. Only used for time scales. Has no effect when used on time scales in bar charts. It guarantees that the ticks are at least this interval apart.
E.g. if the value is set to "month", the ticks could also be a year apart but not weeks. Depending on the available space.


Type: CategoricalAxisOptions

Type: "categorical"
Required

Type: string[]
Default: none

Fixed categorical domain.

Categorical axes do not support tickFormat, extendedFormat, or showGrid.