score:1

Accepted answer

Setting the orientation only affects the placement of the labels with respect to the axis line, D3 won't automatically position the axis on the canvas for you. The way this is usually done is to set a margin for the axes and offset the containers accordingly:

svgContainer.append('g')
            .attr("class", "axis")
            .attr("transform", "translate(" + margin + "," + (1000 - margin) + ")")
            .call(xAxis);

svgContainer.append('g')
            .attr("class", "axis")
            .attr("transform", "translate(" + margin + ",0)")
            .call(yAxis);

Complete demo here.


Related Query

More Query from same tag