Skip to content

[8.19] [ColorMapping] Store assignments as raw/serialized values (#207957)#221704

Merged
nickofthyme merged 7 commits intoelastic:8.19from
nickofthyme:backport/8.19/pr-207957
Jun 3, 2025
Merged

[8.19] [ColorMapping] Store assignments as raw/serialized values (#207957)#221704
nickofthyme merged 7 commits intoelastic:8.19from
nickofthyme:backport/8.19/pr-207957

Conversation

@nickofthyme
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

@nickofthyme nickofthyme added the backport This PR is a backport of another PR label May 27, 2025
@nickofthyme nickofthyme enabled auto-merge (squash) May 27, 2025 21:00
nickofthyme and others added 2 commits June 2, 2025 09:56
…7957)

Refactors color mapping logic to store raw values in save objects.

Main changes:

- Instead assignments having a single rule with many values, we now have
assignments with multiple rules of varying types with a single value.
- As per the previous change, there is no more explicit `auto` rule,
this is now implicit when there are no rules in the assignment.
- Raw values can now be raw and in cases such as `RangeKey`s and
`MultiValueKey`s can be instance values. This is not ok for storing in
redux nor the SO so be have added a `serialize` methods to facilitate
this value storage. Code changes attempt to identify which value is used
based on variable/param names and type aliases as both are `unknown`.
- For values that are non-string or non-number types, we no longer allow
creating custom matching options.
- Values are now correctly formatted.
- Add runtime migration for `xy`, `partition`, `tagcloud` and
`datatable` viz. Requires `formBased` `datasourceState` to determine
best string-to-raw value convertion.

Closes elastic#193080
Fixes elastic#187519

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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)

<!-- Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging -->

- [x] Migration from previous stored types.

This PR fixes an issue
([elastic#193080](elastic#193080)) where
custom ranges and multi-field values were not correctly colored based on
selected color mapping configurations.

This change includes a runtime migration to convert old mappings as
strings to their raw value equivalent. This conversion is done at
runtime when the vis is rendered and only updated when the visualization
is saved. Thus this conversion does not dirty the state of the
visualization such as when first opening to edit.

This _should_ have no affect to the user apart from improved value
formatting in the color mapping assignment selection UI. In rare cases,
some assignments may not be correctly converted exactly to the new raw
value but are still preserved to use as string value matches. The only
know case where we are not be able to fully convert the value is when
using labels on custom ranges, the label will not show in the color
mapping assignment UI unless the value is removed as added back.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
@nickofthyme nickofthyme force-pushed the backport/8.19/pr-207957 branch from c9dd61e to 508d838 Compare June 2, 2025 16:57
@elastic elastic deleted a comment from elasticmachine Jun 2, 2025
Copy link
Copy Markdown
Contributor

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

LGTM

@nickofthyme nickofthyme merged commit 4e85033 into elastic:8.19 Jun 3, 2025
9 checks passed
@nickofthyme nickofthyme deleted the backport/8.19/pr-207957 branch June 3, 2025 17:25
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
charts 155 159 +4
data 540 542 +2
eventAnnotationListing 592 596 +4
expressionGauge 69 174 +105
expressionHeatmap 187 191 +4
expressionLegacyMetricVis 27 132 +105
expressionMetricVis 127 131 +4
expressionPartitionVis 198 202 +4
expressionTagcloud 176 180 +4
expressionXY 247 251 +4
lens 1417 1437 +20
observability 1303 1307 +4
visDefaultEditor 224 228 +4
visTypeTimeseries 449 453 +4
visualizations 527 624 +97
total +369

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 20 24 +4
@kbn/coloring 149 160 +11
data 2606 2635 +29
total +44

Async chunks

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

id before after diff
expressionPartitionVis 33.1KB 33.8KB +764.0B
expressionTagcloud 17.2KB 17.8KB +710.0B
expressionXY 95.2KB 96.1KB +865.0B
lens 1.5MB 1.5MB +7.1KB
total +9.4KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/coloring 8 10 +2
data 27 29 +2
lens 60 61 +1
total +5

Page load bundle

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

id before after diff
data 401.6KB 403.2KB +1.6KB
expressionPartitionVis 26.4KB 26.4KB +5.0B
expressionTagcloud 11.2KB 11.2KB +5.0B
expressionXY 40.1KB 40.1KB +5.0B
lens 59.6KB 60.0KB +367.0B
total +2.0KB
Unknown metric groups

API count

id before after diff
@kbn/chart-expressions-common 24 29 +5
@kbn/coloring 190 213 +23
data 3223 3260 +37
total +65

ESLint disabled in files

id before after diff
@kbn/coloring 0 1 +1

ESLint disabled line counts

id before after diff
@kbn/coloring 2 3 +1

References to deprecated APIs

id before after diff
expressionPartitionVis 7 8 +1

Total ESLint disabled count

id before after diff
@kbn/coloring 2 4 +2

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants