data = {
const data = d3.csvParse(await FileAttachment("data@4.csv").text(), d3.autoType);
const age = Array.from(d3.group(data, d => +d.age).keys()).sort(d3.ascending)
return {
age: age,
series: d3.groups(data, d => d.year).map(([name, values]) => {
const value = new Map(values.map(d => [+d.age, d.n]));
return {name, values: age.map(d => value.get(d))};
})
}
}