Skip to main content

Type Alias: NumberFormatterOptions

NumberFormatterOptions = object

Defined in: src/sdk/graphics/text/NumberFormatter.ts:6

Options for creating a number formatter.

Properties

cache?

optional cache: boolean

Defined in: src/sdk/graphics/text/NumberFormatter.ts:72

Whether to cache and reuse the previously generated string when possible. If a non-zero hysteresis value is specified, then this option is ignored because hysteresis always requires cached values to be used. Defaults to false.


forceDecimalZeroes?

optional forceDecimalZeroes: boolean

Defined in: src/sdk/graphics/text/NumberFormatter.ts:41

Whether to force trailing zeroes to the right of the decimal point. The number of trailing zeroes is determined by the precision option. Specifically, trailing zeroes are added to the least significant decimal place required to represent the value of precision (and therefore, any possible output rounded to precision) with no rounding. Defaults to true.


forceSign?

optional forceSign: boolean

Defined in: src/sdk/graphics/text/NumberFormatter.ts:53

Whether to force the display of a positive sign. Ignored if hideSign is true. Defaults to false.


hideSign?

optional hideSign: boolean

Defined in: src/sdk/graphics/text/NumberFormatter.ts:56

Whether to hide the display of the positive/negative sign. Overrides forceSign. Defaults to false.


hysteresis?

optional hysteresis: number | readonly [number, number]

Defined in: src/sdk/graphics/text/NumberFormatter.ts:24

The hysteresis to apply to the formatter. If defined as a [number, number] tuple, then the first number in the tuple is taken as the lower hysteresis and second number as the upper hysteresis. If defined as a single number, then that is taken as both the lower and upper hysteresis. Negative values are clamped to zero.

When a previously formatted string exists, any new input number (x) is compared to the precision-rounded value of the previously formatted string (x0). Define x1 as the least number that can be rounded to x0 and x2 as the greatest number that can be rounded to x0. Then the formatter returns a newly formatted string for x if and only if x < x1 - h1 or x > x2 + h2, where h1 and h2 are the lower and upper hysteresis values, respectively. Otherwise, the formatter returns the previously formatted string.


maxDigits?

optional maxDigits: number

Defined in: src/sdk/graphics/text/NumberFormatter.ts:33

The maximum number of digits to enforce. Digits to the right of the decimal point will be omitted (with proper rounding behavior) as necessary until the total number of digits in the output is less than or equal to the value of this option or until there are no more digits to omit. Digits to the left of the decimal point are always preserved, even if it means the number of digits in the output will exceed the value of this option. Defaults to Infinity.


nanString?

optional nanString: string

Defined in: src/sdk/graphics/text/NumberFormatter.ts:59

The string to output for an input of NaN. Defaults to 'NaN'.


negInfinityString?

optional negInfinityString: string

Defined in: src/sdk/graphics/text/NumberFormatter.ts:65

The string to output for an input of -Infinity. Defaults to '-Infinity'.


pad?

optional pad: number

Defined in: src/sdk/graphics/text/NumberFormatter.ts:44

The number of digits to which to pad with zeroes to the left of the decimal point. Defaults to 1.


posInfinityString?

optional posInfinityString: string

Defined in: src/sdk/graphics/text/NumberFormatter.ts:62

The string to output for an input of Infinity. Defaults to 'Infinity'.


precision?

optional precision: number

Defined in: src/sdk/graphics/text/NumberFormatter.ts:8

The precision to which to round the number. A value of 0 denotes no rounding. Defaults to 0.


round?

optional round: Rounding

Defined in: src/sdk/graphics/text/NumberFormatter.ts:11

Rounding behavior. Defaults to Rounding.Nearest.


showCommas?

optional showCommas: boolean

Defined in: src/sdk/graphics/text/NumberFormatter.ts:47

Whether to show commas. Defaults to false.


useMinusSign?

optional useMinusSign: boolean

Defined in: src/sdk/graphics/text/NumberFormatter.ts:50

Whether to use a minus sign () in place of a dash (-) in front of negative numbers. Defaults to false.