charton API / @chart-on/core / index / Localizer
Interface: Localizer
Defined in: packages/core/src/util/locale.ts:220
Numbers, dates and text in the chart's language: chart.localization. Built from the localization option; a new one replaces it when the option changes (localization:change).
Properties
decimalSeparator
readonlydecimalSeparator:string
Defined in: packages/core/src/util/locale.ts:223
hourCycle
readonlyhourCycle:"h12"|"h23"
Defined in: packages/core/src/util/locale.ts:225
intlDates
readonlyintlDates:boolean
Defined in: packages/core/src/util/locale.ts:283
True when dates go through Intl; false for the built-in English labels, which the axis and crosshair draw themselves.
locale
readonlylocale:string|undefined
Defined in: packages/core/src/util/locale.ts:222
The locale option; undefined for the built-in English formats.
minusSign
readonlyminusSign:string
Defined in: packages/core/src/util/locale.ts:224
Methods
compact()
compact(
value):string
Defined in: packages/core/src/util/locale.ts:242
Compact amounts. With a locale, in its own words, digits and grouping through Intl, e.g. 1,25 Mio. in German, 12.35L (lakh) in Indian English or ١٫٢٥ مليون in Egyptian Arabic; without one, 1.25M.
Parameters
value
number
Returns
string
date()
date(
wall,fields):string
Defined in: packages/core/src/util/locale.ts:265
Format a wall-clock Date (its UTC fields hold the chart-timezone time, as Zone.date returns) with Intl fields in this locale.
Parameters
wall
Date
fields
DateTimeFormatOptions
Returns
string
dateTime()
dateTime(
wall,dateOnly,seconds?):string
Defined in: packages/core/src/util/locale.ts:278
The full date of the crosshair label (see dateFormat), with the time (and its seconds with seconds) unless dateOnly. ISO 8601 (2026-10-16 14:30) while dates do not go through Intl.
Parameters
wall
Date
dateOnly
boolean
seconds?
boolean
Returns
string
delocalize()
delocalize(
text):string
Defined in: packages/core/src/util/locale.ts:255
The reverse of localize, for parsing what a user typed.
Parameters
text
string
Returns
string
localize()
localize(
text):string
Defined in: packages/core/src/util/locale.ts:253
Number text made with ASCII digits, . and - (e.g. by a price format), in this locale's digits, decimal mark and minus sign.
Parameters
text
string
Returns
string
monthShort()
monthShort(
wall):string
Defined in: packages/core/src/util/locale.ts:267
Short month name of a wall-clock date, e.g. Jan or janv..
Parameters
wall
Date
Returns
string
number()
number(
value,decimals):string
Defined in: packages/core/src/util/locale.ts:232
value with exactly decimals places and no grouping, e.g. 1234,50 in German or ١٢٣٤٫٥٠ in Egyptian Arabic.
Parameters
value
number
decimals
number
Returns
string
parseCompact()
parseCompact(
text):number
Defined in: packages/core/src/util/locale.ts:248
The reverse of compact, for parsing what a user typed: the locale's suffixes, digits and grouping, or a K, M, B or T suffix. NaN when the text is not an amount.
Parameters
text
string
Returns
number
percent()
percent(
value,decimals,signed?):string
Defined in: packages/core/src/util/locale.ts:236
value as a percentage with decimals places and the locale's percent sign; signed adds a + to positive values.
Parameters
value
number
decimals
number
signed?
boolean
Returns
string
price()
price(
value,decimals):string
Defined in: packages/core/src/util/locale.ts:234
A price with decimals places: number, with its digits grouped when the grouping option is on (1.234,50).
Parameters
value
number
decimals
number
Returns
string
priceFormat()
priceFormat(
model,custom?):PriceFormatModel
Defined in: packages/core/src/util/locale.ts:260
A price format whose text follows this locale, grouped when the grouping option is on (except a format with a unit); custom formats are returned as they are.
Parameters
model
custom?
boolean
Returns
text()
text(
key,params?,fallback?):string
Defined in: packages/core/src/util/locale.ts:230
The text for key with params filled in: translate, else messages, else fallback, else the built-in default, else the key itself.
Parameters
key
string
params?
Readonly<Record<string, string | number>>
fallback?
string
Returns
string
time()
time(
wall,seconds?):string
Defined in: packages/core/src/util/locale.ts:272
Hours and minutes of a wall-clock date in the hour cycle, e.g. 14:30 or 2:30 PM; with seconds, also the seconds.
Parameters
wall
Date
seconds?
boolean
Returns
string