score:1

Accepted answer

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

So I added

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

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