NumberFormatter
Formats numeric values according to specified patterns.Constructor
Root element instance
Configuration options
Settings
numberFormat
Number format to be used when formatting numbers. Can be a format string or Intl.NumberFormatOptions object.
negativeBase
A threshold value for negative numbers.
bigNumberPrefixes
Prefixes and thresholds to group big numbers into (e.g., 1M for 1,000,000). Used with the
a modifier.smallNumberPrefixes
Prefixes and thresholds to group small numbers into (e.g., 1m for 0.001). Used with the
a modifier.smallNumberThreshold
All numbers below this value are considered small.
bytePrefixes
Prefixes and thresholds for grouping data size numbers (e.g., 1MB). Used with the
b modifier.numericFields
Indicates which fields in data should be considered numeric for placeholder formatting.
intlLocales
Locales if using Intl.NumberFormatOptions syntax.
forceLTR
If true, forces the number string to be LTR even if RTL is enabled.
Methods
format()
Value to format
Format to apply (uses default if not specified)
Number of decimal places
Formatted number string
Format Syntax
The format string uses special characters:#- Optional digit0- Required digit,- Thousands separator.- Decimal separatora- Abbreviated notation (K, M, B)b- Byte notation (KB, MB, GB)%- Multiply by 100 and add percent sign‰- Multiply by 1000 and add per mille signe- Scientific notations- Suppress negative signp- Percentage (no multiplication)!- Force prefix on small numbers
DateFormatter
Formats Date objects into strings.Constructor
Root element instance
Configuration options
Settings
dateFormat
A date format to be used when formatting dates.
dateFields
Array of data fields that hold date values and should be formatted with DateFormatter.
capitalize
Should the first letter of the formatted date be capitalized?
intlLocales
Locales to use when formatting using Intl.DateFormatter.
Methods
format()
Date to format
Output format (uses default if not specified)
Ignore timezone when formatting
Formatted date string
parse()
String to parse
Format of the source string
Parse as UTC
Parsed Date object
Format Syntax
The format string uses special tokens: Year:yyyy- Full year (2024)yy- Two-digit year (24)y- Year with any number of digits
MMMM- Full month name (January)MMM- Short month name (Jan)MM- Two-digit month (01)M- Month (1)
dd- Two-digit day (05)d- Day (5)DDD- Day of year with leading zeros (065)D- Day of year (65)
EEEE- Full weekday name (Monday)EEE- Short weekday name (Mon)EE- Two-digit weekday (01)E- Weekday number (1)
HH- Two-digit 24-hour (14)H- 24-hour (14)hh- Two-digit 12-hour (02)h- 12-hour (2)mm- Two-digit minutes (05)m- Minutes (5)ss- Two-digit seconds (09)s- Seconds (9)SSS- Milliseconds (123)a- AM/PMaa- A.M./P.M.
ww- Week of year with leading zero (05)w- Week of year (5)
Z- Timezone offset (GMT-05:00)ZZ- Timezone offset (-0500)
DurationFormatter
Formats numeric values as time durations.Constructor
Root element instance
Configuration options
Settings
durationFormat
A universal duration format to use wherever number needs to be formatted as a duration.
baseUnit
Identifies what values are used in duration. Available options:
"millisecond", "second", "minute", "hour", "day", "week", "month", "year".negativeBase
A base value. Any number below it will be considered negative.
durationFormats
Time unit dependent duration formats. Used by DurationAxis.
durationFields
Array of data fields that hold duration values and should be formatted with DurationFormatter.
Methods
format()
Value to format
Format to apply
Override base unit
Formatted duration string
getFormat()
Value to format
Maximum value to determine time unit
Base unit of the value
Format string
toTimeStamp()
Source value
Base unit the source value is in
Value as timestamp in milliseconds
getMilliseconds()
Source duration value
Base unit
Value in milliseconds
getValueUnit()
"minute", while 59 seconds would still be "second".
Source duration value
Base unit
Denominator time unit
Format Syntax
The format string uses special tokens:y- YearsM- Monthsd- Daysw- Weeksh- Hoursm- Minutess- SecondsS- Millisecondsa- Absolute value modifier