File tree 4 files changed +30
-2
lines changed
4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ function drawOne(gd, index) {
69
69
fullLayout . _infolayer . selectAll ( '.annotation[data-index="' + index + '"]' ) . remove ( ) ;
70
70
71
71
// remember a few things about what was already there,
72
- var optionsIn = layout . annotations [ index ] ,
72
+ var optionsIn = ( layout . annotations || [ ] ) [ index ] ,
73
73
options = fullLayout . annotations [ index ] ;
74
74
75
75
// this annotation is gone - quit now after deleting it
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ function drawOne(gd, index) {
63
63
. selectAll ( '.shapelayer [data-index="' + index + '"]' )
64
64
. remove ( ) ;
65
65
66
- var optionsIn = gd . layout . shapes [ index ] ,
66
+ var optionsIn = ( gd . layout . shapes || [ ] ) [ index ] ,
67
67
options = gd . _fullLayout . shapes [ index ] ;
68
68
69
69
// this shape is gone - quit now after deleting it
Original file line number Diff line number Diff line change @@ -200,6 +200,17 @@ describe('annotations relayout', function() {
200
200
201
201
return Plotly . relayout ( gd , { annotations : null } ) ;
202
202
} )
203
+ . then ( function ( ) {
204
+ expect ( countAnnotations ( ) ) . toEqual ( 0 ) ;
205
+ expect ( Loggers . warn ) . not . toHaveBeenCalled ( ) ;
206
+
207
+ return Plotly . relayout ( gd , { 'annotations[0]' : ann } ) ;
208
+ } )
209
+ . then ( function ( ) {
210
+ expect ( countAnnotations ( ) ) . toEqual ( 1 ) ;
211
+
212
+ return Plotly . relayout ( gd , { 'annotations[0]' : null } ) ;
213
+ } )
203
214
. then ( function ( ) {
204
215
expect ( countAnnotations ( ) ) . toEqual ( 0 ) ;
205
216
expect ( Loggers . warn ) . not . toHaveBeenCalled ( ) ;
Original file line number Diff line number Diff line change @@ -320,6 +320,23 @@ describe('Test shapes:', function() {
320
320
expect ( countShapePathsInLowerLayer ( ) ) . toEqual ( 0 ) ;
321
321
expect ( countShapePathsInSubplots ( ) ) . toEqual ( 0 ) ;
322
322
} )
323
+ . then ( function ( ) {
324
+ return Plotly . relayout ( gd , { 'shapes[0]' : getRandomShape ( ) } ) ;
325
+ } )
326
+ . then ( function ( ) {
327
+ expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( 1 ) ;
328
+ expect ( countShapePathsInLowerLayer ( ) ) . toEqual ( 0 ) ;
329
+ expect ( countShapePathsInSubplots ( ) ) . toEqual ( 0 ) ;
330
+ expect ( gd . layout . shapes . length ) . toBe ( 1 ) ;
331
+
332
+ return Plotly . relayout ( gd , { 'shapes[0]' : null } ) ;
333
+ } )
334
+ . then ( function ( ) {
335
+ expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( 0 ) ;
336
+ expect ( countShapePathsInLowerLayer ( ) ) . toEqual ( 0 ) ;
337
+ expect ( countShapePathsInSubplots ( ) ) . toEqual ( 0 ) ;
338
+ expect ( gd . layout . shapes ) . toBeUndefined ( ) ;
339
+ } )
323
340
. catch ( failTest )
324
341
. then ( done ) ;
325
342
} ) ;
You can’t perform that action at this time.
0 commit comments