JavaFX LineChart

In general, the Line Chart is defined as the type of graph in which the group of data points called markers are used to display the information.

In Line Chart, the markers are plotted on the mapping points between the two Number axes. The markers are connected by the line segments. Basically, the line chart shows the deviation in the values of one axis with respect to the change in values of other axis.

In the following image, the line chart shows the variation in the price of Milk over the last 8 years. On the Y axis, the price is shown while on the X axis, the years are shown.


JavaFX LineChart1

In JavaFX, the Line Chart is represented by the class javafx.scene.chart.LineChart

Properties

The properties of the class along with the setter methods are described in the following table.

PropertyDescriptionSetter Methods
axisSortingPolicyThis is an LineChart.SortingPolicy type property. It represents whether the data is to be sorted according the nature of one of the axis.setAxisSortingProperty(LineChart.SortingPolicy value)
createSymbolsThis is a boolean type property. It represents whether the symbols are needed to be created for the ones for which the symbol nodes are not specified.setCreateSymbols(Boolean true)

Constructors

There are two constructors in the class.

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

Example

In the following example, we have shown the variation in the share price of a stock in the different years.


JavaFX LineChart2




Latest Courses