[Lens][XY] Truncate long axis tick labels in horizontal bar charts#268106
Merged
biamalveiro merged 11 commits intoMay 25, 2026
Conversation
a40d380 to
3758756
Compare
3758756 to
81f105c
Compare
8dbca9d to
2455b6d
Compare
biamalveiro
commented
May 22, 2026
| return { | ||
| truncate: data.labels.truncate, | ||
| // axis expressions expect pixels, we approximate pixels from character count | ||
| truncate: charsToPixels(data.labels.truncate), |
Contributor
Author
There was a problem hiding this comment.
Legacy xy charts truncated axis tick labels by character count, and then in expression_xy, the formatter sliced tick strings to that length:
We now use elastic-charts's tickLabelMaxLength which expects a value in pixels.
Without converting, a saved value like 100 would be treated as 100px instead of 100 characters, so labels would truncate much more aggressively than before.
markov00
approved these changes
May 25, 2026
Contributor
markov00
left a comment
There was a problem hiding this comment.
Thanks, works pretty well locally!
Contributor
💛 Build succeeded, but was flaky
Failed CI Steps
Test Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires axis tick label truncation to
@elastic/chartsthrough the newtickLabel.truncationstyle option, replacing previous character based truncating happening inside the formatter. We now interpretaxis.truncateas pixels instead of characters now.To fix #265517, for horizontal charts with bars and no explicit truncate, we apply a default truncation of 40% relative to the chart container's width.
Before:

After:

Legacy compatibility
Agg-based XY charts truncated axis tick labels by character count, and the renderer sliced tick strings to that length in the formatter. We now use elastic-charts's
tickLabelMaxLengthwhich expects a value in pixels. Without converting, a saved value like 100 would be treated as 100px instead of ~100 characters, so labels would truncate much more aggressively than before. charsToPixels used in vis_types/xy/public/to_ast.ts approximates character count to pixels so existing legacy charts and editor keep a similar behavior.To test:
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:*label is applied per the guidelinesbackport:*labels.