In stacked bar charts, the values of the different groups are displayed on a rectangular bar in the form of a stack. This is mainly used to compare the values of the different groups according to its length plotted on the bar.
In the following image, the population of men and women in the different states, is compared. On the x-axis, the states plotted while, on the y-axis the population is plotted.
In JavaFX, the class javafx.scene.chart.StackedBarChart represents the stacked bar chart. We need to instantiate this class to generate a StackedBarChart node.
The class contains only one property which is described in the following table along with its setter method.
There are the three constructors in the class.
In the following example, we have shown the comparison between the popularity of two programming languages in each month of a year. The x-axis is a category axis while the y-axis is a number axis. On X-axis, we have plotted the months of a year while on the y-axis we have plotted the number of readers.