Axis options
AxisConfig, AxisFormatter, AxisOptions, AxisPosition and 14 more: generated from the source of active-charts.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Types#
High-level axis configuration for chart wrappers. Compiles down to AxisOptions internally.
interface AxisConfig {
type?: AxisType;
temporalSemantic?: TemporalSemantic;
valueSemantics?: ChartValueSemantics;
position?: AxisPosition;
title?: string;
formatter?: AxisFormatter;
format?: string;
tickCount?: number;
tickInterval?: number;
targetPixelInterval?: number;
minPixelInterval?: number;
min?: number;
max?: number;
softMin?: number;
softMax?: number;
nice?: boolean;
rotation?: number;
autoRotate?: boolean;
maxLabelWidth?: number;
truncate?: boolean;
wrap?: number;
tickValues?: TickValues;
reversed?: boolean;
style?: AxisStyleOptions;
gridLine?: {
enabled?: boolean;
style?: StrokeStyle;
};
parentLevel?: boolean | ParentLevelOptions;
}Reusable axis formatter signature, parameterised by tick-value runtime type.
Consumers can opt into stricter typing by picking the appropriate Axis alias. Defaults to the widest union so that (v) => … and (v: unknown) => … call-sites type-check.
The optional index and all arguments enable boundary-aware decisions — e.g. show the year only on the first tick, or whenever the year changes between ticks. (value) => string formatters remain compatible (the extra arguments are ignored).
type AxisFormatter<V extends AxisTickValue = AxisTickValue> = (
value: V,
index?: number,
allValues?: V[],
) => string;The internal axis configuration of <Chart>. A 'time' or 'ordinal- axis declares its Temporal; no other axis does.
type AxisOptions = AxisOptionsBase & AxisTypeDeclaration;type AxisPosition = 'top' | 'right' | 'bottom' | 'left';Axis-level styling overrides. Each sub-object overrides theme defaults for the corresponding axis element. Mirrors the Tooltip pattern — a single flat object with sub-categories (no deep nesting).
interface AxisStyleOptions {
line?: {
stroke?: string;
strokeWidth?: number;
visible?: boolean;
};
tick?: {
stroke?: string;
length?: number;
};
label?: {
fill?: string;
fontSize?: number;
fontFamily?: string;
fontWeight?: number | string;
};
title?: {
fill?: string;
fontSize?: number;
fontFamily?: string;
fontWeight?: number | string;
};
}- Type
type AxisTick Value = Date | string | number;
Union of possible tick-value runtime types passed to axis formatters.
The actual type depends on the axis-type the formatter is bound to:
| Axis type | Runtime value | Helper alias | | ---------------- | ------------------------------------------ | ----------------------- | | 'ordinal- | ISO date string ("2024-) | Time | | 'time' | Date objects (continuous time scale) | Time | | 'category' | string (the category key) | Category | | 'number' | number | Number | | 'log' / 'sqrt' | number | Number |
The 'ordinal- scale converts all data values to ISO strings internally via . (see d3-). Consumers should treat the formatter value as a string in this case and use format from @workspace/ which handles strings via parse.
type AxisType =
'number' | 'log' | 'sqrt' | 'time' | 'ordinal-time' | 'category';Axis narrowed for a category (scale) axis.
The tick formatter value is a string (Category): scale stringifies its domain, so a date passed here is rendered as a non-ISO string. Typing the value as string makes format and v as Date fail to compile, closing the date-on-category trap. The type is pinned to 'category' (optional, since this is the default for bar-class wrappers).
type CategoryAxisConfig = Omit<
AxisConfig,
'type' | 'formatter' | 'temporalSemantic' | 'softMin' | 'softMax'
> & {
type?: 'category';
temporalSemantic?: never;
formatter?: AxisFormatter<CategoryAxisTickValue>;
};- Type
type CategoryAxis Tick Value = string;
Runtime value type for 'category' axis formatters (the category key).
Axis narrowed for a numeric axis ('number', 'log', or 'sqrt'). The tick formatter value is a number (Number).
type NumberAxisConfig = Omit<
AxisConfig,
'type' | 'formatter' | 'temporalSemantic' | 'wrap'
> & {
type?: 'number' | 'log' | 'sqrt';
temporalSemantic?: never;
formatter?: AxisFormatter<NumberAxisTickValue>;
};- Type
type NumberAxis Tick Value = number;
Runtime value type for 'number' / 'log' / 'sqrt' axis formatters.
Configuration for hierarchical "parent level" axis labels — a second row of labels under the main ticks that shows the next-coarser calendar unit (e.g. years under months, months under days).
Inspired by AG Charts' parent and Highcharts' second-pass date. Opt-in on every axis type: enable with the boolean shorthand parent or pass an options object to customise. Omitted (or false) leaves the second row disabled.
interface ParentLevelOptions {
enabled?: boolean;
formatter?: (value: unknown) => string;
fill?: string;
fontSize?: number;
fontWeight?: number | string;
showTicks?: boolean;
}interface StrokeStyle {
stroke?: string;
strokeWidth?: number;
lineDash?: number[];
}- Type
type TemporalAxis Type = 'time' | 'ordinal- time';
The two axis types whose values are dates or times.
What the values of a temporal axis ARE. Required on every 'time' and 'ordinal- axis; there is no default.
'calendar: a calendar day (a trading day, a reporting date, a month). The day never moves:Date' 2026-is 1 January in every zone. The day is read from the value itself: a01- 01 YYYY-or ISO string by its date part, aMM- DD Dateor timestamp by its UTC fields (the storage convention of a calendar day). Language and notation still follow the chart presentation.'instant': a point in time (a page view, a login). Its day and time are read in the chart presentation's zone, so the same value can fall on another day in another zone.
The same declaration governs every surface that shows the axis value: tick labels, the parent row, the tooltip, the crosshair, the screen-reader table and the keyboard announcement. A custom label. receives the raw value and must read it the same way (format for a calendar date).
type TemporalSemantic = 'calendarDate' | 'instant';Custom tick values. Either a fixed array of values, or a callback that receives the resolved domain and returns the tick values.
type TickValues = unknown[] | ((domain: unknown[]) => unknown[]);Axis narrowed for a time axis ('time' or 'ordinal-).
The tick formatter value is a Date | string (Time): 'time' yields Date, 'ordinal- yields ISO strings; format accepts both via parse.
type TimeAxisConfig = Omit<
AxisConfig,
'type' | 'formatter' | 'temporalSemantic' | 'wrap' | 'softMin' | 'softMax'
> & {
type?: TemporalAxisType;
temporalSemantic: TemporalSemantic;
formatter?: AxisFormatter<TimeAxisTickValue>;
};- Type
type TimeAxis Tick Value = Date | string;
Runtime value type for 'time' / 'ordinal- axis formatters.
Includes both Date (continuous time scale) and string (ordinal-time scale ISO strings). Use with format from @workspace/ which handles both via parse.