Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
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 privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
69c11fe880973ad247b8b1919b72e942bc51813d6c9e4f1a0706e7ae7c24d2953d7ce387c30fe7a32036b436003fe7ab49644c4e3ccaef04dc8ba12ea73c64File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,20 +9,13 @@ | ||
| 'use strict'; | ||
| var fontAttrs = require('../../plots/font_attributes'); | ||
| var plotAttrs = require('../../plots/attributes'); | ||
| var colorAttrs = require('../../components/color/attributes'); | ||
| var fxAttrs = require('../../components/fx/attributes'); | ||
| var domainAttrs = require('../../plots/domain').attributes; | ||
| var extendFlat = require('../../lib/extend').extendFlat; | ||
| var overrideAll = require('../../plot_api/edit_types').overrideAll; | ||
| module.exports = overrideAll({ | ||
| hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { | ||
| flags: ['label', 'text', 'value', 'percent', 'name'], | ||
| }), | ||
| hoverlabel: fxAttrs.hoverlabel, // needs editType override | ||
| var attrs = module.exports = overrideAll({ | ||
| domain: domainAttrs({name: 'sankey', trace: true}), | ||
| orientation: { | ||
| @@ -127,6 +120,18 @@ module.exports = overrideAll({ | ||
| role: 'style', | ||
| description: 'Sets the thickness (in px) of the `nodes`.' | ||
| }, | ||
| hoverinfo: { | ||
| valType: 'enumerated', | ||
| values: ['all', 'none', 'skip'], | ||
| dflt: 'all', | ||
| role: 'info', | ||
| description: [ | ||
| 'Determines which trace information appear when hovering nodes.', | ||
| 'If `none` or `skip` are set, no information is displayed upon hovering.', | ||
| 'But, if `none` is set, click and hover events are still fired.' | ||
| ].join(' ') | ||
| }, | ||
| hoverlabel: fxAttrs.hoverlabel, // needs editType override, | ||
| description: 'The nodes of the Sankey plot.' | ||
| }, | ||
| @@ -185,6 +190,21 @@ module.exports = overrideAll({ | ||
| role: 'info', | ||
| description: 'A numeric value representing the flow volume value.' | ||
| }, | ||
| hoverinfo: { | ||
| valType: 'enumerated', | ||
| values: ['all', 'none', 'skip'], | ||
| dflt: 'all', | ||
| role: 'info', | ||
| description: [ | ||
| 'Determines which trace information appear when hovering links.', | ||
| 'If `none` or `skip` are set, no information is displayed upon hovering.', | ||
| 'But, if `none` is set, click and hover events are still fired.' | ||
| ].join(' ') | ||
| }, | ||
| hoverlabel: fxAttrs.hoverlabel, // needs editType override, | ||
| description: 'The links of the Sankey plot.' | ||
| } | ||
| }, 'calc', 'nested'); | ||
| // hide unsupported top-level properties from plot-schema | ||
| attrs.hoverinfo = undefined; | ||
| attrs.hoverlabel = undefined; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But wait, trace Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... I think we should either make node/link
| ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -13,37 +13,55 @@ var attributes = require('./attributes'); | ||||||||||||||||||||||||||||||||
| var Color = require('../../components/color'); | ||||||||||||||||||||||||||||||||
| var tinycolor = require('tinycolor2'); | ||||||||||||||||||||||||||||||||
| var handleDomainDefaults = require('../../plots/domain').defaults; | ||||||||||||||||||||||||||||||||
| var handleHoverLabelDefaults = require('../../components/fx/hoverlabel_defaults'); | ||||||||||||||||||||||||||||||||
| var Template = require('../../plot_api/plot_template'); | ||||||||||||||||||||||||||||||||
| module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { | ||||||||||||||||||||||||||||||||
| function coerce(attr, dflt) { | ||||||||||||||||||||||||||||||||
| return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| coerce('node.label'); | ||||||||||||||||||||||||||||||||
| coerce('node.pad'); | ||||||||||||||||||||||||||||||||
| coerce('node.thickness'); | ||||||||||||||||||||||||||||||||
| coerce('node.line.color'); | ||||||||||||||||||||||||||||||||
| coerce('node.line.width'); | ||||||||||||||||||||||||||||||||
| // node attributes | ||||||||||||||||||||||||||||||||
| var nodeIn = traceIn.node, nodeOut = Template.newContainer(traceOut, 'node'); | ||||||||||||||||||||||||||||||||
| function coerceNode(attr, dflt) { | ||||||||||||||||||||||||||||||||
| return Lib.coerce(nodeIn, nodeOut, attributes.node, attr, dflt); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| coerceNode('label'); | ||||||||||||||||||||||||||||||||
| coerceNode('pad'); | ||||||||||||||||||||||||||||||||
| coerceNode('thickness'); | ||||||||||||||||||||||||||||||||
| coerceNode('line.color'); | ||||||||||||||||||||||||||||||||
| coerceNode('line.width'); | ||||||||||||||||||||||||||||||||
| coerceNode('hoverinfo'); | ||||||||||||||||||||||||||||||||
| handleHoverLabelDefaults(nodeIn, nodeOut, coerceNode, layout.hoverlabel); | ||||||||||||||||||||||||||||||||
| var colors = layout.colorway; | ||||||||||||||||||||||||||||||||
| var defaultNodePalette = function(i) {return colors[i % colors.length];}; | ||||||||||||||||||||||||||||||||
| coerce('node.color', traceOut.node.label.map(function(d, i) { | ||||||||||||||||||||||||||||||||
| coerceNode('color', nodeOut.label.map(function(d, i) { | ||||||||||||||||||||||||||||||||
| return Color.addOpacity(defaultNodePalette(i), 0.8); | ||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||
| coerce('link.label'); | ||||||||||||||||||||||||||||||||
| coerce('link.source'); | ||||||||||||||||||||||||||||||||
| coerce('link.target'); | ||||||||||||||||||||||||||||||||
| coerce('link.value'); | ||||||||||||||||||||||||||||||||
| coerce('link.line.color'); | ||||||||||||||||||||||||||||||||
| coerce('link.line.width'); | ||||||||||||||||||||||||||||||||
| coerce('link.color', traceOut.link.value.map(function() { | ||||||||||||||||||||||||||||||||
| return tinycolor(layout.paper_bgcolor).getLuminance() < 0.333 ? | ||||||||||||||||||||||||||||||||
| 'rgba(255, 255, 255, 0.6)' : | ||||||||||||||||||||||||||||||||
| 'rgba(0, 0, 0, 0.2)'; | ||||||||||||||||||||||||||||||||
| // link attributes | ||||||||||||||||||||||||||||||||
| var linkIn = traceIn.link, linkOut = Template.newContainer(traceOut, 'link'); | ||||||||||||||||||||||||||||||||
| function coerceLink(attr, dflt) { | ||||||||||||||||||||||||||||||||
| return Lib.coerce(linkIn, linkOut, attributes.link, attr, dflt); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| coerceLink('label'); | ||||||||||||||||||||||||||||||||
| coerceLink('source'); | ||||||||||||||||||||||||||||||||
| coerceLink('target'); | ||||||||||||||||||||||||||||||||
| coerceLink('value'); | ||||||||||||||||||||||||||||||||
| coerceLink('line.color'); | ||||||||||||||||||||||||||||||||
| coerceLink('line.width'); | ||||||||||||||||||||||||||||||||
| coerceLink('hoverinfo'); | ||||||||||||||||||||||||||||||||
| handleHoverLabelDefaults(linkIn, linkOut, coerceLink, layout.hoverlabel); | ||||||||||||||||||||||||||||||||
| var defaultLinkColor = tinycolor(layout.paper_bgcolor).getLuminance() < 0.333 ? | ||||||||||||||||||||||||||||||||
| 'rgba(255, 255, 255, 0.6)' : | ||||||||||||||||||||||||||||||||
| 'rgba(0, 0, 0, 0.2)'; | ||||||||||||||||||||||||||||||||
| coerceLink('color', linkOut.value.map(function() { | ||||||||||||||||||||||||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Lines 167 to 181 in 7ae6fd6
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know about the existence | ||||||||||||||||||||||||||||||||
| return defaultLinkColor; | ||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||
| handleDomainDefaults(traceOut, layout, coerce); | ||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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
hoverinfois no longer available for sankey traces? Luckily it never worked so this isn't breaking change.Does this PR close #3097 ?
Uh oh!
There was an error while loading. Please reload this page.
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
hoverinfooptions other than the basicskipandnone. Although the current doc say that we support many:none actually worked except
all. This PR is solely about adding support forskipandnone. 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!