Problem
ChartAxisLabels supports numberFormat, dateFormat and dateTimeLabelFormats, but it does not accept the shared ValueFormat API used by data labels and tooltips.
As a result, axis labels cannot use {type: 'custom', formatter} for domain-specific or custom time-zone formatting. Converting a numeric or datetime axis to a category axis changes its scale semantics and is not a general workaround.
Proposal
Add format?: ValueFormat to ChartAxisLabels:
const dateFormatter = new Intl.DateTimeFormat('en-US', {
timeZone: 'America/New_York',
month: 'short',
day: 'numeric',
hour: '2-digit',
});
xAxis: {
type: 'datetime',
labels: {
format: {
type: 'custom',
formatter: ({value}) => dateFormatter.format(Number(value)),
},
},
}
When labels.format is set, the raw tick value should be formatted through the existing getFormattedValue utility. It should take precedence over the axis-type-specific options rather than be merged with them. When it is omitted, the current formatting behavior should remain unchanged, including smart datetime formats selected from the tick step.
This reuses the same public contract as series.dataLabels.format and the same formatting pipeline as data labels and tooltips. A separate axis-specific callback API is not needed.
Expected behavior
labels.format is available for both X and Y axes. Each ValueFormat variant keeps the existing getFormattedValue semantics for the supplied tick value.
- A custom formatter receives the raw tick value through the existing
{value} argument.
- The same formatted result is used for label measurement, truncation, overlap handling and both SVG and HTML rendering.
- Existing
numberFormat, dateFormat and dateTimeLabelFormats behavior is preserved when format is omitted.
Additional tick context such as index or first/last state, full custom rendering, per-label styles and event handlers are outside the scope of this issue.
Tests and documentation
Add unit and visual coverage for all format variants, precedence over the existing axis-specific options, both axis directions, and SVG/HTML labels. Add a Storybook example and document labels.format in the Axis Labels and Value Formatting guides.
Related APIs and use cases
Problem
ChartAxisLabelssupportsnumberFormat,dateFormatanddateTimeLabelFormats, but it does not accept the sharedValueFormatAPI used by data labels and tooltips.As a result, axis labels cannot use
{type: 'custom', formatter}for domain-specific or custom time-zone formatting. Converting a numeric or datetime axis to a category axis changes its scale semantics and is not a general workaround.Proposal
Add
format?: ValueFormattoChartAxisLabels:When
labels.formatis set, the raw tick value should be formatted through the existinggetFormattedValueutility. It should take precedence over the axis-type-specific options rather than be merged with them. When it is omitted, the current formatting behavior should remain unchanged, including smart datetime formats selected from the tick step.This reuses the same public contract as
series.dataLabels.formatand the same formatting pipeline as data labels and tooltips. A separate axis-specific callback API is not needed.Expected behavior
labels.formatis available for both X and Y axes. EachValueFormatvariant keeps the existinggetFormattedValuesemantics for the supplied tick value.{value}argument.numberFormat,dateFormatanddateTimeLabelFormatsbehavior is preserved whenformatis omitted.Additional tick context such as index or first/last state, full custom rendering, per-label styles and event handlers are outside the scope of this issue.
Tests and documentation
Add unit and visual coverage for all format variants, precedence over the existing axis-specific options, both axis directions, and SVG/HTML labels. Add a Storybook example and document
labels.formatin the Axis Labels and Value Formatting guides.Related APIs and use cases
xAxis.labels.formatterprovides custom formatting based on the raw tick value.ticks.callbackprovides custom tick formatting through a callback.