February 2019
Beginner to intermediate
284 pages
6h 20m
English
Let's create a simple pie chart to compare CO2 emissions among the world's greatest polluters for a single year. You can use the same data we used for the area chart, but you will need to choose one of the datasets, place the country names in a labels array, the data for one year in the data array, and generate colors for each slice. All this can be done in JavaScript (see Pie/pie-2-fetch.html), but for the sake of simplicity and to focus on the construction of a simple pie chart, we will include the data directly in the HTML file, as shown in the following code block:
const dataset = [1.21, 1.71, 2.24, 3.24, 5.25, 10.29, 10.3]; // 2014 data const labels = ["Japan", "Russian Federation", "India", "European Union", ...
Read now
Unlock full access