…5426) (#216225)
# Backport
This will backport the following commits from `main` to `8.x`:
- [[Lens] Fix coloring/palette assignment on partition charts
(#215426)](#215426)
<!--- Backport version: 9.6.6 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)
<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"nicholas.partridge@elastic.co"},"sourceCommit":{"committedDate":"2025-03-27T19:29:01Z","message":"[Lens]
Fix coloring/palette assignment on partition charts (#215426)\n\nFixes
an issue where reordering the groups within a layer would incorrectly
assign the color mapping to a group other than the
first.","sha":"2cbfe8641cc3b6a3929c46e7737938c3cb665c8a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:version","v9.1.0","v8.19.0"],"title":"[Lens]
Fix coloring/palette assignment on partition
charts","number":215426,"url":"https://github.com/elastic/kibana/pull/215426","mergeCommit":{"message":"[Lens]
Fix coloring/palette assignment on partition charts (#215426)\n\nFixes
an issue where reordering the groups within a layer would incorrectly
assign the color mapping to a group other than the
first.","sha":"2cbfe8641cc3b6a3929c46e7737938c3cb665c8a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215426","number":215426,"mergeCommit":{"message":"[Lens]
Fix coloring/palette assignment on partition charts (#215426)\n\nFixes
an issue where reordering the groups within a layer would incorrectly
assign the color mapping to a group other than the
first.","sha":"2cbfe8641cc3b6a3929c46e7737938c3cb665c8a"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
---------
Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
Summary
Fixes an issue where reordering the groups within a layer would incorrectly assign the color mapping to a group other than the first.
Zight.Recording.2025-03-20.at.05.44.41.PM.mp4
Fixes #203178
release_note: Fixes issue with color mapping when reordering groups in partition charts.
Details
The issue here was due to the order of the columns. The
colorMappingprop is applied at the layer so we need to find the first non-collapsed group to take "ownership" of the color mapping config. Previously we usedlayer.primaryGroupsas the order but this could be incorrect when reordering groups.We can correct this by relying on the column order from the
datasourceusing thegetSortedAccessorsForGrouputility.This issue applied to both the group display properties that control the appearance of the group in the editor, and the
Color mappingrow within the editor.Checklist
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelines