Skip to content

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

Merged
merged 3 commits into from
Mar 16, 2017
Merged

Conversation

alexcjohnson
Copy link
Collaborator

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 and x2y2 but put a shape on xy2 - 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.

@@ -107,7 +107,7 @@ describe('Layout images', function() {
it('should draw images on the right layers', function() {

Plotly.plot(gd, data, { images: [{
source: 'imageabove',
Copy link
Collaborator Author

@alexcjohnson alexcjohnson Mar 15, 2017

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.

Copy link
Contributor

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;
}
Copy link
Collaborator Author

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)

@etpinard etpinard added status: reviewable bug something broken labels Mar 16, 2017
// 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);
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. That makes sense 👍

@etpinard
Copy link
Contributor

Thanks again for making shapes/images 🚅 proof!

💃 my comment is non-blocking.

@etpinard etpinard added this to the v1.25.0 milestone Mar 16, 2017
@alexcjohnson alexcjohnson merged commit 388287b into master Mar 16, 2017
@alexcjohnson alexcjohnson deleted the below-no-plot branch March 16, 2017 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants