Accepted answer

This has nothing to do with "moving the chart". Here is the problem.

When you do this:

var labels = svg.selectAll("text")

You're selecting text elements that already exist in your SVG. Because of that, your "enter" selection will have less elements compared to what it should contain.

The solution is simple: select something that doesn't exist:

var labels = svg.selectAll("foo")

Or, alternatively, move the blocks that append the axes' labels to the bottom of the code.

Here is your updated fiddle:

Related Query