Setting Properties on a Graph and on Graph Components

For properties that you set on the graph, the constants are in the Graph class. For properties of the graph components, the constants are in the BaseGraphComponent class.

Properties to set on the graph

The following table lists graph properties that are commonly set.

Property

Description

DataSource

The data source for the data that the graph displays. See also the topic "Specifying Data for a Graph."

GraphType

The type of graph to display, such as a stacked bar graph or a single pie graph. See also the topic "Choosing a Graph Type."

MarkerDisplayed

Whether markers appear in a line graph. (Do not set both this property and LineDataLineDisplayed to false.)

LineDataLineDisplayed Whether lines appear in a line graph. (Do not set both this property and MarkerDisplayed to false.)
ScatterDataLineDisplayed Whether lines appear in a scatter graph.
FitToContainer Whether the graph changes size when its container changes size.
ImageSize The size of the graph, when FitToContainer is false. Also the printed size of the graph when FitToContainer is true.

For information about other properties on the Graph class, see its javadoc.

Example: Changing the graph type

The following line of code changes the graph type to a single pie graph.


graph.setGraphType(Graph.PIE);

Example: Specifying the size of a graph

The following lines of specify the size of a graph.


graph.setFitToContainer(false); graph.setImageSize(new Dimension(300, 200));

Properties for components

Each component has properties of its own. To see the properties for each component, look at the javadoc for each component class.

Example: Setting the color of the graph background

The following line of code sets the color of the graph background to cyan.


graph.getBackground().setFillColor(Color.cyan);

Example: Setting the text of the group axis

The following line of code sets the text of the group axis (O1Title) to "Product".


graph.getO1Title().setText("Product");

 

Managing Automatic Graph Layout
Choosing a Graph Type
Customizing Graph Legends
Customizing Graph Markers in a Series
Customizing the Display of Tick Labels in a Graph
Customizing the Scale of Graph Data Axes
Formatting Numbers in Graphs
Managing Font Sizes in Graphs
Using Special Effects in Graphs