chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.selectAll("path")
.data(series)
.join("path")
.attr("fill", ({key}) => color(key))
.attr("d", area)
.append("title")
.text(({key}) => key);
svg.append("g")
.attr("fill", "none")
.attr("stroke", "white")
.selectAll("path")
.data(series)
.join("path")
.attr("d", area.lineY1());
svg.append("g")
.attr("font-size", 10)
.attr("font-family", "sans-serif")
.attr("text-anchor", "middle")
.selectAll("text")
.data(series)
.join("text")
.attr("dy", "0.35em")
.text(d => d.key)
.datum(d => d3.greatest(d, ([a, b]) => b - a))
.attr("text-anchor", d => x(d.data[0]) < 100 ? "start" : x(d.data[0]) > width - 100 ? "end" : null)
.attr("dx", d => x(d.data[0]) < 100 ? "1em" : x(d.data[0]) > width - 100 ? "-1em" : null)
.attr("transform", d => `translate(${x(d.data[0])},${y((d[0] + d[1]) / 2)})`);
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
return svg.node();
}