-
Notifications
You must be signed in to change notification settings - Fork 19.7k
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
[Bug] Tooltip formatter gives wrong values #16930
Comments
Problem locatingThe problem seems to be that when tooltip is only updated by echarts/src/component/tooltip/TooltipView.ts Lines 263 to 272 in 3961cef
But after that it is treated as a relative position on axis. So when axis extent changes, the same relative position sits a totally different value. Here cbParams tries to get the value on a relative position dataIndex of the axis extent.echarts/src/component/tooltip/TooltipView.ts Line 565 in 3961cef
SolutionSince the code of getting value of relative solution is a well-wrapped and widely used by all kinds of other chart. It would be better to play a trick here by preventing Echarts from updating tooltip unless item is clicked when echarts/src/component/tooltip/TooltipView.ts Lines 254 to 260 in 3961cef
So that Echarts wouldn't update tooltip untill another click. However this method will still allow Echarts to move axisPointer as axis extent changes so the axisPointer would not be compatible to the clicked item. I think there should be another better solution. Might need some help here. |
Version
Bug appeared in v.5.2.0 and still is in latest version (v5.3.2)
Link to Minimal Reproduction
https://codepen.io/meredev/pen/OJzqwNg
Steps to Reproduce
Here is a visualization of the steps to follow (click to expand) :

Current Behavior
The tooltip is not displaying the value it's supposed to (the one along the axisPointer). If you move the chart to a side (=pan), the axisPointer stays on the point (here x=13) BUT the tooltip doesn't display the value of this point. In the screenshot below, we see that it displays y=900 (which is the value of x=15) instead of showing y=377 (which is the value for x=13).
When looking to the
params
object of the formatter function (with console.log), we can clearly see thataxisValue
(which is good) doesn't fit withvalue
orname
...Formatter function
params
object :Expected Behavior
It should display the value of the point that is on the axisPointer (the vertical dashed-line). If you move the chart to a side (=pan), the axisPointer stays on the point (that already works) BUT the tooltip should display the value of this point.
In the
params
object of the formatter function,axisValue
should be the same asname
, and should fit withdata
,dataIndex
andvalue
.Environment
Any additional comments?
This worked prior to v5.2.0 (I tried with v.5.1.2 and it worked as expected)
After digging a bit more in this bug, i think the formatter function should not even be called when zooming or panning (since the values to display in the tooltip stay the same, there is no reason to call the tooltip formatter function).
The text was updated successfully, but these errors were encountered: