quantiles = {
const formatPercentage = d3.format(".0%");
const wijkenWestToEast = wijkenClean.sort((a, b) =>
d3.descending(a.lon, b.lon)
);
const cumulative = d3.cumsum(wijkenWestToEast, (d) => d.bevolking);
const quantiles = [0.1, 0.25, 0.5, 0.75, 0.9];
const indices = quantiles.map((n) => d3.quantileIndex(cumulative, n));
return indices.map((wijkIndex, i) => ({
lat: wijkenWestToEast[wijkIndex - 1].lat,
text: `${formatPercentage(1 - quantiles[i])} live east of here (aprox.)`,
wijkIndex: wijkIndex - 1
}));
}