{
const width = 920;
const height = 560;
const projection = d3.geoAlbersUsa().fitSize([width, height], states);
const path = d3.geoPath().projection(projection);
const svg = d3.create("svg").attr("viewBox", [0, 0, 975, 610]);
svg
.selectAll(".state")
.data(states.features)
.join("path")
.attr("d", path)
.attr("class", "state")
.style("fill", function(d) {
const value = stateHouseholdIncome.get(d.properties.NAME);
if (value) {
return colorScale(value);
} else {
return "#ccc";
}
})
.attr("fill-opacity", 1)
.attr("stroke", "black");
svg.append("g")
.attr("transform", "translate(520,-5)")
.append(() => legend({color, title: "Houshold Income, 2017, thousands, $", width: 340}));
return svg.node();
}