Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional Sankey diagram orientations #110

Closed
wants to merge 31 commits into from
Closed

Add support for additional Sankey diagram orientations #110

wants to merge 31 commits into from

Conversation

jayaddison
Copy link

Adds orientation-specific sankey generator constructors: sankeyTop (top-to-bottom), sankeyRight (left-to-right), sankeyBottom (bottom-to-top) and sankeyLeft (right-to-left).

A new function linkShape is exposed on the sankey generator which allows the caller to retrieve the 'correct' D3 link shape matching the orientation of the constructor.

This was developed against a working copy of https://github.com/LonnyGomes/sankey-diagram-poc, with one styling modification applied for vertical mode: updating text element positioning logic to improve readability.

Bottom-to-top
image

Top-to-bottom
image

Right-to-left
image

Left-to-right
image

Resolves #55.

Revives #71.

jayaddison and others added 30 commits January 8, 2020 14:22
- Export per-orientation constructors (sankeyTop, ...)
- Rename alignment options (sankeyLeft -> sankeyAlignLeft, ...)
- Rename orient* functions and variables to transform*
- Move transformNodes function within Sankey class
- Remove orientation getter/setter
- Remove export of orientations
@curran
Copy link

curran commented Jun 22, 2022

LGTM!

@jayaddison
Copy link
Author

Thanks for the review @curran!

@jtfell
Copy link

jtfell commented Aug 3, 2022

I've successfully used this fork to create a vertical sankey - keen to see it merged so I can depend on the official d3-sankey package!

@jayaddison
Copy link
Author

Thanks @jtfell - there seems to be some consensus building that maintaining a fork with these changes would be more successful than getting them included in-library here.

I don't feel like I'd be an effective maintainer for a separate package (neither JavaScript nor diagramming are expertises of mine), and also I'd like to reduce the set of pull requests that I have open, so I'm going to close this.

As an alternative, it's possible to use SVG transformations (rotate(...), in particular) to present a horizontally-generated sankey as a vertical sankey.

@jayaddison jayaddison closed this Dec 29, 2022
@jayaddison jayaddison deleted the vertical-orientation branch December 29, 2022 17:51
@EricDuminil
Copy link

This looks great. Would it be possible to change the orientation independently for each node?

One source from the left, one sink to the right, and one sink to the bottom? https://datavizcatalogue.com/methods/images/anatomy/sankey_diagram.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple orientations?
4 participants