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) {
1921
1921
objList = layout [ objType ] || [ ] ,
1922
1922
obji = objList [ objNum ] || { } ;
1923
1923
1924
+ // new API, remove annotation / shape with `null`
1925
+ if ( vi === null ) aobj [ ai ] = 'remove' ;
1926
+
1924
1927
// if p.parts is just an annotation number, and val is either
1925
1928
// 'add' or an entire annotation to add, the undo is 'remove'
1926
1929
// 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() {
69
69
expect ( countAnnotations ( ) ) . toEqual ( len + 1 ) ;
70
70
71
71
return Plotly . relayout ( gd , 'annotations[' + 0 + ']' , 'remove' ) ;
72
- } ) . then ( function ( ) {
72
+ } )
73
+ . then ( function ( ) {
73
74
expect ( countAnnotations ( ) ) . toEqual ( len ) ;
74
75
76
+ return Plotly . relayout ( gd , 'annotations[' + 0 + ']' , null ) ;
77
+ } )
78
+ . then ( function ( ) {
79
+ expect ( countAnnotations ( ) ) . toEqual ( len - 1 ) ;
80
+
75
81
return Plotly . relayout ( gd , { annotations : [ ] } ) ;
76
- } ) . then ( function ( ) {
82
+ } )
83
+ . then ( function ( ) {
77
84
expect ( countAnnotations ( ) ) . toEqual ( 0 ) ;
78
85
79
86
done ( ) ;
Original file line number Diff line number Diff line change @@ -183,12 +183,21 @@ describe('Test shapes:', function() {
183
183
expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( pathCount + 1 ) ;
184
184
expect ( getLastShape ( gd ) ) . toEqual ( shape ) ;
185
185
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 ( ) {
189
191
expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( pathCount ) ;
190
192
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 ) ;
192
201
} ) ;
193
202
194
203
it ( 'should be able to remove all shapes' , function ( done ) {
You can’t perform that action at this time.
0 commit comments