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");
var noLines = width;
for (var i = 0; i < noLines; i++) {
var rand = Math.random();
var randHeight = Math.random();
const end = {
x: x(Math.floor(rand * 100 + 1)),
y: y(Math.floor(randHeight * 100 + 1))
};
svg
.append("line")
.attr("x1", function () {
var off = Math.random() * 0.5;
if (off < 0.15) off = -off;
return end.x + off * 100 * randHeight;
})
.attr("x2", end.x)
.attr("y1", y(0))
.attr("y2", end.y)
.attr("opacity", Math.random() + 0.1)
.style("mix-blend-mode", "screen")
.attr("stroke", d3.interpolateRainbow(rand));
svg
.append("circle")
.attr("class", "photon")
.attr("cx", end.x)
.attr("cy", end.y)
.style("mix-blend-mode", "screen")
.attr("opacity", Math.random() + 0.1)
.attr("fill", "white")
.attr("r", Math.floor(Math.random() * 5 + 2));
}
var defs = svg.append("defs");
var filter = defs.append("filter").attr("id", "glow");
filter
.append("feGaussianBlur")
.attr("stdDeviation", "2")
.attr("result", "coloredBlur");
var feMerge = filter.append("feMerge");
feMerge.append("feMergeNode").attr("in", "coloredBlur");
feMerge.append("feMergeNode").attr("in", "SourceGraphic");
svg.selectAll(".photon").style("filter", "url(#glow)");
return svg.node();
}