Skip to content

color links with gradients in Sankey plots #3261

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

Open
OliBravo opened this issue Nov 19, 2018 · 8 comments
Open

color links with gradients in Sankey plots #3261

OliBravo opened this issue Nov 19, 2018 · 8 comments
Labels
feature something new P3 backlog

Comments

@OliBravo
Copy link

OliBravo commented Nov 19, 2018

Hi,
I was looking for adding gradient to sankey links. I would like to reproduce a diagram like this:
image

I'm highly interested in such an option for R, because I'm a developer of Shiny apps. At the moment, it would be sufficient for me to know a workaround solution, for example custom JS code I could use to add gradients after a sankey diagram is already rendered.

@OliBravo OliBravo changed the title [sankey] color links with gradients [sankey] color links with gradients type: feature Nov 19, 2018
@OliBravo OliBravo changed the title [sankey] color links with gradients type: feature [sankey] color links with gradients Nov 19, 2018
@antoinerg
Copy link
Contributor

antoinerg commented Jan 23, 2019

This feature should be rolled in at the same time as we close #3318 .

screenshot_2019-01-23_12-04-53

@alexcjohnson
Copy link
Collaborator

It looks like in your example @OliBravo the gradient specifically fades between the two node colors (plus some opacity). That's a nice effect - not as the default, but perhaps we can have that as an explicit option somewhere, rather than forcing you to explicitly specify both end colors for each link - although explicit colors everywhere should also be supported.

@alexcjohnson alexcjohnson added the feature something new label Jan 23, 2019
@antoinerg antoinerg self-assigned this Jan 24, 2019
@aesharpe
Copy link

Hi! Has this feature been added yet? I'd also like to include a gradient feature in my sankey

@mattsiler
Copy link

I'm also interested in this feature.

@antoinerg antoinerg removed their assignment Jan 21, 2020
@Jedevold
Copy link

Jedevold commented May 6, 2021

Was this ever implemented?

@migupry
Copy link

migupry commented Jul 5, 2022

I've found multiple examples of color links with gradients implementation using d3Sankey:
https://stackoverflow.com/a/21208382
https://bl.ocks.org/micahstubbs/3c0cb0c0de021e0d9653032784c035e9
https://observablehq.com/@d3/sankey

Could someone give me some general insights on how to implement such functionality on a working plotly.js sankey diagram? Or is it easier to simply go directly to d3Sankey and avoid the hassle?

@alexcjohnson
Copy link
Collaborator

@migupry note that plotly.js uses a fork of d3-sankey: https://github.com/plotly/d3-sankey - mainly this was done to switch how we draw links: d3-sankey draws a path from source to target, using stroke-width and stroke-color to set its size and color. Our fork draws the full link outline and uses fill-color. This allows us to avoid overlaps when several links travel in parallel, and lets us outline the links. But as a result we would need to re-implement gradient link colors. There would be two steps to getting this into plotly.js: (1) add the capability to https://github.com/plotly/d3-sankey - probably following the general pattern of how this was done in the original, but applying it to fill instead of stroke; if the only gradient allowed by the original is 'source-target', that seems like the main thing people are interested in but if we can do something more general and allow each link to specify its own gradient that would be even better. (2) expose this capability inside plotly.js

@gregorywaynepower
Copy link

gregorywaynepower commented Jul 6, 2023

@alexcjohnson I appreciate the explanation, I'd also like to take up the mantle on trying to fix this issue since this is something that I've had an issue with as well.

@antoinerg If there's any way you could look way back in time and tell me some of the roadblocks you ran into?

@gvwilson gvwilson self-assigned this Jun 11, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson changed the title [sankey] color links with gradients color links with gradients in Sankey plots Aug 8, 2024
@gvwilson gvwilson added the P3 backlog label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

9 participants