Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function drawOne(gd, index) {
fullLayout._infolayer.selectAll('.annotation[data-index="' + index + '"]').remove();

// remember a few things about what was already there,
var optionsIn = layout.annotations[index],
var optionsIn = (layout.annotations || [])[index],
Copy link
Contributor

@etpinard etpinard Mar 8, 2017

Choose a reason for hiding this comment

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

Ha. I'm looking forward to making annotations and shapes updates d3-idiomatic. These user / full container double standard headaches will be gone!

options = fullLayout.annotations[index];

// this annotation is gone - quit now after deleting it
Expand Down
2 changes: 1 addition & 1 deletion src/components/shapes/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function drawOne(gd, index) {
.selectAll('.shapelayer [data-index="' + index + '"]')
.remove();

var optionsIn = gd.layout.shapes[index],
var optionsIn = (gd.layout.shapes || [])[index],
options = gd._fullLayout.shapes[index];

// this shape is gone - quit now after deleting it
Expand Down
11 changes: 11 additions & 0 deletions test/jasmine/tests/annotations_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ describe('annotations relayout', function() {

return Plotly.relayout(gd, {annotations: null});
})
.then(function() {
expect(countAnnotations()).toEqual(0);
expect(Loggers.warn).not.toHaveBeenCalled();

return Plotly.relayout(gd, {'annotations[0]': ann});
})
.then(function() {
expect(countAnnotations()).toEqual(1);

return Plotly.relayout(gd, {'annotations[0]': null});
})
.then(function() {
expect(countAnnotations()).toEqual(0);
expect(Loggers.warn).not.toHaveBeenCalled();
Expand Down
17 changes: 17 additions & 0 deletions test/jasmine/tests/shapes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,23 @@ describe('Test shapes:', function() {
expect(countShapePathsInLowerLayer()).toEqual(0);
expect(countShapePathsInSubplots()).toEqual(0);
})
.then(function() {
return Plotly.relayout(gd, {'shapes[0]': getRandomShape()});
})
.then(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests! Annotations and shapes are getting nicely 🔒 ed down.

expect(countShapePathsInUpperLayer()).toEqual(1);
expect(countShapePathsInLowerLayer()).toEqual(0);
expect(countShapePathsInSubplots()).toEqual(0);
expect(gd.layout.shapes.length).toBe(1);

return Plotly.relayout(gd, {'shapes[0]': null});
})
.then(function() {
expect(countShapePathsInUpperLayer()).toEqual(0);
expect(countShapePathsInLowerLayer()).toEqual(0);
expect(countShapePathsInSubplots()).toEqual(0);
expect(gd.layout.shapes).toBeUndefined();
})
.catch(failTest)
.then(done);
});
Expand Down