Caplin Trader 4.7.1

Class: module:caplin/element/formatter/PercentFormatter

module:caplin/element/formatter/PercentFormatter

Constructor

new module:caplin/element/formatter/PercentFormatter()

Converts the number to a percentage.

PercentFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to "61.8%":

caplin.element.formatter.PercentFormatter.format(0.618, {dp:1})
Implements:

Methods

format(vValue, mAttributes) → {String}

Converts a decimal number to a percentage.
Parameters:
Name Type Description
vValue Variant the decimal number (String or Number type).
mAttributes Map the map of attributes.
Properties
Name Type Description
sf int the number of significant figures to apply.
dp int the number of decimal places to apply.
rounding int the number of decimal places to be rounded, omitting any trailing zeros.
Returns:
the number specified as a percentage.
Type
String