Dashboards utilities
There was once a time when we needed to add libraries as external resources to leverage the process of formatting dates and numbers. Nowadays, it is possible to do the formatting without the need to include external files. We can do the formatting just by including the cfd/dashboard/Utils
module. This will make require
load all the dependencies without any more effort.
Formatting numbers
Numbers can be formatted to look like currency, percentages with decimal places, thousands, and abbreviations. To format numbers, you should use the function numberFormat
, available in the dashboard object. In our examples, you could do this by calling Utils.numberFormat(value[, format[, langCode]])
. The function accepts the arguments; the first one is the value to format, the second one is the format mask, and the last is the language and locale to use when formatting the number.
The mask or format argument is a string made up of symbols that shows how to format the number. The most commonly...