Skip to content

How do I get the dimension of <AxisLeft>? #1086

Answered by williaster
parkdoeui asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @DoParkEQ thanks for checking out visx.

This is a pretty common challenge with visualization engineering with svgs because svgs don't gracefully handle overflow and instead clip their contents. You're right that we don't currently expose ref on Axis (which powers AxisLeft/Right/Top/Bottom), I'd be happy to review a PR if you or someone else wants to add that.

A couple other ideas:

  • in your chart you have numbers of the form 1,000,000,000, you could consider simply truncating these using scientific notation (e.g., 1k, 100k, 100M, 1B, etc.) to keep the labels short
  • you could leverage Axis.tickLabelProps which is a function of the form (value: TickValue, index: number) => Partial<TextProps>

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mtoneil
Comment options

Answer selected by hshoff
Comment options

You must be logged in to vote
1 reply
@VigneshTrantor
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1031 on February 24, 2021 16:25.