@@ -306,6 +306,17 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
306
306
purgeSubplotLayers ( oldFullLayout . _cartesianlayer . selectAll ( '.subplot' ) , oldFullLayout ) ;
307
307
oldFullLayout . _defs . selectAll ( '.axesclip' ) . remove ( ) ;
308
308
}
309
+ // otherwise look for subplots we need to remove
310
+ else if ( oldSubplotList . cartesian ) {
311
+ for ( i = 0 ; i < oldSubplotList . cartesian . length ; i ++ ) {
312
+ var oldSubplotId = oldSubplotList . cartesian [ i ] ;
313
+ if ( newSubplotList . cartesian . indexOf ( oldSubplotId ) === - 1 ) {
314
+ var selector = '.' + oldSubplotId + ',.' + oldSubplotId + '-x,.' + oldSubplotId + '-y' ;
315
+ oldFullLayout . _cartesianlayer . selectAll ( selector ) . remove ( ) ;
316
+ removeSubplotExtras ( oldSubplotId , oldFullLayout ) ;
317
+ }
318
+ }
319
+ }
309
320
} ;
310
321
311
322
exports . drawFramework = function ( gd ) {
@@ -484,11 +495,9 @@ function purgeSubplotLayers(layers, fullLayout) {
484
495
485
496
layers . each ( function ( subplotId ) {
486
497
var plotgroup = d3 . select ( this ) ;
487
- var clipId = 'clip' + fullLayout . _uid + subplotId + 'plot' ;
488
498
489
499
plotgroup . remove ( ) ;
490
- fullLayout . _draggers . selectAll ( 'g.' + subplotId ) . remove ( ) ;
491
- fullLayout . _defs . select ( '#' + clipId ) . remove ( ) ;
500
+ removeSubplotExtras ( subplotId , fullLayout ) ;
492
501
493
502
overlayIdsToRemove [ subplotId ] = true ;
494
503
@@ -515,6 +524,11 @@ function purgeSubplotLayers(layers, fullLayout) {
515
524
}
516
525
}
517
526
527
+ function removeSubplotExtras ( subplotId , fullLayout ) {
528
+ fullLayout . _draggers . selectAll ( 'g.' + subplotId ) . remove ( ) ;
529
+ fullLayout . _defs . select ( '#clip' + fullLayout . _uid + subplotId + 'plot' ) . remove ( ) ;
530
+ }
531
+
518
532
function joinLayer ( parent , nodeType , className , dataVal ) {
519
533
var layer = parent . selectAll ( '.' + className )
520
534
. data ( [ dataVal || 0 ] ) ;
0 commit comments