Java Reference
In-Depth Information
■
as discussed earlier regarding
PieChart
, we can use different patterns here. We used the JavaBeans pattern
in the examples, but we could also use properties.
Note
To create a
ScatterChart
, we need to create an
xAxis
and a
yAxis
. In our first simple implementation, we use
two instances of
NumberAxis
for this:
NumberAxis xAxis = new NumberAxis();
NumberAxis yAxis = new NumberAxis();
Apart from calling the following
ScatterChart
constructor, there is nothing different in this method than in the
case of the
PieChart
.
ScatterChart scatterChart = new ScatterChart(xAxis, yAxis);
Improving the Simple Implementation
One of the first observations when looking at Figure
8-5
is that all data plots in a series are almost rendered on top of
each other. The reason for this is clear: the
x-Axis
starts at 0 and ends at 2250. By default, the
NumberAxis
determines
its range automatically. We can overrule this behavior by setting the
autoRanging
property to false, and by providing
values for the
lowerBound
and the
upperBound
. If we replace the constructor for the
xAxis
in the original example by
the following code snippet,
NumberAxis xAxis = new NumberAxis();
xAxis.setAutoRanging(false);
xAxis.setLowerBound(2011);
xAxis.setUpperBound(2021);
the resulting output will look similar to that shown in Figure
8-7
.
Figure 8-7.
Defining the behavior of the
xAxis
Search WWH ::
Custom Search