apache / echarts

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

[Feature] when symbol is svg,make the whole area of svg can trigger mouse event,not just the svg path #20434

Closed Xiaobaishushu25 closed 1 month ago

Xiaobaishushu25 commented 1 month ago

What problem does this feature solve?

When Symbol is SVG, only the SVG paths will generate a click event. so the User need to be precise in order to click on a node. The area between the paths is not clickable. A For example,Like the SVG above, only the middle T and black border can correspond to mouse events, and the transparent area in the middle cannot be triggered.

What does the proposed API look like?

Suggested is to augment the Symbol attributes with SymbolMask: match | square| none, where:

matchwill make the whole SVG clickable, tracking the outline shape perimeter square will create a square clickable area around the shape perimeter none (or undefined or not-set) - events will fire only when clicking the paths

helgasoft commented 1 month ago

The area between the paths is not clickable.

Could you please present SVG code for such symbol ? I'm trying with single path and cannot reproduce - Demo

Xiaobaishushu25 commented 1 month ago

The area between the paths is not clickable.

Could you please present SVG code for such symbol ? I'm trying with single path and cannot reproduce - Demo

Thank you very much for your demo. I learned how to use 'image://data:image/svg+xml;charset=utf8,'+ svg, to set up symbol. At first, I consulted the official documentation https://echarts.apache.org/zh/option.html#series-scatter.symbol and only provided such examples symbol:'path://xx' when setting up SVG. I wrote the demo according to the document demo, and you can see that the tooltip cannot be triggered when the mouse is placed in a transparent area. But now with your method, it works very well.