Skip to content

Commit 4825f8e

Browse files
authored
Merge pull request #1934 from plotly/sankey-multilink
Sankey fix for 4+ multilinks
2 parents 88764fa + 00bfcd6 commit 4825f8e

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/traces/sankey/render.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ function linkModel(uniqueKeys, d, l) {
155155
var tc = tinycolor(l.color);
156156
var basicKey = l.source.label + '|' + l.target.label;
157157
var foundKey = uniqueKeys[basicKey];
158-
uniqueKeys[basicKey] = (foundKey === void(0) ? foundKey : 0) + 1;
159-
var key = basicKey + (foundKey === void(0) ? '' : '__' + foundKey);
158+
uniqueKeys[basicKey] = (foundKey || 0) + 1;
159+
var key = basicKey + '__' + uniqueKeys[basicKey];
160160

161161
// for event data
162162
l.trace = d.trace;
@@ -186,8 +186,8 @@ function nodeModel(uniqueKeys, d, n) {
186186

187187
var basicKey = n.label;
188188
var foundKey = uniqueKeys[basicKey];
189-
uniqueKeys[basicKey] = (foundKey === void(0) ? foundKey : 0) + 1;
190-
var key = basicKey + (foundKey === void(0) ? '' : '__' + foundKey);
189+
uniqueKeys[basicKey] = (foundKey || 0) + 1;
190+
var key = basicKey + '__' + uniqueKeys[basicKey];
191191

192192
// for event data
193193
n.trace = d.trace;
1.36 KB
Loading

test/image/mocks/sankey_energy.json

+15-5
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@
192192
44,
193193
45,
194194
46,
195-
47
195+
47,
196+
35,
197+
35
196198
],
197199
"target": [
198200
1,
@@ -263,7 +265,9 @@
263265
15,
264266
1,
265267
15,
266-
15
268+
15,
269+
26,
270+
26
267271
],
268272
"value": [
269273
124.729,
@@ -313,7 +317,7 @@
313317
14.375,
314318
122.952,
315319
500,
316-
339.978,
320+
139.978,
317321
504.287,
318322
107.703,
319323
611.99,
@@ -334,7 +338,9 @@
334338
9.452,
335339
182.01,
336340
19.013,
337-
289.366
341+
289.366,
342+
100,
343+
100
338344
],
339345
"color": [
340346
"rgba(0,0,96,0.2)",
@@ -405,7 +411,9 @@
405411
"rgba(0,0,96,0.2)",
406412
"rgba(0,0,96,0.2)",
407413
"rgba(0,0,96,0.2)",
408-
"rgba(0,0,96,0.2)"
414+
"rgba(0,0,96,0.2)",
415+
"lightgreen",
416+
"goldenrod"
409417
],
410418
"label": [
411419
"stream 1",
@@ -476,6 +484,8 @@
476484
"",
477485
"",
478486
"",
487+
"",
488+
"",
479489
""
480490
]
481491
}

0 commit comments

Comments
 (0)