score:2

Accepted answer

I have improved your fiddle: https://jsfiddle.net/y1vctdsg/1/ I have changed following part of the code:

svg.append("g")
 .attr("class", "x axis")
 .attr("transform", `translate(20,${height+margin.top})`)
 .call(xAxis);

And also I've changed from axisBottom() to axisTop() only for better readability:

g.append("g")
 .attr("class", "xAxis")
 .call(d3.axisTop(x))

Related Query