-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Experiment] Component rendered tooltip #838
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: 8.0
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
The limitation is that the tooltip detached from the current component tree, not provide/inject will try teleport next
How about we go over the external API first? |
We could consider supporting multiple or dynamic slots—e.g., tooltip, tooltip-series-line, etc.—which could then map to the corresponding tooltip configurations at different levels. The idea would be to let slots fully override the tooltip formatters.
From what I’ve seen, showTip is triggered whenever the pointer moves within the chart. Could you clarify what specific information is missing for our use case?
If we can implement tooltips as slots, we should be able to make the content reactive to async states or even render The most tricky part I can think of is when and how to update the slot props when |
I also considered this, but then I remembered that For multiple series of the same type but with different formatters, should we add a modifier like Most series support formatter for each single datum. But I think users can achieve similar functionality by using a series-level tooltip formatter and
I think the slotProps should be the
We could override users' formatter(params) {
// slotName.slotProps is a shallowRef
slotName.slotProps.value = params
return toHtml(slotContent)
} The slot props would be updated whenever |
Summary
This PR proposes a new
echarts-tooltip
component. The component provides aformatter
method that can be used with ECharts'tooltip.formatter
option, allowing users to define tooltip content using Vue's template syntax.The slot props are what users passed to the
formatter
method. The component teleports its slot content to a detached DOM element so that it does not exist in the html body.Example
For a practical example, see the Line Chart in the demo preview which features a Pie Chart as its tooltip.
Design Rationale
Why a Separate Component?
VChart
would make it difficult to handle these various use cases intuitively.The
showTip
event doesn't provide sufficient information for implementing the approach suggested in Use Web Components without native class support detection #836 (comment).We may need to support ECharts' asynchronous tooltip formatting:
By making it a separate component, users can:
@Justineo , do you have any other ideas for us to try?