Methods
-
<static> add(l, r [, t])
-
Arbitrary add one value to another.
If the value l is of type Date, adds r units to it. t becomes the unit. For example dc.utils.add(dt, 3, 'week') will add 3 (r = 3) weeks (t= 'week') to dt.
If l is of type numeric, t is ignored. In this case if r is of type string, it is assumed to be percentage (whether or not it includes %). For example dc.utils.add(30, 10) will give 40 and dc.utils.add(30, '10') will give 33.
They also generate strange results if l is a string.
Parameters:
Name Type Argument Default Description l
Date | Number the value to modify
r
String | Number the amount by which to modify the value
t
function | String <optional>
d3.timeDay if
l
is aDate
, then this should be a d3 time interval. For backward compatibility with dc.js 2.0, it can also be the name of an interval, i.e. 'millis', 'second', 'minute', 'hour', 'day', 'week', 'month', or 'year'Returns:
- Type
- Date | Number
-
<static> appendOrSelect(parent, selector, tag)
-
Append or select an item on a parent element.
Parameters:
Name Type Description parent
d3.selection selector
String tag
String Returns:
- Type
- d3.selection
-
<static> arraysEqual(a1, a2)
-
Return true if both arrays are equal, if both array are null these are considered equal
Parameters:
Name Type Description a1
Array | null a2
Array | null Returns:
- Type
- Boolean
-
<static> clamp(val, min, max)
-
Ensure the value is no greater or less than the min/max values. If it is return the boundary value.
Parameters:
Name Type Description val
any min
any max
any Returns:
- Type
- any
-
<static> constant(x)
-
Given
x
, return a function that always returnsx
.d3.functor
was removed in d3 version 4. This function helps to implement the replacement,typeof x === "function" ? x : dc.utils.constant(x)
Parameters:
Name Type Description x
any Returns:
- Type
- function
-
<static> isFloat(n)
-
Is the value a float?
Parameters:
Name Type Description n
any Returns:
- Type
- Boolean
-
<static> isInteger(n)
-
Is the value an integer?
Parameters:
Name Type Description n
any Returns:
- Type
- Boolean
-
<static> isNegligible(n)
-
Is the value very close to zero?
Parameters:
Name Type Description n
any Returns:
- Type
- Boolean
-
<static> isNumber(n)
-
Is the value a number?
Parameters:
Name Type Description n
any Returns:
- Type
- Boolean
-
<static> nameToId(name)
-
Convert a name to an ID.
Parameters:
Name Type Description name
String Returns:
- Type
- String
-
<static> printSingleValue(filter)
-
Print a single value filter.
Parameters:
Name Type Description filter
any Returns:
- Type
- String
-
<static> safeNumber(n)
-
Return the number if the value is a number; else 0.
Parameters:
Name Type Description n
Number | any Returns:
- Type
- Number
-
<static> subtract(l, r [, t])
-
Arbitrary subtract one value from another.
If the value l is of type Date, subtracts r units from it. t becomes the unit. For example dc.utils.subtract(dt, 3, 'week') will subtract 3 (r = 3) weeks (t= 'week') from dt.
If l is of type numeric, t is ignored. In this case if r is of type string, it is assumed to be percentage (whether or not it includes %). For example dc.utils.subtract(30, 10) will give 20 and dc.utils.subtract(30, '10') will give 27.
They also generate strange results if l is a string.
Parameters:
Name Type Argument Default Description l
Date | Number the value to modify
r
String | Number the amount by which to modify the value
t
function | String <optional>
d3.timeDay if
l
is aDate
, then this should be a d3 time interval. For backward compatibility with dc.js 2.0, it can also be the name of an interval, i.e. 'millis', 'second', 'minute', 'hour', 'day', 'week', 'month', or 'year'Returns:
- Type
- Date | Number
-
<static> uniqueId()
-
Using a simple static counter, provide a unique integer id.
Returns:
- Type
- Number