-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Sankey: colorscales per component, linked to concentration #3501
Conversation
Here's a Codepen showcasing the new feature introduced in this PR: https://codepen.io/antoinerg/pen/qgJbOr . Hovering on links will display the new computed statistics. By default in Sankey, when we hover on a link, its opacity is reduced. I think this looks odd in the Codepen above. @alexcjohnson what do you think? |
src/traces/sankey/render.js
Outdated
@@ -10,6 +10,7 @@ | |||
|
|||
var c = require('./constants'); | |||
var d3 = require('d3'); | |||
var sum = require('d3-array').sum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will do the latter and save one line in our package.json
.
I should probably replace all the forEach
while I'm at it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should probably replace all the
forEach
while I'm at it right?
That would be amazing 💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in c228b37
Nice - perhaps we can include the concentration in the label by default, for links that have a concentration colorscale?
That's weird, normally opacity is increased on hover - is that because normally the opacity is low but here its high, and on hover it gets some set value that's more than the default but less than we have here? Anyway it seems like we probably don't want an opacity change at all when the color is displaying quantitative information via a colorscale - especially since scales like you've used, with white at one end, will probably be common, and these scales are equivalent to opacity. But nor do we want to decrease opacity on hover even for non-colorscaled links. Perhaps we just need to find a different way to highlight the hovered links if their opacity is above some threshold and/or they have a colorscale. Perhaps adding, thickening, or increasing the contrast of the link outline? By the same token, we probably want the hover label to be fully opaque when it's describing a colorscaled link, so it will have the same color as the link. |
Done in c228b37
Yes you are right: it used to simply set the opacity of 0.4 which is higher than the default but less than we had here.
In c228b37, I simply removed hover effects for links with a concentration colorscale. @etpinard Do you have any suggestion of what to do to highlight the hovered links? Is there any precedent in
Done in c228b37 |
Do you really "need" to highlight them? their positioning and coloring makes the hover labels pretty unambiguous to me, at least in this scenario. |
@etpinard I was wondering the exact same thing. I'd be curious to have @alexcjohnson's opinion on this one! |
Good call. I'm voting no. |
That's a pretty simple diagram, but in more complicated ones like the energy flows example a highlight can really help to see clearly what nodes the link connects. I'd be OK with omitting highlighting for now when the link is opaque, but we should keep it in the default case and reserve the right to add something like outlining later on. |
@etpinard It seems like @alexcjohnson is OK with not highlighting colorscaled links (at least for now). Nothing precludes us from changing their appearance later on so I'm comfortable with the status quo. I agree that the existing appearance of hovered non-colorscaled links is useful and I confirm that it is still intact. As of right now, I'm not testing in jasmine that the flow statistics are properly computed although the mock effectively 🔒 this down. Let me know if that is sufficient. |
package-lock.json
Outdated
@@ -4142,8 +4142,7 @@ | |||
"ansi-regex": { | |||
"version": "2.1.1", | |||
"bundled": true, | |||
"dev": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoinerg which version of npm
are you using?
Your PR doesn't change any of our dependencies, so it shouldn't change the package-lock
. Can you revert these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now updated to npm 6.8.0
, ran npm i
and the package-lock.json
has now zero changes! Sorry about that... I need a safety check on my dev machine.
Done f628b54
src/traces/sankey/render.js
Outdated
@@ -616,6 +686,7 @@ module.exports = function(svg, calcData, layout, callbacks) { | |||
.attr('d', linkPath()) | |||
.call(attachPointerEvents, sankey, callbacks.linkEvents); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡ no need to commit this newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f628b54
Nicely done @antoinerg ! I made two minor comments. This thing is set to be part of 1.45.0! |
Nicely done. 💃 |
An attempt at closing #3318