API Docs for:
Show:

ChartUtils Class

Module: ChartUtils

Methods

abbreviateNumber

(
  • value
  • n
)
Array

Defined in chart_utils.js:620

Takes a value and returns it's abbreviated text representation.

  • If abs(val) > 1, the following standard abbreviations will be used:
    • K thousands
    • M million
    • G billion
    • T trillion
    • P quadrillion
    • E quintillion
    One decimal place is always kept.
    F.i.:
    • 123 -> "123"
    • 1234 -> "1.2K"
    • 12345 -> "12.3K"
    • 123456789 -> "123.4M"
  • If abs(val)


WARNING: since shallow copy is used, only works for primitive (immutable) values

Parameters:

  • value String | Number

    The value to assign to each element of the newly created array. If value is a function, it is called n times, with no parameters

  • n Number

    The size of the final array;
    Must be a positive integer.

Returns:

Array: The newly created array.

addIntToTimeString

(
  • timeString
  • minutes
)
String

Defined in chart_utils.js:785

Takes a string and an int value and checks if it is a valid time representation, according to the format HH:MM

Parameters:

  • timeString String

    The time string taken as initial time

  • minutes Number

    How many minutes needs to be added to the time string;

Returns:

String: A string representation of the sum of the two time values, in the format HH:MM (modulo 24 hours) <=> Both inputs validates successfully

addTimeStrings

(
  • timeString_1
  • timeString_2
)
String

Defined in chart_utils.js:752

Takes two strings as input and checks if they are valid time representations, according to the format HH:MM
If it is so, sums them and returns a new string representing the resulting time;

Parameters:

  • timeString_1 String

    The first time string to be added

  • timeString_2 String

    The second time string to be added

Returns:

String: A string representation of the sum of the two timeStamps, in the format HH:MM (modulo 24 hours) <=> Both strings validates successfully

fillArray

(
  • value
  • n
)
Array

Defined in chart_utils.js:692

Takes a value and a positive integer n and returns an Array of n copies of that value.

WARNING: since shallow copy is used, only works for primitive (immutable) values

Parameters:

  • value String | Number

    The value to assign to each element of the newly created array. If value is a function, it is called n times, with no parameters

  • n Number

    The size of the final array;
    Must be a positive integer.

Returns:

Array: The newly created array.

formatTimeString

(
  • HH
  • MM
)
String private

Defined in chart_utils.js:587

Format a hours, minutes couple into a proper time string

INVARIANT: HH and MM must be valid, positive integers (since it's a private method, defensive programming is avoided
If the overcome their range, proper formatting is enforced: F.i. HH=23, MM=60 -> "00:00"

Parameters:

  • HH Number

    An int value (between 0 and 23), representing the hours

  • MM Number

    An int value (between 0 and 59), representing the minutes

Returns:

String: The properly formatted time string.

validateTimeString

(
  • timeString
)
Array | Null

Defined in chart_utils.js:726

Takes a string as input and checks if it is a valid time representation, according to the format HH:MM

Parameters:

  • timeString String

    The string to be evaluated

Returns:

Array | Null:
  • An array with two integers, the values for hours and minutes <=> The input string validates successfully
  • null Otherwise

Properties

SUFFIXES

Array private final

Defined in chart_utils.js:608

Abbreviations suffixes for large numbers;