{
const svg = d3.create('svg')
.attr('width', mapWidth)
.attr('height', mapHeight);
svg.selectAll("path")
.data(nycGeo.features)
.join("path")
.attr("d", path)
.attr("fill", '#d3d3d3')
.attr("stroke", "white");
svg.append("g")
.selectAll("circle")
.data(nycGeo.features)
.join("circle")
.attr("stroke", "steelblue")
.attr("fill", "steelblue")
.attr("fill-opacity", 0.5)
.attr("transform", d => `translate(${path.centroid(d)})`)
.attr("r", d => radius(zipToInjuries[d.properties.zcta]));
const legendGroup = svg.append("g")
.attr('transform', `translate(${maxRadius * 2}, 10)`)
.attr('font-family', 'sans-serif')
.attr('font-size', 12);
legendGroup.append('text')
.attr('dominant-baseline', 'hanging')
.attr('font-weight', 'bold')
.text('Vehicle collision injuries, 2019');
const legendRows = legendGroup.selectAll("g")
.data([100, 200, 400, 800])
.join("g")
.attr("transform", (d, i) => `translate(0, ${30 + i * 2.5 * maxRadius})`);
legendRows.append("circle")
.attr("r", d => radius(d))
.attr("stroke", "steelblue")
.attr("fill", "steelblue")
.attr("fill-opacity", 0.5);
legendRows.append("text")
.attr("dominant-baseline", "middle")
.attr("x", maxRadius + 5)
.text(d => d);
return svg.node();
}