cell_1_1 = {
const grouped = d3.rollups(
funderLimitData(data, countries),
(v) => {
return {
year: new Date(
new Date(0).setFullYear(v[0].trans_day.getYear() + 1900)
),
trans_value: d3.sum(v, (d) => d.trans_value),
funder_country: v[0].funder_country,
value: d3.sum(v, (d) => d.trans_value)
};
},
(d) => d.trans_day.getYear() + 1900 + "_" + d.funder_country
);
const sorted = grouped.sort((a, b) => a[1].year - b[1].year);
return Plot.plot({
width,
color: {
legend: true,
domain: countries.map((c) => getCountryName(c))
},
x: {
nice: true
},
y: {
nice: true,
type: "log",
grid: true
},
marks: [
Plot.line(sorted, {
x: (d) => d[1].year,
y: (d) => d[1].value,
stroke: (d) => getCountryName(d[1].funder_country)
}),
Plot.dot(sorted, {
x: (d) => d[1].year,
y: (d) => d[1].value,
fill: (d) => getCountryName(d[1].funder_country),
title: (d) =>
`${getCountryName(d[1].funder_country)} - ${
d[1].year.getYear() + 1900
}
Total Foreign Investment: ${formatNumbersNice(d[1].trans_value)}`
})
]
});
}