-
-
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
unified hover: honor layout.hoverlabel #4687
Conversation
With the changes made in this PR, a bunch of mocks are now broken in unified hover modes because they contain this in their layout: "legend": {
"font": {
"family": "",
"size": 0,
"color": ""
}, This is all over our mocks and I wonder why that is the case? EDIT: Commit 4ef8205 now takes care of the problem. |
Ah yeah, that's in a lot of really old mocks... my recollection is these came from the predecessor to chart studio, which at one point had a bug that it was saving effectively |
I don't particularly like the changes I made in I must say however that inheriting the |
We explicitly force the legend bgcolor to transparent in some mocks? |
We do. For example: plotly.js/test/image/mocks/11.json Line 240 in 60425d2
|
src/components/fx/hover.js
Outdated
bgcolor: fullLayout.paper_bgcolor, | ||
title: {text: t0, font: fullLayout.hoverlabel.font}, | ||
font: fullLayout.hoverlabel.font, | ||
bgcolor: fullLayout.hoverlabel.bgcolor || fullLayout.paper_bgcolor, |
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.
why do we need the paper_bgcolor
fallback here?
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.
If hoverlabel.bgcolor
is undefined, we need a fallback. We can either specify it here or specify paper_bgcolor
in mockLayoutOut
in order for legendSupplyDefaults
to use it as a fallback. Let me know what you prefer!
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.
Do we have a test for this?
Should we update the descriptions?
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.
Yes, the background color is well tested to make sure that the color is set by layout attribute hoverlabel.bgcolor
> legend.bgcolor
> paper_bgcolor
.
We should definitely update the description.
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.
Just closing the loop based on our off-GH conversation: layout.hoverlabel.bgcolor
is empty by default, so that each hoverlabel knows to take its color from its trace. It only has a value if you explicitly set one, that will become the common hover label color for all traces.
Re: transparent legend bgcolor - there are two interesting cases: legend over the margin, and legend over the plot. Both of these will happen from time to time, but I'd say we should fall back on |
Yes, looking at it again I think you're right. Also because the default for |
Ok, I went with |
src/core.js
Outdated
require('./components/legend'), | ||
require('./components/fx'), |
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.
Heh that was easy 😅 A little fragile though. Can we add a comment at least, saying that fx needs to come after legend for supplyDefaults
to work correctly? I wonder if there are any other couplings like this?
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.
Done in 0d406a0
It's a bit fragile although the hoverlable_test
would fail if the order was changed!
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.
Fantastic - just one request for a comment then this is ready to go! 💃
Fixes #4683
TODO
bordercolor
(531fe79)hoverlabel.bgcolor
is opaque by default (cc8ca1c)