forked from codesinghanoop/react-native-d3-tree-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsiblingUtil.js
More file actions
34 lines (33 loc) · 781 Bytes
/
Copy pathsiblingUtil.js
File metadata and controls
34 lines (33 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as d3 from "d3";
export function sblingLine(d,allNodes) {
//start point
var start = allNodes.filter(function (v) {
if (d.source.id == v.id) {
return true;
} else {
return false;
}
});
//end point
var end = allNodes.filter(function (v) {
if (d.target.id == v.id) {
return true;
} else {
return false;
}
});
//define teh start coordinate and end co-ordinate
var linedata = [{
x: start[0].x,
y: start[0].y
}, {
x: end[0].x,
y: end[0].y
}];
var fun = d3.svg.line().x(function (d) {
return d.x;
}).y(function (d) {
return d.y;
}).interpolate("linear");
return fun(linedata);
}