Skip to content

Commit 05db465

Browse files
authored
Merge pull request #3723 from VisActor/fix/tooltip-max-width
Fix/tooltip max width
2 parents 68570b1 + 136c22e commit 05db465

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "fix: tooltip should auto wrap when `maxWidth` is valid and `multiLine` is not false, fix #3718\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "dingling112@gmail.com"
11+
}

packages/vchart/src/plugin/components/tooltip-handler/utils/attribute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function getTextAttributes(
8484
fontWeight: style.fontWeight,
8585
lineHeight: style.lineHeight as number,
8686
spacing: style.spacing,
87-
multiLine: style.multiLine,
87+
multiLine: isValid(style.maxWidth) ? style.multiLine !== false : style.multiLine,
8888
maxWidth: style.maxWidth,
8989
wordBreak: style.wordBreak,
9090
autoWidth: style.autoWidth

packages/vchart/src/plugin/components/tooltip-handler/utils/style.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ export const getTextStyle = (style: ITooltipTextTheme = {}, textStyle: Partial<C
3434
if (isValid(style.fontSize)) {
3535
textStyle.fontSize = getPixelPropertyStr(style.fontSize as number);
3636
}
37+
3738
if (isValid(style.maxWidth)) {
3839
textStyle.maxWidth = getPixelPropertyStr(style.maxWidth as number);
3940
}
40-
if (style.multiLine) {
41+
42+
if (style.multiLine || (isValid(style.maxWidth) && style.multiLine !== false)) {
4143
textStyle.whiteSpace = 'initial';
4244
textStyle.wordBreak = style.wordBreak ?? 'break-word';
4345
} else {

0 commit comments

Comments
 (0)