Skip to content

Commit 067869f

Browse files
committed
implement dragging
1 parent be1acc8 commit 067869f

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"country-regex": "^1.1.0",
6666
"d3": "^3.5.12",
6767
"d3-sankey": "git://github.com/antoinerg/d3-sankey.git#4f37ed8d3578b545a8569ecd74583f373768e900",
68-
"d3-sankey-circular": "^0.26.0",
68+
"d3-sankey-circular": "git://github.com/antoinerg/d3-sankey-circular.git#a298acf674f0a9c7158243d45814cd8060dad728",
6969
"d3-array": "1",
7070
"d3-collection": "1",
7171
"d3-force": "^1.0.6",

src/traces/sankey/render.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ function sankeyModel(layout, d, traceIndex) {
4848
.nodePadding(nodePad)
4949
.circularLinkGap(2)
5050
.nodes(nodes)
51-
.links(links);
51+
.links(links)
52+
.nodeId(function(d) {
53+
return d.pointNumber;
54+
});
5255

5356
var graph = sankey();
57+
5458
if(sankey.nodePadding() < nodePad) {
5559
Lib.warn('node.pad was reduced to ', sankey.nodePadding(), ' to fit within the figure.');
5660
}
@@ -160,6 +164,7 @@ function nodeModel(d, n, i) {
160164
n.dy = n.y1 - n.y0;
161165

162166
return {
167+
index: n.pointNumber,
163168
key: key,
164169
traceId: d.key,
165170
node: n,
@@ -185,7 +190,7 @@ function nodeModel(d, n, i) {
185190
valueFormat: d.valueFormat,
186191
valueSuffix: d.valueSuffix,
187192
sankey: d.sankey,
188-
graph: d.sankey.graph,
193+
graph: d.graph,
189194
arrangement: d.arrangement,
190195
uniqueNodeLabelPathId: [d.guid, d.key, key].join('_'),
191196
interactionState: d.interactionState
@@ -540,8 +545,8 @@ module.exports = function(svg, calcData, layout, callbacks) {
540545
.call(updateNodePositions)
541546
.call(attachPointerEvents, sankey, callbacks.nodeEvents);
542547

543-
// sankeyNode
544-
// .call(attachDragHandler, sankeyLink, callbacks); // has to be here as it binds sankeyLink
548+
sankeyNode
549+
.call(attachDragHandler, sankeyLink, callbacks); // has to be here as it binds sankeyLink
545550

546551
sankeyNode.transition()
547552
.ease(c.ease).duration(c.duration)
-1.78 KB
Loading

test/image/mocks/sankey_circular.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "sankey",
55
"node": {
66
"pad": 1,
7-
"label": ["0", "1", "2", "3", "4", "5"]
7+
"label": ["0", "1", "2", "3", "4", "5", "6"]
88
},
99
"link": {
1010
"source": [
@@ -15,15 +15,11 @@
1515
],
1616
"value": [
1717
1, 2, 1, 1, 1, 1, 1
18-
],
19-
"label": ["1", "2", "3", "4", "5"]
18+
]
2019
}
2120
}],
2221
"layout": {
2322
"title": "Sankey with circular data",
24-
"margin": {
25-
"l": 25, "r": 25, "t": 25, "b": 25
26-
},
2723
"width": 800,
2824
"height": 800
2925
}

0 commit comments

Comments
 (0)