Creating index charts
An index chart is a line chart that shows the percentage change of something over time. Frequently, such a chart is based on a single data attribute. In the following example, we will be using the Belgian population for six decades. The data is a subset of population data found at https://ourworldindata.org/grapher/population-by-country?tab=data:
Decade | Population |
1950 | 8639369 |
1960 | 9118700 |
1970 | 9637800 |
1980 | 9846800 |
1990 | 9969310 |
2000 | 10263618 |
We start by creating the MainApp
class, which extends Application
. We create a series of instance variables. The XYChart.Series
class represents a series of data points for some plot. In our case, this will be for the decades and population, which we will initialize shortly. The next declaration is for the CategoryAxis
and NumberAxis
instances. These represent the X and Y axes respectively. The declaration for the Y axis includes range and increment values for the population. This makes the chart a bit more readable. The last declaration is a...