Creating a Bar Chart in JavaFX with FXML | JavaFX Tutorial for Beginners

In this tutorial, we will learn to create a BarChart win JavaFX with FXML.
Important components of the Bar Chart:
1) X-Axis and Y-Axis
2) X-Axis and Y-Axis Label
3) Series of data (more than one)
4) Legends
5) Title

Steps to create Bar Chart:

*********************
1) First Create Barchart Class instance (use fx:id if using Fxml)
2) define the series of data ( Ex. XYChart.Series series1 = new XYChart.Series();)
3) adding data in series ( Ex. new XYChart.Data(“USA”, 8000))
4) add all series in chart.

Objective: Sales figures in multiple countries in 2003, 2004, 2005
– we will create 3 series, a series per year.

series1.setName(“2003”); // this will display as legends

series1.getData().add(new XYChart.Data(“Austria”, 25601)); //adding data in series.


Please watch this video tutorial for complete understanding.

If you find this tutorial useful, so please hit like button to let us know. You can subscribe my YouTube channel to learn more.


Leave a Comment