chart = {
const width = 960;
const height = 600;
const path = d3.geoPath();
const formatNumber = d3.format(",.0f");
const radius = d3.scaleSqrt().domain([0, 1e6]).range([0, 15]);
const svg = d3.select(DOM.svg(width, height))
.style("width", "100%")
.style("height", "auto");
svg.append("path")
.datum(topojson.feature(us, us.objects.nation))
.attr("fill", "#ccc")
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(us, us.objects.states, (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-linejoin", "round")
.attr("d", path);
const legend = svg.append("g")
.attr("fill", "#777")
.attr("transform", `translate(${width - 50},${height - 2})`)
.attr("text-anchor", "middle")
.style("font", "10px sans-serif")
.selectAll("g")
.data([1e6, 5e6, 1e7])
.join("g");
legend.append("circle")
.attr("fill", "none")
.attr("stroke", "#ccc")
.attr("cy", d => -radius(d))
.attr("r", radius);
legend.append("text")
.attr("y", d => -2 * radius(d))
.attr("dy", "1.3em")
.text(d3.format(".1s"));
svg.append("g")
.attr("fill", "brown")
.attr("fill-opacity", 0.5)
.attr("stroke", "#fff")
.attr("stroke-width", 0.5)
.selectAll("circle")
.data(topojson.feature(us, us.objects.counties).features
.map(d => (d.population = population.get(d.id), d))
.sort((a, b) => b.population - a.population))
.join("circle")
.attr("transform", d => `translate(${path.centroid(d)})`)
.attr("r", d => radius(d.population))
.append("title")
.text(d => formatNumber(d.population));
return svg.node();
}