public class Area extends PathDataGenerator
Conceptually, the polygon is formed using two lines: the top line is formed using the x- and y1-accessor functions, and proceeds from left-to-right; the bottom line is added to this line, using the x- and y0-accessor functions, and proceeds from right-to-left. By setting the transform attribute to rotate the path element by 90 degrees, you can also generate vertical areas. By changing the interpolation, you can also generate splines and step functions.
The area generator is designed to work in conjunction with the line generator. For example, when producing an area chart, you might use an area generator with a fill style, and a line generator with a stroke style to emphasize the top edge of the area. Since the area generator is only used to set the d attribute, you can control the appearance of the area using standard SVG styles and attributes, such as fill.
To create streamgraphs (stacked area charts), use the stack layout. This layout sets the y0 attribute for each value in a series, which can be used from the y0- and y1-accessors. Note that each series must have the same number of values per series, and each value must have the same x-coordinate; if you have missing data or inconsistent x-coordinates per series, you must resample and interpolate your data before computing the stacked layout.
Modifier and Type | Class and Description |
---|---|
static class |
Area.InterpolationMode |
Modifier | Constructor and Description |
---|---|
protected |
Area() |
Modifier and Type | Method and Description |
---|---|
<T> String |
apply(T data)
Generate a piecewise linear area, as in an area chart.
|
<T> String |
apply(T data,
int index)
Generate a piecewise linear area, as in an area chart.
|
Line |
defined(DatumFunction<Boolean> callback)
FIXME: D3 bug ???
|
Area.InterpolationMode |
interpolate()
Returns the current interpolation mode.
|
Area |
interpolate(Area.InterpolationMode i)
Set the current interpolation mode.
|
double |
tension()
Returns the current tension
|
Area |
tension(double tension)
Sets the Cardinal spline interpolation tension to the specified number in
the range [0, 1].
|
Area |
x(DatumFunction<Double> callback)
Set the function used to compute x coordinates of points generated by
this area generator.
|
Area |
x(double d)
Set the x coordinates of points generated by this generator.
|
Area |
x0(DatumFunction<Double> callback) |
Area |
x0(double d)
Set the x0 coordinates of points generated by this generator.
|
Area |
x1(DatumFunction<Double> callback) |
Area |
x1(double d)
Set the x1 coordinates of points generated by this generator.
|
Area |
y(DatumFunction<Double> callback)
See
x(DatumFunction) . |
Area |
y(double d)
Set the y coordinates of points generated by this generator.
|
Area |
y0(DatumFunction<Double> callback)
See
y(DatumFunction) . |
Area |
y0(double d)
Set the y0 coordinates of points generated by this generator.
|
Area |
y1(DatumFunction<Double> callback)
See
y(DatumFunction) . |
Area |
y1(double d)
Set the y1 coordinates of points generated by this generator.
|
generate, generate, generate, generate
public final Area.InterpolationMode interpolate()
public final Area interpolate(Area.InterpolationMode i)
i
- the interpolation modepublic final Area x(DatumFunction<Double> callback)
The default accessor assumes that each input element is a two-element array of numbers.
datumFunction
- public final Area x(double d)
d
- public final Area x0(double d)
d
- public final Area x0(DatumFunction<Double> callback)
callback
- x(DatumFunction).
public final Area x1(double d)
d
- public final Area x1(DatumFunction<Double> callback)
callback
- x(DatumFunction).
public final Area y(double d)
d
- public final Area y0(double d)
d
- public final Area y1(double d)
d
- public final Area y(DatumFunction<Double> callback)
x(DatumFunction)
.
Note that, like most other graphics libraries, SVG uses the top-left corner as the origin and thus higher values of y are lower on the screen. For visualization we often want the origin in the bottom-left corner instead; one easy way to accomplish this is to invert the range of the y-scale by using range([h, 0]) instead of range([0, h]).
callback
- public final Area y0(DatumFunction<Double> callback)
y(DatumFunction)
.
Note that, like most other graphics libraries, SVG uses the top-left corner as the origin and thus higher values of y are lower on the screen. For visualization we often want the origin in the bottom-left corner instead; one easy way to accomplish this is to invert the range of the y-scale by using range([h, 0]) instead of range([0, h]).
callback
- public final Area y1(DatumFunction<Double> callback)
y(DatumFunction)
.
Note that, like most other graphics libraries, SVG uses the top-left corner as the origin and thus higher values of y are lower on the screen. For visualization we often want the origin in the bottom-left corner instead; one easy way to accomplish this is to invert the range of the y-scale by using range([h, 0]) instead of range([0, h]).
callback
- public final Line defined(DatumFunction<Boolean> callback)
The defined accessor can be used to define where the area is defined and undefined, which is typically useful in conjunction with missing data; the generated path data will automatically be broken into multiple distinct subpaths, skipping undefined data.
callback
- public final double tension()
public final Area tension(double tension)
The tension only affects the Cardinal interpolation modes:
Area.InterpolationMode.CARDINAL
,
Area.InterpolationMode.CARDINAL_OPEN
and
InterpolationMode#CARDINAL_CLOSED
.
The default tension is 0.7.
In some sense, this can be interpreted as the length of the tangent; 1 will yield all zero tangents, and 0 yields a Catmull-Rom spline.
tension
- the tension in the range [0, 1].public final <T> String apply(T data)
Data must be an array-like structure. the type of the array elements depends on the x and y functions. the default x and y functions assumes that each input element is a two-element array of numbers.
public final <T> String apply(T data, int index)
Data must be an array-like structure. the type of the array elements depends on the x and y functions. the default x and y functions assumes that each input element is a two-element array of numbers.
The index will be passed through to the line's accessor functions.
data
- index
- Copyright © 2015 gwt-d3. All rights reserved.