Here is my codes:
var text = container.append('text');
text.text('text')
.attr('transform',function(){
return "translate(" + x1 + "," + y1 + ")"
})
.transition()
.attr('transform',function(){
return "translate(" + x2 + "," + y2 + ")";
});
addTextBackground(text);
Passing text to the function addTextBackground, I found the values in the transform attr were still x1, y1 rather than x2, y2. Seems addTextBackground is called before the transition. How can I make it called after the transition?
Thanks
I figured it out. Using each('end',callback) like:
text.text('text')
.attr('transform',function(){
return "translate(" + x1 + "," + y1 + ")"
})
.transition()
.attr('transform',function(){
return "translate(" + x2 + "," + y2 + ")";
})
.each('end',function(){addTextBackground(d3.select(this))});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.