The Series
class groups properties that are common to all of the data in a
series. For example, in a bar graph, all the bars in a series have the same color. The color
identifies the series of bars. The color of the markers is a series property.
In addition, you can limit the width of a bar in a bar graph, combination graph, or stock
graph, by setting the MaxBarWidth
property of the Graph
class.
The following table lists the properties that you set for individual series.
The methods for setting these properties take a series
argument,
which specifies the series to which the property value applies.
Property |
Description |
---|---|
|
The color of the border of the markers in the series |
|
Whether the border of the series is transparent |
|
The color that fills the markers in the series |
|
Whether this marker is transparent |
|
Whether this series belongs to the Y2-axis or the Y1-axis |
|
The type of the marker or markers for this series (bar, data marker, or area) |
|
The shape of the markers in this series, in a line (or point) graph |
|
The width of the data line for this series, in a line graph |
|
The amount by which the pie slices in this series are separated from the rest of their pies |
|
The special effects object for this series. |
|
The kind of fitline, if any, that is displayed for the series |
You can set default properties of the series class, so that all series have the same property value. For example, you can set a default width for data lines in a line graph. Default property settings are useful when you want to customize the way that data markers will look when series are added to a graph.
In the user interface for the Graph Bean, the default values appear as "all series" values in the Plot Area panel.
The following table describes the properties that can apply to all series in a graph.
Default Series Property | Description |
---|---|
|
The default color of the borders of all the series (not exposed in the user interface) |
|
Whether the borders of all series are transparent by default (not exposed in the user interface) |
BorderUsingDefaults |
Whether all of the borders are using the values of DefaultBorderColor
and DefaultBorderTransparent |
DefaultAssignedToY2 |
The default Y-axis assignment |
DefaultColor |
The default color for markers |
DefaultFitlineType |
The default type of fitline |
DefaultLineWidth |
The default line width (relevant in line and combination graphs) |
DefaultMarkerShape |
The default marker shape (relevant in line, point, and combination graphs) |
DefaultMarkerType |
The default marker type (relevant in combination graphs) |
The following example sets the default shape of the data markers in a line
graph to a plus sign. It then changes the shape of the markers in the first
series, so that they are displayed as a circle. This example assumes that the
graph variable is graph
.
// must be a line graph; any constant starting with LINE_ will do graph.setGraphType(Graph.LINE_VERT_ABS); // markers should be displayed graph.setMarkerDisplayed(true); // set the default marker shape Series series = graph.getSeries(); series.setDefaultMarkerShape(BaseGraphComponent.MS_PLUS); // set the shape of DataMarkers in the first series to circles series.setMarkerShape(BaseGraphComponent.MS_CIRCLE, 0);
The following code sets the color for the last bar in a bar graph to red.
// must be a bar graph; any constant that begins with BAR_ will do graph.setGraphType(Graph.BAR_VERT_CLUST); // find the total numbers of series for which properties are saved int numSeries = graph.getSeriesObjectCount(); // get red java.awt.Color colorRed = new Color(red); // set the last series to red graph.getSeries().setColor(colorRed, (numSeries - 1));
This example sets the default fitline to a linear fitline, and then sets a logarithmic fitline for the first series of data in the graph. This fitline identifies the logarithmic trend in the data.
// turn linear fitlines on by default Series series = graph.getSeries(); series.setDefaultFitlineType(BaseGraphComponent.FT_LINEAR); // set a logarithmic fitline for the first series series.setFitlineType(BaseGraphComponent.FT_LOGARITHMIC, 0);
The following code sets the default Y-axis assignment to the Y1-axis. Then it sets the first series in the graph to the Y2-axis.
// assign to Y1 by default Series series = graph.getSeries(); series.setDefaultAssignedToY2(false); series.setAssignedToY2(true, 0);
The following code sets the maximum width of the bars in a graph to one-tenth the size of the graph. The width is expressed in virtual coordinates.
graph.setMaxBarWidth(1600);