Unlisted
Edited
Apr 26, 2023
Insert cell
Insert cell
map = {
let w = 900;
let h = 500;
let svg = d3
.create("svg")
.attr("viewBox", [0, 0, w, h])
.attr("width", "100%")
.style("max-width", `${w}px`);

let proj = d3.geoEqualEarth().fitSize([w, h], geojson);
let path = d3.geoPath().projection(proj);

let map = svg.append("g");
let state_group = map.append("g");
state_group
.selectAll("path.state")
.data(geojson.features)
.join("path")
.attr("d", path)
.attr("stroke", "white")
.attr("stroke-width", "1")
.attr("fill", (d) =>
iguana_data.map((o) => o.Importer).indexOf(d.properties.ISO_A2) > -1
? "#D7B895"
: "lightgray"
)
.append("title")
.text((d) => d.properties.ISO_A2);

return svg.node();
}
Insert cell
geojson = topojson.feature(topo, topo.objects.countries)
Insert cell
topo = FileAttachment("countries.json").json()
Insert cell
url = FileAttachment("countries.json").url()
Insert cell
iguana_data = FileAttachment("iguana.csv").csv()
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