O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Like any other two-axis chart, the line chart has the x axis and y axis. These axes can be of string types or numeric. String values are represented by javafx.scene.chart.CategoryAxis and numeric values by javafx.scene.chart.NumberAxis

A new LineChart is created by providing the x axis and y axis objects as parameters to its constructor:

final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Category");
yAxis.setLabel("Price");
final LineChart<String,Number> lineChart = new LineChart<>(xAxis,yAxis);

Data to LineChart is provided in the form of an instance of XYChart.Series. So, if LineChart uses String on the x axis and Number on the y axis, then we create an instance of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required