echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] Tooltips on line series - also show on line segments

Open ob-ARC opened this issue 1 year ago • 3 comments

What problem does this feature solve?

My use case is a line series with steps, i.e. it only consists of vertical and horizontal segments. Our users would like to see tooltips on the line segments as well, indicating the current value of y on the horizontal segments, and the value of x on the vertical segments. I would suggest that the data sent to the formatter are either interpolated (I assume that calculation is not performance-critical), or the data of the nearest data point is used (this was already mentioned in #15437).

Example:

https://echarts.apache.org/examples/en/editor.html?c=line-simple&version=5.5.0&code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5AG4CGANgK5W0A0J6AthNCIAGbqVi9GGIgHYSAX1GxyOfEVRiK1OkzYdFfAcP3jJRAMzzFYYMGaQQanrDwALYAHciYAE7tLJPCpvCCpCWABtJ3UxWAgAEzpmASoARi4ndGhGXhpYWiToVPSYskpc_OTimLxyXgAjWzoAYwhvJuY9DOc3dwBlWobmL18qY3Qa-tteiAAvXJSRLrjGMEYicPCUzhSAXU4IgCZtvcPOA5PwszOLq9398IAWY_un8_uAVmuP54iANmO9l1rLZ7I4SugAPQQgBmwG8EjAYCCRGhrGgTUgMAAFCBGN5snh9pAmgBrKhgfZNFjMOqMUkASmQsG85NY3jgtCReDAtAA3OgFF10LD4Sskd46EhGHJkE05FUSq4PMN2GNSIwQNRoHEACrAABCwDi5BVVC6cicgrE0TE8USyQOCtIWRy9sKjrVmnKBU6ioGjTyLTaHSd4x6_UmQzIIzVE0G0zmRAWauWq3W4REdwiWzepwOADp3jczvmDkWXiXpOWIp8C9Xwv8UvmqztASVgXYIA5iODYCKEeKUWiMVBoDi8QSiRBSeTKdTaQymSywGyOVyefzYFbwVD-2LkXkpTKkHLQ6QlZ5o6qhbANVrdQajSar2aShaxO_YDsUHJeUA

What does the proposed API look like?

No additional API required.

ob-ARC avatar Apr 23 '24 07:04 ob-ARC

if both axes can be converted to type 'category', then axisPointer could be used instead of tooltip - Demo

helgasoft avatar Apr 23 '24 17:04 helgasoft

if both axes can be converted to type 'category', then axisPointer could be used instead of tooltip

I know that, but it is not an option.

ob-ARC avatar Apr 24 '24 09:04 ob-ARC

If anybody is interested, the following example shows how a hint on the line (showing the closest data point, interpolation not possible as far as I can see) can be achieved by using mouse event handlers and the showTip/hideTip actions via dispatchAction:

https://jsfiddle.net/gjrn97pm/4/

ob-ARC avatar Apr 26 '24 11:04 ob-ARC