Updating an axis from horizontal to vertical breaks tick alignment
chrisnicola opened this issue · comments
JSFiddle: https://jsfiddle.net/u6mLuxpq/
I've noticed that if I take an existing axis that is horizontal (say axisBottom
) and then re-call
it with axisRight
or axisLeft
the tick marks all end up on an angle. For right now, my fix is to call select('g.ticks').remove()
but I'm assuming that this isn't the ideal solution.
Changing the orientation of an axis is not currently supported. The recommended way to handle orientation changes is to remove the entire axis (the parent G element) and then add a new axis.
@mbostock ok good to know. That's what I'm doing now. I do realize it is an unusual situation and only comes up in a demonstration mode I have. Figured I'd mention it just in case it wasn't known.
Yep, no problem. For what it’s worth, this limitation is documented in the README:
The orientation of an axis is fixed; to change the orientation, remove the old axis and create a new axis.