Example usage for javafx.scene.chart StackedAreaChart StackedAreaChart

List of usage examples for javafx.scene.chart StackedAreaChart StackedAreaChart

Introduction

In this page you can find the example usage for javafx.scene.chart StackedAreaChart StackedAreaChart.

Prototype

public StackedAreaChart(@NamedArg("xAxis") Axis<X> xAxis, @NamedArg("yAxis") Axis<Y> yAxis) 

Source Link

Document

Construct a new Area Chart with the given axis

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {

    Group root = new Group();
    final NumberAxis xAxis = new NumberAxis(1, 12, 1);

    final NumberAxis yAxis = new NumberAxis();
    final StackedAreaChart<Number, Number> stackedAreaChart = new StackedAreaChart<Number, Number>(xAxis,
            yAxis);/* w  w  w  .j  a v a 2 s  .c o m*/
    final XYChart.Series<Number, Number> series1 = new XYChart.Series<Number, Number>();

    xAxis.setLabel("Month");
    yAxis.setLabel("Value");

    stackedAreaChart.setTitle("StackedAreaChart");
    series1.setName("XYChart.Series 1");

    series1.getData().add(new XYChart.Data(1, 100));
    series1.getData().add(new XYChart.Data(2, 200));
    series1.getData().add(new XYChart.Data(10, 150));

    XYChart.Series<Number, Number> series2 = new XYChart.Series();
    series2.setName("XYChart.Series 2");

    series2.getData().add(new XYChart.Data(1, 50));
    series2.getData().add(new XYChart.Data(2, 200));
    series2.getData().add(new XYChart.Data(10, 260));

    stackedAreaChart.getData().addAll(series1, series2);

    root.getChildren().addAll(stackedAreaChart);

    primaryStage.setScene(new Scene(root, 500, 400));
    primaryStage.show();
}