我有一个 SVG 图表控件。请参考下面的 SVG 代码。
<svg id="container_svg" style="width: 800px; height: 600px;">
<rect id="container_svg_SvgRect" x="0" y="0" width="800" height="600" fill="#111122" stroke-width="0" stroke="white"/>
<rect id="container_svg_ChartArea" x="73" y="107" width="707" height="428" fill="#111122" stroke-width="1" stroke="White"/>
<g transform="translate(73,535)" id="container_svg_ChartArea">
<defs>
<clipPath id="container_svg_ChartAreaClip">
<rect id="container_svg_ChartAreaClipRect" x="73" y="107" width="707" height="428" fill="white" stroke-width="1" stroke="Gray" transform="translate(-73,-535)" style="display: inline-block; width: 707px;"/></clipPath></defs>
-----------------------------------------------
<circle id="container_svg_circlesymbol4" cx="589.1666666666667" cy="-321" r="7.0710678118654755" fill="url(#container_svg_symbol1Gradient)" stroke-width="1" stroke="Gray"/>
我想从上面的代码中得到圆圈符号。
当我访问 document.elementFromPoint(0,0) 时返回“body”而不是 svg rect 元素。
所以我已经将svg 对象的偏移位置添加到elementfrompoint但它仍然返回空元素。
对于圆,我添加了圆位置+圆的平移位置+ svg对象偏移位置,但除了jquery中的elementfrompoint之外,仍然无法使用任何其他解决方案。
以下链接中提供的解决方案不起作用。
谢谢,
湿婆