Public
Edited
Apr 9
2 forks
25 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// this is a pretty rough, not-super-correct calculation
quantiles = {
const formatPercentage = d3.format(".0%");
const wijkenNorthToSouth = wijkenClean.sort((a, b) =>
d3.descending(a.lat, b.lat)
);
const cumulative = d3.cumsum(wijkenNorthToSouth, (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: wijkenNorthToSouth[wijkIndex - 1].lat,
text: `${formatPercentage(1 - quantiles[i])} live south of here (aprox.)`,
wijkIndex: wijkIndex - 1
}));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Don't know how to match these :(
leftOvers = centers.filter(
(d) => typeof d.bevolking === "undefined" && d.wijk !== "Groot water"
)
Insert cell
wijkenClean = centers.filter((d) => Boolean(d.bevolking))
Insert cell
Insert cell
Insert cell
Insert cell
import { freelanceBanner } from "@julesblm/freelance-banner"
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