-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix shapes and images referencing a missing subplot #1481
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
Conversation
@@ -107,7 +107,7 @@ describe('Layout images', function() { | |||
it('should draw images on the right layers', function() { | |||
|
|||
Plotly.plot(gd, data, { images: [{ | |||
source: 'imageabove', |
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.
These were generating 404
warnings when you run the tests, which seem distracting and unnecessary, so I just put in jsLogo
everywhere.
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.
Nice touch 👌
'use strict'; | ||
function countShapesInLowerLayer(gd) { | ||
return gd._fullLayout.shapes.filter(isShapeInLowerLayer).length; | ||
} |
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.
Moved these helpers to the root level so I could use them in a different describe
block (which wants to set up a different plot in gd
)
// Fall back to _shapeLowerLayer in case the requested subplot doesn't exist. | ||
// This can happen if you reference the shape to an x / y axis combination | ||
// that doesn't have any data on it (and layer is below) | ||
drawShape(gd._fullLayout._shapeLowerLayer); |
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.
Looks good.
I see that annotations don't need a similar fix. @alexcjohnson Can I ask why?
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.
Annotations don't have the concept of layer. They're always on top.
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.
Right. That makes sense 👍
Thanks again for making shapes/images 🚅 proof! 💃 my comment is non-blocking. |
Soooo many edge cases... This one comes up in the workspace trying to move shapes or images between unlinked subplots, but it can also happen on initial draw - for example you put data on
xy
andx2y2
but put a shape onxy2
- not sure why you'd do this but it should be allowed, and certainly shouldn't error as it does now.Meanwhile on the workspace side I'll just move these components to
layer: 'above'
- which may be less confusing there anyway since much of the time the objects would get hidden behind a plot otherwise.@etpinard please review.