Skip to content

Commit 46f0b6c

Browse files
authored
Merge pull request #3550 from VisActor/fix/dom-tooltip-content-update
Fix/dom tooltip content update
2 parents a1a41e2 + 03c8b7d commit 46f0b6c

File tree

5 files changed

+251
-168
lines changed

5 files changed

+251
-168
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: html tooltip can reuse the dom content and fix the unneed animation\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "[email protected]"
11+
}
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: fix tooltip content when only has `valueFormatter` or `keyFormatter`\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "[email protected]"
11+
}

packages/vchart/src/component/tooltip/utils/common.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,30 @@ function addContentLine(
7878
...spec
7979
}
8080
: { ...shapeAttrs, ...spec };
81-
82-
Object.keys(finalSpec).forEach(k => {
83-
if (k === 'key') {
84-
res.key = getTimeString(
85-
getTooltipContentValue(finalSpec.key, datum, params, finalSpec.keyFormatter),
86-
finalSpec.keyTimeFormat,
87-
finalSpec.keyTimeFormatMode
88-
);
89-
} else if (k === 'value') {
90-
res.value = getTimeString(
91-
getTooltipContentValue(finalSpec.value, datum, params, finalSpec.valueFormatter),
92-
finalSpec.valueTimeFormat,
93-
finalSpec.valueTimeFormatMode
94-
);
95-
} else {
96-
(res as any)[k] = getTooltipContentValue((finalSpec as any)[k], datum, params);
97-
}
81+
const {
82+
key,
83+
keyFormatter,
84+
keyTimeFormat,
85+
keyTimeFormatMode,
86+
value,
87+
valueFormatter,
88+
valueTimeFormat,
89+
valueTimeFormatMode,
90+
...others
91+
} = finalSpec;
92+
93+
res.key = getTimeString(
94+
getTooltipContentValue(key, datum, params, keyFormatter),
95+
keyTimeFormat,
96+
keyTimeFormatMode
97+
);
98+
res.value = getTimeString(
99+
getTooltipContentValue(value, datum, params, valueFormatter),
100+
valueTimeFormat,
101+
valueTimeFormatMode
102+
);
103+
Object.keys(others).forEach(k => {
104+
(res as any)[k] = getTooltipContentValue((finalSpec as any)[k], datum, params);
98105
});
99106
if (res.visible !== false && (isValid(res.key) || isValid(res.value))) {
100107
result.push(res);

0 commit comments

Comments
 (0)