JavaFX StackedAreaChart

Stacked area chart is the extension of the basic area charts in which the evolution of the values of several groups on the same graphic is displayed. The area is plotted for all the data points of a certain group. However, the areas of the different groups are shown in the form of a stack but they don't overlap each other. The stacked area chart is mainly used to trace the comparison between the values of the two groups.

In the following image, the population of different states is shown. The population of men and women are represented by the two different area where the area representing the women population is plotted onto the area representing the women population. On the X-axis, some states are plotted while, on the Y-axis, the population (in crores) is plotted.


JavaFX StackedAreaChart1

In JavaFX, the class javafx.scene.chart.StackedAreaChart is used to represent the stacked area chart. We need to instantiate this class in order to generate a Stacked-Area-Chart node.

Properties

The class contains only one property that is described along with its setter method in the following table.

PropertyDescriptionSetter Method
createSymbolsIt is a boolean type property. Its true value indicates that the CSS symbols will get created for any of the data items for which the symbols are not created yet.setCreateSymbols(boolean value)

Constructors

There are two constructors in the class.

  1. public StackedAreaChart(AxisXaxis, AxisYaxis) :creates the new instance of StackedAreaChart with the specified axis.
  2. public StackedAreaChart(AxisXaxis, AxisYaxis, ObservableList> data)) :creates the new instance of StackedAreaChart with the specified axis and data.

Example

In the following example, we have shown the comparison between the sales of a company in two different years.


JavaFX StackedAreaChart2




Latest Courses