javascript - Finding the coordinates of a node in D3.js -
i trying x , y coordinates nodes, , use coordinates draw straight line 1 node if edge has been specified straight:
(var x = 0; x < edges.length; x++) { // check if nodes exist 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"); }
my node object looks this:
{ 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)"},
my edges this:
{ 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 },
how connect the nodes straight line edge, identified shape property in edges?
thanks