Public
Edited
Jan 22, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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);

console.log(matchingRow)
// Add the new property 'when_legal' based on the additional data
return {
...d,
when_legal: matchingRow ? +matchingRow.year : null
}
});

// Now, each object in the output array has a new 'when_legal' property based on the legality data
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