How do I get the dimension of <AxisLeft>? #1086
-
I am trying to fit a bar chart with axes in a container. The issue is that I cannot reserve the right amount of space for AxisLeft because its width is dynamic based on data. Giving it a fixed space causes cropped tick labels as a result. I was trying to get the width of the How should I solve this problem? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey @DoParkEQ thanks for checking out This is a pretty common challenge with visualization engineering with A couple other ideas:
Overall I kind of like your suggestion of exposing a |
Beta Was this translation helpful? Give feedback.
-
Thanks for answering! I'll try the methods you suggested 👍 |
Beta Was this translation helpful? Give feedback.
Hey @DoParkEQ thanks for checking out
visx
.This is a pretty common challenge with visualization engineering with
svg
s becausesvg
s don't gracefully handle overflow and instead clip their contents. You're right that we don't currently exposeref
onAxis
(which powersAxisLeft/Right/Top/Bottom
), I'd be happy to review a PR if you or someone else wants to add that.A couple other ideas:
1,000,000,000
, you could consider simply truncating these using scientific notation (e.g., 1k, 100k, 100M, 1B, etc.) to keep the labels shortAxis.tickLabelProps
which is a function of the form(value: TickValue, index: number) => Partial<TextProps>