Skip to content

[Lens] Always show number sign when comparing to Primary metric#222824

Merged
dej611 merged 9 commits intoelastic:mainfrom
dej611:fix/221882
Jun 10, 2025
Merged

[Lens] Always show number sign when comparing to Primary metric#222824
dej611 merged 9 commits intoelastic:mainfrom
dej611:fix/221882

Conversation

@dej611
Copy link
Copy Markdown
Contributor

@dej611 dej611 commented Jun 5, 2025

Summary

Fixes #221882

This is a possible take of the enhancement request in #221882.
In this scenario the chart automatically enters the alwaysShowSign mode when rendering the delta difference with the Primary Metric in the Secondary badge.

Some notes:

  • The user has no control over it.
  • The behaviour is disabled automatically when moving into Static value mode, while it can be replicated using the custom format in the Value format control
  • The affected formats are number, bytes, bits, percentage in any possible configuration (i.e. also compact mode)
  • I've noticed that some formats change a bit when the sign is displayed (ie Currency goes from $ xx.xxx to + xx.xx $)

Compare to Primary Metric

Default Number Number (compact) Custom Format (i.e. Currency) Percentage Bytes Bits
Screenshot 2025-06-05 at 14 41 09 Screenshot 2025-06-05 at 15 40 37 Screenshot 2025-06-05 at 15 41 29 Screenshot 2025-06-05 at 15 42 33 Screenshot 2025-06-05 at 14 48 18 Screenshot 2025-06-05 at 15 44 11 Screenshot 2025-06-05 at 14 47 54

When using Static value:

Default Number Number (compact) Custom format (i.e. Currency) Percentage Bytes Bits
Screenshot 2025-06-05 at 14 56 17 Screenshot 2025-06-05 at 15 49 51 Screenshot 2025-06-05 at 15 46 24 Screenshot 2025-06-05 at 15 52 27 Screenshot 2025-06-05 at 15 46 40 Screenshot 2025-06-05 at 15 45 50 Screenshot 2025-06-05 at 15 46 05

Extra bits:

  • I did notice that when rendering in Icon mode only and the secondary raw value is null an empty badge was rendered. Now it should not.
  • When running Jest tests a warning about a missing act wrapping was shown, which was due to the jest.advanceTimers call. Now it is properly wrapped
  • When testing with a time shift it is very likely to encounter into [Lens] Multiple layers with identical time shifted aggs are ignored in visualization #221886 and have all badges set to NA. In such case close the inline editor and hit Refresh again to see fresh values.

Checklist


const formatted = numeralInst.set(val).format(this.param('pattern'));
let pattern = this.param('pattern');
if (this.param('alwaysShowSign')) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having this set to false by default it should not impact existing configurations

