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 3 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
23 changes: 11 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": "git://github.com/plotly/d3-sankey.git#6f19390be0da4a81abf6f7f6cfdf5fc8dc73e583",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the PR associated with the changes: plotly/d3-sankey#3

"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
21 changes: 21 additions & 0 deletions test/jasmine/tests/sankey_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,27 @@ describe('sankey tests', function() {
.then(done);
});
});

it('emits a warning if node.pad is too large', function(done) {
var gd = createGraphDiv();
var mockCopy = Lib.extendDeep({}, mock);

var warnings = [];
spyOn(Lib, 'warn').and.callFake(function(msg) {
warnings.push(msg);
});
Plotly.plot(gd, mockCopy).then(function() {
expect(warnings.length).toEqual(0);

return Plotly.restyle(gd, 'node.pad', 50);
})
.then(function() {
expect(warnings.length).toEqual(1);
})
.catch(failTest)
.finally(destroyGraphDiv)
.then(done);
});
});

function assertLabel(content, style) {
Expand Down