Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedAreaChart;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

public class Main extends Application {
    final NumberAxis xAxis = new NumberAxis(1, 10, 1);
    final NumberAxis yAxis = new NumberAxis();
    final StackedAreaChart<Number, Number> sac = new StackedAreaChart<>(xAxis, yAxis);

    @Override
    public void start(Stage stage) {
        sac.setTitle("title");
        XYChart.Series<Number, Number> seriesApril = new XYChart.Series<>();
        seriesApril.setName("April");
        seriesApril.getData().add(new XYChart.Data(1, 4));
        seriesApril.getData().add(new XYChart.Data(3, 10));
        seriesApril.getData().add(new XYChart.Data(6, 15));
        XYChart.Series<Number, Number> seriesMay = new XYChart.Series<>();
        seriesMay.setName("May");
        seriesMay.getData().add(new XYChart.Data(1, 23));
        seriesMay.getData().add(new XYChart.Data(7, 26));
        seriesMay.getData().add(new XYChart.Data(10, 26));
        Scene scene = new Scene(sac, 800, 600);
        sac.getData().addAll(seriesApril, seriesMay);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}