Skip to content
Open
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
1 change: 1 addition & 0 deletions draftlogs/8158_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Position a sankey node at `node.x` or `node.y` of `0` instead of placing it automatically [[#8158](https://github.com/plotly/plotly.js/pull/8158)]
2 changes: 1 addition & 1 deletion src/traces/sankey/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function sankeyModel(layout, d, traceIndex) {
if(forcedNode.partOfGroup) continue;

var p = forcedNode.pointNumber;
if (trace.node.x[p] && trace.node.y[p]) {
if (trace.node.x[p] != null && trace.node.y[p] != null) {
var pos = [trace.node.x[p] * width, trace.node.y[p] * height];
forcedNode.x0 = pos[0] - nodeThickness / 2;
forcedNode.x1 = pos[0] + nodeThickness / 2;
Expand Down
14 changes: 14 additions & 0 deletions test/jasmine/tests/sankey_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,20 @@ describe('sankey tests', function () {
.then(done, done.fail);
});

it('applies a position of 0 like any other position', (done) => {
const fig = makeFixedMock();
// A falsy test used to treat 0 as a missing position
fig.data[0].node.x[0] = 0;
fig.data[0].node.y[0] = 0;
fig.data[0].node.y[4] = 0;

Plotly.newPlot(gd, fig)
.then(() => {
assertPositions(fig.data[0], getCentersByIndex(), [0, 2, 3, 4], 'zero');
})
.then(done, done.fail);
});

it('keeps the positions of the other nodes after a drag when a node is unlinked', (done) => {
const fig = makeFixedMock();
fig.data[0].arrangement = 'freeform';
Expand Down