File tree 3 files changed +18
-4
lines changed
3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,12 @@ function linearToData(ax) { return ax.type === 'category' ? ax.l2c : ax.l2d; }
94
94
95
95
shapes . drawAll = function ( gd ) {
96
96
var fullLayout = gd . _fullLayout ;
97
+
98
+ // Remove previous shapes before drawing new in shapes in fullLayout.shapes
99
+ fullLayout . _shapeUpperLayer . selectAll ( 'path' ) . remove ( ) ;
100
+ fullLayout . _shapeLowerLayer . selectAll ( 'path' ) . remove ( ) ;
101
+ fullLayout . _subplotShapeLayer . selectAll ( 'path' ) . remove ( ) ;
102
+
97
103
for ( var i = 0 ; i < fullLayout . shapes . length ; i ++ ) {
98
104
shapes . draw ( gd , i ) ;
99
105
}
Original file line number Diff line number Diff line change @@ -2630,6 +2630,10 @@ function makePlotFramework(gd) {
2630
2630
// single ternary layer for the whole plot
2631
2631
fullLayout . _ternarylayer = fullLayout . _paper . append ( 'g' ) . classed ( 'ternarylayer' , true ) ;
2632
2632
2633
+ // shape layers in subplots
2634
+ fullLayout . _subplotShapeLayer = fullLayout . _paper
2635
+ . selectAll ( '.shapelayer-subplot' ) ;
2636
+
2633
2637
// upper shape layer
2634
2638
// (only for shapes to be drawn above the whole plot, including subplots)
2635
2639
fullLayout . _shapeUpperLayer = fullLayout . _paper . append ( 'g' )
@@ -2815,10 +2819,6 @@ function makeCartesianPlotFramwork(gd, subplots) {
2815
2819
. style ( 'fill' , 'none' )
2816
2820
. classed ( 'crisp' , true ) ;
2817
2821
} ) ;
2818
-
2819
- // shape layers in subplots
2820
- fullLayout . _subplotShapeLayer = fullLayout . _paper
2821
- . selectAll ( '.shapelayer-subplot' ) ;
2822
2822
}
2823
2823
2824
2824
// layoutStyles: styling for plot layout elements
Original file line number Diff line number Diff line change @@ -187,6 +187,14 @@ describe('Test shapes:', function() {
187
187
} ) . then ( done ) ;
188
188
} ) ;
189
189
190
+ it ( 'should be able to remove all shapes' , function ( done ) {
191
+ Plotly . relayout ( gd , { shapes : [ ] } ) . then ( function ( ) {
192
+ expect ( countShapePathsInUpperLayer ( ) ) . toEqual ( 0 ) ;
193
+ expect ( countShapePathsInLowerLayer ( ) ) . toEqual ( 0 ) ;
194
+ expect ( countShapePathsInSubplots ( ) ) . toEqual ( 0 ) ;
195
+ } ) . then ( done ) ;
196
+ } ) ;
197
+
190
198
it ( 'should be able to update a shape layer' , function ( done ) {
191
199
var index = countShapes ( gd ) ,
192
200
astr = 'shapes[' + index + ']' ,
You can’t perform that action at this time.
0 commit comments