Public
Edited
Dec 10, 2023
2 forks
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
countries110m = FileAttachment("countries-110m.json").json()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Merge data from the second CSV into the original data array
dataJoined = data.map(d => {
const matchingRow = legalityData.find(row => row.country === d.country);
const matchingPop = popsize4.find(row => row.country === d.country);
console.log(matchingRow)
// Add the new property 'when_legal' based on the additional data
return {
...d,
when_legal: matchingRow ? +matchingRow.year : null,
pop_size: matchingPop ? +matchingPop[d.year] : null,
}
});

// Now, each object in the output array has a new 'when_legal' property based on the legality data
Insert cell
popSize@4.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
popSize@2.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
popsize3[0][data[0].year]
Insert cell
popSize@3.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3Legend = require("d3-svg-legend")
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more