addAnimation = (
plot,
{ type = "circle", attribute = "fill-opacity", delay = 50, endValue = 1 } = {}
) => {
const wrapper = d3.create("div");
const chart = d3.select(plot);
let attr;
switch (attribute) {
case "fillOpacity":
attr = "fill-opacity";
break;
case "strokeOpacity":
attr = "stroke-opacity";
break;
default:
attr = attribute;
}
const marks = chart.selectAll(type).filter(function () {
return !this.parentNode.classList.contains("tick");
});
marks
.transition()
.duration(500)
.delay((d, i) => i * delay)
.style(attr, endValue);
if (attr === "r") {
marks
.transition()
.duration(500)
.delay((d, i) => i * delay)
.attr(attr, endValue);
}
return chart.node();
}