Skip to content

Add bottom-up and right-left orientations for Sankey diagrams#7870

Open
wf-r wants to merge 4 commits into
plotly:v4.0from
wf-r:Add_bottom-up_and_right-left_orientation_for_Sankey
Open

Add bottom-up and right-left orientations for Sankey diagrams#7870
wf-r wants to merge 4 commits into
plotly:v4.0from
wf-r:Add_bottom-up_and_right-left_orientation_for_Sankey

Conversation

@wf-r

@wf-r wf-r commented Jun 26, 2026

Copy link
Copy Markdown

What

See #7865

Adds two new flow directions to Sankey traces and gives the existing horizontal/vertical modes explicit, direction-named aliases, fully backward compatible.

orientation now accepts:

  • h — horizontal, default (unchanged)
  • left-right — sources left, flow rightward (synonym of h)
  • right-left — sources right, flow leftward (new)
  • v — vertical (unchanged)
  • top-down — sources top, flow downward (synonym of v)
  • bottom-up — sources bottom, flow upward (new)

Why

So far, h is always left→right and v is always top-down. Right-to-left and build-up (bottom-up) flows are common conventions with no equivalent today. This closes both gaps additively, without changing any existing rendering.

Backward compatibility

Purely additive. Existing figures using h/v render identically; the default is unchanged.

@camdecoster camdecoster self-assigned this Jul 20, 2026
@camdecoster

camdecoster commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

I'm going to change the target branch from master to our upcoming major version branch, v4.0. We've made some changes in the Sankey code and I'd like to add your changes against that. If you have time, it would be great to get this in for that version. I'll leave you a review tomorrow.

@camdecoster
camdecoster changed the base branch from master to v4.0 July 20, 2026 23:19
@wf-r
wf-r force-pushed the Add_bottom-up_and_right-left_orientation_for_Sankey branch from 904f306 to 5ea67d9 Compare July 21, 2026 04:54
wfr added 4 commits July 21, 2026 07:01
Adjust node label alignment for vertical case (labels below still need work)
Finalize node label alignment for vertical cases
@wf-r

wf-r commented Jul 21, 2026

Copy link
Copy Markdown
Author

Thanks for having a look (I have rebased on v4.0 for the moment)

@camdecoster 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.

This is a great addition and pretty simple to add. Could you please separate out the direction config into a second attribute? I added a suggestion. This will require changes to your code elsewhere, but I don't think it will be too much work. Let me know what you think

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.

Instead of adding additional orientation values, let's add another attribute that covers the direction of the chart. This follows precedent with some existing attributes (polar.angularaxis.direction, pie.direction, etc.) and keeps two config options distinct.

        direction: {
            valType: 'enumerated',
            values: ['forward', 'reverse'],
            dflt: 'forward',
            description: [
                'Sets the direction of the flow along the `orientation` axis.',
                'With `forward` (the default), sources are on the left (horizontal) or top (vertical).',
                'With `reverse`, sources are on the right (horizontal) or bottom (vertical).',
            ].join(' ')
        }

orientation: {
valType: 'enumerated',
values: ['v', 'h'],
values: ['v', 'h', 'left-right', 'right-left', 'top-down', 'bottom-up'],

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.

Suggested change
values: ['v', 'h', 'left-right', 'right-left', 'top-down', 'bottom-up'],
values: ['v', 'h'],

Comment on lines +36 to +43
description: [
'Sets the orientation of the Sankey diagram.',
'`left-right` (synonym of the legacy value `h`) places sources on the left',
'with the flow running rightward; `right-left` places sources on the right',
'with the flow running leftward; `top-down` (synonym of the legacy value `v`)',
'places sources at the top with the flow running downward; `bottom-up` places',
'sources at the bottom with the flow running upward.'
].join(' ')

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.

Suggested change
description: [
'Sets the orientation of the Sankey diagram.',
'`left-right` (synonym of the legacy value `h`) places sources on the left',
'with the flow running rightward; `right-left` places sources on the right',
'with the flow running leftward; `top-down` (synonym of the legacy value `v`)',
'places sources at the top with the flow running downward; `bottom-up` places',
'sources at the bottom with the flow running upward.'
].join(' ')
description: [
'Sets the orientation of the Sankey diagram.',
'With `h` (the default), the flow runs horizontally.',
'With `v`, the flow runs vertically.',
].join(' ')

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.

2 participants