chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
svg
.selectAll("#path")
.data(data)
.join("path")
.attr("id", "path")
.attr("fill", "none")
.attr("stroke", (d) => d.color)
.attr("stroke-width", 2)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", (d) => line(d.value))
.attr("stroke-dasharray", 1500 + " " + 1500)
.attr("stroke-dashoffset", 1500)
.transition()
.duration(5000)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0);
const legend = svg.append("g").attr("transform", "translate(550,-75)");
legend
.selectAll("mydots")
.data(data)
.join("rect")
.attr("class", "mydots")
.attr("x", 100)
.attr("y", (d, i) => 100 + i * (20 + 5))
.attr("width", 20)
.attr("height", 20)
.style("fill", (d) => d.color);
legend
.selectAll("mylabels")
.data(data)
.join("text")
.attr("class", "mylabels")
.attr("x", 100 + 20 * 1.2)
.attr("y", (d, i) => 100 + i * (20 + 5) + 20 / 2)
.style("fill", (d) => d.color)
.text((d) => d.platform)
.attr("text-anchor", "left")
.style("alignment-baseline", "middle");
return svg.node();
}