Revealing correlations with scatter charts

Scatter charts are great to show correlations between data. The following example will combine NASA/GISS global temperature data (Data/monthly_json.json) and CO2 emission data (Data/co2_mm_mlo.csv) measured in Mauna Loa, Hawaii, to discover if there is any correlation between the two. Since the Mauna Loa data is only available after 1959, we will only use the GISS data after that year.

Since we must load multiple files, we will use JavaScript promises. Each data source is parsed and the data is sent to the combine() function, which returns an array that can be used by Chart.js, as follows:

const canvas = document.getElementById("my-scatter-chart"); const files = ['../Data/monthly_json.json', '../Data/co2_mm_mlo.csv']; ...

Get Learn Chart.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.