Creating scatter charts
Scatter charts also use the XYChart.Series
class in JavaFX. For this example, we will use a set of European data that includes the previous Europeans countries and their population data for the decades 1500 through 2000. This information is stored in a file called EuropeanScatterData.csv
. The first part of this file is shown here:
1500 1400000
1600 1600000
1650 1500000
1700 2000000
1750 2250000
1800 3250000
1820 3434000
1830 3750000
1840 4080000
...
We start with the declaration of the JavaFX MainApp
class, as shown next. The main
method launches the application and the start
method creates the user interface:
public class MainApp extends Application { @Override public void start(Stage stage) throws Exception { ... } public static void main(String[] args) { launch(args); } }
Within the start
method we set the title, create the axes, and create an instance of the ScatterChart
that represents the scatter plot. The NumberAxis...