Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xuwb opened this issue Jul 17, 2024 · 1 comment

Comments

@xuwb
Copy link
Contributor

xuwb commented Jul 17, 2024

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

@xuwb xuwb changed the title label 使用padding并且折行的情况下,background宽度不能覆盖全部文字内容 [V5] label 使用padding并且折行的情况下,background宽度不能覆盖全部文字内容 Jul 17, 2024
@Aarebecca
Copy link
Contributor

看起来应该是需要改为:

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

有兴趣给 G6 提个 PR 吗

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

No branches or pull requests

2 participants