Public
Edited
Nov 9, 2023
1 fork
Also listed in…
Dataviz
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
population = {
opacity;
carte.selectAll(".circles").remove();
if (option !== "cercles") {
carte.selectAll(".circles").remove();
} // Les cercles sont enlevés
else {
const radius = d3.scaleSqrt().domain([0, 1e4]).range([0, 12]);

const path = d3
.geoPath() // Projection et centrage automatique des données dans la carte
.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)})`) // Le centre du contour
.attr("r", (d) => radius(d.properties.population_2014))
.append("title")
.text(
(d) =>
d.properties.commune +
":" +
formatNumber(d.properties.population_2014)
);
}
return md` `;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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