-
Notifications
You must be signed in to change notification settings - Fork 129
fix(legend): avoid re-rendering #2646
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
base: main
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
packages/charts/src/state/chart_selectors.ts:148
- Removing the export from ChartSelectorsFactory may lead to breakages if it is expected to be used externally. Confirm that this type is intended for internal use only.
type ChartSelectorsFactory = () => ChartSelectors;
packages/charts/src/chart_types/xy_chart/state/selectors/get_legend_item_extra_values.ts:24
- Using legendValues.length directly assumes that legendValues is always an array; ensure that getLegendConfigSelector always returns an array to prevent potential runtime errors.
type === ScaleType.Ordinal || legendValues.length === 0
packages/charts/src/chart_types/goal_chart/state/selectors/get_screen_reader_data.ts
Show resolved
Hide resolved
packages/charts/src/chart_types/xy_chart/state/selectors/get_legend_item_extra_values.ts
Show resolved
Hide resolved
packages/charts/src/state/selectors/get_screen_reader_summary.ts
Outdated
Show resolved
Hide resolved
mariairiartef
left a comment
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.
I've left some comments!
✅ Successful Deployment (build#5280) - fafec1a |
mariairiartef
left a comment
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.
Thanks for addressing the comments!
| type ChartSelectorsFactory = () => ChartSelectors; | ||
|
|
||
| const EMPTY_TOOLTIP = Object.freeze({ header: null, values: [] }); | ||
| const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = []; |
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.
| const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = []; | |
| const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = Object.freeze([]); |
Do you think it's too much to use Object.freeze on all these? It's unlikely they would change based on our aversion to mutations but still you never know. I don't think freeze affects runtime performance in any meaningful way.
Up to you...
Improve legend rendering efficiency by avoiding unnecessary re-renders when the legend configuration changes. This change enhances performance and maintains the integrity of the displayed legend items.