Skip to content

Commit

Permalink
fix(tooltip): for fisheye (#5590)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored Sep 25, 2023
1 parent bece2a7 commit b39be0a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/interaction/fisheye.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export function Fisheye({
setState('fisheye', (options) => {
// Clone options and mutate it.
// Disable animation.
const clonedOptions = deepMix({}, options);
const clonedOptions = deepMix({}, options, {
interaction: { tooltip: { preserve: true } },
});
for (const mark of clonedOptions.marks) mark.animate = false;
const [x, y] = focus;
const fisheye = maybeCoordinate(clonedOptions);
Expand Down
14 changes: 12 additions & 2 deletions src/interaction/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ export function seriesTooltip(
theme,
disableNative = false,
marker = true,
preserve = false,
style: _style = {},
css = {},
...rest
Expand Down Expand Up @@ -742,7 +743,11 @@ export function seriesTooltip(
emitter.off('tooltip:hide', onTooltipHide);
emitter.off('tooltip:disable', onTooltipDisable);
emitter.off('tooltip:enable', onTooltipEnable);
destroy();
if (preserve) {
hideTooltip({ root, single, emitter, nativeEvent: false });
} else {
destroy();
}
};
}

Expand Down Expand Up @@ -774,6 +779,7 @@ export function tooltip(
shared = false,
body = true,
disableNative = false,
preserve = false,
css = {},
}: Record<string, any>,
) {
Expand Down Expand Up @@ -899,7 +905,11 @@ export function tooltip(
removeEventListeners();
emitter.off('tooltip:show', onTooltipShow);
emitter.off('tooltip:hide', onTooltipHide);
destroyTooltip({ root, single });
if (preserve) {
hideTooltip({ root, single, emitter, nativeEvent: false });
} else {
destroyTooltip({ root, single });
}
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ function updateTooltip(
container: selection.node(),
update: (options) => Promise.resolve(options),
};
applyTooltip(target, [], context.emitter);
const newTooltip = applyTooltip(target, [], context.emitter);
nameInteraction.set('tooltip', newTooltip);
}

async function initializeView(
Expand Down

0 comments on commit b39be0a

Please sign in to comment.