Skip to content

[BUG]: sankey: node.x / node.y of 0 is ignored #8150

Open

Description

@camdecoster

Description

Node coordinates of 0 for node.x or node.yare ignored and the node gets positioned automatically.

Screenshots

With 0 coords:

Image

With close to 0 coords:

Image

Steps to reproduce

  • Open Plotly devtools and paste the following into browser devtools:
Plotly.newPlot('g', [{
  type: 'sankey',
  arrangement: 'fixed',
  node: {label: ['a', 'b', 'c'], x: [0, 0.5, 0.8], y: [0, 0, 0.7]},
  link: {source: [0, 1], target: [1, 2], value: [1, 1]}
}], {margin: {l: 0, r: 0, t: 0, b: 0}});
  • Note that the center of a is not in the top left corner of the plot

Notes

  • This issue stems from the fact that the "Force node position" loop in src/traces/sankey/render.js uses a truthy test (if(trace.node.x[p] && trace.node.y[p])), and 0 is falsy
  • The fix is to change the test for missing values to != null
  • The mock sankey_x_y_with_arrows.json sets y: [0, 0, 0], so the fix changes its baseline
  • Discovered while working on Respect explicit node x/y positions in fixed-arrangement Sankey #7826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions