import type { Language } from "./Language"; import { Entity, IEntitySettings, IEntityPrivate } from "./Entity"; /** * @ignore */ export interface INumberSuffix { number: number; suffix: string; } export interface INumberFormatterSettings extends IEntitySettings { /** * Format used when no other format is given: a format string, or options * for `Intl.NumberFormat`. * * @default "#,###.#####" */ numberFormat?: string | Intl.NumberFormatOptions; /** * Values below this use the negative part of the format (after the first * `|`), and a value equal to it the zero part (after the second `|`). The * minus sign still shows only for values below `0`. * * @default 0 */ negativeBase?: number; /** * Suffixes for big numbers and the values they stand for, such as `"M"` * for a million. Used by the `a` modifier of the number format. */ bigNumberPrefixes?: INumberSuffix[]; /** * Suffixes for small numbers and the values they stand for, such as `"m"` * for a thousandth. Used by the `a` modifier of the number format. */ smallNumberPrefixes?: INumberSuffix[]; /** * Numbers below this use `smallNumberPrefixes` with the `a` modifier; * others use `bigNumberPrefixes`. * * @default 1 */ smallNumberThreshold?: number; /** * Suffixes for data sizes and the byte counts they stand for, such as * `"KB"` for 1024. Used by the `b` modifier of the number format. */ bytePrefixes?: INumberSuffix[]; /** * Data fields that hold numbers. Text placeholders with these fields are * formatted as numbers even without `formatNumber()`. */ numericFields?: string[]; /** * Locale for formats given as `Intl.NumberFormat` options, such as * `"de-DE"`. The browser's locale if not set. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat} for more info */ intlLocales?: string; /** * Forces formatted numbers to read left to right, even in a right-to-left * layout. * * @default false * @since 5.3.13 */ forceLTR?: boolean; } export interface INumberFormatterPrivate extends IEntityPrivate { } /** * Formats numbers in labels, tooltips and other text. * * @see {@link https://www.amcharts.com/docs/v5/concepts/formatters/formatting-numbers/} for more info * @important */ export declare class NumberFormatter extends Entity { _settings: INumberFormatterSettings; _privateSettings: INumberFormatterPrivate; static className: string; static classNames: Array; protected _setDefaults(): void; _beforeChanged(): void; /** * Formats a number as a string. * * @param value Value to format * @param format Format string or `Intl.NumberFormat` options; `numberFormat` if not given * @param precision Minimum number of decimals, padded with zeros; ignored for a format with a modifier * @return Formatted number */ format(value: number | string, format?: string | Intl.NumberFormatOptions, precision?: number): string; /** * Parses supplied format into structured object which can be used to format * the number. * * @param format Format string, e.g. "#,###.00" * @param language Language * @ignore */ protected parseFormat(format: string, language: Language): any; /** * Applies parsed format to a numeric value. * * @param value Value * @param details Parsed format as returned by parseFormat() * @return Formatted number * @ignore */ protected applyFormat(value: number, details: any): string; protected applyPrefix(value: number, prefixes: any[], force?: boolean): any[]; /** * Replaces a double vertical bar (`||`) with a temporary placeholder. * * @ignore Exclude from docs * @param text Input text * @return Escaped text */ escape(text: string): string; /** * Replaces the placeholder with a single vertical bar (`|`). * * @ignore Exclude from docs * @param text Escaped text * @return Unescaped text */ unescape(text: string): string; } //# sourceMappingURL=NumberFormatter.d.ts.map