File tree Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Expand file tree Collapse file tree 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) {
6969 fullLayout . _infolayer . selectAll ( '.annotation[data-index="' + index + '"]' ) . remove ( ) ;
7070
7171 // remember a few things about what was already there,
72- var optionsIn = layout . annotations [ index ] ,
72+ var optionsIn = ( layout . annotations || [ ] ) [ index ] ,
7373 options = fullLayout . annotations [ index ] ;
7474
7575 // 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) {
6363 . selectAll ( '.shapelayer [data-index="' + index + '"]' )
6464 . remove ( ) ;
6565
66- var optionsIn = gd . layout . shapes [ index ] ,
66+ var optionsIn = ( gd . layout . shapes || [ ] ) [ index ] ,
6767 options = gd . _fullLayout . shapes [ index ] ;
6868
6969 // 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() {
200200
201201 return Plotly . relayout ( gd , { annotations : null } ) ;
202202 } )
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+ } )
203214 . then ( function ( ) {
204215 expect ( countAnnotations ( ) ) . toEqual ( 0 ) ;
205216 expect ( Loggers . warn ) . not . toHaveBeenCalled ( ) ;
Original file line number Diff line number Diff line change @@ -320,6 +320,23 @@ describe('Test shapes:', function() {
320320 expect ( countShapePathsInLowerLayer ( ) ) . toEqual ( 0 ) ;
321321 expect ( countShapePathsInSubplots ( ) ) . toEqual ( 0 ) ;
322322 } )
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+ } )
323340 . catch ( failTest )
324341 . then ( done ) ;
325342 } ) ;
You can’t perform that action at this time.
0 commit comments