Accepted answer

Create a g element for the y-axis outside the update function.

In the update;

Why do you have all that code duplication inside the update function?

Put it all in a function and call it with a selection to update the selection.

Related Query

More Query from same tag