API Docs for:
Show:

Array Class

Module: ChartUtils

Item Index

Methods

clear

(
  • [deepClear=false]
)
Array

Defined in chart_utils.js:336

Clears an Array, removing all its elements;

Parameters:

  • [deepClear=false] Boolean optional

    If it is required for all the array elements to be cleared, this paramenter should be true; can be omitted otherwise;
    If deep clearance is required, thie method will try to call the clear method for each and every element of this array (Object class has already been extended with a clear method).

Returns:

Array: This array.

map

(
  • f
  • [contest=window]
)
Array

Defined in chart_utils.js:363

Maps a function on every element of the array, creting a new array populated with the results of these calls.

Parameters:

  • f Function

    The function to map on the array;

  • [contest=window] Object optional

    The new this pointer for the function to map, if needed;

Returns:

Array: The array of the results of mapping f over the elements this array.

max

(
  • [extract_element_key]
)
Number | NaN

Defined in chart_utils.js:453

Return the maximum element of an array.

Parameters:

  • [extract_element_key] Object optional

    A function that, given any element of the array, will produce a numeric value used for ranking the element itself (its sorting key)

Returns:

Number | NaN: The maximum value in the array, if all elements (or their keys) are Number; NaN otherwise

min

(
  • [extract_element_key]
)
Number | NaN

Defined in chart_utils.js:474

Return the minimum element of an array.

Parameters:

  • [extract_element_key] Object optional

    A function that, given any element of the array, will produce a numeric value used for ranking the element itself (its sorting key)

Returns:

Number | NaN: The minimum value in the array, if all elements (or their keys) are Number; NaN otherwise

shallowCopy

(
  • [n]
)
Array

Defined in chart_utils.js:422

Creates a new array (shallow) copying the elements of the current one

Parameters:

  • [n] Object optional

    If defined, the max number of elements to copy from the current array

Returns:

Array: A new array, with a shallow copy of all the elements in the original one.

sum

() Number | String

Defined in chart_utils.js:393

Sums the elements of an array.

Returns:

Number | String: The sum of the elements in the array; WARNING:
  • If all the elements in the array are numbers, then returs their arithmetic sum
  • If any element of the array isn't a number, returns a string obtained by concatenating the partial arithmetic sum until that element, and the concatenation of the string conversion of every other element in the array.