-
-
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
Feature: Sankey Link Hover Styling #6839
Conversation
src/traces/sankey/plot.js
Outdated
// Figure out whether the user has provided their own sankey-link-hover style. | ||
var styleExists = false; | ||
for(var i = 0; i < document.styleSheets.length; i++) { | ||
var rules = document.styleSheets[i].cssRules; |
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.
Here I get the following error in the console when start using hover:
Uncaught DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules
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.
Hi @archmoj , thanks for having a look at this. I guess this is due to cross-origin resource sharing policy preventing your browser from looking at css sheets from different domains. I didn't encounter it personally, but I've added a try/catch block to allow the code to skip over css sheets that it's not allowed to read. Does it work now on your end?
… update test case to look for css styling
@TortoiseHam thanks for the PR! I think though we should implement it via trace attributes rather than CSS. Most users of this library are coming not directly from JS - primarily they're in Python but there are other clients too - so they don't readily have access to the CSS, and even if you're staying in JS we want the figure (data and layout objects) to be self-contained so it's portable. I'd suggest adding just The default here is kind of tricky - and in fact looking at it in detail I think the hover opacity is handled badly right now if you either provide your own link color (we always use opacity 0.4 on hover, regardless of whether the color you provide has greater or lesser - or the same - opacity) or you don't provide a color but the background is dark (the default opacity is 0.6 in that case, so on hover the link becomes less prominent, not more) I'd suggest the default
|
Hi @alexcjohnson , thanks for taking a look. I agree that link.hovercolor seems like a better long term design. Unfortunately I have almost no understanding of javascript and that design seems like it would be a significantly larger change to the existing codebase. Any chance that you or anyone else who knows what they're doing is now inspired to work on this? If not I can poke at a solution in that direction but it'll likely take quite a while. If you're looking to change the current default behavior, one option would be taking a 180 degree hue rotation of link.color at an opacity of 1.0. Upside would be that it ought to be easily noticeable in most situations. Downside would be that it probably isn't as aesthetically pleasing for small/simple diagrams. If link.color is white or black might have to just set it as grey since I don't think hue rotation would work in that case. |
Alright, I think I've got the alternative method figured out. I'm closing this in favor of: #6864 |
Existing Behavior:
When a user hovers over a link in a Sankey diagram, the diagram changes the style of all of the links with the same title. This is useful for tracking what path a particular thing took while it travelled through the diagram. This style change leaves the color the same, but sets the link opacity to 0.4.
Problem:
The current behavior works well when there are only a small number of links, but when dealing with hundreds or thousands of links it becomes impossible to track where an individual link came from. Users have requested a solution to this several times over the past several years:
Proposed Change:
Allow end users to override the sankey link hover style by providing their own css styling. With this PR users can build apps which include css like the following:
This makes it feasible to track individual instances across complex diagrams even when there are hundreds of links at once.
Translations:
No user-faces changes to translate.
Features, Bug fixes, and others:
Before opening a pull request, developer should:
master
branch of their fork as usingmaster
for a pull request would make it difficult to fetchupstream
changes.upstream/master
into your fork i.e.origin/master
then pullorigin/master
from you localmaster
.git rebase master
their local dev branch off the latestmaster
which should be sync withupstream/master
at this time.git add
thedist/
folder (thedist/
is updated only on version bumps).package-lock.json
file (if any new dependency required).After opening a pull request, developer:
1010_fix.md
or1010_add.md
insidedraftlogs
folder as described in this README, commit it and push.git push -f
) to remote branches associated with opened pull requests. Force pushes make it hard for maintainers to keep track of updates. Therefore, if required, please fetchupstream/master
and "merge" with master instead of "rebase".