Example usage for javafx.scene.chart LineChart LineChart

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

Introduction

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

Prototype

public LineChart(@NamedArg("xAxis") Axis<X> xAxis, @NamedArg("yAxis") Axis<Y> yAxis,
        @NamedArg("data") ObservableList<Series<X, Y>> data) 

Source Link

Document

Construct a new LineChart with the given axis and data.

Usage

From source file:nl.rivm.cib.fx.HelloWorldJavaFX.java

public Parent createContent() {
    final ObservableList<XYChart.Series<Double, Double>> lineChartData = FXCollections.observableArrayList(

            new LineChart.Series<>("Series 1", FXCollections.observableArrayList(

                    new XYChart.Data<>(0.0, 1.0),

                    new XYChart.Data<>(1.2, 1.4),

                    new XYChart.Data<>(2.2, 1.9),

                    new XYChart.Data<>(2.7, 2.3),

                    new XYChart.Data<>(2.9, 0.5)

            )),//from   ww  w  .j  a v  a  2 s.  c  o  m

            new LineChart.Series<>("Series 2", FXCollections.observableArrayList(

                    new XYChart.Data<>(0.0, 1.6),

                    new XYChart.Data<>(0.8, 0.4),

                    new XYChart.Data<>(1.4, 2.9),

                    new XYChart.Data<>(2.1, 1.3),

                    new XYChart.Data<>(2.6, 0.9)

            ))

    );

    final NumberAxis xAxis = new NumberAxis();
    xAxis.setAutoRanging(false);
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarkVisible(false);

    final NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRanging(true);

    this.chart = new LineChart(xAxis, yAxis, lineChartData);
    return this.chart;

}