Java Reference
In-Depth Information
c.getData().add(new XYChart.Data(i, cValue));
cValue = Math.max(cValue + 4 * diff - 2, 0);
diff = Math.random();
cpp.getData().add(new XYChart.Data(i, cppValue));
cppValue = Math.max(cppValue + 4 * diff - 2, 0);
}
answer.addAll(java, c, cpp);
return answer;
}
}
The xAxis ranges from 20110 to 20201, but of course we want to show the years at the axis. This can be achieved
by calling
xAxis.setTickLabelFormatter(new StringConverter<Number>() {
...
}
where the StringConverter we supply converts the numbers we use (e.g., 20150) to Strings (e.g., 2015) and vice
versa. Doing so, we are able to use whatever quantity we want for calculating the bubbles and still have a nice way of
formatting the labels. Running this example results in the chart shown in Figure 8-16 .
Figure 8-16. Using a BubbleChart with fixed radius
Until now, we didn't leverage the three-argument constructor of XYChart.Data . Apart from the two-argument
constructor that we are already familiar with,
XYChart.Data (X xValue, Y yValue)
XYChart.Data also has a three-argument constructor:
XYChart.Data (X xValue, Y yValue, Object extraValue)
 
Search WWH ::




Custom Search