Skip to content

Commit

Permalink
Merge pull request #3550 from VisActor/fix/dom-tooltip-content-update
Browse files Browse the repository at this point in the history
Fix/dom tooltip content update
  • Loading branch information
xile611 authored Dec 11, 2024
2 parents a1a41e2 + 03c8b7d commit 46f0b6c
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 168 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: html tooltip can reuse the dom content and fix the unneed animation\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: fix tooltip content when only has `valueFormatter` or `keyFormatter`\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
41 changes: 24 additions & 17 deletions packages/vchart/src/component/tooltip/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,30 @@ function addContentLine(
...spec
}
: { ...shapeAttrs, ...spec };

Object.keys(finalSpec).forEach(k => {
if (k === 'key') {
res.key = getTimeString(
getTooltipContentValue(finalSpec.key, datum, params, finalSpec.keyFormatter),
finalSpec.keyTimeFormat,
finalSpec.keyTimeFormatMode
);
} else if (k === 'value') {
res.value = getTimeString(
getTooltipContentValue(finalSpec.value, datum, params, finalSpec.valueFormatter),
finalSpec.valueTimeFormat,
finalSpec.valueTimeFormatMode
);
} else {
(res as any)[k] = getTooltipContentValue((finalSpec as any)[k], datum, params);
}
const {
key,
keyFormatter,
keyTimeFormat,
keyTimeFormatMode,
value,
valueFormatter,
valueTimeFormat,
valueTimeFormatMode,
...others
} = finalSpec;

res.key = getTimeString(
getTooltipContentValue(key, datum, params, keyFormatter),
keyTimeFormat,
keyTimeFormatMode
);
res.value = getTimeString(
getTooltipContentValue(value, datum, params, valueFormatter),
valueTimeFormat,
valueTimeFormatMode
);
Object.keys(others).forEach(k => {
(res as any)[k] = getTooltipContentValue((finalSpec as any)[k], datum, params);
});
if (res.visible !== false && (isValid(res.key) || isValid(res.value))) {
result.push(res);
Expand Down
Loading

0 comments on commit 46f0b6c

Please sign in to comment.