Skip to content

[Lens] Update @elastic/charts to 71.0.0 and use new metric chart#229815

Merged
mariairiartef merged 183 commits intoelastic:mainfrom
mariairiartef:lens/228964/new-metric
Sep 4, 2025
Merged

[Lens] Update @elastic/charts to 71.0.0 and use new metric chart#229815
mariairiartef merged 183 commits intoelastic:mainfrom
mariairiartef:lens/228964/new-metric

Conversation

@mariairiartef
Copy link
Contributor

@mariairiartef mariairiartef commented Jul 29, 2025

closes #228964

Replaces renovate bot PR #230486 for Elastic Charts v71.0.0

Summary

  • Upgrade Elastic Charts to version 71.0.0

  • Update Metric Chart toolbar with new settings:

    • Primary Metric alignment
    • Secondary Metric alignment
    • Primary Metric position
    • Title weight
  • Update Primary Metric sidebar settings by adding ability to apply color to value when supporting visualization is a panel

  • Update Secondary Metric sidebar settings by adding ability to add label (previously called prefix) before or after the Secondary Metric value

  • Use default Secondary Metric component from Elastic Charts so we don't rely on a custom Secondary Metric component created in Lens

  • Update unit and functional tests when using the new metric version

Screenshots and screen recordings

New progress bar style

Screenshot 2025-08-22 at 11 22 50

Allows new primary metric position "top"*

Screen.Recording.2025-08-22.at.12.26.27.mov

*note: when the user selects primary position > top, it automatically selects title weight to normal and primary align to left. And when the user selects primary position > bottom, it automatically selects title weight to bold and primary align to right

New toolbar settings

Screen.Recording.2025-08-13.at.15.39.30.mov

Allows applying color to the Metric chart background (panel) or Primary Metric value*

Screen.Recording.2025-08-13.at.15.31.55.mov

*note: when value is selected, we use the data visualization text colors

Enables changing the label position for the Secondary Metric

Screen.Recording.2025-08-13.at.15.33.42.mov

