Skip to content

sankey - fix issue with large padding #3143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"3d-view": "^2.0.0",
"@plotly/d3-sankey": "^0.5.0",
"@plotly/d3-sankey": "^0.5.1",
"alpha-shape": "^1.0.0",
"array-range": "^1.0.1",
"canvas-fit": "^1.5.0",
Expand Down
4 changes: 4 additions & 0 deletions src/traces/sankey/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ function sankeyModel(layout, d, traceIndex) {
.links(links)
.layout(c.sankeyIterations);

if(sankey.nodePadding() < nodePad) {
Lib.warn('node.pad was reduced to ', sankey.nodePadding(), ' to fit within the figure.');
}

var node, sankeyNodes = sankey.nodes();
for(var n = 0; n < sankeyNodes.length; n++) {
node = sankeyNodes[n];
Expand Down
Binary file added test/image/baselines/sankey_large_padding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
301 changes: 301 additions & 0 deletions test/image/mocks/sankey_large_padding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
{
"data": [{
"node": {
"color": [
"#000000",
"#BFDAE3",
"#FF7080",
"#FF707F",
"#E64438",
"#B0F0FF",
"#F1483B",
"#98D6F8",
"#F2483A",
"#FF4C3C",
"#8599CC",
"#FF5446",
"#FF64FF",
"#97D6F9",
"#FE8EFE",
"#FF6F80",
"#B1BFDF",
"#B3C0DE",
"#FC8FFF",
"#FF5346",
"#90CAEC",
"#90CBED",
"#FF4B3E",
"#FE909C",
"#F2473B",
"#B0FFB8",
"#90CAED",
"#FF4A3D",
"#80C0E1",
"#F24839",
"#FF5C4E",
"#95A7D3",
"#A2B0D8",
"#96A6D2",
"#CAC7CB",
"#FD4B3C",
"#A2B1D7",
"#70FF70",
"#FF9B87",
"#FE8E9D",
"#FE5445",
"#F2483B",
"#CAC7CB",
"#CAC7CB",
"#CAC7CB",
"#CAC7CB",
"#CAC7CB",
"#FF9B87",
"#FF9B87",
"#FF9B87",
"#FF5C4E",
"#FC8FFF",
"#80C0E1",
"#70FF70",
"#70FF70"
],
"line": {
"color": "black",
"width": 0.5
},
"label": [
"root",
"grey",
"BS",
"IB",
"HY",
"CH",
"LZ",
"CNU",
"LHA",
"MEZ",
"PAL",
"PVR",
"MB",
"STR",
"MBmot",
"TH",
"PALc",
"BST",
"PAG",
"MPO",
"LSX",
"LS",
"AHN",
"DORpm",
"LPO",
"CTX",
"LSr",
"VMH",
"sAMY",
"TU",
"PVZ",
"PALm",
"PALv",
"MSC",
"fiber tracts",
"PH",
"SI",
"CTXpl",
"HB",
"MTN",
"DMH",
"RCH",
"fiber tracts#1",
"fiber tracts#2",
"fiber tracts#3",
"fiber tracts#4",
"fiber tracts#5",
"HB#3",
"HB#4",
"HB#5",
"PVZ#5",
"PAG#5",
"sAMY#5",
"CTXpl#4",
"CTXpl#5"
],
"pad": 20,
"thickness": 50
},
"link": {
"source": [
0,
0,
34,
42,
43,
44,
45,
1,
1,
2,
2,
2,
38,
47,
48,
3,
3,
4,
4,
4,
4,
6,
6,
6,
6,
9,
9,
9,
11,
11,
30,
15,
23,
12,
14,
18,
5,
5,
7,
7,
10,
10,
10,
16,
31,
32,
13,
13,
20,
28,
25,
37,
53
],
"target": [
34,
1,
42,
43,
44,
45,
46,
2,
5,
38,
3,
12,
47,
48,
49,
4,
15,
6,
9,
11,
30,
8,
24,
41,
29,
22,
35,
27,
40,
19,
50,
23,
39,
14,
18,
51,
7,
25,
10,
13,
16,
31,
32,
17,
33,
36,
20,
28,
21,
52,
37,
53,
54
],
"value": [
1,
1,
0.5,
0.3333333333333333,
0.25,
0.2,
0.16666666666666666,
0.5,
0.5,
0.3333333333333333,
0.3333333333333333,
0.3333333333333333,
0.25,
0.2,
0.16666666666666666,
0.25,
0.25,
0.2,
0.2,
0.2,
0.2,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.2,
0.16666666666666666,
0.25,
0.2,
0.16666666666666666,
0.3333333333333333,
0.3333333333333333,
0.25,
0.25,
0.2,
0.2,
0.2,
0.16666666666666666,
0.16666666666666666,
0.16666666666666666,
0.2,
0.2,
0.16666666666666666,
0.16666666666666666,
0.25,
0.2,
0.16666666666666666
]
},
"type": "sankey",
"orientation": "h"
}],
"layout": {
"font": {
"size": 10
},
"title": "Injection in VISpm"
}
}
Loading