Accepted answer

Your Solution:

Hope this helps!!

You can slow down the speed of transition by increasing parameter passed to duration(500) at line 200.(and vice versa)

Read update, enter and exit selections. They are handy almost all the time while working with D3. Take this for reference.

Related Query