Public
Edited
Oct 25, 2024
Insert cell
Insert cell
Insert cell
Insert cell
marimekkoXY = (sX, sY, options) => marimekko(options) // deprecated, do not use
Insert cell
marimekkoMid = marimekko // deprecated, do not use
Insert cell
marimekkoTopLeft = options => marimekko({...options, anchor: "top-left"}) // deprecated, do not use
Insert cell
data = reduceData(neo_natal_deaths_subRegion1)
Insert cell
function moveOtherToEnd(data) {
// Sort the data by region, prioritizing "other" elements
data.sort((a, b) => {
if (a.region === 'Other' && b.region !== 'Other') {
return 1;
} else if (a.region !== 'Other' && b.region === 'Other') {
return -1;
} else {
return 0;
}
});

return data;
}
Insert cell
function reduceData(data) {
const reducedData = [];

data.forEach(item => {
const { region, subRegion, period, value } = item;

// Check if the sub-region is not Sub-Saharan Africa or Southern Asia
if (subRegion !== 'Sub-Saharan Africa' && subRegion !== 'Southern Asia') {
// Find the existing item for the given year
const existingItem = reducedData.find(item => item.period === period);

if (existingItem) {
// If item exists, update its value by adding the current value
existingItem.value += value;
} else {
// If item doesn't exist, create a new item with the current values
reducedData.push({
region: 'Other',
subRegion: 'Other',
period,
value
});
}
} else {
// If sub-region is Sub-Saharan Africa or Southern Asia, add the item directly
reducedData.push(item);
}
});

return reducedData;
}

Insert cell
neo_natal_deaths_sub-region@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

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