Skip to content

Get YAxis tick values to calculate width #4445

Answered by ckifer
dalvarez asked this question in Q&A
Discussion options

You must be logged in to vote

Left offset is margin + YAxis width so make sure margin is accounted for (you have direct control over that).

You cannot (currently) easily grab the domain/range that recharts calculates for you.

In 3.0 we will expose hooks that will allow you to get this information back - for now the only thing I could suggest leads to more hacks which you may not want to rely on.

You can use the Customized component to do all sorts of crazy things and access all/most of the internal state of recharts, but this will be going away in 3.0 with hooks in its place (as its hard to document and maintain). There you have access to what the entire left offset value is. The codesandbox should show using it, but …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dalvarez
Comment options

@ckifer
Comment options

@dalvarez
Comment options

Answer selected by dalvarez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants