-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically set y-axis label width for credits chart #12625
Conversation
… width otherwise.
@@ -16,6 +16,11 @@ const BarChart: React.FC<BarChartProps> = ({ data, legendLabels, xLabel, yLabel | |||
const chartLinesColor = theme.greyColor20; | |||
const chartTicksColor = theme.lightTextColor; | |||
|
|||
const width = Math.min( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some sorting happening. I think it deserves a memo
@@ -16,6 +16,11 @@ const BarChart: React.FC<BarChartProps> = ({ data, legendLabels, xLabel, yLabel | |||
const chartLinesColor = theme.greyColor20; | |||
const chartTicksColor = theme.lightTextColor; | |||
|
|||
const width = Math.min( | |||
Math.max([...data].sort((a, b) => b.value - a.value)[0].value.toFixed(0).length * 10, 80), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assumes that there's always at least 1 item in the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default data is an array of dates + values at 0.
* This feels a little hacky, but we don't have a way to dynamically set width otherwise. * memo width
Fixes #11586
This is honestly a little hackier than I wanted, but we don't have a way to dynamically set the width