Skip to content

fix: Apply sankey node.x / node.y of 0 instead of positioning the node automatically - #8158

Open
adimalkar wants to merge 2 commits into
plotly:mainfrom
adimalkar:fix/sankey-zero-node-position
Open

adimalkar wants to merge 2 commits into
plotly:mainfrom
adimalkar:fix/sankey-zero-node-position

Conversation

@adimalkar

Copy link
Copy Markdown

Description

Closes #8150.

Apply a sankey node position of 0 in node.x or node.y. Before this change, the layout placed such a node automatically.

Changes

  • In src/traces/sankey/render.js, the force-node-position loop tested trace.node.x[p] && trace.node.y[p]. The value 0 is falsy, so the loop skipped the node. The loop now tests != null, so only a missing value skips the node.
  • Add a jasmine test in test/jasmine/tests/sankey_test.js that places nodes at x = 0 and y = 0.
  • Add a draftlog.

Testing

  • npm run test-jasmine -- sankey --nowatch: 92 of 92 specs pass.
  • npm run lint, npm run typecheck and npm run test-syntax pass.
  • I rendered the snippet from the issue before and after the change. After the change, the center of node a is at the top-left corner.
  • The mock sankey_x_y_with_arrows sets y: [0, 0, 0], so its baseline changes: its nodes now sit at the top of the plot. No other sankey mock has a 0 coordinate. The new baseline will come from the baselines-default-diff CI artifact.

This change was developed with AI assistance.

…cally

The force-node-position loop tested node.x and node.y for truthiness, so a
coordinate of 0 counted as missing and the node was positioned by the
layout instead. Test for null and undefined only.
Copilot AI balanced review requested due to automatic review settings November 1, 2026 03:18

Copilot AI left a comment

Copy link
Copy Markdown