Skip to content

Conversation

Justin-ZS
Copy link
Contributor

@Justin-ZS Justin-ZS commented Jan 22, 2025

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

fix: Changing tooltip trigger from axis to item doesn't refresh the displayed tooltip

Fixed issues

#20706
截屏2025-01-23 15 26 40

Details

Before: What was the problem?

After: How does it behave after the fixing?

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

Copy link

echarts-bot bot commented Jan 22, 2025

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

⚠️ MISSING DOCUMENT INFO: Please make sure one of the document options are checked in this PR's description. Search "Document Info" in the description of this PR. This should be done either by the author or the reviewers of the PR.

@Justin-ZS
Copy link
Contributor Author

@Ovilia @100pah
Could you help to review the PR? Thanks!

@Ovilia
Copy link
Contributor

Ovilia commented Mar 10, 2025

@Ovilia @100pah Could you help to review the PR? Thanks!

Sure. I'm going to review more PRs every day recently.

Copy link
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20710@d6b12d2

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

@Justin-ZS Justin-ZS requested a review from Ovilia March 12, 2025 08:56
@Justin-ZS
Copy link
Contributor Author

@Ovilia I've updated the code accordingly. Could you help to review again? Thanks!

@Justin-ZS
Copy link
Contributor Author

@Ovilia @100pah @plainheart Could someone help to review? Thanks!

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply! We've been quite busy working towards 6.0.

@@ -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)

@Justin-ZS Justin-ZS requested a review from Ovilia June 13, 2025 09:00
@Justin-ZS
Copy link
Contributor Author

@Ovilia @100pah @plainheart Could someone help to review? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants