I am trying to listen end of the transition event on each of my circles:
var n=0;
//drawing the plot
var circles = svg.selectAll("circle")
.data(dataset)
.enter()
.append("circle")
.attr("cx", function(d, i){return xScale(max-createDate(dataset[dataset.length-1-i]["Time"]));})
.attr("cy", -100)
.attr("r", 5)
.attr("fill", function(d){return d["Doping"]?"#ff1d25":"#009267";})
.each(function() { n++; console.log(n)})
.transition()
.delay(function(d,i){return i*50})
.duration(1500)
.attr("cy", function(d){return yScale(d["Place"]);})
.each('end', function() {
n--;
if (!n) {
console.log("end")
}
})
But "end" is never printed! What am I doing wrong? The full code is here