Skip to content

feat(axis): wordBreak, maxLines settings and correct geometry for wrapped labels - #965

Draft
patricnordstrom wants to merge 2 commits into
qlik-oss:masterfrom
patricnordstrom:feat/axis-wordbreak
Draft

patricnordstrom wants to merge 2 commits into
qlik-oss:masterfrom
patricnordstrom:feat/axis-wordbreak

Conversation

@patricnordstrom

@patricnordstrom patricnordstrom commented Mar 26, 2026

Copy link
Copy Markdown

Summary

  • Expose wordBreak and maxLines settings for axis labels, allowing text wrapping control via the component configuration
  • Correct dock-space reservation and vertical centering for wrapped (multi-line) axis labels so geometry reflects actual rendered height

Test plan

  • Verify wordBreak and maxLines settings are applied to axis label nodes
  • Verify wrapped labels reserve correct dock space (no clipping or overlap)
  • Verify wrapped labels are vertically centered within their allocated space
  • Run existing axis unit tests

🤖 Generated with Claude Code

Size

A small, self-contained feature — all hand-authored source across the axis component and the text-manipulation helper; no new files, tests, or generated content.

Lens Files Lines
Full PR diff (vs master) 5 +87 / -7

By area:

  • chart-components/axis: 4 files, +59 / -6 — new wordBreak/maxLines defaults (axis-default-settings.js +16), label node/size, and wrapped-label geometry in axis-node-builder.js (+23/-2).
  • web/text-manipulation/line-break-resolver.js: +28 / -1 — the line-break/geometry logic.

Patric Nordström and others added 2 commits March 24, 2026 15:08
Add `wordBreak` ('break-word' | 'break-all' | false) and `maxLines`
(number) to axis label defaults. Thread both settings through the
axis pipeline — axis-node-builder computes a per-tick `maxHeight`
slot (full bandwidth height for left/right; fixed `maxLines × h`
for top/bottom; geometry-aware for tilted), and axis-label-node
stamps `wordBreak`/`maxLines` onto each text node struct so the
existing SVG renderer's `onLineBreak()` picks them up automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… wrapped labels

axis-label-size: suppress auto-tilt when wordBreak is active; reserve
correct dock height (lineHeight × maxLines for horizontal, width-based
projection for tilted); compute tilted lineMultiplier dynamically from
the available bandwidth slot so maxLines never over-reserves space.

line-break-resolver: center the rendered N-line block within its
reserved slot. Uses two coordinate models — for left/right axes y is
at the slot top (text-before-edge), offset = (maxHeight − N×lh) / 2;
for bottom/top axes y is at the slot bottom, offset = h − (maxHeight +
N×lh) / 2 — so every label's visual midpoint aligns to the slot center
regardless of how many lines actually wrap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@veinfors
veinfors marked this pull request as draft August 26, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants