|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph2.Axis
org.faceless.graph2.BarAxis
public class BarAxis
A subclass of Axis
useful for plotting Bar Series. A BarAxis works the same
way as a regular axis - it formats and plots a range of numbers along a spine.
The difference is that in this case, the BarAxis formats those numbers as Strings.
It does this because internally, each bar added to the graph is stored as a number -
the first bar is "0", the second is "1" and so on. So, for example:
Axesgraph graph = new AxesGraph(); BarSeries series = new BarSeries("Fruit"); series.set("Apples", 10); series.set("Bananas", 15); series.set("Carrots", 8); graph.addSeries(AxesGraph.BOTTOMLEFT, s);Will result in the graph having a BarAxis along the bottom which will plot values from 0 to 2, formatting 0 as "Apples", 1 as "Bananas" and 2 as "Carrots". This order can be overridden by calling the
setOrder(java.util.List)
method if required.
Field Summary |
---|
Fields inherited from class org.faceless.graph2.Axis |
---|
BOTTOM, DENSITY_MINIMAL, DENSITY_NORMAL, DENSITY_SPARSE, LEFT, RIGHT, TOP, ZAXIS |
Constructor Summary | |
---|---|
BarAxis()
Create a new BarAxis |
|
BarAxis(List labels)
Create a new BarAxis with the specified labels. |
|
BarAxis(String[] labels)
Create a new BarAxis with the specified labels. |
Method Summary | |
---|---|
String |
format(double in)
Given the specified number, return the text that should be placed against the tooth at that position. |
void |
setOrder(List list)
Set the order of the keys on the axis. |
double[] |
steps(double min,
double max)
The steps method controls where the teeth are placed on the spine. |
Methods inherited from class org.faceless.graph2.Axis |
---|
setLabel, setMaxValue, setMinValue, setSpineStyle, setToothLength, setToothTextStyle, setWallPaint, setWallPaint, setZeroIntersection, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BarAxis()
public BarAxis(String[] labels)
labels
- the list of labels to use on the axispublic BarAxis(List labels)
labels
- the list of labels to use on the axisMethod Detail |
---|
public void setOrder(List list)
an
- IllegalArgumentException if there are any duplicate entries in the list,
or if the list is null
public String format(double in)
Axis
Given the specified number, return the text that should be placed against the
tooth at that position. For example, an Axis that simply plotted integer
values might return Integer.toString((int)in)
Those wanting to create their own custom axis will typically override this
method and Axis.steps(double, double)
.
format
in class Axis
in
- the value to format
public double[] steps(double min, double max)
Axis
The steps
method controls where the teeth are placed on the spine.
Each subclass of Axis has a different strategy - for instance, the
DateAxis
will try and place ticks on the 1st of the month, the
NumericAxis
will try and place them evenly across the range and so on.
The returned array should consist of a range of numbers, ordered from low to high,
which mark the locations of the teeth on the spine. min
and max
are the minimum and maximum values of the data to plot, and these values will usually
be the first and last values in the returned array.
Those wanting to create their own custom axis will typically override this method and
Axis.format(double)
.
steps
in class Axis
min
- the minimum value of the data to plotmax
- the maximum value of the data to plot
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |