|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph2.Series
org.faceless.graph2.GeneralBarSeries
public abstract class GeneralBarSeries
The superclass for all types of series that involve plotting Bars to an AxesGraph
.
Bars can be plotted against any type of axis, but generally a BarAxis
will be used
on the "x" axis (this is the default if none is specified).
When plotting bars representing dates against a DateAxis
, care must be taken to
make sure the names of the bars match up against the values plotted on the axis, otherwise
bars will go missing. For example, the first two values in this bar series will not appear
on the graph:
DateAxis axis = new DateAxis(new SimpleDateFormat("yyyy-MM-dd")); axesgraph.setAxis(Axis.BOTTOM, axis); BarSeries series = new BarSeries("dates"); series.add("21 March 2004"); // Wrong series.add("2004-03-22 00:00"); // Wrong series.add("2004-03-23"); // Right! axesgraph.addSeries(series);How much of a date each bar represents is determined by the format being used. In the example above each bar is assumed to represent one day (because the format used on the axis can only represent a day). Had we used the line
DateAxis axis = new DateAxis(new SimpleDateFormat("yyyy-MM-dd HH:MM"));then each bar would represent one minute of time. If you want a bar to represent one hour, but still want to display the minutes on the axis, you could do something like this:
DateAxis axis = new DateAxis(new SimpleDateFormat("yyyy-MM-dd HH:00"));
DateAxis.setBarsAtNoon(boolean)
Method Summary | |
---|---|
void |
addMarker(AbstractMarker marker,
String x,
double y)
Add a Marker to this Series. |
void |
setBarDepth(double depth)
Set the depth of each bar. |
void |
setBarLabels(TextStyle style,
NumberFormat format)
Set a label on each bar. |
void |
setBarWidth(double width)
Set the width of each bar. |
void |
setBarWidth(double topwidth,
double bottomwidth)
Set the width of each bar. |
void |
setBarWidth(double topwidth,
double middlewidth,
double bottomwidth)
Set the width of each bar. |
void |
setRoundBars(boolean round)
This method has been replaced with the more flexible setRoundBars(double) . |
void |
setRoundBars(double size)
By default bars are drawn as boxes, but by passing a non-zero value to this method you can draw your bars as cylinders for a slightly different effect - although as this generates more polygons it will result in longer processing time and (for vector output formats like SVG or PDF), a bigger file. |
void |
setStyle(String name,
Style style)
Set the style to use for a specific bar. |
Methods inherited from class org.faceless.graph2.Series |
---|
addBox, addLine, addMarker, getName, outputToSeries, outputToSeriesFunction, setStyle, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public void setStyle(String name, Style style)
name
- the name of the barstyle
- the style to paint the bar inpublic void setBarWidth(double width)
setBarWidth(double)
and setBarDepth(double)
methods control how
much of that square is filled. The default width and depth are both 1,
ie. the whole square is used.
width
- the width of the bar - must be 0 < width <= 1public void setBarWidth(double topwidth, double bottomwidth)
setBarWidth(double)
, but this method
allows you to "taper" the bar to be wider at the top or bottom. This method is
used to draw pyramids instead of regular bar charts.
All values must be between 0 and 1 inclusive.
topwidth
- the width of the bar at the topbottomwidth
- the width of the bar at the bottompublic void setBarWidth(double topwidth, double middlewidth, double bottomwidth)
setBarWidth(double)
, but this method
allows you to "taper" the bar to be wider at the top or bottom with a middle "waist".
This method is used to draw "funnels" instead of regular bar charts.
All values must be between 0 and 1 inclusive.
topwidth
- the width of the bar at the topmiddlewidth
- the width of the bar at the middlebottomwidth
- the width of the bar at the bottompublic void setBarDepth(double depth)
setBarWidth(double)
and setBarDepth(double)
methods control how
much of that square is filled. The default width and depth are both 1,
ie. the whole square is used.
depth
- the depth of the bar - must be 0 < depth <= 1public void setRoundBars(boolean round)
setRoundBars(double)
.
Passing true to this method is identical to calling setRoundBars(5)
.
round
- whether to draw round bars or notpublic void setRoundBars(double size)
size
- the size of each edge in the polygon that is the bar - 0, or between 0.5 and 120public void setBarLabels(TextStyle style, NumberFormat format)
NumberFormat
to format the value.
If this isn't flexible enough, the addMarker(org.faceless.graph2.AbstractMarker, java.lang.String, double)
method can be used to
add a Text
with a custom label anywhere you like.
style
- the style to draw the label in. Remember the
setAlign
and setPadding
methods can be used for fine control of position.format
- how to format the value for displaypublic void addMarker(AbstractMarker marker, String x, double y)
Marker
to this Series.
marker
- the Marker to addx
- the X co-ordinate to place the marker at as a Stringy
- the Y co-ordinate to place the marker at
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |