Util

F2.Util

Methods

upperFirst([string=''])

Converts the first character of string to upper case.

Arguments

  • [string=''] (string): The string to convert.

Returns

(string): Returns the converted string.

Example

F2.Util.upperFirst('fred');
// => 'Fred'
 
F2.Util.upperFirst('FRED');
// => 'FRED

lowerFirst([string=''])

Converts the first character of string to lower case.

Arguments

  • [string=''] (string): The string to convert.

Returns

(string): Returns the converted string.

Example

isString(value)

Checks if value is classified as a String primitive or object.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is a string, else false.

Example

isNumber(value)

Checks if value is classified as a Number primitive or object.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is a number, else false.

Example

isBoolean(value)

Checks if value is classified as a boolean primitive or object.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is a boolean, else false.

Example

isFunction(value)

Checks if value is classified as a Function object.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is a function, else false.

Example

isPlainObject(value)

Checks if value is a plain object, that is, an object created by the Object constructor or one with a [[Prototype]] of null.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is a plain object, else false.

Example

isArray(value)

Checks if value is classified as an Array object.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is an array, else false.

Example

isDate(value)

Checks if value is classified as a Date object.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is a date object, else false.

Example

isNil(value)

Checks if value is null or undefined.

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is nullish, else false.

Example

isObject(value)

Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))

Arguments

  • value (*): The value to check.

Returns

(boolean): Returns true if value is an object, else false.

Example

mix(object, [sources])

Assigns own enumerable string keyed properties of source objects to the destination object. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.

Arguments

  1. object (Object): The destination object.

  2. [sources] (...Object): The source objects. Support for up to 3 objects

Returns

(Object): Returns object.

Example

deepMix(object, [sources])

This method is like F2.Util.mix except that it iterates over own source properties.

Arguments

  1. object (Object): The destination object.

  2. [sources] (...Object): The source objects.

Returns

(Object): Returns object.

Example

indexOf(array, value)

Gets the index at which the first occurrence of value is found in array.

Arguments

  1. array (Array): The array to inspect.

  2. value (*): The value to search for.

Returns

(number): Returns the index of the matched value, else -1.

Example

forEach(collection, [iteratee=_.identity])

Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false.

Arguments

  1. collection (Array|Object): The collection to iterate over.

  2. [iteratee=_.identity] (Function): The function invoked per iteration.

Returns

(*): Returns collection.

Example

getPixelRatio()

Get the current pixel ratio.

Returns

(number): Returns the current pixel ratio.

getRelativePosition(point, canvas)

Convert the position of the mouse to the relative coordinate of the canvas.

Arguments

  1. point (Object): the point need to convert.

  2. canvas (Canvas): the canvas instance of chart.

Returns

(object): Returns the relative coordinate of the canvas.

Example

Last updated