Skip to content

fix(treemap): clear the parent transform of a label that became single-line - #4274

Merged
netil merged 1 commit into
naver:latestfrom
netil:treemap-label
Nov 11, 2026
Merged

netil merged 1 commit into
naver:latestfrom
netil:treemap-label

Conversation

@netil

@netil netil commented Nov 11, 2026

Copy link
Copy Markdown
Member

Issue

Fix #4273

Details

A multiline treemap label is positioned by the transform of its parent g, a single-line one by the x and y of the text itself. When a centered label went from multiline to single-line (for example after a resize with a treemap.label.format that returns fewer lines for narrow tiles), the old parent transform stayed and was applied on top of the new x and y, so the label was drawn outside its tile.

redrawText() now removes the parent transform when it writes the position to the text.

The reverse direction (one line to two lines) is not changed: the stale y is measured through getBBox() in getCenteredTextPos() and compensated. A test covers both directions by comparing the label positions with a chart drawn directly in the final state. It fails without the change (375 vs 186).

This is based on latest so that it can be released as a patch.

…e-line

A multiline treemap label is positioned by the transform of its parent
group, a single-line one by the x and y of the text itself. When a label
went from multiline to single-line, the old transform stayed and was
applied on top of the new x and y.

Remove the parent transform when the position is written to the text.

Fix naver#4273
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 93.703% — netil:treemap-label into naver:latest. No base build found for naver:latest.

@netil
netil merged commit f220e4c into naver:latest Nov 11, 2026
10 checks passed
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