chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append("rect")
.attr("x", 0)
.attr("y", 0)
.attr("width", width)
.attr("height", height - margin.bottom)
.attr("fill", "black");
draw();
function draw() {
var lines = 10;
var offset = height / (lines + 1);
for (var i = 0; i < lines; i++) {
var data = Array.from({ length: Math.random() * 72 + 28 }, () =>
Math.random()
);
var lineGroup = svg
.append("g")
.attr("transform", `translate(0,${-i * offset - offset / 4})`);
var randDuration = Math.random() * 4000 + 3000;
lineGroup
.append("path")
.datum(data)
.attr("class", `path${i}`)
.attr("stroke", color(i))
.attr("stroke-width", 6)
.style("mix-blend-mode", "screen")
.attr("d", line)
.transition()
.duration(randDuration)
.ease(d3.easeLinear)
.attrTween("stroke-dasharray", function (d, i) {
const length = this.getTotalLength();
return d3.interpolate(`0,${length}`, `${length},${length}`);
});
}
}
return svg.node();
}