@dej611 dej611 self-assigned this Jun 5, 2025
@dej611 dej611 added Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// release_note:skip Skip the PR/issue when compiling release notes Feature:Lens backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Jun 5, 2025
getParamDefaults = () => ({
pattern: this.getConfig!(`format:${this.id}:defaultPattern`),
// While this should be always defined, it is not guaranteed in testing that the function is available
pattern: this.getConfig?.(`format:${this.id}:defaultPattern`),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Apparently a test was broken due to the force cast previously present who was throwing when this.param was looking for a missing parameter.

@dej611 dej611 marked this pull request as ready for review June 6, 2025 12:06
@dej611 dej611 requested review from a team as code owners June 6, 2025 12:06
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
expressionMetricVis 8.1KB 8.4KB +254.0B

Page load bundle

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

id before after diff
fieldFormats 61.9KB 62.1KB +171.0B

History

cc @dej611

Copy link
Copy Markdown
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.

Tested locally, works fine.
Thanks for removing the unused fontSize prop

@dej611 dej611 merged commit af3b804 into elastic:main Jun 10, 2025
10 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 10, 2025
…tic#222824)

## Summary

Fixes elastic#221882

This is a possible take of the enhancement request in elastic#221882.
In this scenario the chart automatically enters the `alwaysShowSign`
mode when rendering the delta difference with the Primary Metric in the
Secondary badge.

Some notes:
* The user has no control over it.
* The behaviour is disabled automatically when moving into `Static
value` mode, while it can be replicated using the `custom format` in the
`Value format` control
* The affected formats are `number`, `bytes`, `bits`, `percentage` in
any possible configuration (i.e. also compact mode)
* I've noticed that some formats change a bit when the sign is displayed
(ie Currency goes from `$ xx.xxx` to `+ xx.xx $`)

**Compare to Primary Metric**
| Default | Number | Number (compact) | Custom Format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| <img width="819" alt="Screenshot 2025-06-05 at 14 41 09"
src="https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 40 37"
src="https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 41 29"
src="https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 42 33"
src="https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7"
/> | <img width="472" alt="Screenshot 2025-06-05 at 14 48 18"
src="https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb"
/> | <img width="478" alt="Screenshot 2025-06-05 at 15 44 11"
src="https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd"
/> | <img width="477" alt="Screenshot 2025-06-05 at 14 47 54"
src="https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b"
/> |

When using Static value:

| Default | Number | Number (compact) | Custom format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | --- | ---- | ---- | ---- | ---- | ---- |
| <img width="471" alt="Screenshot 2025-06-05 at 14 56 17"
src="https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 49 51"
src="https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce"
/> | <img width="477" alt="Screenshot 2025-06-05 at 15 46 24"
src="https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 52 27"
src="https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78"
/> | <img width="482" alt="Screenshot 2025-06-05 at 15 46 40"
src="https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 45 50"
src="https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 46 05"
src="https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa"
/> |

Extra bits:
* I did notice that when rendering in Icon mode only and the secondary
raw value is `null` an empty badge was rendered. Now it should not.
* When running Jest tests a warning about a missing `act` wrapping was
shown, which was due to the `jest.advanceTimers` call. Now it is
properly wrapped
* When testing with a time shift it is very likely to encounter into
elastic#221886 and have all badges set
to `NA`. In such case close the inline editor and hit `Refresh` again to
see fresh values.

### 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

(cherry picked from commit af3b804)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.19

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 10, 2025
#222824) (#223201)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Lens] Always show number sign when comparing to Primary metric
(#222824)](#222824)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-06-10T09:46:13Z","message":"[Lens]
Always show number sign when comparing to Primary metric (#222824)\n\n##
Summary\n\nFixes #221882 \n\nThis is a possible take of the enhancement
request in #221882.\nIn this scenario the chart automatically enters the
`alwaysShowSign`\nmode when rendering the delta difference with the
Primary Metric in the\nSecondary badge.\n\nSome notes:\n* The user has
no control over it.\n* The behaviour is disabled automatically when
moving into `Static\nvalue` mode, while it can be replicated using the
`custom format` in the\n`Value format` control\n* The affected formats
are `number`, `bytes`, `bits`, `percentage` in\nany possible
configuration (i.e. also compact mode)\n* I've noticed that some formats
change a bit when the sign is displayed\n(ie Currency goes from `$
xx.xxx` to `+ xx.xx # Backport

This will backport the following commits from `main` to `8.19`:
{{{{raw}}}} - [[Lens] Always show number sign when comparing to Primary
metric
(#222824)](https://github.com/elastic/kibana/pull/222824){{{{/raw}}}}

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT )\n\n**Compare to Primary Metric**\n| Default | Number |
Number (compact) | Custom Format (i.e. Currency) |\nPercentage | Bytes |
Bits |\n| ---- | ---- | ---- | ---- | ---- | ---- | ---- |\n| <img
width=\"819\" alt=\"Screenshot 2025-06-05 at 14 41
09\"\nsrc=\"https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 40
37\"\nsrc=\"https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 15 41
29\"\nsrc=\"https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99\"\n/>
| <img width=\"480\" alt=\"Screenshot 2025-06-05 at 15 42
33\"\nsrc=\"https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 14 48
18\"\nsrc=\"https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb\"\n/>
| <img width=\"478\" alt=\"Screenshot 2025-06-05 at 15 44
11\"\nsrc=\"https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd\"\n/>
| <img width=\"477\" alt=\"Screenshot 2025-06-05 at 14 47
54\"\nsrc=\"https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b\"\n/>
|\n\nWhen using Static value:\n\n| Default | Number | Number (compact) |
Custom format (i.e. Currency) |\nPercentage | Bytes | Bits |\n| ---- |
--- | ---- | ---- | ---- | ---- | ---- | \n| <img width=\"471\"
alt=\"Screenshot 2025-06-05 at 14 56
17\"\nsrc=\"https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 49
51\"\nsrc=\"https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce\"\n/>
| <img width=\"477\" alt=\"Screenshot 2025-06-05 at 15 46
24\"\nsrc=\"https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 15 52
27\"\nsrc=\"https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78\"\n/>
| <img width=\"482\" alt=\"Screenshot 2025-06-05 at 15 46
40\"\nsrc=\"https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a\"\n/>
| <img width=\"480\" alt=\"Screenshot 2025-06-05 at 15 45
50\"\nsrc=\"https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 46
05\"\nsrc=\"https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa\"\n/>
|\n\nExtra bits:\n* I did notice that when rendering in Icon mode only
and the secondary\nraw value is `null` an empty badge was rendered. Now
it should not.\n* When running Jest tests a warning about a missing
`act` wrapping was\nshown, which was due to the `jest.advanceTimers`
call. Now it is\nproperly wrapped\n* When testing with a time shift it
is very likely to encounter
into\nhttps://github.com//issues/221886 and have all
badges set\nto `NA`. In such case close the inline editor and hit
`Refresh` again to\nsee fresh values.\n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"af3b804ed331d7a5802fbc7e6ae78912ed603c06","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","backport:version","v9.1.0","v8.19.0"],"title":"[Lens]
Always show number sign when comparing to Primary
metric","number":222824,"url":"https://github.com/elastic/kibana/pull/222824","mergeCommit":{"message":"[Lens]
Always show number sign when comparing to Primary metric (#222824)\n\n##
Summary\n\nFixes #221882 \n\nThis is a possible take of the enhancement
request in #221882.\nIn this scenario the chart automatically enters the
`alwaysShowSign`\nmode when rendering the delta difference with the
Primary Metric in the\nSecondary badge.\n\nSome notes:\n* The user has
no control over it.\n* The behaviour is disabled automatically when
moving into `Static\nvalue` mode, while it can be replicated using the
`custom format` in the\n`Value format` control\n* The affected formats
are `number`, `bytes`, `bits`, `percentage` in\nany possible
configuration (i.e. also compact mode)\n* I've noticed that some formats
change a bit when the sign is displayed\n(ie Currency goes from `$
xx.xxx` to `+ xx.xx # Backport

This will backport the following commits from `main` to `8.19`:
{{{{raw}}}} - [[Lens] Always show number sign when comparing to Primary
metric
(#222824)](https://github.com/elastic/kibana/pull/222824){{{{/raw}}}}

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT )\n\n**Compare to Primary Metric**\n| Default | Number |
Number (compact) | Custom Format (i.e. Currency) |\nPercentage | Bytes |
Bits |\n| ---- | ---- | ---- | ---- | ---- | ---- | ---- |\n| <img
width=\"819\" alt=\"Screenshot 2025-06-05 at 14 41
09\"\nsrc=\"https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 40
37\"\nsrc=\"https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 15 41
29\"\nsrc=\"https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99\"\n/>
| <img width=\"480\" alt=\"Screenshot 2025-06-05 at 15 42
33\"\nsrc=\"https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 14 48
18\"\nsrc=\"https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb\"\n/>
| <img width=\"478\" alt=\"Screenshot 2025-06-05 at 15 44
11\"\nsrc=\"https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd\"\n/>
| <img width=\"477\" alt=\"Screenshot 2025-06-05 at 14 47
54\"\nsrc=\"https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b\"\n/>
|\n\nWhen using Static value:\n\n| Default | Number | Number (compact) |
Custom format (i.e. Currency) |\nPercentage | Bytes | Bits |\n| ---- |
--- | ---- | ---- | ---- | ---- | ---- | \n| <img width=\"471\"
alt=\"Screenshot 2025-06-05 at 14 56
17\"\nsrc=\"https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 49
51\"\nsrc=\"https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce\"\n/>
| <img width=\"477\" alt=\"Screenshot 2025-06-05 at 15 46
24\"\nsrc=\"https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 15 52
27\"\nsrc=\"https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78\"\n/>
| <img width=\"482\" alt=\"Screenshot 2025-06-05 at 15 46
40\"\nsrc=\"https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a\"\n/>
| <img width=\"480\" alt=\"Screenshot 2025-06-05 at 15 45
50\"\nsrc=\"https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 46
05\"\nsrc=\"https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa\"\n/>
|\n\nExtra bits:\n* I did notice that when rendering in Icon mode only
and the secondary\nraw value is `null` an empty badge was rendered. Now
it should not.\n* When running Jest tests a warning about a missing
`act` wrapping was\nshown, which was due to the `jest.advanceTimers`
call. Now it is\nproperly wrapped\n* When testing with a time shift it
is very likely to encounter
into\nhttps://github.com//issues/221886 and have all
badges set\nto `NA`. In such case close the inline editor and hit
`Refresh` again to\nsee fresh values.\n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"af3b804ed331d7a5802fbc7e6ae78912ed603c06"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/222824","number":222824,"mergeCommit":{"message":"[Lens]
Always show number sign when comparing to Primary metric (#222824)\n\n##
Summary\n\nFixes #221882 \n\nThis is a possible take of the enhancement
request in #221882.\nIn this scenario the chart automatically enters the
`alwaysShowSign`\nmode when rendering the delta difference with the
Primary Metric in the\nSecondary badge.\n\nSome notes:\n* The user has
no control over it.\n* The behaviour is disabled automatically when
moving into `Static\nvalue` mode, while it can be replicated using the
`custom format` in the\n`Value format` control\n* The affected formats
are `number`, `bytes`, `bits`, `percentage` in\nany possible
configuration (i.e. also compact mode)\n* I've noticed that some formats
change a bit when the sign is displayed\n(ie Currency goes from `$
xx.xxx` to `+ xx.xx # Backport

This will backport the following commits from `main` to `8.19`:
{{{{raw}}}} - [[Lens] Always show number sign when comparing to Primary
metric
(#222824)](https://github.com/elastic/kibana/pull/222824){{{{/raw}}}}

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT )\n\n**Compare to Primary Metric**\n| Default | Number |
Number (compact) | Custom Format (i.e. Currency) |\nPercentage | Bytes |
Bits |\n| ---- | ---- | ---- | ---- | ---- | ---- | ---- |\n| <img
width=\"819\" alt=\"Screenshot 2025-06-05 at 14 41
09\"\nsrc=\"https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 40
37\"\nsrc=\"https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 15 41
29\"\nsrc=\"https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99\"\n/>
| <img width=\"480\" alt=\"Screenshot 2025-06-05 at 15 42
33\"\nsrc=\"https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 14 48
18\"\nsrc=\"https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb\"\n/>
| <img width=\"478\" alt=\"Screenshot 2025-06-05 at 15 44
11\"\nsrc=\"https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd\"\n/>
| <img width=\"477\" alt=\"Screenshot 2025-06-05 at 14 47
54\"\nsrc=\"https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b\"\n/>
|\n\nWhen using Static value:\n\n| Default | Number | Number (compact) |
Custom format (i.e. Currency) |\nPercentage | Bytes | Bits |\n| ---- |
--- | ---- | ---- | ---- | ---- | ---- | \n| <img width=\"471\"
alt=\"Screenshot 2025-06-05 at 14 56
17\"\nsrc=\"https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 49
51\"\nsrc=\"https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce\"\n/>
| <img width=\"477\" alt=\"Screenshot 2025-06-05 at 15 46
24\"\nsrc=\"https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26\"\n/>
| <img width=\"472\" alt=\"Screenshot 2025-06-05 at 15 52
27\"\nsrc=\"https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78\"\n/>
| <img width=\"482\" alt=\"Screenshot 2025-06-05 at 15 46
40\"\nsrc=\"https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a\"\n/>
| <img width=\"480\" alt=\"Screenshot 2025-06-05 at 15 45
50\"\nsrc=\"https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee\"\n/>
| <img width=\"473\" alt=\"Screenshot 2025-06-05 at 15 46
05\"\nsrc=\"https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa\"\n/>
|\n\nExtra bits:\n* I did notice that when rendering in Icon mode only
and the secondary\nraw value is `null` an empty badge was rendered. Now
it should not.\n* When running Jest tests a warning about a missing
`act` wrapping was\nshown, which was due to the `jest.advanceTimers`
call. Now it is\nproperly wrapped\n* When testing with a time shift it
is very likely to encounter
into\nhttps://github.com//issues/221886 and have all
badges set\nto `NA`. In such case close the inline editor and hit
`Refresh` again to\nsee fresh values.\n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"af3b804ed331d7a5802fbc7e6ae78912ed603c06"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
pmuellr pushed a commit to pmuellr/kibana that referenced this pull request Jun 11, 2025
…tic#222824)

## Summary

Fixes elastic#221882 

This is a possible take of the enhancement request in elastic#221882.
In this scenario the chart automatically enters the `alwaysShowSign`
mode when rendering the delta difference with the Primary Metric in the
Secondary badge.

Some notes:
* The user has no control over it.
* The behaviour is disabled automatically when moving into `Static
value` mode, while it can be replicated using the `custom format` in the
`Value format` control
* The affected formats are `number`, `bytes`, `bits`, `percentage` in
any possible configuration (i.e. also compact mode)
* I've noticed that some formats change a bit when the sign is displayed
(ie Currency goes from `$ xx.xxx` to `+ xx.xx $`)

**Compare to Primary Metric**
| Default | Number | Number (compact) | Custom Format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| <img width="819" alt="Screenshot 2025-06-05 at 14 41 09"
src="https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 40 37"
src="https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 41 29"
src="https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 42 33"
src="https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7"
/> | <img width="472" alt="Screenshot 2025-06-05 at 14 48 18"
src="https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb"
/> | <img width="478" alt="Screenshot 2025-06-05 at 15 44 11"
src="https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd"
/> | <img width="477" alt="Screenshot 2025-06-05 at 14 47 54"
src="https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b"
/> |

When using Static value:

| Default | Number | Number (compact) | Custom format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | --- | ---- | ---- | ---- | ---- | ---- | 
| <img width="471" alt="Screenshot 2025-06-05 at 14 56 17"
src="https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 49 51"
src="https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce"
/> | <img width="477" alt="Screenshot 2025-06-05 at 15 46 24"
src="https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 52 27"
src="https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78"
/> | <img width="482" alt="Screenshot 2025-06-05 at 15 46 40"
src="https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 45 50"
src="https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 46 05"
src="https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa"
/> |

Extra bits:
* I did notice that when rendering in Icon mode only and the secondary
raw value is `null` an empty badge was rendered. Now it should not.
* When running Jest tests a warning about a missing `act` wrapping was
shown, which was due to the `jest.advanceTimers` call. Now it is
properly wrapped
* When testing with a time shift it is very likely to encounter into
elastic#221886 and have all badges set
to `NA`. In such case close the inline editor and hit `Refresh` again to
see fresh values.

### 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
nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
…tic#222824)

## Summary

Fixes elastic#221882 

This is a possible take of the enhancement request in elastic#221882.
In this scenario the chart automatically enters the `alwaysShowSign`
mode when rendering the delta difference with the Primary Metric in the
Secondary badge.

Some notes:
* The user has no control over it.
* The behaviour is disabled automatically when moving into `Static
value` mode, while it can be replicated using the `custom format` in the
`Value format` control
* The affected formats are `number`, `bytes`, `bits`, `percentage` in
any possible configuration (i.e. also compact mode)
* I've noticed that some formats change a bit when the sign is displayed
(ie Currency goes from `$ xx.xxx` to `+ xx.xx $`)

**Compare to Primary Metric**
| Default | Number | Number (compact) | Custom Format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| <img width="819" alt="Screenshot 2025-06-05 at 14 41 09"
src="https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 40 37"
src="https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 41 29"
src="https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 42 33"
src="https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7"
/> | <img width="472" alt="Screenshot 2025-06-05 at 14 48 18"
src="https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb"
/> | <img width="478" alt="Screenshot 2025-06-05 at 15 44 11"
src="https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd"
/> | <img width="477" alt="Screenshot 2025-06-05 at 14 47 54"
src="https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b"
/> |

When using Static value:

| Default | Number | Number (compact) | Custom format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | --- | ---- | ---- | ---- | ---- | ---- | 
| <img width="471" alt="Screenshot 2025-06-05 at 14 56 17"
src="https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 49 51"
src="https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce"
/> | <img width="477" alt="Screenshot 2025-06-05 at 15 46 24"
src="https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 52 27"
src="https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78"
/> | <img width="482" alt="Screenshot 2025-06-05 at 15 46 40"
src="https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 45 50"
src="https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 46 05"
src="https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa"
/> |

Extra bits:
* I did notice that when rendering in Icon mode only and the secondary
raw value is `null` an empty badge was rendered. Now it should not.
* When running Jest tests a warning about a missing `act` wrapping was
shown, which was due to the `jest.advanceTimers` call. Now it is
properly wrapped
* When testing with a time shift it is very likely to encounter into
elastic#221886 and have all badges set
to `NA`. In such case close the inline editor and hit `Refresh` again to
see fresh values.

### 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
iblancof pushed a commit to iblancof/kibana that referenced this pull request Jun 16, 2025
…tic#222824)

## Summary

Fixes elastic#221882 

This is a possible take of the enhancement request in elastic#221882.
In this scenario the chart automatically enters the `alwaysShowSign`
mode when rendering the delta difference with the Primary Metric in the
Secondary badge.

Some notes:
* The user has no control over it.
* The behaviour is disabled automatically when moving into `Static
value` mode, while it can be replicated using the `custom format` in the
`Value format` control
* The affected formats are `number`, `bytes`, `bits`, `percentage` in
any possible configuration (i.e. also compact mode)
* I've noticed that some formats change a bit when the sign is displayed
(ie Currency goes from `$ xx.xxx` to `+ xx.xx $`)

**Compare to Primary Metric**
| Default | Number | Number (compact) | Custom Format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| <img width="819" alt="Screenshot 2025-06-05 at 14 41 09"
src="https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 40 37"
src="https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 41 29"
src="https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 42 33"
src="https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7"
/> | <img width="472" alt="Screenshot 2025-06-05 at 14 48 18"
src="https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb"
/> | <img width="478" alt="Screenshot 2025-06-05 at 15 44 11"
src="https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd"
/> | <img width="477" alt="Screenshot 2025-06-05 at 14 47 54"
src="https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b"
/> |

When using Static value:

| Default | Number | Number (compact) | Custom format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | --- | ---- | ---- | ---- | ---- | ---- | 
| <img width="471" alt="Screenshot 2025-06-05 at 14 56 17"
src="https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 49 51"
src="https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce"
/> | <img width="477" alt="Screenshot 2025-06-05 at 15 46 24"
src="https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 52 27"
src="https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78"
/> | <img width="482" alt="Screenshot 2025-06-05 at 15 46 40"
src="https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 45 50"
src="https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 46 05"
src="https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa"
/> |

Extra bits:
* I did notice that when rendering in Icon mode only and the secondary
raw value is `null` an empty badge was rendered. Now it should not.
* When running Jest tests a warning about a missing `act` wrapping was
shown, which was due to the `jest.advanceTimers` call. Now it is
properly wrapped
* When testing with a time shift it is very likely to encounter into
elastic#221886 and have all badges set
to `NA`. In such case close the inline editor and hit `Refresh` again to
see fresh values.

### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Lens][Metric] Always show the sign in the Compare to when compared to the primary metric

5 participants