{
const duration = 5000;
const axisX = d3.select(".xAxis>.xAxisBottom>.domain");
const axisXLen = axisX.node().getTotalLength();
axisX
.attr("stroke-dasharray", function () {
return `0 ${axisXLen}`;
})
.transition()
.duration(`${duration}`)
.ease(d3.easeQuadIn)
.attr("stroke-dasharray", function () {
return `${axisXLen} ${axisXLen}`;
});
d3.selectAll(".xAxis>.xAxisBottom>.tick>line")
.each(function (d, i) {
const selection = d3.select(this);
selection.attr("data-t", `${this.getAttribute("y2")}`);
})
.attr("y2", "0")
.transition()
.duration(3000)
.delay(function () {
const child = this;
const parent = this.parentNode;
const p = parseFloat(
parent.getAttribute("transform").match(/(\d+\.\d+)(?=\,)|(\d+)(?=\,)/gm)
);
const b = axisX.node().getPointAtLength(axisXLen * 0).x;
const c = axisXLen;
const elapsedTimePct = Math.sqrt((p - b) / c);
return `${duration}` * elapsedTimePct;
})
.attrTween("y2", function () {
const end = this.getAttribute("data-t");
return d3.interpolate(0, end);
});
}