Caplin Trader 5.1.0

Class: module:ct-element/formatter/AmountFormatter

module:ct-element/formatter/AmountFormatter()

new module:ct-element/formatter/AmountFormatter()

Formats a number into an amount with a thousands, millions or billions token.

AmountFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to '1.23456789B' and '1.230B' respectively:

AmountFormatter.format(1234567890, {}) AmountFormatter.format(1234567890, {dp: 4})
Implements:

Methods

format(value, attributes) → {String}

Formats a number into an amount with a thousands, millions or billions token.

Parameters:
Name Type Description
value Variant

the numeric amount (String or Number type).

attributes Map

a list of attributes, as specified here and in module:ct-element/formatter/RoundingFormatter.

Properties
Name Type Attributes Default Description
thousands String <optional>
'K'

token representing thousands

millions String <optional>
'M'

token representing millions

billions String <optional>
'B'

token representing billions

Implements:
Returns:

the tokenized amount.

Type
String