JavaFX Scatter Chart

0

JavaFX Scatter Chart Tutorial:

The Scatter Chart is a two axis chart is used to shows the relationship between two sets of data.
Scatter chart represents its data as a set of points.

Create a Scatter Chart :

  • Creation of Scatter chart is also similar to Area and Line chart.
  • First Create two axis for the line Chart using NumberAxis class.

    This constructor create an axis with auto ranging for bounds of axis.

  • Now creates an object of BubbleChart by initiating BubbleChart class with axis as

    ScatterChart scatterChart = new ScatterChart(xAxis,yAxis);
  • Now create a series of data by using XYChart.Series Class as

    XYChart.Series dataSeries = new XYChart.Series();
  • Now assigning data for this series with two values as

  • And at last add this series to the scatter Chart as
    scatterChart.getData().add(dataSeries);

Constructors :

  • ScatterChart(Axis xAxis, Axis yAxis)
    Construct a new ScatterChart with the given axis and data.
  • ScatterChart(Axis xAxis, Axis yAxis, ObservableList<X,Y>> data)
    Construct a new ScatterChart with the given axis and data.

Example of scatter chart:

Output :

Share.

Leave A Reply