apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.63k stars 19.61k forks source link

[Bug] Tooltip coordinate markers created by "makeStyleCoord" are not disposed #19998

Open csisy-bt4w opened 5 months ago

csisy-bt4w commented 5 months ago

Version

5.5.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5AMYCGYVA5sAE7m0A0J6AE2aMiAbVoBZGL1i0AKgFcqM2gHUqAlXIAWClQDEOEFQGVmphdFoBdEgF8-6cjnxFUpMpRqyAbowA2SrT2jrB4VEZUhLCi_MQegsJiAIwArAAMPLAATADMmTnZACxZ2ckAHFnJualVRQDspQBs6dahHhTUdP4Q0MpxdiRtJGDAwP6QIG5xjCDU0AJywHQARsAC3KGDdgDcQA

Steps to Reproduce

  1. Set the tooltip to append to the body
  2. The tooltip will create these "marker points" inside the makeStyleCoord function
  3. These elements will be appended to the body
  4. Dispose the chart

Current Behavior

When the chart is disposed (and thus the tooltip is disposed), these marker elements are not removed from the DOM. This is kind of unexpected in a SPA, where the whole component is destroyed. image

Expected Behavior

These elements should not remain cached when all charts (we currently have a single one) are disposed.

Environment

- OS: Windows 11
- Browser: Chrome 125.0.6422.114
- Framework: Angular@17

Any additional comments?

It's not that big of a deal since these are hidden, 0x0 elements, but still, unnecessary 4 elements in the DOM.

sz-p commented 1 month ago

I see this issue is in 5.5.2, and follow the code to zrender transformCoordWithViewport It create dom but not return.

should we add a constant class name in dom created by transformCoordWithViewport.

then query and remove those dom on tooltip dispose?