Step 3: Creating the Line Chart

Create a line chart by instantiating the class named LineChart of the package javafx.scene.chart. To the constructor of this class, pass the objects representing the X and Y axis created in the previous step.

LineChart linechart = new LineChart(xAxis, yAxis);

Step 4: Preparing the Data

Instantiate the XYChart.Series class. Then add the data (a series of, x and y coordinates) to the Observable list of this class as follows −