Add bottom-up and right-left orientations for Sankey diagrams#7870
Add bottom-up and right-left orientations for Sankey diagrams#7870wf-r wants to merge 4 commits into
Conversation
|
I'm going to change the target branch from |
904f306 to
5ea67d9
Compare
Rebase to v4.
Adjust node label alignment for vertical case (labels below still need work)
Finalize node label alignment for vertical cases
|
Thanks for having a look (I have rebased on |
camdecoster
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'], |
There was a problem hiding this comment.
| values: ['v', 'h', 'left-right', 'right-left', 'top-down', 'bottom-up'], | |
| values: ['v', 'h'], |
| 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(' ') |
There was a problem hiding this comment.
| 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(' ') |
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.
orientationnow accepts:h— horizontal, default (unchanged)left-right— sources left, flow rightward (synonym ofh)right-left— sources right, flow leftward (new)v— vertical (unchanged)top-down— sources top, flow downward (synonym ofv)bottom-up— sources bottom, flow upward (new)Why
So far,
his always left→right andvis 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/vrender identically; the default is unchanged.