FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(sankey): transpose node.x/node.y scaling for vertical orientation by waterWang · Pull Request #7957 · plotly/plotly.js · GitHub

fix(sankey): transpose node.x/node.y scaling for vertical orientation - #7957

Open
waterWang wants to merge 2 commits into
plotly:mainfrom
waterWang:fix/sankey-node-xy-orientation
Open

fix(sankey): transpose node.x/node.y scaling for vertical orientation#7957
waterWang wants to merge 2 commits into
plotly:mainfrom
waterWang:fix/sankey-node-xy-orientation

Conversation

Copy link
Copy Markdown

Problem

For vertical Sankey traces (orientation: 'v'), user-supplied node.x / node.y are normalized against the wrong extent. The d3-sankey layout space always carries the flow along its x axis, but for vertical orientation that space is transposed onto the screen. When the plotting area is non-square, nodes are placed outside the bounding box and the values written back after a drag can exceed the documented [0, 1] range.

Root cause

In src/traces/sankey/render.js, sankeyModel():

sankey.size(horizontal ? [width, height] : [height, width]);   // (1) correctly transposed
...
var pos = [trace.node.x[i] * width, trace.node.y[i] * height]; // (2) NOT transposed

The user coordinates at (2) are scaled by the un-transposed extents, while the d3-sankey layout at (1) uses the transposed extents. The same asymmetry exists in the write-back path persistFinalNodePositions().

Fix

  1. In sankeyModel(): scale node.x by the flow-axis extent and node.y by the cross-axis extent, matching the sankey.size() transposition
  2. In persistFinalNodePositions(): divide by the same transposed extents on write-back

Closes #7947

camdecoster changed the title fix(sankey): transpose node.x/node.y scaling for vertical orientation (Fixes #7947) fix(sankey): transpose node.x/node.y scaling for vertical orientation Aug 18, 2026

camdecoster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the fix! The solution looks right to me, but you'll need to add the missing paren to get CI to complete. Could you also please add a test for this situation?

Comment thread src/traces/sankey/render.js Outdated
Co-authored-by: Cameron DeCoster <cameron.decoster@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: sankey: node.x / node.y are normalized against the wrong extent when orientation: 'v'

2 participants


Back | FazBrowse Home | New Git URL