Accepted answer

The problem was that the "transform", "translate(" in your createAxis() moved your axis to the side.

So I added

.attr("transform", "translate(" + margin.left + "," + + ")");

To your original svg variable so that it aligns with the axis and removed the

  .attr("transform", "translate(" + 0 + "," + 0 + ")");

From the createAxis()

Here's the link: Plunker

Related Query

More Query from same tag