Public
Edited
Jul 23, 2023
2 forks
Insert cell
depts_geojson = FileAttachment("departements.geojson").json()
Insert cell
n_anesth = FileAttachment("n_anesth.csv").csv()
Insert cell
Insert cell
map = {
const height = 1250;

const projection = d3.geoMercator().fitExtent(
[
[0, 0],
[width, height]
],
depts_geojson
);

const path = d3.geoPath(projection);

const svg = d3
.create("svg")
.attr("id", "svg")
.attr("viewBox", [0, 0, width, height]);

const g = svg.append("g");

var features = g
.selectAll("path")
.data(depts_geojson.features)
.enter()
.append("path")
.attr("id", (d) => "d" + d.properties.code)
.attr("d", path)
.attr("fill", "white")
.attr("stroke", "black");

function zoomed(event) {
const {transform} = event;
g.attr("transform", transform);
g.attr("stroke-width", 1 / transform.k);
}

const zoom = d3.zoom()
.scaleExtent([1, 8])
.on("zoom", zoomed);

svg.call(zoom);
return svg.node();
}
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