Skip to content

[Lens][Datatable] Fix color mapping of transposed datatables#208623

Merged
nickofthyme merged 6 commits intoelastic:mainfrom
nickofthyme:fix-transpose-color-mapping
Feb 5, 2025
Merged

[Lens][Datatable] Fix color mapping of transposed datatables#208623
nickofthyme merged 6 commits intoelastic:mainfrom
nickofthyme:fix-transpose-color-mapping

Conversation

@nickofthyme
Copy link
Copy Markdown
Contributor

@nickofthyme nickofthyme commented Jan 28, 2025

Summary

In #189895 we added logic to the getColorCategories util function to handle transpose columns. This mistakenly assumed the first row of the datatable would include all transposed column ids (i.e. ${value}---${columnId}). After closer analysis the need to handle transpose a datatable is only in the table rendering (i.e. table_basic.tsx), but in this context we also have the original non-transposed datatable.

So to simplify this we revert this logic to not care about transposed datatables. Now the color mappings are correctly assigned across split by columns.

image

Fixes #208555

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Release note

Fixes an issue in Lens (#208555) Table where a split-by metric on a terms rendered incorrect colors in table cells.

@nickofthyme nickofthyme added release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// Feature:Lens backport:prev-major labels Jan 28, 2025
@nickofthyme nickofthyme requested a review from a team as a code owner January 28, 2025 20:38
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

nickofthyme added a commit to nickofthyme/kibana that referenced this pull request Jan 28, 2025
…lastic#208623

- only handle untransposed data to collate categories
- use untransposed data in lens datatable renderer
- updates usages of getColorCategories
Copy link
Copy Markdown
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor performance comment inline.
Tested locally and it solves the issue for the split by scenario.

@nickofthyme nickofthyme enabled auto-merge (squash) February 5, 2025 03:49
@nickofthyme nickofthyme merged commit a93aaee into elastic:main Feb 5, 2025
1 check passed
@nickofthyme nickofthyme deleted the fix-transpose-color-mapping branch February 5, 2025 06:07
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.16, 8.17, 8.18, 8.x

https://github.com/elastic/kibana/actions/runs/13151299994

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/chart-expressions-common 21 20 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.6MB 1.6MB -290.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
expressionPartitionVis 26.7KB 26.6KB -77.0B
expressionTagcloud 10.8KB 10.7KB -77.0B
expressionXY 39.5KB 39.5KB -77.0B
total -231.0B
Unknown metric groups

API count

id before after diff
@kbn/chart-expressions-common 25 24 -1

History

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.16 Backport failed because of merge conflicts
8.17 Backport failed because of merge conflicts
8.18 Backport failed because of merge conflicts
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 208623

Questions ?

Please refer to the Backport tool documentation

nickofthyme added a commit to nickofthyme/kibana that referenced this pull request Feb 5, 2025
…#208623)

## Summary

In elastic#189895 we added logic to the `getColorCategories` util function to
handle transpose columns. This mistakenly assumed the first row of the
datatable would include all transposed column ids (i.e.
`${value}---${columnId}`). After closer analysis this case is only
present the in datatable rendering (i.e. `table_basic.tsx`), but in this
context we also have the original non-transposed datatable.

So to simplify this we revert this logic to not care about transposed
datatables. Now the color mappings are correctly assigned across **split
by** columns.

<img width="720" alt="image"
src="https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38"
/>

Fixes elastic#208555

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

## Release note

Fixes an issue in Lens (elastic#208555) Table where a split-by metric on a
terms rendered incorrect colors in table cells.

---------

Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
(cherry picked from commit a93aaee)
@nickofthyme
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 6, 2025
drewdaemon pushed a commit to drewdaemon/kibana that referenced this pull request Feb 6, 2025
…#208623)

## Summary

In elastic#189895 we added logic to the `getColorCategories` util function to
handle transpose columns. This mistakenly assumed the first row of the
datatable would include all transposed column ids (i.e.
`${value}---${columnId}`). After closer analysis this case is only
present the in datatable rendering (i.e. `table_basic.tsx`), but in this
context we also have the original non-transposed datatable.

So to simplify this we revert this logic to not care about transposed
datatables. Now the color mappings are correctly assigned across **split
by** columns.

<img width="720" alt="image"
src="https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38"
/>

Fixes elastic#208555

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

## Release note

Fixes an issue in Lens (elastic#208555) Table where a split-by metric on a
terms rendered incorrect colors in table cells.

---------

Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

nickofthyme added a commit that referenced this pull request Feb 10, 2025
…208623) (#209927)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens][Datatable] Fix color mapping of transposed datatables
(#208623)](#208623)

<!--- Backport version: 9.6.4 -->

### 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-02-05T06:07:26Z","message":"[Lens][Datatable]
Fix color mapping of transposed datatables (#208623)\n\n##
Summary\r\n\r\nIn #189895 we added logic to the `getColorCategories`
util function to\r\nhandle transpose columns. This mistakenly assumed
the first row of the\r\ndatatable would include all transposed column
ids (i.e.\r\n`${value}---${columnId}`). After closer analysis this case
is only\r\npresent the in datatable rendering (i.e. `table_basic.tsx`),
but in this\r\ncontext we also have the original non-transposed
datatable.\r\n\r\nSo to simplify this we revert this logic to not care
about transposed\r\ndatatables. Now the color mappings are correctly
assigned across **split\r\nby** columns.\r\n\r\n<img width=\"720\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38\"\r\n/>\r\n\r\nFixes
#208555\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n##
Release note\r\n\r\nFixes an issue in Lens (#208555) Table where a
split-by metric on a\r\nterms rendered incorrect colors in table
cells.\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra
<4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a93aaeee97d018c3e20c9cd1e26b8bc596986a58","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:prev-major","v9.1.0"],"title":"[Lens][Datatable]
Fix color mapping of transposed
datatables","number":208623,"url":"https://github.com/elastic/kibana/pull/208623","mergeCommit":{"message":"[Lens][Datatable]
Fix color mapping of transposed datatables (#208623)\n\n##
Summary\r\n\r\nIn #189895 we added logic to the `getColorCategories`
util function to\r\nhandle transpose columns. This mistakenly assumed
the first row of the\r\ndatatable would include all transposed column
ids (i.e.\r\n`${value}---${columnId}`). After closer analysis this case
is only\r\npresent the in datatable rendering (i.e. `table_basic.tsx`),
but in this\r\ncontext we also have the original non-transposed
datatable.\r\n\r\nSo to simplify this we revert this logic to not care
about transposed\r\ndatatables. Now the color mappings are correctly
assigned across **split\r\nby** columns.\r\n\r\n<img width=\"720\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38\"\r\n/>\r\n\r\nFixes
#208555\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n##
Release note\r\n\r\nFixes an issue in Lens (#208555) Table where a
split-by metric on a\r\nterms rendered incorrect colors in table
cells.\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra
<4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a93aaeee97d018c3e20c9cd1e26b8bc596986a58"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208623","number":208623,"mergeCommit":{"message":"[Lens][Datatable]
Fix color mapping of transposed datatables (#208623)\n\n##
Summary\r\n\r\nIn #189895 we added logic to the `getColorCategories`
util function to\r\nhandle transpose columns. This mistakenly assumed
the first row of the\r\ndatatable would include all transposed column
ids (i.e.\r\n`${value}---${columnId}`). After closer analysis this case
is only\r\npresent the in datatable rendering (i.e. `table_basic.tsx`),
but in this\r\ncontext we also have the original non-transposed
datatable.\r\n\r\nSo to simplify this we revert this logic to not care
about transposed\r\ndatatables. Now the color mappings are correctly
assigned across **split\r\nby** columns.\r\n\r\n<img width=\"720\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38\"\r\n/>\r\n\r\nFixes
#208555\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n##
Release note\r\n\r\nFixes an issue in Lens (#208555) Table where a
split-by metric on a\r\nterms rendered incorrect colors in table
cells.\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra
<4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a93aaeee97d018c3e20c9cd1e26b8bc596986a58"}}]}]
BACKPORT-->

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
nickofthyme added a commit that referenced this pull request Feb 10, 2025
…208623) (#209924)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Lens][Datatable] Fix color mapping of transposed datatables
(#208623)](#208623)

<!--- Backport version: 9.6.4 -->

### 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-02-05T06:07:26Z","message":"[Lens][Datatable]
Fix color mapping of transposed datatables (#208623)\n\n##
Summary\r\n\r\nIn #189895 we added logic to the `getColorCategories`
util function to\r\nhandle transpose columns. This mistakenly assumed
the first row of the\r\ndatatable would include all transposed column
ids (i.e.\r\n`${value}---${columnId}`). After closer analysis this case
is only\r\npresent the in datatable rendering (i.e. `table_basic.tsx`),
but in this\r\ncontext we also have the original non-transposed
datatable.\r\n\r\nSo to simplify this we revert this logic to not care
about transposed\r\ndatatables. Now the color mappings are correctly
assigned across **split\r\nby** columns.\r\n\r\n<img width=\"720\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38\"\r\n/>\r\n\r\nFixes
#208555\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n##
Release note\r\n\r\nFixes an issue in Lens (#208555) Table where a
split-by metric on a\r\nterms rendered incorrect colors in table
cells.\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra
<4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a93aaeee97d018c3e20c9cd1e26b8bc596986a58","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:prev-major","v9.1.0"],"title":"[Lens][Datatable]
Fix color mapping of transposed
datatables","number":208623,"url":"https://github.com/elastic/kibana/pull/208623","mergeCommit":{"message":"[Lens][Datatable]
Fix color mapping of transposed datatables (#208623)\n\n##
Summary\r\n\r\nIn #189895 we added logic to the `getColorCategories`
util function to\r\nhandle transpose columns. This mistakenly assumed
the first row of the\r\ndatatable would include all transposed column
ids (i.e.\r\n`${value}---${columnId}`). After closer analysis this case
is only\r\npresent the in datatable rendering (i.e. `table_basic.tsx`),
but in this\r\ncontext we also have the original non-transposed
datatable.\r\n\r\nSo to simplify this we revert this logic to not care
about transposed\r\ndatatables. Now the color mappings are correctly
assigned across **split\r\nby** columns.\r\n\r\n<img width=\"720\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38\"\r\n/>\r\n\r\nFixes
#208555\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n##
Release note\r\n\r\nFixes an issue in Lens (#208555) Table where a
split-by metric on a\r\nterms rendered incorrect colors in table
cells.\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra
<4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a93aaeee97d018c3e20c9cd1e26b8bc596986a58"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208623","number":208623,"mergeCommit":{"message":"[Lens][Datatable]
Fix color mapping of transposed datatables (#208623)\n\n##
Summary\r\n\r\nIn #189895 we added logic to the `getColorCategories`
util function to\r\nhandle transpose columns. This mistakenly assumed
the first row of the\r\ndatatable would include all transposed column
ids (i.e.\r\n`${value}---${columnId}`). After closer analysis this case
is only\r\npresent the in datatable rendering (i.e. `table_basic.tsx`),
but in this\r\ncontext we also have the original non-transposed
datatable.\r\n\r\nSo to simplify this we revert this logic to not care
about transposed\r\ndatatables. Now the color mappings are correctly
assigned across **split\r\nby** columns.\r\n\r\n<img width=\"720\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c588930e-53b9-409f-a257-2c5be35aaa38\"\r\n/>\r\n\r\nFixes
#208555\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n##
Release note\r\n\r\nFixes an issue in Lens (#208555) Table where a
split-by metric on a\r\nterms rendered incorrect colors in table
cells.\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra
<4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a93aaeee97d018c3e20c9cd1e26b8bc596986a58"}}]}]
BACKPORT-->

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine added v9.0.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Lens release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Lens][ColorMapping] Sparse tables fail to apply auto assignments

5 participants