JavaFX PieChart

In general, Pie chart is a type of the graph or diagram in which the sectors of a circle are used to represent different proportions of the whole information. The angle of the arc of a sector varies according to the percentage of information represented by that sector.

In the following image,A pie-chart is shown whose sectors represents the amount of fruits a person is having in its basket.

JavaFX PieChart1

In JavaFX, Pie Chart is represented by the class javafx.scene.chart.PieChrt. We need to instantiate this class in order to create pi-chart.


The properties of the class javafx.scene.chart.PieChart are described along with the setter methods in the following table.

Property Description Setter Methods
clockwise It is a boolean type property. Its true value means that the slices get placed clockwise from the start angle. setClockWise(Boolean value)
data It is an observable List type property. It represents the data which is to be set in the pie chart. The class PieChart.Data is used to deal with the assignment of data to the slices of pie chart. setData(PieChart.Data value)
labelLineLength It is a double type property. It represents the length of the line from the outside of the pie to the slice labels. setLabelLineLength(double value)
labelsVisible It is a boolean type property. Its true value means that pie slice labels will be drawn. setLabelsVisible(boolean value)
startAngle It is a double type property. It represents the angle of the first pie slice. setStartAngle(double value)


There are the two constructors in the class.

  1. public PieChart() : creates the new instance of an empty PieChart.
  2. public PieChart(ObservableList data) : creates the new instance of a pie-chart with the specified data slices.

Example 1:

JavaFX PieChart2

Example 2:

In the following Example, we have created a piechart which shows the popularities of all the computer programming languages.

JavaFX PieChart3
Next TopicJavaFX Line Chart

Hot Tutorials

Contact US

JavaFX Pie Chart