Java Reference
In-Depth Information
Running the application now produces output like that shown in Figure 8-13 .
Figure 8-13. Rendering stacked bar chart plots using StackedBarChart
Using the AreaChart
In some cases, it makes sense to fill the area under the line connecting the dots. Although the same data are rendered
as in the case of a LineChart , the result looks different. Listing 8-10 contains the modified start() method that
uses an AreaChart instead of the original ScatterChart . As in the previous modifications, we didn't change the
getChartData() method.
Listing 8-10. Using an AreaChart Instead of a ScatterChart
public void start(Stage primaryStage) {
CategoryAxis xAxis = new CategoryAxis();
NumberAxis yAxis = new NumberAxis();
AreaChart areaChart = new AreaChart(xAxis, yAxis);
areaChart.setData(getChartData());
areaChart.setTitle("speculations");
primaryStage.setTitle("AreaChart example");
StackPane root = new StackPane();
root.getChildren().add(areaChart);
primaryStage.setScene(new Scene(root, 400, 250));
primaryStage.show();
}
Running this application results in output like that shown in Figure 8-14 .
 
Search WWH ::




Custom Search