Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ class TooltipView extends ComponentView {
const api = this._api;
const triggerOn = tooltipModel.get('triggerOn');

if (tooltipModel.option.trigger !== 'axis') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why we should check if it's axis here? What happens if we don't use this if? Because I don't see other places checking this before setting _lastDataByCoordSys to be null.

Copy link
Contributor Author

@Justin-ZS Justin-ZS Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_lastDataByCoordSys is used for axis tooltip only
If current trigger is still axis, it should not be cleared.
Other cases to clear the _lastDataByCoordSys

  1. When the tooltip is hidden (regardless of trigger mode)
  2. In TooltipView. _tryShow
  • Showing axis tooltip via _showAxisTooltip()
  • Or other tooltip (set to null)

// _lastDataByCoordSys is used for axis tooltip.
this._lastDataByCoordSys = null;
}

// Try to keep the tooltip show when refreshing
if (this._lastX != null
&& this._lastY != null
Expand Down Expand Up @@ -365,11 +370,13 @@ class TooltipView extends ComponentView {
else if (payload.x != null && payload.y != null) {
// FIXME
// should wrap dispatchAction like `axisPointer/globalListener` ?
api.dispatchAction({
type: 'updateAxisPointer',
x: payload.x,
y: payload.y
});
if (tooltipModel.option.trigger === 'axis') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this action should only be dispatched for axis triggers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this action causes the emphasis state lost.
After dispatch:
截屏2025-03-11 17 10 48
Expected:
截屏2025-03-11 17 17 49
Maybe dispatch this action only when axisPointer is enabled would be better.
Is there any way to check if axisPointer is enabled or not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically speaking, I don't think whether the axisPointer is enabled makes any difference in this regard. If we consider that setOption should lead to an update of the tooltip, then it is also logical that setOption causes the emphasis state to become updated.

This is also one of the reasons why I'm more inclined to think that the issue in this PR isn't a bug. Perhaps keeping the setting of "changing the 'trigger' via setOption won't trigger the redrawing of the tooltip" would simplify matters. May I ask what initially led you to need to fix the problem in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert this change because you think losing the "emphasis" is not a bug.
But changing the tooltip "trigger" without updating the tooltip is certainly a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

api.dispatchAction({
type: 'updateAxisPointer',
x: payload.x,
y: payload.y
});
}

this._tryShow({
offsetX: payload.x,
Expand Down
1 change: 1 addition & 0 deletions test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/runTest/actions/tooltip-refresh.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 120 additions & 0 deletions test/tooltip-refresh.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.