Checklist

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • 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.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.
@mariairiartef mariairiartef self-assigned this Jul 29, 2025
@mariairiartef mariairiartef added the Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// label Aug 1, 2025
@mariairiartef mariairiartef changed the title [Lens] Update metric styles Aug 1, 2025
@mariairiartef mariairiartef added Feature:Lens v9.2.0 backport:version Backport to applied version labels labels Aug 5, 2025
@mariairiartef mariairiartef force-pushed the lens/228964/new-metric branch 8 times, most recently from 96a35bc to 60f3c3d Compare August 8, 2025 11:23
@mariairiartef mariairiartef added backport:skip This PR does not require backporting and removed backport:version Backport to applied version labels v9.2.0 labels Aug 8, 2025
@mariairiartef mariairiartef force-pushed the lens/228964/new-metric branch 2 times, most recently from c9ff587 to 9c625fd Compare August 11, 2025 12:59
@mariairiartef mariairiartef changed the title [Lens] Update @elastic/charts and use new metric chart Aug 12, 2025
@mariairiartef mariairiartef force-pushed the lens/228964/new-metric branch from e5cf06a to d4fe004 Compare August 13, 2025 13:22
? euiLightVars.euiColorPrimary
: euiThemeVars.euiColorEmptyShade;
if (showingBar(state) && isMetricNumeric) {
return euiLightVars.euiColorPrimary;
Copy link
Contributor Author

@mariairiartef mariairiartef Aug 13, 2025

Choose a reason for hiding this comment

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

I'm not sure why we default to color.primary from brand colors if in the palette selection we don't show this color as we show the data visualization colors.

Copy link
Contributor

Choose a reason for hiding this comment

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

In agreement with giovanni we can use the VisColor 2, but is not need to do it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

issue created: #233834

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#9131

[✅] x-pack/platform/test/functional/apps/lens/group6/config.ts: 25/25 tests passed.

see run history

@elastic elastic deleted a comment from kibanamachine Aug 13, 2025
async ({ id, pattern, finalPattern }) => {
await getFormattedMetrics(394.2393, 983123.984, { id, params: { pattern } });
expect(mockDeserialize).toHaveBeenCalledTimes(2);
expect(mockDeserialize).toHaveBeenCalledTimes(4);
Copy link
Contributor Author

@mariairiartef mariairiartef Aug 13, 2025

Choose a reason for hiding this comment

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

Using the default secondary metric component and calling the getSecondaryMetricInfo method from metric_vis, it gets called 3 times. Should we optimize this?

Copy link
Contributor

Choose a reason for hiding this comment

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

not in this PR, please open an issue for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

issue created: #233835


import { DimensionsVisParam, MetricVisParam } from '../../common';
import { FormatOverrides } from './helpers';
import { getMetricFormatter } from './helpers';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: import the formatter directly from the file instead of passing it as parameter from metric_vis

@mariairiartef mariairiartef marked this pull request as ready for review August 13, 2025 14:49
@mariairiartef mariairiartef requested a review from a team as a code owner August 13, 2025 14:49
@markov00
Copy link
Contributor

markov00 commented Sep 2, 2025

@gvnmagni @mariairiartef I've created a follow up issue with Giovanni's comments #233702

Copy link
Contributor

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Changes looks good to me, tested locally also with preexisting metrics.
No major differences and new logic works fine

async ({ id, pattern, finalPattern }) => {
await getFormattedMetrics(394.2393, 983123.984, { id, params: { pattern } });
expect(mockDeserialize).toHaveBeenCalledTimes(2);
expect(mockDeserialize).toHaveBeenCalledTimes(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

not in this PR, please open an issue for that

? euiLightVars.euiColorPrimary
: euiThemeVars.euiColorEmptyShade;
if (showingBar(state) && isMetricNumeric) {
return euiLightVars.euiColorPrimary;
Copy link
Contributor

Choose a reason for hiding this comment

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

In agreement with giovanni we can use the VisColor 2, but is not need to do it in this PR

Copy link
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

This looks great! I tested locally with a few old Metrics and everything works smoothly.

I reviewed most files and left only minor comments. I have about 10 more files to review that are the larger code diffs, but I ran out of time tonight. I'll pick back up reviewing in the morning.

Copy link
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

Ok, I went through the rest of the code changes and everything look great.

@mariairiartef mariairiartef enabled auto-merge (squash) September 4, 2025 07:03
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
expressionMetricVis 145 144 -1
lens 1407 1411 +4
total +3

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
expressionMetricVis 81 90 +9
lens 563 570 +7
total +16

Async chunks

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

id before after diff
expressionMetricVis 9.1KB 7.8KB -1.2KB
lens 1.5MB 1.5MB +6.4KB
synthetics 1.0MB 1.0MB +19.0B
total +5.1KB

Page load bundle

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

id before after diff
expressionMetricVis 15.5KB 16.5KB +1.0KB
kbnUiSharedDeps-npmDll 6.5MB 6.5MB +8.6KB
total +9.6KB
Unknown metric groups

API count

id before after diff
expressionMetricVis 81 91 +10
lens 662 669 +7
total +17

History

cc @mariairiartef

@mariairiartef mariairiartef merged commit 44185df into elastic:main Sep 4, 2025
13 checks passed
ymao1 pushed a commit to ymao1/kibana that referenced this pull request Sep 4, 2025
…stic#229815)

closes elastic#228964

Replaces renovate bot PR elastic#230486
for Elastic Charts v71.0.0

## Summary

- Upgrade Elastic Charts to version 71.0.0



- Update Metric Chart toolbar with new settings: 
  - Primary Metric alignment 
  - Secondary Metric alignment
  - Primary Metric position 
  - Title weight
- Update Primary Metric sidebar settings by adding ability to apply
color to value when supporting visualization is a panel
- Update Secondary Metric sidebar settings by adding ability to add
label (previously called prefix) before or after the Secondary Metric
value
- Use default Secondary Metric component from Elastic Charts so we don't
rely on a custom Secondary Metric component created in Lens
- Update unit and functional tests when using the new metric version

## Screenshots and screen recordings

### New progress bar style

<img width="327" height="328" alt="Screenshot 2025-08-22 at 11 22 50"
src="https://github.com/user-attachments/assets/e800cda4-ad94-48f1-9af6-bfe0b58f0034"
/>


### Allows new primary metric position "top"*



https://github.com/user-attachments/assets/9158cf22-2988-489f-81a9-71810d6ac550



*note: when the user selects primary position > top, it automatically
selects title weight to normal and primary align to left. And when the
user selects primary position > bottom, it automatically selects title
weight to bold and primary align to right

### New toolbar settings


https://github.com/user-attachments/assets/068d5877-c3ba-4191-bd78-b5b68eab4d99

### Allows applying color to the Metric chart background (panel) or
Primary Metric value*


https://github.com/user-attachments/assets/42700919-b358-4227-b05b-ea89ad450ea1

*note: when value is selected, we use the [data visualization text
colors](https://eui.elastic.co/docs/getting-started/theming/tokens/colors/#dataVisText)

### Enables changing the label position for the Secondary Metric


https://github.com/user-attachments/assets/3f070821-d2b9-4236-943a-a0d651ea32ec


## Checklist
- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] 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.
- [ ] [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)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
nickofthyme added a commit that referenced this pull request Sep 30, 2025
## Summary

Moves several Lens state runtime migrations to CM migrations before `v1`
is established.

- Add ColorMapping fix for looping mode
#231165
- Add Changes to metric config from
#229815
- Cleanup Lens SO attributes
- The `description` and `visualizationType` properties can be more
strict and less redundant for saving the SO.

### 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] 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] 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)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
alaudazzi added a commit to elastic/docs-content that referenced this pull request Oct 3, 2025
This PR adds the new appearance settings for the metric chart.

Closes #3088
Relates to elastic/kibana#229815 and
elastic/kibana#233992
rylnd pushed a commit to rylnd/kibana that referenced this pull request Oct 17, 2025
## Summary

Moves several Lens state runtime migrations to CM migrations before `v1`
is established.

- Add ColorMapping fix for looping mode
elastic#231165
- Add Changes to metric config from
elastic#229815
- Cleanup Lens SO attributes
- The `description` and `visualizationType` properties can be more
strict and less redundant for saving the SO.

### 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] 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] 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)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Lens needs_docs release_note:enhancement Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v9.2.0

8 participants