map = {
let w = d3.min([width, 1100]);
let h = 0.6 * w;
let pad = 10;
let svg = d3
.create("svg")
.attr("viewBox", [0, 0, w, h])
.style("max-width", `${w}px`);
let projection = d3.geoAlbersUsa();
projection.fitExtent(
[
[pad, pad],
[w - pad, h - pad]
],
states
);
let path = d3.geoPath().projection(projection);
let color_scale = d3
.scaleQuantile()
.domain(Array.from(state_populations.values()))
.range(d3.schemeBlues[8]);
svg
.append("g")
.selectAll("path")
.data(states.features)
.join("path")
.attr("d", path)
.attr("fill", (d) =>
color_scale(state_populations.get(d.properties.STATEFP))
)
.attr("stroke", "black")
.attr("stroke-width", 1);
svg.node().scale = color_scale;
return svg.node();
}