Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
D3.js 不同SVG中的连接元素_D3.js_Svg - Fatal编程技术网

D3.js 不同SVG中的连接元素

D3.js 不同SVG中的连接元素,d3.js,svg,D3.js,Svg,我需要在svg1中的元素和svg2中的元素之间绘制箭头。除了将两个svg元素放在一个svg中,您知道如何做到这一点吗?您可以使用位于两个其他svg之上的第三个svg 定位它,使第三个svg的边缘正好位于您希望箭头指向的位置,并使用线x1、y1、x2、y2坐标的百分比,使其位于0%、0%、100%、100% 不要忘记将指针事件设置为“无”,以便仍然能够与页面交互 var c1=document.getElementById(“svg1”).getBoundingClientRect() var

我需要在svg1中的元素和svg2中的元素之间绘制箭头。除了将两个svg元素放在一个svg中,您知道如何做到这一点吗?

您可以使用位于两个其他svg之上的第三个svg

定位它,使第三个svg的边缘正好位于您希望箭头指向的位置,并使用线x1、y1、x2、y2坐标的百分比,使其位于0%、0%、100%、100%

不要忘记将指针事件设置为“无”,以便仍然能够与页面交互

var c1=document.getElementById(“svg1”).getBoundingClientRect()
var c2=document.getElementById(“svg2”).getBoundingClientRect()
var svg3=document.getElementById(“svg3”)
svg3.style.top=c1.top+c1.height/2
svg3.style.left=c1.left+c1.width/2
svg3.setAttribute(“宽度”,(c2.left+c2.width/2)-(c1.left+c1.width/2))
svg3.setAttribute(“高度”,(c2.top+c2.height/2)-(c1.top+c1.height/2))
#svg3{
位置:绝对位置;
溢出:可见;
指针事件:无;
}
#svg3线{
标记开始:url(#箭头开始);
标记结束:url(#箭头结束);
笔划线头:对接;
笔画:蓝色;
不透明度:0.5;
笔画宽度:5;
}

一些文字。。。

其他一些文本
您可以使用第三个svg,它位于其他两个svg之上

定位它,使第三个svg的边缘正好位于您希望箭头指向的位置,并使用线x1、y1、x2、y2坐标的百分比,使其位于0%、0%、100%、100%

不要忘记将指针事件设置为“无”,以便仍然能够与页面交互

var c1=document.getElementById(“svg1”).getBoundingClientRect()
var c2=document.getElementById(“svg2”).getBoundingClientRect()
var svg3=document.getElementById(“svg3”)
svg3.style.top=c1.top+c1.height/2
svg3.style.left=c1.left+c1.width/2
svg3.setAttribute(“宽度”,(c2.left+c2.width/2)-(c1.left+c1.width/2))
svg3.setAttribute(“高度”,(c2.top+c2.height/2)-(c1.top+c1.height/2))
#svg3{
位置:绝对位置;
溢出:可见;
指针事件:无;
}
#svg3线{
标记开始:url(#箭头开始);
标记结束:url(#箭头结束);
笔划线头:对接;
笔画:蓝色;
不透明度:0.5;
笔画宽度:5;
}

一些文字。。。

其他一些文本