-
Notifications
You must be signed in to change notification settings - Fork 19.7k
feat(tooltip): inject tooltip position in formatter and data params's point coordinates #18715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(tooltip): inject tooltip position in formatter and data params's point coordinates #18715
Conversation
Thanks for your contribution! 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I think providing which series is in focus can be helpful in some cases. However, returing position in the callback is not intuitive. As you can see in your demo in the test, the user has to write a lot of code to accomplish the job. So I would suggest this information should be returned in the params series like:
formatter: params => {
params[0].state // 'normal' | 'emphasis' | 'select' | 'blur'
}
@Ovilia In fact, it would be more user-friendly to provide state to the user (can you define each of the state you've given me as examples?). |
If you want to provide the position, I think it may be a better idea to be the position of the mouse position relative to the canvas top-left corder. Your current code seems to return the Element states are defined in https://github.com/apache/echarts/blob/master/src/util/types.ts#L650 Please also simplify your test case data and remove the unnecessary data. |
@Ovilia The mouse position is already provided as a fourth parameter of For the element states, I'm not sure if this is something I have to calculate (how?) or if this is something I can already get; currently, from what I see after a code search, To conclude, I'm new to the codebase, I'd like to do my best, but I don't know where to find the resources to help me.
|
Brief Information
This pull request is in the type of:
What does this PR do?
Adds tooltip position as
tooltip.formatter
argument and injects graphic element's point coordinates intoCallbackDataParams
.Fixed issues
Details
Before: What was the problem?
It was not possible to format the tooltip based on its position relative to the points.
After: How does it behave after the fixing?
The user can use the tooltip's
position
argument and the point coordinates in theparams
argument oftooltip.formatter
to customize the tooltip display.For example: Highlight nearest serie in tooltip, displays only the nearest point in the tooltip.
Document Info
One of the following should be checked.
Misc
ZRender Changes
Related test cases or examples to use the new APIs
tooltip-formatter
test caseOthers
Merging options
Other information
IMPORTANT NOTE: I retrieved the coordinates from the graphic element of the data, but I'm not sure this is the right way to proceed. I'd be pleased to receive feedback on this.