Skip to main content

Helper Functions & Variables (utils)

The utils object provides some helper functions and variables for the Visualizer. Available methods are the following:

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:

monthsNamesShort month names starting on Jan
monthsFullNamesFull month names starting on January
lastYearMonthsShort month names starting a year ago
lastYearFullMonthsFull month names starting a year ago
lastYearMonthsObjsAn array of objects contains (short name, full name, year) about months starting a year ago