chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const zx = x.copy();
const line = d3.line()
.x(d => zx(d.date))
.y(d => y(d.close));
const path = svg.append("path")
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-width", 2)
.attr("stroke-miterlimit", 1)
.attr("stroke-dasharray", [lineLength/2,lineLength/2])
.attr("d", line(data));
const gx = svg.append("g")
.call(xAxis, zx);
const gy = svg.append("g")
.call(yAxis, y);
return Object.assign(svg.node(), {
update(domain) {
zx.domain(domain);
path.attr("stroke-dasharray", `${t * lineLength},${lineLength}`);
}
});
}