public abstract class PathDataGenerator extends com.google.gwt.core.client.JavaScriptObject implements IsFunction
PathDataGenerator
is an object containing information to simplify
the construction of the d
attribute for SVG path
element, allowing users to generate
complex shapes.
The d
attribute of SVG path
defines the path data, which is a mini-language of path
commands, such as moveto (M), lineto (L) and closepath (Z). PathDataGenerator
s are Javascript functions that
generate these commands.
From a Javascript point of view, a PathDataGenerator
is both an object containing properties and a function
that can be called to generate the path.
When passing the generator to the d
attribute of a path
selection, the function represented
by the generator is called for each datum of the selection data. The function takes the datum in argument and return
the path.
Each generator specifies a default way of using the datum to create the path, but generally speaking, the default
behaviour can be overriden by providing DatumFunction
for each generator attribute. Please refer to generator
subclass documention for more information.
Usage:
PathDataGenerator pathGenerator = ...
Selection g = D3.select("body").append("svg").append("g");
g.append("path").attr("d", pathGenerator);
Modifier | Constructor and Description |
---|---|
protected |
PathDataGenerator() |
Modifier and Type | Method and Description |
---|---|
String |
generate(double... data)
Alias for
generate(JavaScriptObject) . |
String |
generate(com.google.gwt.core.client.JavaScriptObject data)
Generate the path data as String using the given data object in argument.
|
String |
generate(com.google.gwt.core.client.JavaScriptObject data,
int index)
Generate the path data as String using the given data object in argument.
|
String |
generate(List<?> data)
Alias for
generate(JavaScriptObject) . |
public final String generate(com.google.gwt.core.client.JavaScriptObject data)
The data object must contains valid attributes for the corresponding generator to work (see each subclass documentation).
data
- an array of datapublic final String generate(List<?> data)
generate(JavaScriptObject)
.data
- the datapublic final String generate(double... data)
generate(JavaScriptObject)
.data
- an array of datapublic final String generate(com.google.gwt.core.client.JavaScriptObject data, int index)
The data object must contains valid attributes for the corresponding generator to work (see each subclass documentation).
Apply the function using the given object in argument.
The object argument must provide missing attributes expected by the path generator. For instance, if this path
generator is a Line
, the provided object could be an array of {x,y} objects. Please refer to subclass
documentation for more information.
data
- the array of dataindex
- an index to be passed to each accessor functionsCopyright © 2017 gwt-d3. All rights reserved.