Example usage for javafx.scene.chart AreaChart AreaChart

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

Introduction

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

Prototype

public AreaChart(@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 CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();

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

    final AreaChart<String, Number> areaChart = new AreaChart<String, Number>(xAxis, yAxis);

    areaChart.setTitle("AreaChart");
    XYChart.Series series = new XYChart.Series();
    series.setName("XYChart.Series");

    series.getData().add(new XYChart.Data("January", 100));
    series.getData().add(new XYChart.Data("February", 200));
    series.getData().add(new XYChart.Data("March", 50));

    areaChart.getData().add(series);/*from   w w  w .  j  av  a  2s .  c  o m*/

    root.getChildren().add(areaChart);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("Area Chart Sample");
    final NumberAxis xAxis = new NumberAxis(1, 30, 1);
    final NumberAxis yAxis = new NumberAxis(-5, 27, 5);
    final AreaChart<Number, Number> ac = new AreaChart<Number, Number>(xAxis, yAxis);
    xAxis.setForceZeroInRange(true);// w w w.  ja  va2s  . c  o  m

    ac.setTitle("Temperature Monitoring (in Degrees C)");

    XYChart.Series series1 = new XYChart.Series();
    series1.setName("March");
    series1.getData().add(new XYChart.Data(0, -2));
    series1.getData().add(new XYChart.Data(3, -4));
    series1.getData().add(new XYChart.Data(6, 0));
    series1.getData().add(new XYChart.Data(9, 5));

    XYChart.Series series2 = new XYChart.Series();
    series2.setName("April");
    series2.getData().add(new XYChart.Data(0, 4));
    series2.getData().add(new XYChart.Data(3, 10));
    series2.getData().add(new XYChart.Data(6, 15));
    series2.getData().add(new XYChart.Data(9, 8));

    XYChart.Series series3 = new XYChart.Series();
    series3.setName("May");
    series3.getData().add(new XYChart.Data(0, 20));
    series3.getData().add(new XYChart.Data(3, 15));
    series3.getData().add(new XYChart.Data(6, 13));
    series3.getData().add(new XYChart.Data(9, 12));

    Scene scene = new Scene(ac, 800, 600);
    //scene.getStylesheets().add("areachartsample/Chart.css");
    ac.setHorizontalZeroLineVisible(true);
    ac.getData().addAll(series1, series2, series3);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("Area Chart Sample");
    final NumberAxis xAxis = new NumberAxis(1, 30, 1);
    final NumberAxis yAxis = new NumberAxis(-5, 27, 5);
    final AreaChart<Number, Number> ac = new AreaChart<Number, Number>(xAxis, yAxis);
    xAxis.setForceZeroInRange(true);/*from w  ww  .  j av a  2 s  .c o m*/

    ac.setTitle("Temperature Monitoring (in Degrees C)");

    XYChart.Series series1 = new XYChart.Series();
    series1.setName("March");
    series1.getData().add(new XYChart.Data(0, -2));
    series1.getData().add(new XYChart.Data(3, -4));
    series1.getData().add(new XYChart.Data(6, 0));
    series1.getData().add(new XYChart.Data(9, 5));
    series1.getData().add(new XYChart.Data(12, -4));
    series1.getData().add(new XYChart.Data(15, 6));
    series1.getData().add(new XYChart.Data(18, 8));
    series1.getData().add(new XYChart.Data(21, 14));
    series1.getData().add(new XYChart.Data(24, 4));
    series1.getData().add(new XYChart.Data(27, 6));
    series1.getData().add(new XYChart.Data(30, 6));

    XYChart.Series series2 = new XYChart.Series();
    series2.setName("April");
    series2.getData().add(new XYChart.Data(0, 4));
    series2.getData().add(new XYChart.Data(3, 10));
    series2.getData().add(new XYChart.Data(6, 15));
    series2.getData().add(new XYChart.Data(9, 8));
    series2.getData().add(new XYChart.Data(12, 5));
    series2.getData().add(new XYChart.Data(15, 18));
    series2.getData().add(new XYChart.Data(18, 15));
    series2.getData().add(new XYChart.Data(21, 13));
    series2.getData().add(new XYChart.Data(24, 19));
    series2.getData().add(new XYChart.Data(27, 21));
    series2.getData().add(new XYChart.Data(30, 21));

    XYChart.Series series3 = new XYChart.Series();
    series3.setName("May");
    series3.getData().add(new XYChart.Data(0, 20));
    series3.getData().add(new XYChart.Data(3, 15));
    series3.getData().add(new XYChart.Data(6, 13));
    series3.getData().add(new XYChart.Data(9, 12));
    series3.getData().add(new XYChart.Data(12, 14));
    series3.getData().add(new XYChart.Data(15, 18));
    series3.getData().add(new XYChart.Data(18, 25));
    series3.getData().add(new XYChart.Data(21, 25));
    series3.getData().add(new XYChart.Data(24, 23));
    series3.getData().add(new XYChart.Data(27, 26));
    series3.getData().add(new XYChart.Data(30, 26));

    Scene scene = new Scene(ac, 800, 600);
    //scene.getStylesheets().add("areachartsample/Chart.css");
    ac.setHorizontalZeroLineVisible(true);
    ac.getData().addAll(series1, series2, series3);
    stage.setScene(scene);
    stage.show();
}