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

Different Link Width at Source and Target #91

Open
chanansh opened this issue May 13, 2021 · 3 comments
Open

Different Link Width at Source and Target #91

chanansh opened this issue May 13, 2021 · 3 comments

Comments

@chanansh
Copy link

I would like the link width to represent Pr(target | source) at the source node (aka probability for the transition from a given source node to a specific target node) and by contrast, represent Pr(source | target) at the target node (aka probability to transition to a given target node from specific source node). Can this be done?
The motivation is well explained here: https://anneya.ca/articles/2017-10/normalized-sankey-diagrams.html

@Fil
Copy link
Member

Fil commented May 13, 2021

The links generated by this module are made of a central path, connecting the center of the source to the center of the target. Its movement is given by the bump-x curve, and it is painted with a wide stroke. This makes it impossible (to my knowledge) to give it a variable stroke-width.

By contrast, Anneya's method is creating an area (with a fill), where the top and bottom edges are two curves, each determined by a (possibly different) bump-x curve. Maybe you could emulate that approach?

Unfortunately, using two parallel curves like this results in "squeezed" shapes (the ribbons appear smaller in the middle due to shearing), so it can't be the default method. This might be fixed by computing path offsets with path.getTangentAtLength and so on, but it seems like a lot of work.

Capture d’écran 2021-05-13 à 10 47 36

Refs:

@Fil
Copy link
Member

Fil commented May 13, 2021

I've added a solution with @rveciana’s svg-path-properties

Capture d’écran 2021-05-13 à 11 36 34

@james-mckenzie-cko
Copy link

I've just done this using the approach outlined here:

https://observablehq.com/@enjalot/weird-sankey-links

The only caveat is that I've found an issue here (#92). It may or may not affect you depending on how you use it (we were scaling values either side of a node and so needed to recalculate the link height using the adjacent link positions)

hope this helps

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

No branches or pull requests

3 participants