我正在尝试获取节点的x和y坐标,然后使用这些坐标从一个节点绘制直线,如果边缘已被指定为直线:
for (var x = 0; x < edges.length; x++) {
// Check if the nodes exist for this edge
var nodeFrom = nodes.filter(function(item:any) { return item.id === edges[x].from; });
var nodeTo = nodes.filter(function(item:any) { return item.id === edges[x].to; });
var currentStyle;
var currentArrowheadStyle;
if (edges[x].shape === "straight") {
edges[x].shape = svg.selectAll("g.edgePath").data(edges).enter().append("line");
}
我的节点对象如下所示:
{ id: 1, shape: "ellipse", label: "Start"},
{ id: 2, shape: "rect", label: "Square"},
{ id: 3, shape: "diamond", label: "Split (A)", class: "completed"},
{ id: 4, shape: "rect", label: "Square (A)", class: "in-progress"},
{ id: 5, shape: "rect",label: "Square (A)"},
{ id: 6, shape: "rect", label: "Square (A)"},
我的边缘看起来像这样:
{ from: 5, to: 7, type: "vee", dashed: false },
{ from: 6, to: 7, type: "vee", dashed: false },
{ from: 3, to: 6, type: "vee", dashed: false, shape: "straight"},
{ from: 4, to: 7, type: "vee", dashed: false },
如何将节点连接到直线边缘,由边缘中的shape属性标识?
由于