在两个设备之间同时有多条电路时,可以使用弧线来表示,这样就不会相互覆盖。(另一种实现方式是电路组,适合电路很多的情况) 相应的函数为: //3级函数 //创建弧线电路 function createCurveCircuit(identifer,fromP,toP,name,color,titleArray,fromid,toid,rank,bandwidth,target){ //alert("hi"); var circuit=createCurveLink(identifer,fromP,toP,name,color,titleArray,fromid,toid,rank,target); circuit.strokeweight=bandwidth return circuit; } function createCurveLink(identifer,fromP,toP,name,color,titleArray,fromid,toid,rank,target){ var curve=document.createElement("v:curve"); if (target == undefined){ document.body.appendChild(curve); } else{ document.getElementById(target).appendChild(curve); } //document.body.appendChild(curve); curve.setAttribute("startP",fromP); curve.setAttribute("endP",toP); var fromObj=document.getElementById(fromid); var fromLinks=fromObj.fromLinks; if(fromLinks==null){ fromLinks=new Array(); fromObj.setAttribute("fromLinks",fromLinks); } fromLinks[fromLinks.length]=curve; var toObj=document.getElementById(toid); var tolinks=toObj.toLinks; if(tolinks==null){ tolinks=new Array(); toObj.setAttribute("toLinks",tolinks); } tolinks[tolinks.length]=curve; curve.setAttribute("hasAlarm",false); curve.from=fromP; curve.to=toP; curve.id=identifer; curve.name=name; curve.strokecolor=color; curve.setAttribute("selfColore",color); curve.filled="f"; curve.strokeweight="1px"; curve.style.top=0; curve.style.left=0; curve.style.position="absolute"; curve.style.zIndex="1"; curve.setAttribute("rank",rank); setControl(curve); return curve; } //1.底层函数 //设置曲线弯度 function setControl(curve){ var rank=curve.rank; var xSlope = curve.to.x- curve.from.x; var ySlope = curve.to.y - curve.from.y; var xLen = xSlope/3.; var yLen = ySlope/3.; var alpha = 0; if((rank & 1) == 0) alpha=Math.PI/2; else alpha=-Math.PI/2; alpha =alpha+ Math.atan(ySlope/xSlope); var dist = 13.*((rank+1)>>1); var xOff = dist * Math.cos(alpha); var yOff = dist * Math.sin(alpha); curve.control1.x=curve.from.x+(xLen+xOff); curve.control1.y=curve.from.y+(yLen+yOff); curve.control2.x=curve.from.x+(xLen*2+xOff); curve.control2.y=curve.from.y+(yLen*2+yOff); //alert("hi"); }