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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more