Util
F2.Util
Methods
upperFirst([string=''])
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
lowerFirst([string=''])
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)
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)
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)
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)
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)
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)
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)
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)
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)
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])
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
object
(Object): The destination object.[sources]
(...Object): The source objects. Support for up to 3 objects
Returns
(Object): Returns object
.
Example
deepMix(object, [sources])
deepMix(object, [sources])
This method is like F2.Util.mix
except that it iterates over own source properties.
Arguments
object
(Object): The destination object.[sources]
(...Object): The source objects.
Returns
(Object): Returns object
.
Example
indexOf(array, value)
indexOf(array, value)
Gets the index at which the first occurrence of value
is found in array
.
Arguments
array
(Array): The array to inspect.value
(*): The value to search for.
Returns
(number): Returns the index of the matched value, else -1
.
Example
forEach(collection, [iteratee=_.identity])
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
collection
(Array|Object): The collection to iterate over.[iteratee=_.identity]
(Function): The function invoked per iteration.
Returns
(*): Returns collection
.
Example
getPixelRatio()
getPixelRatio()
Get the current pixel ratio.
Returns
(number): Returns the current pixel ratio.
getRelativePosition(point, canvas)
getRelativePosition(point, canvas)
Convert the position of the mouse to the relative coordinate of the canvas.
Arguments
point
(Object): the point need to convert.canvas
(Canvas): the canvas instance of chart.
Returns
(object): Returns the relative coordinate of the canvas.
Example
Last updated