下面列出了怎么用javafx.scene.chart.StackedAreaChart的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected XYChart<String, Number> createXYChart() {
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
final XYChart<String, Number> chart = new StackedAreaChart<String, Number>(xAxis, yAxis);
chart.getStyleClass().add("chart-extension");
return chart;
}
public StackedAreaChartSample() {
NumberAxis xAxis = NumberAxisBuilder.create()
.label("X Values")
.lowerBound(1.0d)
.upperBound(9.0d)
.tickUnit(2.0d).build();
NumberAxis yAxis = NumberAxisBuilder.create()
.label("Y Values")
.lowerBound(0.0d)
.upperBound(30.0d)
.tickUnit(2.0d).build();
ObservableList<StackedAreaChart.Series> areaChartData = FXCollections.observableArrayList(
new StackedAreaChart.Series("Series 1",FXCollections.observableArrayList(
new StackedAreaChart.Data(0,4),
new StackedAreaChart.Data(2,5),
new StackedAreaChart.Data(4,4),
new StackedAreaChart.Data(6,2),
new StackedAreaChart.Data(8,6),
new StackedAreaChart.Data(10,8)
)),
new StackedAreaChart.Series("Series 2", FXCollections.observableArrayList(
new StackedAreaChart.Data(0,8),
new StackedAreaChart.Data(2,2),
new StackedAreaChart.Data(4,9),
new StackedAreaChart.Data(6,7),
new StackedAreaChart.Data(8,5),
new StackedAreaChart.Data(10,7)
)),
new StackedAreaChart.Series("Series 3", FXCollections.observableArrayList(
new StackedAreaChart.Data(0,2),
new StackedAreaChart.Data(2,5),
new StackedAreaChart.Data(4,8),
new StackedAreaChart.Data(6,6),
new StackedAreaChart.Data(8,9),
new StackedAreaChart.Data(10,7)
))
);
StackedAreaChart chart = new StackedAreaChart(xAxis, yAxis, areaChartData);
getChildren().add(chart);
}
public StackedAreaChartSample() {
NumberAxis xAxis = NumberAxisBuilder.create()
.label("X Values")
.lowerBound(1.0d)
.upperBound(9.0d)
.tickUnit(2.0d).build();
NumberAxis yAxis = NumberAxisBuilder.create()
.label("Y Values")
.lowerBound(0.0d)
.upperBound(30.0d)
.tickUnit(2.0d).build();
ObservableList<StackedAreaChart.Series> areaChartData = FXCollections.observableArrayList(
new StackedAreaChart.Series("Series 1",FXCollections.observableArrayList(
new StackedAreaChart.Data(0,4),
new StackedAreaChart.Data(2,5),
new StackedAreaChart.Data(4,4),
new StackedAreaChart.Data(6,2),
new StackedAreaChart.Data(8,6),
new StackedAreaChart.Data(10,8)
)),
new StackedAreaChart.Series("Series 2", FXCollections.observableArrayList(
new StackedAreaChart.Data(0,8),
new StackedAreaChart.Data(2,2),
new StackedAreaChart.Data(4,9),
new StackedAreaChart.Data(6,7),
new StackedAreaChart.Data(8,5),
new StackedAreaChart.Data(10,7)
)),
new StackedAreaChart.Series("Series 3", FXCollections.observableArrayList(
new StackedAreaChart.Data(0,2),
new StackedAreaChart.Data(2,5),
new StackedAreaChart.Data(4,8),
new StackedAreaChart.Data(6,6),
new StackedAreaChart.Data(8,9),
new StackedAreaChart.Data(10,7)
))
);
StackedAreaChart chart = new StackedAreaChart(xAxis, yAxis, areaChartData);
getChildren().add(chart);
}