chart = {
const zoom = d3
.zoom()
.scaleExtent([1, 70])
.extent([
[margin.left, 0],
[width - margin.right, height]
])
.translateExtent([
[margin.left, -Infinity],
[width - margin.right, Infinity]
])
.on("zoom", zoomed);
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
const clip = DOM.uid("clip");
svg
.append("clipPath")
.attr("id", clip.id)
.append("rect")
.attr("x", margin.left)
.attr("y", margin.top)
.attr("width", width - margin.left - margin.right)
.attr("height", height - margin.top - margin.bottom);
const path = svg
.append("path")
.attr("clip-path", clip)
.attr("fill", "steelblue")
.attr("d", area(data, x));
const gx = svg.append("g").call(xAxis, x);
svg.append("g").call(yAxis, y);
svg
.call(zoom)
.transition()
.duration(750)
.call(zoom.scaleTo, 68, [x(Date.UTC(2001, 9, 11)), 0]);
function zoomed(event) {
const xz = event.transform.rescaleX(x);
path.attr("d", area(data, xz));
gx.call(xAxis, xz);
}
return svg.node();
}