Use chart axis formatters
createChartAxisFormatters, useChartAxisFormatters, ChartAxisFormatters: generated from the source of active-charts.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Functions, hooks and constants#
Internal. Shareable implementation, callable without React context.
(presentation: ChartPresentation) => ChartAxisFormattersThe axis-formatter factories for this chart tree's presentation.
Resolution: explicit argument → Chart (the app shell) → a configuration error; there is no 'en' fallback (active-format D14). The result is memoised on the presentation identity, so a presentation object should be referentially stable, as with the locale prop.
(presentation?: ChartPresentation) => ChartAxisFormattersReturns
An object with these fields.
- Type
(currency, options?) => …
Currency axis. The currency identity comes from the data or the caller's domain invariant: required, never derived from the language.
- Type
(semantic, preset?) => …
Date axis with a date preset (default 'day-). The semantic is required and equals the axis's temporal: a calendar date stays its own day, an instant follows the presentation's zone. A calendar date only accepts a calendar-day preset.
Types#
Factories for the common axis-label forms. Each factory returns a closure that passes non-numeric (or non-date) values through as String(value).
interface ChartAxisFormatters {
number: (preset?: NumberFormat) => AxisValueFormatter;
currency: (
currency: string,
options?: CurrencyFormatOptions,
) => AxisValueFormatter;
fractionAsPercent: (preset?: PercentPreset) => AxisValueFormatter;
percentagePoints: (preset?: PercentPreset) => AxisValueFormatter;
date: (semantic: TemporalSemantic, preset?: DatePreset) => AxisValueFormatter;
}