Helper Functions & Variables (utils)
The utils
object provides some helper functions and variables for the Visualizer.
Available methods are the following:
Name | Description |
---|---|
round (fn) | Round a number to two decimal places. Takes one number. |
formatNumber (fn) | To format numbers, like converting 123456 to 123,456. Takes one number. |
abbreviateNumber (fn) | To convert numbers to a shorter version, like converting 123456 to 123.4k. Takes one number. |
daysBetween (fn) | Get the number of days between two dates. Takes t wo dates, where the first should be older than the second. |
parseJSON (fn) | Just a try/catch wrapper around JSON.parse |
stringifyJSON (fn) | Just a try/catch wrapper around JSON.stringify |
Available variables are the following:
Name | Description |
---|---|
monthsNames | Short month names starting on Jan |
monthsFullNames | Full month names starting on January |
lastYearMonths | Short month names starting a year ago |
lastYearFullMonths | Full month names starting a year ago |
lastYearMonthsObjs | An array of objects contains (short name, full name, year) about months starting a year ago |