population = {
opacity;
carte.selectAll(".circles").remove();
if (option !== "cercles") {
carte.selectAll(".circles").remove();
}
else {
const radius = d3.scaleSqrt().domain([0, 1e4]).range([0, 12]);
const path = d3
.geoPath()
.projection(
d3.geoMercator().fitExtent(
[
[20, 20],
[size.width - 20, size.height - 20]
],
data
)
);
carte
.append("g")
.attr("fill", "brown")
.attr("fill-opacity", opacity)
.attr("stroke", "#fff")
.attr("stroke-width", 0.5)
.classed("circles", true)
.selectAll("circle")
.data(data.features)
.enter()
.append("circle")
.attr("transform", (d) => `translate(${path.centroid(d)})`)
.attr("r", (d) => radius(d.properties.population_2014))
.append("title")
.text(
(d) =>
d.properties.commune +
":" +
formatNumber(d.properties.population_2014)
);
}
return md` `;
}