public class Axis extends com.google.gwt.core.client.JavaScriptObject implements IsFunction
Scale
s
automatically.
This lets you focus on displaying the data, while the axis component takes care of the tedious task of drawing axes and labeled ticks.
The axis component is designed to work with D3’s QuantitativeScale
,
TimeScale
and OrdinalScale
scales.
Modifier and Type | Class and Description |
---|---|
static class |
Axis.Orientation
Orientation of the ticks in relation to the axis.
|
Modifier | Constructor and Description |
---|---|
protected |
Axis() |
Modifier and Type | Method and Description |
---|---|
Axis |
apply(Selection selection)
Apply the axis to a selection.
|
Axis |
apply(Transition transition)
Apply the axis to a transition.
|
int |
innerTickSize() |
Axis |
innerTickSize(int innerTickSizeInPixels)
Sets the inner tick size to the specified value and returns the axis.
|
Axis.Orientation |
orient()
Returns the current orientation, which defaults to
Axis.Orientation.BOTTOM . |
Axis |
orient(Axis.Orientation o)
Sets the axis orientation and returns the axis.
|
int |
outerTickSize() |
Axis |
outerTickSize(int outerTickSizeInPixels)
Sets the outer tick size to the specified value and returns the axis.
|
<S extends Scale<S>> |
scale()
Return the associated scale, which defaults to a linear scale.
|
<S extends Scale<S>> |
scale(S s)
Set the associated scale.
|
Formatter |
tickFormat()
Returns the current format function, which defaults to null.
|
Axis |
tickFormat(DatumFunction<String> formatFunction)
Set the function to be used to format tick values.
|
Axis |
tickFormat(Formatter format)
Override the tick formatting for labels.
|
int |
tickPadding()
Returns the current padding which defaults to 3 pixels
|
Axis |
tickPadding(int padding)
Sets the padding to the specified value in pixels and returns the axis.
|
Array<?> |
ticks()
Get the arguments that will be passed to the associated scale
Scale#ticks() method to compute the tick values. |
Axis |
ticks(int count)
Specify the argument that will be passed to the associated scale
Scale#ticks() method to compute the tick values. |
Axis |
ticks(int count,
DatumFunction<String> formatSpecifier)
Same as
ticks(int) but suitable for
LogScale.tickFormat(int, DatumFunction) . |
Axis |
ticks(Interval interval,
int steps)
Same as
ticks(int) but suitable for
TimeScale.ticks(Interval, int) . |
Axis |
ticks(int count,
String formatSpecifier)
Same as
ticks(int) but suitable for
LogScale.tickFormat(int, String) . |
int |
tickSize() |
Axis |
tickSize(int outerInnerTickSizeInPixels)
Sets the outer and inner ticks to the specified value.
|
Axis |
tickSize(int majorMinor,
int end)
Deprecated.
|
Axis |
tickSize(int major,
int minor,
int end)
Deprecated.
|
int |
tickSubdivide()
Deprecated.
this method has no effect anymore !
|
Axis |
tickSubdivide(int count)
Deprecated.
this method has no effect anymore ! use
|
Array<?> |
tickValues()
Return the currently-set tick values, which defaults to null.
|
Axis |
tickValues(double... values)
Alias for
tickValues(JavaScriptObject) . |
Axis |
tickValues(com.google.gwt.core.client.JavaScriptObject values)
Specify the values to be used for ticks, rather than using the scale's
automatic tick generator.
|
Axis |
tickValues(List<?> values)
Alias for
tickValues(JavaScriptObject) . |
Axis |
tickValues(String... values)
* Alias for
tickValues(JavaScriptObject) . |
public final <S extends Scale<S>> S scale()
public final <S extends Scale<S>> Axis scale(S s)
the
- scale.public final Axis.Orientation orient()
Axis.Orientation.BOTTOM
.
orient(Orientation)
public final Axis orient(Axis.Orientation o)
The orientation of an axis is the position of the ticks and their labels in relation to the axis path.
For a vertical axis, specify Axis.Orientation.LEFT
or
Axis.Orientation.RIGHT
; for a horizontal axis, specify
Axis.Orientation.TOP
or Axis.Orientation.BOTTOM
.
If instead you want to determine the position of the axis with respect to the plot, use the transform attribute.
o
- the orientationpublic final Array<?> ticks()
Scale#ticks()
method to compute the tick values.count
- public final Axis ticks(int count)
Scale#ticks()
method to compute the tick values. This version
specify the desired tick count.
The count parameter is also passed to the
Scale#tickFormat(int, String)
method to generate the default tick
format.
This version suits for LinearScale
and LogScale
.
count
- the argument to be passed to the underlying scale.public final Axis ticks(int count, String formatSpecifier)
ticks(int)
but suitable for
LogScale.tickFormat(int, String)
.count
- the count to be passed to the underlying scale.formatSpecifier
- the format argument to be passed to the underlying scale.public final Axis ticks(int count, DatumFunction<String> formatSpecifier)
ticks(int)
but suitable for
LogScale.tickFormat(int, DatumFunction)
.count
- the count to be passed to the underlying scale.formatSpecifier
- the format argument to be passed to the underlying scale.public final Axis ticks(Interval interval, int steps)
ticks(int)
but suitable for
TimeScale.ticks(Interval, int)
.interval
- the time interval to be passed to the underlying scale.steps
- the steps argument to be passed to the underlying scale.public final int tickSize()
public final Axis tickSize(int outerInnerTickSizeInPixels)
outerInnerTickSizeInPixels
- the tick size in pixelspublic final Axis innerTickSize(int innerTickSizeInPixels)
The inner tick size controls the length of the tick lines, offset from the native position of the axis.
innerTickSizeInPixels
- the new valuepublic final int innerTickSize()
public final Axis outerTickSize(int outerTickSizeInPixels)
The outer tick size controls the length of the square ends of the domain path, offset from the native position of the axis.
Thus, the “outer ticks” are not actually ticks but part of the domain path, and their position is determined by the associated scale's domain extent.
Thus, outer ticks may overlap with the first or last inner tick. An outer tick size of 0 suppresses the square ends of the domain path, instead producing a straight line.
outerTickSizeInPixels
- the new valuepublic final int outerTickSize()
@Deprecated public final Axis tickSize(int majorMinor, int end)
majorMinor
- the new value for major and minor ticksend
- the new end value@Deprecated public final Axis tickSize(int major, int minor, int end)
majorMinor
- the new value for major and minor ticksend
- the new end value@Deprecated public final int tickSubdivide()
@Deprecated public final Axis tickSubdivide(int count)
Sets the number of uniform subdivision ticks to make between major tick marks. The specified count specifies the number of minor ticks, which is one less than the number of subdivisions.
For example, axis.tickSubdivide(1) produces one minor tick per major tick, thus cutting the space between each major tick in two. As another example, decimal subdivision is specified as axis.tickSubdivide(9).
count
- the tick subdivision countpublic final int tickPadding()
public final Axis tickPadding(int padding)
padding
- the padding in pixelspublic final Axis apply(Selection selection)
The selection must contain an SVG or G element.
selection
- the selection to apply the axis topublic final Axis apply(Transition transition)
The transition must contain an SVG or G element.
transition
- the transition to apply the axis topublic final Axis tickFormat(Formatter format)
format
- the tick value formatter for labels.public final Axis tickFormat(DatumFunction<String> formatFunction)
This method can be used for example to add prefix or suffix to the result
of a Formatter.format(double)
method.
Note: the given function of context argument will be null instance, and the index will be -1.
formatFunction
- the function converting each tick value to a String.Axis
public final Formatter tickFormat()
Scale
's default formatter should be
used, which is generated by calling Scale#tickFormat(int)
. In
this case, the arguments specified by ticks are likewise passed to scale
tickFormat.format
- the tick value formatter for labels.public final Array<?> tickValues()
public final Axis tickValues(com.google.gwt.core.client.JavaScriptObject values)
If values is null, clears any previously-set explicit tick values, reverting back to the scale's tick generator.
The explicit tick values take precedent over the tick arguments set by axis.ticks. However, any tick arguments will still be passed to the scale's tickFormat function if a tick format is not also set; thus, it may be valid to set both axis.ticks and axis.tickValues.
values
- the values to be used for tickspublic final Axis tickValues(double... values)
tickValues(JavaScriptObject)
.values
- the valuespublic final Axis tickValues(String... values)
tickValues(JavaScriptObject)
.values
- the valuespublic final Axis tickValues(List<?> values)
tickValues(JavaScriptObject)
.values
- the valuesCopyright © 2015 gwt-d3. All rights reserved.