antvis/G6

[V5] label 使用padding并且折行的情况下,background宽度不能覆盖全部文字内容 #6051

xuwb posted onGitHub

Describe the bug / 问题描述

label 使用padding并且折行的情况下,background宽度不能覆盖全部文字内容。

image

查看了下 label.ts 源码,这里宽度的计算好像有点问题。

Object.assign(backgroundStyle, { x: minX - left, y: minY - top, width: wordWrap ? Math.min(totalWidth, wordWrapWidth) : totalWidth, height: halfHeight * 2 + top + bottom, });

是不是可以改成 width: wordWrap ? Math.min(totalWidth, wordWrapWidth + left + right) : totalWidth,

或者不做判断直接用 totalWidth 好像也可以 width: totalWidth

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

macOS

Browser / 浏览器

Chrome

Additional context / 补充说明

No response


看起来应该是需要改为:

width: wordWrap ? Math.min(totalWidth, wordWrapWidth + left + right) : totalWidth,

有兴趣给 G6 提个 PR 吗

posted by Aarebecca 9 months ago

Fund this Issue

$0.00
Funded

Pull requests