chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append(legend)
.attr("transform", "translate(670,200)");
svg.append("g")
.selectAll("path")
.data(topojson.feature(polygons, polygons.objects.NJCounties).features)
.join("path")
.attr("fill", d => color(data.get(d.properties[idAttribute])))
.attr("stroke", "black")
.attr("d", path)
.append("title")
.text(d => `${d.properties[idAttribute]}, ${format(data.get(d.properties[idAttribute]))}`);
return svg.node();
}