Right-align tick text in axisRight() ?
tippmar opened this issue · comments
tippmar commented
Is there a way to right-align the tick text when creating a right axis via axisRight()
?
I'm currently rendering a right axis on my graph like so:
root
.attr("class", "y gap-axis")
.attr("margin-top", margin.top)
.attr("transform", `translate(${width})`)
.call(
d3.axisRight(barYScale)
.tickPadding(-1),
);
}
and I get results like so:
but I want the numbers to be right-aligned.
Mike Bostock commented
You can use d3.axisLeft if you want right-aligned ticks. Sometimes I use an axisRight on the left side of the plot, as in this contour plot example.
Alternatively, you can select the elements generated by the axis and modify them however you like, as in the styled axes example.