Skip to content

fix(legend): avoid re-rendering#2646

Merged
markov00 merged 7 commits intoelastic:mainfrom
markov00:2025_04_10-avoid_rerender_legend
Mar 5, 2026
Merged

fix(legend): avoid re-rendering#2646
markov00 merged 7 commits intoelastic:mainfrom
markov00:2025_04_10-avoid_rerender_legend

Conversation

@markov00
Copy link
Copy Markdown
Collaborator

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.

@markov00 markov00 requested a review from Copilot April 10, 2025 21:09
Copy link
Copy Markdown
Contributor

Copilot AI left a 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

@markov00 markov00 marked this pull request as ready for review October 27, 2025 08:39
@markov00 markov00 requested a review from a team October 27, 2025 08:40
@mariairiartef mariairiartef self-requested a review October 27, 2025 15:56
Copy link
Copy Markdown
Contributor

@mariairiartef mariairiartef left a 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!

Copy link
Copy Markdown
Contributor

@mariairiartef mariairiartef left a 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!

@elastic-datavis
Copy link
Copy Markdown
Contributor

@markov00 markov00 merged commit 0ca3289 into elastic:main Mar 5, 2026
14 checks passed
nickofthyme pushed a commit that referenced this pull request Mar 31, 2026
# [71.4.0](v71.3.0...v71.4.0) (2026-03-31)

### Bug Fixes

* **legend:** avoid re-rendering ([#2646](#2646)) ([0ca3289](0ca3289))
* **legend:** keep legend values visible when hiding series in list layout ([#2807](#2807)) ([c5089f5](c5089f5))

### Features

* **highlight:** Add support to configure dimmed (unhighlight) colors for Bar, Partition, Waffle and Flame charts ([#2774](#2774)) ([b39e24d](b39e24d)), closes [#ECF1F9](https://github.com/elastic/elastic-charts/issues/ECF1F9) [#384861](https://github.com/elastic/elastic-charts/issues/384861)
* **metric:** Add ability to vertically align the metrics values to the middle of the chart ([#2783](#2783)) ([54ca7cb](54ca7cb))
* **theme:** set default labelOptions.widthLimit in themes and update metric.titleWeight default to 500 ([#2802](#2802)) ([fbb8834](fbb8834))
maryam-saeidi added a commit to elastic/kibana that referenced this pull request Apr 2, 2026
## Summary

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@elastic/charts](https://github.com/elastic/elastic-charts) |
dependencies | minor | [`71.3.0` ->
`71.4.0`](elastic/elastic-charts@v71.3.0...v71.4.0)
|

### Release Notes

#
[71.4.0](elastic/elastic-charts@v71.3.0...v71.4.0)
(2026-03-31)


### Bug Fixes

* **legend:** avoid re-rendering
([#2646](elastic/elastic-charts#2646))
([0ca3289](elastic/elastic-charts@0ca3289))
* **legend:** keep legend values visible when hiding series in list
layout ([#2807](elastic/elastic-charts#2807))
([c5089f5](elastic/elastic-charts@c5089f5))


### Features

* **highlight:** Add support to configure dimmed (unhighlight) colors
for Bar, Partition, Waffle and Flame charts
([#2774](elastic/elastic-charts#2774))
([b39e24d](elastic/elastic-charts@b39e24d)),
closes
[#ECF1F9](https://github.com/elastic/elastic-charts/issues/ECF1F9)
[#384861](https://github.com/elastic/elastic-charts/issues/384861)
* **metric:** Add ability to vertically align the metrics values to the
middle of the chart
([#2783](elastic/elastic-charts#2783))
([54ca7cb](elastic/elastic-charts@54ca7cb))
* **theme:** set default labelOptions.widthLimit in themes and update
metric.titleWeight default to 500
([#2802](elastic/elastic-charts#2802))
([fbb8834](elastic/elastic-charts@fbb8834))

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Abdul Zahid <awahab07@yahoo.com>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
## Summary

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@elastic/charts](https://github.com/elastic/elastic-charts) |
dependencies | minor | [`71.3.0` ->
`71.4.0`](elastic/elastic-charts@v71.3.0...v71.4.0)
|

### Release Notes

#
[71.4.0](elastic/elastic-charts@v71.3.0...v71.4.0)
(2026-03-31)


### Bug Fixes

* **legend:** avoid re-rendering
([elastic#2646](elastic/elastic-charts#2646))
([0ca3289](elastic/elastic-charts@0ca3289))
* **legend:** keep legend values visible when hiding series in list
layout ([elastic#2807](elastic/elastic-charts#2807))
([c5089f5](elastic/elastic-charts@c5089f5))


### Features

* **highlight:** Add support to configure dimmed (unhighlight) colors
for Bar, Partition, Waffle and Flame charts
([elastic#2774](elastic/elastic-charts#2774))
([b39e24d](elastic/elastic-charts@b39e24d)),
closes
[#ECF1F9](https://github.com/elastic/elastic-charts/issues/ECF1F9)
[#384861](https://github.com/elastic/elastic-charts/issues/384861)
* **metric:** Add ability to vertically align the metrics values to the
middle of the chart
([elastic#2783](elastic/elastic-charts#2783))
([54ca7cb](elastic/elastic-charts@54ca7cb))
* **theme:** set default labelOptions.widthLimit in themes and update
metric.titleWeight default to 500
([elastic#2802](elastic/elastic-charts#2802))
([fbb8834](elastic/elastic-charts@fbb8834))

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Abdul Zahid <awahab07@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants