There is an excellent example of transitioning data in D3, but this only works in version 3.
D3 version 4 requires a slightly different approach,
namely that the enter
ed selections need to be merge
d prior to transition.
Added transition on exit
. Also did a little code cleanup, especially given that eval
is pretty gross.