File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -1921,6 +1921,9 @@ function _relayout(gd, aobj) {
19211921 objList = layout [ objType ] || [ ] ,
19221922 obji = objList [ objNum ] || { } ;
19231923
1924+ // new API, remove annotation / shape with `null`
1925+ if ( vi === null ) aobj [ ai ] = 'remove' ;
1926+
19241927 // if p.parts is just an annotation number, and val is either
19251928 // 'add' or an entire annotation to add, the undo is 'remove'
19261929 // if val is 'remove' then undo is the whole annotation object
Original file line number Diff line number Diff line change @@ -69,11 +69,18 @@ describe('annotations relayout', function() {
6969 expect ( countAnnotations ( ) ) . toEqual ( len + 1 ) ;
7070
7171 return Plotly . relayout ( gd , 'annotations[' + 0 + ']' , 'remove' ) ;
72- } ) . then ( function ( ) {
72+ } )
73+ . then ( function ( ) {
7374 expect ( countAnnotations ( ) ) . toEqual ( len ) ;
7475
76+ return Plotly . relayout ( gd , 'annotations[' + 0 + ']' , null ) ;
77+ } )
78+ . then ( function ( ) {
79+ expect ( countAnnotations ( ) ) . toEqual ( len - 1 ) ;
80+
7581 return Plotly . relayout ( gd , { annotations : [ ] } ) ;
76- } ) . then ( function ( ) {
82+ } )
83+ . then ( function ( ) {
7784 expect ( countAnnotations ( ) ) . toEqual ( 0 ) ;
7885
7986 done ( ) ;
Original file line number Diff line number Diff line change @@ -183,12 +183,21 @@ describe('Test shapes:', function() {
183183 expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( pathCount + 1 ) ;
184184 expect ( getLastShape ( gd ) ) . toEqual ( shape ) ;
185185 expect ( countShapes ( gd ) ) . toEqual ( index + 1 ) ;
186- } ) . then ( function ( ) {
187- Plotly . relayout ( gd , 'shapes[' + index + ']' , 'remove' ) ;
188- } ) . then ( function ( ) {
186+ } )
187+ . then ( function ( ) {
188+ return Plotly . relayout ( gd , 'shapes[' + index + ']' , 'remove' ) ;
189+ } )
190+ . then ( function ( ) {
189191 expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( pathCount ) ;
190192 expect ( countShapes ( gd ) ) . toEqual ( index ) ;
191- } ) . then ( done ) ;
193+
194+ return Plotly . relayout ( gd , 'shapes[' + 1 + ']' , null ) ;
195+ } )
196+ . then ( function ( ) {
197+ expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( pathCount - 1 ) ;
198+ expect ( countShapes ( gd ) ) . toEqual ( index - 1 ) ;
199+ } )
200+ . then ( done ) ;
192201 } ) ;
193202
194203 it ( 'should be able to remove all shapes' , function ( done ) {
You can’t perform that action at this time.
0 commit comments