score:1

Accepted answer

For a fixed delay, you can use use delay. See https://github.com/d3/d3-transition#transition_delay

For a dynamic delay, you can use the 'end' event, coupled with another transition (from https://stackoverflow.com/a/10692220/6184972), like:

d3.select('#myid').transition().style('opacity', '0').on('end', function () {
    console.log('computing...');
    setTimeout(function () {
        console.log('Done!');
        d3.select('#myid').transition().style('opacity', 1);
    }, Math.random() * 2000 + 1000);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<div id="myid">Hi World</div>


Related Query

More Query from same tag