Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/chart/treemap/TreemapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,14 @@ function renderNode(
}
const textStyle = textEl.style;
const textPadding = normalizeCssArray(textStyle.padding || 0);
const textPosition = normalLabelModel.getShallow('position');
// An explicit rich text height becomes the block height, leaving its tokens
// at the top of the block even when that block is aligned to the bottom.
const isRichTextBottomPosition = textStyle.rich && (
textPosition === 'insideBottom'
|| textPosition === 'insideBottomLeft'
|| textPosition === 'insideBottomRight'
);

if (upperLabelRect) {
rectEl.setTextConfig({
Expand All @@ -1015,9 +1023,12 @@ function renderNode(
const width = Math.max(
(upperLabelRect ? upperLabelRect.width : rectEl.shape.width) - textPadding[1] - textPadding[3], 0
);
const height = Math.max(
(upperLabelRect ? upperLabelRect.height : rectEl.shape.height) - textPadding[0] - textPadding[2], 0
);
const height = isRichTextBottomPosition
? null
: Math.max(
(upperLabelRect ? upperLabelRect.height : rectEl.shape.height)
- textPadding[0] - textPadding[2], 0
);
if (textStyle.width !== width || textStyle.height !== height) {
textEl.setStyle({
width,
Expand Down
98 changes: 98 additions & 0 deletions test/treemap-label-position-rich.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 113 additions & 0 deletions test/ut/spec/series/treemap.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.