Changes
Gallery
Application examples
Using the beans
More about the utility beans
Reference
Known restrictions
Changes
This package contains the following changes and new features:
UniversalChart
bean can be used by applications that need to switch chart type dynamically through an API.
ChartDataReducer bean can be used to coerce large
data sets into a form suitable for presentation by the chart beans.
This package contains a set of lightweight beans for drawing simple business charts. The design-point is "small and simple" to support the practical use use of charting within intranet/internet applications.
The Chart bean takes a 2d array of numerical values to create any of the chart types shown below. You can customize the bean to define the chart type, legends, item colors, y axis labels and scaling. You can also edit standard Java component properties such as size and shape, foreground and background colors, and font.
The product sales application displays a chart of sales data extracted from a separate SalesData class. The user can select the chart type, product group, and presentation style.
The pressure chart application monitors an industrial device in real time to show the current pressure and the
device safety limit. It also tracks the minimum and maximum pressure recorded since starting monitoring.
The chart is rolled to show the last 10 value groups and switches the pressure line to red
whenever the safety limit is exceeded.
You can either use the beans in a visual composition tool, such as Visual Age for Java,
or as Java components manipulated through an API. Although most properties can be edited
through visual composition tools, there are some restrictions documented below.
This section describes some common scenarios for building applets
by using a visual tool such as Visual Age for Java or Lotus bean machine.
You will need to adapt the scenarios to the specific
terminology and connection techniques of the tool you use.
Most tools require you to import the jar before you can use the
beans. The tool may also allow you to add the chart beans to a palette.
Use this scenario when the chart values and attributes are defined at design time.
Use this scenario to derive chart data from another bean capable of
supplying a 2d array of numeric values.
Use this scenario to derive chart data from one or more beans capable of
supplying data as a scalar value
In this application, a user types a set of values into entry field 1. The values are
aggregated into an array by a chart data aggregator 2 and the array is reduced
to 5 smoothed values by a chart data reducer 3 and then passed to a chart
4 for display.
To connect the entry field 1 to the aggregator 2:
To connect the aggregator 2 to the reducer 3
To customize the reducer:
This example demonstrates how to use the Chart bean to graph sales results.
It illustrates the following techniques:
This example demonstrates how to use the Chart bean to display a rolling
plot of device pressure.
It illustrates the following techniques:
This example demonstrates how to use the ChartDataReducer bean to control the amount
of data the Chart bean displays.
It illustrates the following techniques:
View the source code
Each value in the aggregator is identified by a group index and a
a value index within the group. The following diagram shows how
group and value indices identify segments in a stacked bar chart.
To set specific values, use the following sequence of method calls:
Alternatively, you can add values or groups of values at the next spare index:
When you use
Whenever a value is set or added, the bean fires a property change event.
You can use this event to trigger sending the updated values to the Chart bean.
You should not mix calls to
The reducer bean is used as a piping bean between the chart bean and the data source in order
to control the amount of data the chart is to display. It may be desirable occasionally to
focus on a particular section of the data in the chart or to give a general trend of the
data which is possible by using the reducer bean.
The data source is simply plugged into the Input Data property of the reducer and the output
data is fed into the chart.
The way the data is reduced is controlled with the Reducing Rule property which allows the extraction of:
Where n is set by the Number of Output Columns property
The data is reduced, using the property values set, whenever a call to getOutputValues is
made which returns the reduced output.
Using the beans
Using the beans in a visual composition tool
Creating a static chart
Creating a dynamic chart using 2d data from another bean
Creating a dynamic chart using scalar data from other beans
Visual Age example
This example illustrates the use of the chart and utility beans in Visual Age for Java.
To connect the reducer 3 to the chart 4
Using the beans in a Java program
Sales chart example
Pressure chart example
Reduced Sales chart example
More about the utility beans
More about the Chart Data Aggregator bean
| Group1
| Value2
|
| Group1 Group2
| Value2 Value2
|
| Group1 Group2
| Value1 Value2
+---------------
add... methods, you can roll the chart after a
specified number of groups by setting on the rollActive
property and specifying a group count in the rollAfter
property. This property has no effect on set... methods.
set... methods and add....
methods.
More about the Chart Data Reducer bean
Reference
Bean properties
(c) Copyright IBM Corp. 1998,1999