-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
implement hoverinfo 'none' and 'skip' in sankey #3096
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 < 8000 a class="Link--inTextBlock" href="https://docs.github.com/privacy" target="_blank">privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
alternate proposal, before we create some working |
Thank you for your help @alexcjohnson :) I think that commit 644c4e3 makes attribute coercion more efficient as you suggested doing! |
@antoinerg this looks great now! #3096 (comment) would be lovely but nonblocking - otherwise 💃 |
Ok awesome! I'll just wait for the test to complete and merge it :) |
'rgba(255, 255, 255, 0.6)' : | ||
'rgba(0, 0, 0, 0.2)'; | ||
|
||
coerceLink('color', linkOut.value.map(function() { |
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.
For the next time you're working in these files @antoinerg, here's Lib.repeat
:
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; | |
}; |
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.
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; |
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.
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 ?
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.
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).
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.
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; |
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.
But wait, trace hoverlabel
was working before this. Hmm, I'd call this a breaking change.
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 we should either make node/link hoverlabel
inherit from trace hoverlabel
or add some cleanData
logic.
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.
@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 :)
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.
Ah indeed - good catch @etpinard - I'd go for:
make node/link
hoverlabel
inherit from tracehoverlabel
That would be more friendly for the (probably most common) case that users want node and link hover labels styled the same.
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.
... and maybe we should have a trace hoverinfo
that acts similarly.
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.
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.
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.
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.
Closes #2782