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

implement hoverinfo 'none' and 'skip' in sankey #3096

Merged
merged 18 commits into from
Oct 23, 2018

Conversation

antoinerg
Copy link
Contributor

Closes #2782

@antoinerg antoinerg requested review from alexcjohnson and etpinard and removed request for alexcjohnson October 11, 2018 17:43
@antoinerg antoinerg added bug something broken status: reviewable labels Oct 11, 2018
@antoinerg
Copy link
Contributor Author

Note that right now with hoverinfo: 'skip' and hoverinfo: 'none', hovering on a node still highlights its links:
2018-10-11_13-59-54

I figured that if a user doesn't want any highlighting, he/she can use hovermode: false. Is that reasonable?

@alexcjohnson
Copy link
Collaborator

alternate proposal, before we create some working hoverinfo behavior in sankey: #3097 (comment)

@antoinerg
Copy link
Contributor Author

Ok so commit 880973a implements the changes discussed in issue #3097 ie. adding attributes (node|link).hover(info|label).

I removed all the existing hoverinfo flags except for 'all', 'none' and 'skip' since they're the only ones implemented right now.

src/plot_api/edit_types.js Outdated Show resolved Hide resolved
@antoinerg antoinerg added this to the Dash milestone Oct 15, 2018
@antoinerg antoinerg removed this from the Dash milestone Oct 15, 2018
@antoinerg antoinerg self-assigned this Oct 15, 2018
@antoinerg
Copy link
Contributor Author

Thank you for your help @alexcjohnson :)

I think that commit 644c4e3 makes attribute coercion more efficient as you suggested doing!

@alexcjohnson
Copy link
Collaborator

@antoinerg this looks great now! #3096 (comment) would be lovely but nonblocking - otherwise 💃

@antoinerg
Copy link
Contributor Author

Ok awesome! I'll just wait for the test to complete and merge it :)

@antoinerg antoinerg merged commit 7ae6fd6 into master Oct 23, 2018
@antoinerg antoinerg deleted the 2782-hoverinfo-none-skip branch October 23, 2018 17:32
'rgba(255, 255, 255, 0.6)' :
'rgba(0, 0, 0, 0.2)';

coerceLink('color', linkOut.value.map(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the next time you're working in these files @antoinerg, here's Lib.repeat:

plotly.js/src/lib/index.js

Lines 167 to 181 in 7ae6fd6

/**
* create an array of length 'cnt' filled with 'v' at all indices
*
* @param {any} v
* @param {number} cnt
* @return {array}
*/
lib.repeat = function(v, cnt) {
var out = new Array(cnt);
for(var i = 0; i < cnt; i++) {
out[i] = v;
}
return out;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know about the existence Lib.repeat! I just mindlessly reused the .map iterator that was already there! I should know better, for loops are much faster than map 🐎 !

description: 'The links of the Sankey plot.'
}
}, 'calc', 'nested');
// hide unsupported top-level properties from plot-schema
attrs.hoverinfo = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh so, trace-level hoverinfo is no longer available for sankey traces? Luckily it never worked so this isn't breaking change.

Does this PR close #3097 ?

Copy link
Contributor Author

@antoinerg antoinerg Oct 24, 2018

Choose a reason for hiding this comment

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

It wouldn't close it.

Issue #3097 is about supporting hoverinfo options other than the basic skip and none. Although the current doc say that we support many:

Any combination of "label", "text", "value", "percent", "name" joined with a "+" OR "all" or "none" or "skip"

none actually worked except all. This PR is solely about adding support for skip and none. Those two are arguably more urgent to support (ie. whether to hide the hoverlabels and whether to emit hover events at the same time).

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know. Thanks!

description: 'The links of the Sankey plot.'
}
}, 'calc', 'nested');
// hide unsupported top-level properties from plot-schema
attrs.hoverinfo = undefined;
attrs.hoverlabel = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

But wait, trace hoverlabel was working before this. Hmm, I'd call this a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

... I think we should either make node/link hoverlabel inherit from trace hoverlabel or add some cleanData logic.

Copy link
Contributor Author

@antoinerg antoinerg Oct 24, 2018

Choose a reason for hiding this comment

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

@etpinard It's great that you noticed that change and I agree this should be handled better!

FYI, having a hover(label|info) in each node and link was the fruit of discussions with @alexcjohnson. In the future, we could add a hovertemplate on each to provide control over their content. That's one way of dealing with point 2 of this comment #3126 (comment) which we can discuss about later on :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah indeed - good catch @etpinard - I'd go for:

make node/link hoverlabel inherit from trace hoverlabel

That would be more friendly for the (probably most common) case that users want node and link hover labels styled the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

... and maybe we should have a trace hoverinfo that acts similarly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hoverinfo is trickier - could be nice to inherit skip/none, but when we get around to supporting a real flaglist, links and nodes will have completely different options.

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. trace.hoverinfo: 'none' would be equivalent to node.hoverinfo: 'none' + link.hoverinfo: 'none'.

Not all the flags to be implemented in #3097 should be available from the trace hoverinfo, but I think setting trace-wide 'none' and 'skip' could be useful.

@antoinerg antoinerg mentioned this pull request Oct 24, 2018
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants