Skip to content

fix(text): use contentHeight for outerHeight to fix vertical alignment - #1166

Open
waterWang wants to merge 1 commit into
ecomfe:masterfrom
waterWang:fix/treemap-label-vertical-align
Open

fix(text): use contentHeight for outerHeight to fix vertical alignment#1166
waterWang wants to merge 1 commit into
ecomfe:masterfrom
waterWang:fix/treemap-label-vertical-align

Conversation

@waterWang

Copy link
Copy Markdown

What changed

In , was being set from (via the / variable). When is explicitly set — as Treemap does in its to establish a truncation boundary — incorrectly reflects the full block height rather than the actual rendered text height. Since is what uses for vertical alignment (), treemap labels in small blocks appeared vertically misaligned (text positioned as if its bounding box were the whole block).

Fix

  • Simple text path (): use (the actual rendered text height after truncation) for instead of .
  • Rich text path (): separate from . now uses (actual rendered height); keeps as the truncation boundary.

continues to serve only as the truncation boundary; is used purely for placement.

Why

Fixes apache/echarts#21673 — Treemap label vertical alignment broken when is set by with .

Tests

All 68 existing zrender unit tests pass, including . Typecheck passes (only pre-existing unrelated error in ).

…tical alignment

When style.height is set (e.g. by Treemap beforeUpdate for truncation),
outerHeight was incorrectly set to style.height instead of the actual
rendered text height (contentHeight). This caused treemap labels in
small blocks to be vertically misaligned.

Fix:
- In parseText: use contentHeight for outerHeight instead of height.
- In parseRichText: separate outerHeight from height. outerHeight =
  calculatedHeight (actual rendered text height), height = retrieve2().

style.height should only serve as the truncation boundary; outerHeight
is used for vertical alignment placement (adjustTextY in Text.ts).
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.

[Bug] [Treemap] Label vertical alignment is broken when style.height is set by beforeUpdate with lineOverflow: 'truncate'

1 participant