Skip to content

feat(metric): Add ability to vertically align the metrics values to the middle of the chart#2783

Merged
awahab07 merged 11 commits intoelastic:mainfrom
awahab07:234956_Lens_Metric_Allow-Middle-Center-Alignment-for-primary-and-secondary-metrics
Mar 9, 2026
Merged

feat(metric): Add ability to vertically align the metrics values to the middle of the chart#2783
awahab07 merged 11 commits intoelastic:mainfrom
awahab07:234956_Lens_Metric_Allow-Middle-Center-Alignment-for-primary-and-secondary-metrics

Conversation

@awahab07
Copy link
Copy Markdown
Collaborator

@awahab07 awahab07 commented Jan 26, 2026

Summary

The valuePosition prop in the MetricStyle theme now supports a new 'middle' value, allowing the primary metric value to be vertically centered within the chart area. When using valuePosition: 'middle', the title and subtitle remain at the top, while the primary metric value is centered with the secondary metric (extra) displayed directly below it.

234956-Metric-chart-primary-value-vertical-middle-alignment.mov

Details

  • Added 'middle' to the valuePosition union type in MetricStyle interface ('top' | 'middle' | 'bottom')
  • The following stories could be used to test the change:

Update 01

see

Issues

Implement the underlying functionality required by elastic/kibana#234956.

