map = {
let map = d3.create("svg").attr("width", w).attr("height", h);
map
.selectAll("path")
.data(contiguous_states.features)
.join("path")
.attr("d", path)
.attr("fill", "lightgray")
.attr("stroke", "#fff")
.attr("stroke-width", 1);
map
.selectAll("circle")
.data(largest_cities)
.join("circle")
.attr("cx", (c) => c.x)
.attr("cy", (c) => c.y)
.attr("r", (c) => 5 * (c.population / largest_cities.max_pop) ** 0.3)
.attr("fill", "black")
.attr("fill-opacity", 0.5)
.attr("stroke", "black")
.attr("data-name", (c) => c.name)
.attr("data-population", (c) => c.population)
.nodes()
.forEach(function (c) {
tippy(c, {
content: `
<div>
<h3>${c.getAttribute("data-name")}</h3>
<div>Population: ${c.getAttribute("data-population")}</div>
</div>`,
theme: "light-border",
allowHTML: true
});
});
return map.node();
}