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

Sankey: colorscales per component, linked to concentration #3501

Merged
merged 8 commits into from
Feb 18, 2019

Conversation

antoinerg
Copy link
Contributor

@antoinerg antoinerg commented Jan 31, 2019

An attempt at closing #3318

@antoinerg antoinerg changed the base branch from sankey-circular to master February 14, 2019 22:04
@antoinerg
Copy link
Contributor Author

antoinerg commented Feb 14, 2019

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?

@@ -10,6 +10,7 @@

var c = require('./constants');
var d3 = require('d3');
var sum = require('d3-array').sum;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha this here only works between d3-sankey already depends on d3-array.

image

We should add d3-array to the (plotly.js) dependencies OR use plain loops and save one line in our package.json.

Copy link
Contributor Author

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?

Copy link
Contributor

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 💪

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in c228b37

@alexcjohnson
Copy link
Collaborator

Hovering on links will display the new computed statistics.

Nice - perhaps we can include the concentration in the label by default, for links that have a concentration colorscale?

By default in Sankey, when we hover on a link, its opacity is reduced. I think this looks odd in the Codepen above.

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.

@antoinerg
Copy link
Contributor Author

antoinerg commented Feb 15, 2019

Nice - perhaps we can include the concentration in the label by default, for links that have a concentration colorscale?

Done in c228b37

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?

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.

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?

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 plotly.js for such a situation? Displaying a link outline seems like a good idea but I wanted to double-check with you first.

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

@etpinard
Copy link
Contributor

etpinard commented Feb 15, 2019

@etpinard Do you have any suggestion of what to do to highlight the hovered links? Is there any precedent in plotly.js for such a situation?

Do you really "need" to highlight them?

peek 2019-02-15 14-58

their positioning and coloring makes the hover labels pretty unambiguous to me, at least in this scenario.

@antoinerg
Copy link
Contributor Author

Do you really "need" to highlight them?

@etpinard I was wondering the exact same thing. I'd be curious to have @alexcjohnson's opinion on this one!

@etpinard
Copy link
Contributor

I'd be curious to have @alexcjohnson's opinion on this one!

Good call. I'm voting no.

@alexcjohnson
Copy link
Collaborator

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.

@antoinerg
Copy link
Contributor Author

@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.

@etpinard etpinard added this to the v1.45.0 milestone Feb 18, 2019
@@ -4142,8 +4142,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
Copy link
Contributor

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?

Copy link
Contributor Author

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

@@ -616,6 +686,7 @@ module.exports = function(svg, calcData, layout, callbacks) {
.attr('d', linkPath())
.call(attachPointerEvents, sankey, callbacks.linkEvents);


Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f628b54

@etpinard
Copy link
Contributor

Nicely done @antoinerg !

I made two minor comments. This thing is set to be part of 1.45.0!

@etpinard
Copy link
Contributor

Nicely done. 💃

@antoinerg antoinerg merged commit 12097a2 into master Feb 18, 2019
@antoinerg antoinerg deleted the pr-sankey-link-concentration branch February 18, 2019 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants