I need to make a FadeOut method (similar to jQuery) using D3.js. What I need to do is to set the opacity to 0 using
You want to listen for the "end" event of the transition.
From the documentation for
If type is specified, adds a listener for transition events, supporting both "start" and "end" events. The listener will be invoked for each individual element in the transition, even if the transition has a constant delay and duration. The start event can be used to trigger an instantaneous change as each element starts to transition. The end event can be used to initiate multi-stage transitions by selecting the current element,
this, and deriving a new transition. Any transitions created during the end event will inherit the current transition ID, and thus will not override a newer transition that was previously scheduled.
See this forum thread on the topic for more details.
Finally, note that if you just want to remove the elements after they have faded out (after the transition has finished), you can use