Chart Bean | API Documentation |
The WebRunner Chart Bean provides an example of a Java bean that can be used by other beans or simple components. The Chart bean is shipped in the jar file chart.jar.
You can use a Chart Bean to display data in any of four different charts:
To take advantage of all the benefits of well-partitioned Java components, the Chart Bean is based on the Bean Works framework. The model-view-controller paradigm underlying the framework means a Chart Bean can display data in its model in different formats simply by having multiple views maintained by a single controller. The underlying Bean Works architecture also means that you can save any customization made to a Chart Bean's model data or view states.
A true Java bean, these beans allow introspection of their properties, events, and methods. This enables builders like the Bean Tester to wire other beans to the Chart Bean by binding together properties of the beans. This property binding allows the user bean to customize the chart's properties, including the title, the axis labels, the legend, the labels used for the data, the background color, and the colors used for charting the data itself.
The Chart Bean displays data in chart formats, so the data format must be a vector of integers or floating decimal numbers. The vector can be set either programmatically or by using the Bean Tester to connect the Chart Bean to a bean or component that defines similar properties (a vector of numbers). The labels for the data sets, or for the axes, can be set in the same way. The Bean Tester allows you to edit other properties of the chart such as the title and labels, the background color, and whether the data values and labels should be displayed on the chart or hidden.
The different types of views supported by the Chart Bean are shown below.
The program features in the Chart Bean project code demonstrate:
The Chart Bean project defines the following classes:
You can test a Chart Bean in the Bean Tester by wiring the relevant properties of the bean to other beans that have properties of the same type (vectors of numbers ). You can also test a Chart Bean by instantiating it programmatically and setting its properties appropriately.
The following code snippet illustrates how you can programmatically instantiate a Chart Bean that displays a pie chart:
public class DpmView extends ModelView implements ListboxListener, { public void initialize() { ... ... riskView = new Chart( ChartType.PIECHART ); riskChartFrame = new Frame( new String(" Risk Type View")); riskChartFrame.add(riskView); riskChartFrame.setVisible(false); } public class Dpm extends ComponentController { public void actionPerformed(.. ) { PieChart riskView = ((DpmView)getView()).getRiskView(); Frame riskFrame = ((DpmView)getView()).getRiskChartFrame(); riskView.setChartLabels(((DpmView)getView()).getSecurityTypeLabels()); riskView.setChartData(((DpmView)getView()).getSecurityTypeValues()); riskFrame.pack(); riskFrame.setVisible(true); } } }
Copyright ©
Taligent, Inc. 1996 - 1997.
Copyright © IBM Corporation 1996 - 1997.
All Rights Reserved.