chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.selectAll("line")
.data(chapters)
.join("line")
.attr("x1", d => x(d.chapter))
.attr("y1", 0)
.attr("x2", d => x(d.chapter))
.attr("y2", height - margin.top - margin.bottom)
.style("stroke-width", 1)
.style("stroke", "#333")
.style("fill", "none");
svg.append("g")
.selectAll("path")
.data(series)
.join("path")
.attr("fill", ({key}) => color(key))
.attr("opacity", 0.9)
.attr("d", area)
.append("title")
.text(({key}) => key);
svg.append("g")
.selectAll("text")
.data(chapters)
.join("text")
.attr("text-anchor", "middle")
.attr("x", d => x(d.chapter))
.attr("y", d => y(d.maxY))
.attr("y", 30)
.text(d => d.chapter);
svg.append("g")
.call(xAxis);
return svg.node();
}