chart2 = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const paths = svg.selectAll("path")
.data(points)
.join("path")
.attr("id", (d, i) => "path-" + PLAYERS[i])
.attr("d", line)
.attr("stroke", (d, i) => COLORS[PLAYERS[i]])
.attr("fill", "none");
const pathLengths = PLAYERS.map(player =>
svg.select("#path-" + player).node().getTotalLength()
);
paths.data(pathLengths)
.attr("stroke-dasharray", (l, i) => l + " " + l)
.attr("stroke-dashoffset", l => l)
.transition()
.duration(10000)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0);
const indicator = svg.append("line")
.attr("x1", xScale(1))
.attr("y1", yScale(yScale.domain()[0]))
.attr("x2", xScale(1))
.attr("y2", yScale(yScale.domain()[1]))
.style("stroke", "black")
.transition()
.duration(10000)
.ease(d3.easeLinear)
.attr("x1", xScale(xExtent[1]))
.attr("x2", xScale(xExtent[1]));
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}