chart = {
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.attr("style", "max-width: 100%; height: auto; font: 10px sans-serif;");
const g = svg.append("g")
.selectAll("g")
.data(data)
.enter().append("g")
.attr("transform", (d, i) => `translate(0,${i * (step + 1) + margin.top})`);
g.append("clipPath")
.attr("id", d => (d.clip = DOM.uid("clip")).id)
.append("rect")
.attr("width", width)
.attr("height", step);
g.append("defs").append("path")
.attr("id", d => (d.path = DOM.uid("path")).id)
.attr("d", d => area(d.values));
g.append("g")
.attr("clip-path", d => d.clip)
.selectAll("use")
.data(d => Array.from(
{length: overlap * 2},
(_, i) => Object.assign({index: i < overlap ? -i - 1 : i - overlap}, d)
))
.enter().append("use")
.attr("fill", d => color(d.index))
.attr("transform", d => mirror && d.index < 0
? `scale(1,-1) translate(0,${d.index * step})`
: `translate(0,${(d.index + 1) * step})`)
.attr("xlink:href", d => d.path.href);
g.append("text")
.attr("x", 4)
.attr("y", step / 2)
.attr("dy", "0.35em")
.text(d => d.key);
svg.append("g")
.call(xAxis);
return svg.node();
}