feat(line): `triggerLineOnlyEvent` option for more control over mouse event
Brief Information
This pull request is in the type of:
- [ ] bug fixing
- [x] new feature
- [ ] others
What does this PR do?
Add triggerLineOnlyEvent option to line series that can be used to ensure the mouse event only fires when actually hovering on the line, not the shaded area under curve (when areaStyle set).
Fixed issues
- #21000
Details
Before: What was the problem?
Mouse event fires when hovering on shaded region, not just on the actual line. That behavior makes sense in many cases, but when there are many series overlapping, it can be useful to only fire when actually hovering directly on the line (or else it might not actually be the series closest to your cursor)
https://github.com/user-attachments/assets/88fbd1ea-d019-45e6-9cac-10f17a35acae
Bold series in tooltip does not stay in sync with the correct line being hovered over:
https://github.com/user-attachments/assets/193b4b0d-83cf-4966-b256-4fee721befd7
After: How does it behave after the fixing?
When triggerLineOnlyEvent: true, only hovering on the line triggers the mouse event
https://github.com/user-attachments/assets/5ce15f83-eb63-4d19-b1ce-405b8dd9ba7c
Document Info
One of the following should be checked.
- [ ] This PR doesn't relate to document changes
- [ ] The document should be updated later
- [x] The document changes have been made in apache/echarts-doc#447
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
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.
Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.
I think this should be a useful feature to have. Considering compatibility, we shouldn't change the behavior of
triggerLineEvent. Name the new event to be something liketriggerLineOnlyEventor suggest a better name.
Agreed that's a much better approach, I just made the change to triggerLineOnlyEvent and opened a docs PR in apache/echarts-doc#447
@plainheart any additional feedback on this PR? The latest commit should match your suggestion here
Hi @sjcobb, sorry for the delay. I will check it again later and merge it if there are no further changes.
Congratulations! Your PR has been merged. Thanks for your contribution! 👍