Skip to content

Commit 36d9fb4

Browse files
authored
Merge pull request #3143 from plotly/3140-sankey-fix-padding
sankey - fix issue with large padding
2 parents 06ae47d + 75947fe commit 36d9fb4

File tree

6 files changed

+339
-13
lines changed

6 files changed

+339
-13
lines changed

Diff for: package-lock.json

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
"dependencies": {
5959
"3d-view": "^2.0.0",
60-
"@plotly/d3-sankey": "^0.5.0",
60+
"@plotly/d3-sankey": "^0.5.1",
6161
"alpha-shape": "^1.0.0",
6262
"array-range": "^1.0.1",
6363
"canvas-fit": "^1.5.0",

Diff for: src/traces/sankey/render.js

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ function sankeyModel(layout, d, traceIndex) {
148148
.links(links)
149149
.layout(c.sankeyIterations);
150150

151+
if(sankey.nodePadding() < nodePad) {
152+
Lib.warn('node.pad was reduced to ', sankey.nodePadding(), ' to fit within the figure.');
153+
}
154+
151155
var node, sankeyNodes = sankey.nodes();
152156
for(var n = 0; n < sankeyNodes.length; n++) {
153157
node = sankeyNodes[n];

Diff for: test/image/baselines/sankey_large_padding.png

51 KB
Loading

Diff for: test/image/mocks/sankey_large_padding.json

+301
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
{
2+
"data": [{
3+
"node": {
4+
"color": [
5+
"#000000",
6+
"#BFDAE3",
7+
"#FF7080",
8+
"#FF707F",
9+
"#E64438",
10+
"#B0F0FF",
11+
"#F1483B",
12+
"#98D6F8",
13+
"#F2483A",
14+
"#FF4C3C",
15+
"#8599CC",
16+
"#FF5446",
17+
"#FF64FF",
18+
"#97D6F9",
19+
"#FE8EFE",
20+
"#FF6F80",
21+
"#B1BFDF",
22+
"#B3C0DE",
23+
"#FC8FFF",
24+
"#FF5346",
25+
"#90CAEC",
26+
"#90CBED",
27+
"#FF4B3E",
28+
"#FE909C",
29+
"#F2473B",
30+
"#B0FFB8",
31+
"#90CAED",
32+
"#FF4A3D",
33+
"#80C0E1",
34+
"#F24839",
35+
"#FF5C4E",
36+
"#95A7D3",
37+
"#A2B0D8",
38+
"#96A6D2",
39+
"#CAC7CB",
40+
"#FD4B3C",
41+
"#A2B1D7",
42+
"#70FF70",
43+
"#FF9B87",
44+
"#FE8E9D",
45+
"#FE5445",
46+
"#F2483B",
47+
"#CAC7CB",
48+
"#CAC7CB",
49+
"#CAC7CB",
50+
"#CAC7CB",
51+
"#CAC7CB",
52+
"#FF9B87",
53+
"#FF9B87",
54+
"#FF9B87",
55+
"#FF5C4E",
56+
"#FC8FFF",
57+
"#80C0E1",
58+
"#70FF70",
59+
"#70FF70"
60+
],
61+
"line": {
62+
"color": "black",
63+
"width": 0.5
64+
},
65+
"label": [
66+
"root",
67+
"grey",
68+
"BS",
69+
"IB",
70+
"HY",
71+
"CH",
72+
"LZ",
73+
"CNU",
74+
"LHA",
75+
"MEZ",
76+
"PAL",
77+
"PVR",
78+
"MB",
79+
"STR",
80+
"MBmot",
81+
"TH",
82+
"PALc",
83+
"BST",
84+
"PAG",
85+
"MPO",
86+
"LSX",
87+
"LS",
88+
"AHN",
89+
"DORpm",
90+
"LPO",
91+
"CTX",
92+
"LSr",
93+
"VMH",
94+
"sAMY",
95+
"TU",
96+
"PVZ",
97+
"PALm",
98+
"PALv",
99+
"MSC",
100+
"fiber tracts",
101+
"PH",
102+
"SI",
103+
"CTXpl",
104+
"HB",
105+
"MTN",
106+
"DMH",
107+
"RCH",
108+
"fiber tracts#1",
109+
"fiber tracts#2",
110+
"fiber tracts#3",
111+
"fiber tracts#4",
112+
"fiber tracts#5",
113+
"HB#3",
114+
"HB#4",
115+
"HB#5",
116+
"PVZ#5",
117+
"PAG#5",
118+
"sAMY#5",
119+
"CTXpl#4",
120+
"CTXpl#5"
121+
],
122+
"pad": 20,
123+
"thickness": 50
124+
},
125+
"link": {
126+
"source": [
127+
0,
128+
0,
129+
34,
130+
42,
131+
43,
132+
44,
133+
45,
134+
1,
135+
1,
136+
2,
137+
2,
138+
2,
139+
38,
140+
47,
141+
48,
142+
3,
143+
3,
144+
4,
145+
4,
146+
4,
147+
4,
148+
6,
149+
6,
150+
6,
151+
6,
152+
9,
153+
9,
154+
9,
155+
11,
156+
11,
157+
30,
158+
15,
159+
23,
160+
12,
161+
14,
162+
18,
163+
5,
164+
5,
165+
7,
166+
7,
167+
10,
168+
10,
169+
10,
170+
16,
171+
31,
172+
32,
173+
13,
174+
13,
175+
20,
176+
28,
177+
25,
178+
37,
179+
53
180+
],
181+
"target": [
182+
34,
183+
1,
184+
42,
185+
43,
186+
44,
187+
45,
188+
46,
189+
2,
190+
5,
191+
38,
192+
3,
193+
12,
194+
47,
195+
48,
196+
49,
197+
4,
198+
15,
199+
6,
200+
9,
201+
11,
202+
30,
203+
8,
204+
24,
205+
41,
206+
29,
207+
22,
208+
35,
209+
27,
210+
40,
211+
19,
212+
50,
213+
23,
214+
39,
215+
14,
216+
18,
217+
51,
218+
7,
219+
25,
220+
10,
221+
13,
222+
16,
223+
31,
224+
32,
225+
17,
226+
33,
227+
36,
228+
20,
229+
28,
230+
21,
231+
52,
232+
37,
233+
53,
234+
54
235+
],
236+
"value": [
237+
1,
238+
1,
239+
0.5,
240+
0.3333333333333333,
241+
0.25,
242+
0.2,
243+
0.16666666666666666,
244+
0.5,
245+
0.5,
246+
0.3333333333333333,
247+
0.3333333333333333,
248+
0.3333333333333333,
249+
0.25,
250+
0.2,
251+
0.16666666666666666,
252+
0.25,
253+
0.25,
254+
0.2,
255+
0.2,
256+
0.2,
257+
0.2,
258+
0.16666666666666666,
259+
0.16666666666666666,
260+
0.16666666666666666,
261+
0.16666666666666666,
262+
0.16666666666666666,
263+
0.16666666666666666,
264+
0.16666666666666666,
265+
0.16666666666666666,
266+
0.16666666666666666,
267+
0.16666666666666666,
268+
0.2,
269+
0.16666666666666666,
270+
0.25,
271+
0.2,
272+
0.16666666666666666,
273+
0.3333333333333333,
274+
0.3333333333333333,
275+
0.25,
276+
0.25,
277+
0.2,
278+
0.2,
279+
0.2,
280+
0.16666666666666666,
281+
0.16666666666666666,
282+
0.16666666666666666,
283+
0.2,
284+
0.2,
285+
0.16666666666666666,
286+
0.16666666666666666,
287+
0.25,
288+
0.2,
289+
0.16666666666666666
290+
]
291+
},
292+
"type": "sankey",
293+
"orientation": "h"
294+
}],
295+
"layout": {
296+
"font": {
297+
"size": 10
298+
},
299+
"title": "Injection in VISpm"
300+
}
301+
}

0 commit comments

Comments
 (0)