S
- the subclass of scalepublic abstract class Scale<S extends Scale<S>>
extends com.google.gwt.core.client.JavaScriptObject
Scales are functions that map from an input domain to an output range. There are 2 kinds of scales:
Scales are an optional feature in D3; you don't have to use them, if you prefer to do the math yourself. However, using scales can greatly simplify the code needed to map a dimension of data to a visual representation.
Modifier | Constructor and Description |
---|---|
protected |
Scale() |
Modifier and Type | Method and Description |
---|---|
Value |
apply(double d)
Given a value x in the input domain, returns the corresponding value in
the output range.
|
Value |
apply(com.google.gwt.core.client.JavaScriptObject d)
Given a value x in the input domain, returns the corresponding value in
the output range.
|
Value |
apply(String d)
Given a value x in the input domain, returns the corresponding value in
the output range.
|
S |
copy()
Returns an exact copy of this scale.
|
<T> Array<T> |
domain()
Returns the current scale's input domain.
|
S |
domain(double... numbers)
Sets the scale's input domain to the specified array of numbers.
|
S |
domain(com.google.gwt.core.client.JavaScriptObject array)
Sets the scale's input domain to the specified array.
|
S |
domain(String... strings)
Sets the scale's input domain to the specified array of strings.
|
<T> Array<T> |
range()
Return the current output range of this scale.
|
S |
range(double... numbers)
Set the scale's output range.
|
S |
range(com.google.gwt.core.client.JavaScriptObject array)
Set the scale's output range.
|
S |
range(String... strings)
Set the scale's output range.
|
public final S domain(double... numbers)
numbers
- the array of numberspublic final S domain(String... strings)
strings
- the array of stringspublic final S domain(com.google.gwt.core.client.JavaScriptObject array)
strings
- the arraypublic final <T> Array<T> domain()
public final S range(double... numbers)
Scale subclasses may interpret the output range differently. Please refer to subclass documentation.
numbers
- the array of values.public final S range(String... strings)
Scale subclasses may interpret the output range differently. Please refer to subclass documentation.
strings
- the array of values.public final S range(com.google.gwt.core.client.JavaScriptObject array)
Scale subclasses may interpret the output range differently. Please refer to subclass documentation.
array
- the array of values.public final <T> Array<T> range()
public final S copy()
Changes to this scale will not affect the returned scale, and vice versa.
public final Value apply(com.google.gwt.core.client.JavaScriptObject d)
Note: some Interpolator
s reuse return values. For example, if the domain values are arbitrary objects,
then D3#interpolateObject(JavaScriptObject, JavaScriptObject)
is automatically applied and the scale
reuses the returned object.
Often, the return value of a scale is immediately used to set an attribute or style, and you don’t have to worry about this; however, if you need to store the scale’s return value, use string coercion or create a copy as appropriate.
d
- the input valuepublic final Value apply(double d)
Note: some Interpolator
s reuse return values. For example, if the domain values are arbitrary objects,
then D3#interpolateObject(JavaScriptObject, JavaScriptObject)
is automatically applied and the scale
reuses the returned object.
Often, the return value of a scale is immediately used to set an attribute or style, and you don’t have to worry about this; however, if you need to store the scale’s return value, use string coercion or create a copy as appropriate.
d
- the input valuepublic final Value apply(String d)
Note: some Interpolator
s reuse return values. For example, if the domain values are arbitrary objects,
then D3#interpolateObject(JavaScriptObject, JavaScriptObject)
is automatically applied and the scale
reuses the returned object.
Often, the return value of a scale is immediately used to set an attribute or style, and you don’t have to worry about this; however, if you need to store the scale’s return value, use string coercion or create a copy as appropriate.
d
- the input valueCopyright © 2015 gwt-d3. All rights reserved.