Checklist

  • The proper chart type label has been added (e.g. :xy, :partition)
  • The proper feature labels have been added (e.g. :interactions, :axis)
  • All related issues have been linked (i.e. closes #123, fixes #123)
  • New public API exports have been added to packages/charts/src/index.ts
  • Unit tests have been added or updated to match the most common scenarios
  • The proper documentation and/or storybook story has been added or updated
  • The code has been checked for cross-browser compatibility (Chrome, Firefox, Safari, Edge)
  • Visual changes have been tested with light and dark themes

@awahab07 awahab07 added enhancement New feature or request :Lens Kibana Lens related issue :metric Related to Metric chart labels Jan 26, 2026
@awahab07
Copy link
Copy Markdown
Collaborator Author

buildkite test this

@awahab07
Copy link
Copy Markdown
Collaborator Author

buildkite update vrt

@awahab07
Copy link
Copy Markdown
Collaborator Author

buildkite update vrt

@awahab07
Copy link
Copy Markdown
Collaborator Author

buildkite update vrt

@awahab07 awahab07 marked this pull request as ready for review January 28, 2026 10:47
@awahab07 awahab07 enabled auto-merge (squash) February 13, 2026 10:20
@delanni
Copy link
Copy Markdown
Member

delanni commented Feb 18, 2026

buildkite build this

@gvnmagni
Copy link
Copy Markdown

Thanks @awahab07 , can I ask you to fix one detail? The Secondary Metric should always be anchored to the bottom, as the Title is always anchored to the top, and then it is Primary Metric that basically forced its position around the component

This image show an extreme version of this concept (font sizes are wrong, it is purely to show the logic):
Screenshot 2026-02-27 at 11 09 21

@awahab07
Copy link
Copy Markdown
Collaborator Author

awahab07 commented Mar 3, 2026

Update 01

The extra block (secondary metric) will always be anchored now to the bottom (unless when the primary metric is positioned to the bottom in which case secondary metric will appear above it).

Metric-chart-primary-vertical-alignment

Copy link
Copy Markdown

@gvnmagni gvnmagni left a comment

Choose a reason for hiding this comment

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

Looks great! 🚀

@elastic-datavis
Copy link
Copy Markdown
Contributor

@awahab07 awahab07 requested a review from mariairiartef March 4, 2026 23:57
Copy link
Copy Markdown
Contributor

@mariairiartef mariairiartef left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for addressing the comments 💖

Copy link
Copy Markdown
Collaborator

@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, looks good to me!

@awahab07 awahab07 merged commit 54ca7cb into elastic:main Mar 9, 2026
14 checks passed
nickofthyme pushed a commit that referenced this pull request Mar 31, 2026
# [71.4.0](v71.3.0...v71.4.0) (2026-03-31)

### Bug Fixes

* **legend:** avoid re-rendering ([#2646](#2646)) ([0ca3289](0ca3289))
* **legend:** keep legend values visible when hiding series in list layout ([#2807](#2807)) ([c5089f5](c5089f5))

### Features

* **highlight:** Add support to configure dimmed (unhighlight) colors for Bar, Partition, Waffle and Flame charts ([#2774](#2774)) ([b39e24d](b39e24d)), closes [#ECF1F9](https://github.com/elastic/elastic-charts/issues/ECF1F9) [#384861](https://github.com/elastic/elastic-charts/issues/384861)
* **metric:** Add ability to vertically align the metrics values to the middle of the chart ([#2783](#2783)) ([54ca7cb](54ca7cb))
* **theme:** set default labelOptions.widthLimit in themes and update metric.titleWeight default to 500 ([#2802](#2802)) ([fbb8834](fbb8834))
maryam-saeidi added a commit to elastic/kibana that referenced this pull request Apr 2, 2026
## Summary

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@elastic/charts](https://github.com/elastic/elastic-charts) |
dependencies | minor | [`71.3.0` ->
`71.4.0`](elastic/elastic-charts@v71.3.0...v71.4.0)
|

### Release Notes

#
[71.4.0](elastic/elastic-charts@v71.3.0...v71.4.0)
(2026-03-31)


### Bug Fixes

* **legend:** avoid re-rendering
([#2646](elastic/elastic-charts#2646))
([0ca3289](elastic/elastic-charts@0ca3289))
* **legend:** keep legend values visible when hiding series in list
layout ([#2807](elastic/elastic-charts#2807))
([c5089f5](elastic/elastic-charts@c5089f5))


### Features

* **highlight:** Add support to configure dimmed (unhighlight) colors
for Bar, Partition, Waffle and Flame charts
([#2774](elastic/elastic-charts#2774))
([b39e24d](elastic/elastic-charts@b39e24d)),
closes
[#ECF1F9](https://github.com/elastic/elastic-charts/issues/ECF1F9)
[#384861](https://github.com/elastic/elastic-charts/issues/384861)
* **metric:** Add ability to vertically align the metrics values to the
middle of the chart
([#2783](elastic/elastic-charts#2783))
([54ca7cb](elastic/elastic-charts@54ca7cb))
* **theme:** set default labelOptions.widthLimit in themes and update
metric.titleWeight default to 500
([#2802](elastic/elastic-charts#2802))
([fbb8834](elastic/elastic-charts@fbb8834))

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Abdul Zahid <awahab07@yahoo.com>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
## Summary

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@elastic/charts](https://github.com/elastic/elastic-charts) |
dependencies | minor | [`71.3.0` ->
`71.4.0`](elastic/elastic-charts@v71.3.0...v71.4.0)
|

### Release Notes

#
[71.4.0](elastic/elastic-charts@v71.3.0...v71.4.0)
(2026-03-31)


### Bug Fixes

* **legend:** avoid re-rendering
([elastic#2646](elastic/elastic-charts#2646))
([0ca3289](elastic/elastic-charts@0ca3289))
* **legend:** keep legend values visible when hiding series in list
layout ([elastic#2807](elastic/elastic-charts#2807))
([c5089f5](elastic/elastic-charts@c5089f5))


### Features

* **highlight:** Add support to configure dimmed (unhighlight) colors
for Bar, Partition, Waffle and Flame charts
([elastic#2774](elastic/elastic-charts#2774))
([b39e24d](elastic/elastic-charts@b39e24d)),
closes
[#ECF1F9](https://github.com/elastic/elastic-charts/issues/ECF1F9)
[#384861](https://github.com/elastic/elastic-charts/issues/384861)
* **metric:** Add ability to vertically align the metrics values to the
middle of the chart
([elastic#2783](elastic/elastic-charts#2783))
([54ca7cb](elastic/elastic-charts@54ca7cb))
* **theme:** set default labelOptions.widthLimit in themes and update
metric.titleWeight default to 500
([elastic#2802](elastic/elastic-charts#2802))
([fbb8834](elastic/elastic-charts@fbb8834))

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Abdul Zahid <awahab07@yahoo.com>
awahab07 added a commit to elastic/kibana that referenced this pull request Apr 7, 2026
- Adds a **Middle** option to Lens Metric → Style → Primary metric →
Position (**Top | Middle | Bottom**).
- Enables vertically centered primary metric positioning using
elastic-charts support from
[elastic/elastic-charts#2783](elastic/elastic-charts#2783).
kelvtanv pushed a commit to kelvtanv/kibana that referenced this pull request Apr 7, 2026
…c#260902)

- Adds a **Middle** option to Lens Metric → Style → Primary metric →
Position (**Top | Middle | Bottom**).
- Enables vertically centered primary metric positioning using
elastic-charts support from
[elastic/elastic-charts#2783](elastic/elastic-charts#2783).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request :Lens Kibana Lens related issue :metric Related to Metric chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Lens][Metric] Allow Middle Center Alignment for primary and secondary metrics

5 participants