chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.attr("fill-opacity", 0.8)
.selectAll("path")
.data(series)
.join("path")
.attr("fill", ({key}) => color(regionByState.get(key)))
.attr("d", area)
.append("title")
.text(({key}) => key);
svg.append("g")
.attr("fill", "none")
.attr("stroke-width", 0.75)
.selectAll("path")
.data(series)
.join("path")
.attr("stroke", ({key}) => d3.lab(color(regionByState.get(key))).darker())
.attr("d", area.lineY1());
svg.append("defs")
.selectAll("path")
.data(series)
.join("path")
.attr("id", d => (d.id = DOM.uid("state")).id)
.attr("d", midline);
svg.append("g")
.style("font", "10px sans-serif")
.attr("text-anchor", "middle")
.selectAll("text")
.data(series)
.join("text")
.attr("dy", "0.35em")
.append("textPath")
.attr("href", d => d.id.href)
.attr("startOffset", d => `${Math.max(0.05, Math.min(0.95, d.offset = d3.maxIndex(d, d => d[1] - d[0]) / (d.length - 1))) * 100}%`)
.text(d => d.key);
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
return svg.node();
}