Got mad stacks
The stack layout allows us to stack regions in a chart, which is useful for things such as stacked area charts and what have you. It's in the d3-shape
package.
Go back to main.js
and comment out the last example and add the following:
westerosChart.init('stack', 'data/GoT-deaths-by-season.json', false);
We add another option to this because we're going to create two charts from this example. This time we're using our deaths-by-season
dataset.
Inchapter7/index.js
 add the following to the bottom of the file:
westerosChart.stack = function Stack({ data }, isStream = false) { const episodesPerSeason = 10; const totalSeasons = 6; // Create a nest containing deaths per episode const seasons = d3.nest() .key(d => d.death.episode) .key(d => d.death.season) .entries(data.filter(d => !d.death.isFlashback)) .map(v => { return d3.range(1, totalSeasons + 1) .reduce((item, episodeNumber) => { const deaths = v.values.filter...