Perforce JViews Charts Sample: Combined Data Sets
Description
This sample displays three dynamic data sets whose minimum, maximum, and average values for each category are computed dynamically and indicated by the square scatter renderer, the circle scatter renderer, and the gray polyline renderer respectively.
How to Use the Sample
- Click on a data point and drag it to change its Y value.
- Click Animate to update the data sets dynamically.
- Move the slider to adjust the number of updates per second.
- Toggle the Min/Max/Avg check box to show/hide the minimum, maximum, and average values of every category.
- Toggle the Pretty rendering check box to switch between a pretty-but-time-consuming rendering and a faster rendering.
- Move the mouse cursor over a data point to display its coordinates.
- You can change the docking location of the legend by clicking on its border and dragging it.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
minmax.jar
,
that allows you to execute the sample with a double click from a
file browser. Note that if you are using Internet Explorer, you can
open the installation directory
and execute the JAR file from the browser. This
technique may not work in other Web browsers.
Alternatively, you
can run the sample application from the command line.
First check that the Ant utility is properly configured. If not, see the
instructions on how to configure Ant for Perforce JViews.
Then, go to the installation directory
of the sample and type:
ant run
Topics Covered
- Using combined data sets.
- Using rendering hints.
- Filtering chart renderers when performing data picking interactions.
Detailed Description
This sample shows how to handle data sets whose values depend on others
data sets. The minimum, maximum, and average data sets compute their
values from the data contained in three reference data sets.
Such data sets are called combined data sets and are instances of the
IlvCombinedDataSet
class. In this sample, the three combined
data sets are instances of an IlvCombinedDataSet
subclass,
the YOperatorDataSet
class, that dynamically computes its
values when they are fetched (the operation to perform is actually
carried out in specialized subclasses).
To graphically distinguish which of the reference data sets contains the
minimum or maximum value for a given category, the corresponding
renderers use a rendering hint that uses the same stroke as the reference
data set renderers. A rendering hint is an implementation of the
IlvDataRenderingHint
interface. Each time a data point is
about to be drawn by its renderer, its specific rendering hint is
used instead of the renderer one, allowing you to locally customize the
way a data point is drawn.
Because all the chart renderers displayed by a chart do not always
corresponds to real data sets, you might want to ignore some renderers
while performing interaction on data points, like data picking. Data
picking is usually performed by direct interaction on a chart using a data
point interactor (instances of subclasses of
IlvChartDataInteractor
) and is handled by a dedicated object,
an implementation of the IlvChartDataPicker
interface. In
this sample, a concrete implementation filters the renderers so that
interactions on the combined data sets renderer are ignored.
Note that no explicit repaint request is necessary, as the chart is updated automatically when the above operations are performed.
Installation Directory
The Combined Data Sets sample is installed here.
Classes Involved
- ilog.views.chart.data.IlvCombinedDataSet
- ilog.views.chart.graphic.IlvDataRenderingHint
- ilog.views.chart.IlvChartRenderer
- ilog.views.chart.interactor.IlvChartDataInteractor
- ilog.views.chart.IlvChartDataPicker