Published
Edited
Apr 12, 2020
2 forks
6 stars
Insert cell
Insert cell
map = {
const path = d3.geoPath(projection);

const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);

svg.append("g")
.selectAll("path")
.data(topojson.feature(es, es.objects.provinces).features)
.join("path")
.attr("fill", '#ccc')
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(es, es.objects.provinces, (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-opacity", 0.25)
.attr("d", path);

svg.append("path")
.datum(topojson.mesh(es, es.objects.autonomous_regions, (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", "white")
.attr("d", path);
svg
.append("path")
.attr("d", projection.getCompositionBorders())
.attr("fill", "none")
.attr("stroke", "black");

return svg.node();
}
Insert cell
projection = composite.geoConicConformalSpain()
.fitSize([width, height], topojson.feature(es, es.objects.provinces))
Insert cell
es = fetch("https://unpkg.com/es-atlas@0.2.0/es/municipalities.json").then(response => response.json())
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