Skip to content

Commit ab1a0fb

Browse files
committed
update position of phantom children nodes when a group is dragged
1 parent b4d7ff3 commit ab1a0fb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/traces/sankey/calc.js

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ function convertToD3Sankey(trace) {
111111

112112
nodes.push({
113113
group: (i > nodeCount - 1),
114+
children: [],
114115
pointNumber: i,
115116
label: l,
116117
color: hasNodeColorArray ? nodeSpec.color[i] : nodeSpec.color

src/traces/sankey/render.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function sankeyModel(layout, d, traceIndex) {
7979
}
8080
}
8181

82-
graph.nodes.unshift({
82+
var child = {
8383
pointNumber: parseInt(nodePointNumber),
8484
x0: groupingNode.x0,
8585
x1: groupingNode.x1,
@@ -88,7 +88,10 @@ function sankeyModel(layout, d, traceIndex) {
8888
partOfGroup: true,
8989
sourceLinks: [],
9090
targetLinks: []
91-
});
91+
};
92+
93+
graph.nodes.unshift(child);
94+
groupingNode.children.unshift(child);
9295
}
9396

9497
function computeLinkConcentrations() {
@@ -559,6 +562,10 @@ function attachDragHandler(sankeyNode, sankeyLink, callbacks) {
559562

560563
.on('dragend', function(d) {
561564
d.interactionState.dragInProgress = false;
565+
for(var i = 0; i < d.node.children.length; i++) {
566+
d.node.children[i].x = d.node.x;
567+
d.node.children[i].y = d.node.y;
568+
}
562569
});
563570

564571
sankeyNode

0 commit comments

Comments
 (0)