@@ -253,19 +253,29 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
253
253
. remove ( ) ;
254
254
}
255
255
256
+ var oldSubplotList = oldFullLayout . _subplots || { } ;
257
+ var newSubplotList = newFullLayout . _subplots || { xaxis : [ ] , yaxis : [ ] } ;
258
+
259
+ // delete any titles we don't need anymore
260
+ // check if axis list has changed, and if so clear old titles
261
+ if ( oldSubplotList . xaxis && oldSubplotList . yaxis ) {
262
+ var oldAxIDs = oldSubplotList . xaxis . concat ( oldSubplotList . yaxis ) ;
263
+ var newAxIDs = newSubplotList . xaxis . concat ( newSubplotList . yaxis ) ;
264
+
265
+ for ( i = 0 ; i < oldAxIDs . length ; i ++ ) {
266
+ if ( newAxIDs . indexOf ( oldAxIDs [ i ] ) === - 1 ) {
267
+ oldFullLayout . _infolayer . selectAll ( '.g-' + oldAxIDs [ i ] + 'title' ) . remove ( ) ;
268
+ }
269
+ }
270
+ }
271
+
272
+ // if we've gotten rid of all cartesian traces, remove all the subplot svg items
256
273
var hadCartesian = ( oldFullLayout . _has && oldFullLayout . _has ( 'cartesian' ) ) ;
257
274
var hasCartesian = ( newFullLayout . _has && newFullLayout . _has ( 'cartesian' ) ) ;
258
275
259
276
if ( hadCartesian && ! hasCartesian ) {
260
- var subplotLayers = oldFullLayout . _cartesianlayer . selectAll ( '.subplot' ) ;
261
- var axIds = axisIds . listIds ( { _fullLayout : oldFullLayout } ) ;
262
-
263
- subplotLayers . call ( purgeSubplotLayers , oldFullLayout ) ;
277
+ purgeSubplotLayers ( oldFullLayout . _cartesianlayer . selectAll ( '.subplot' ) , oldFullLayout ) ;
264
278
oldFullLayout . _defs . selectAll ( '.axesclip' ) . remove ( ) ;
265
-
266
- for ( i = 0 ; i < axIds . length ; i ++ ) {
267
- oldFullLayout . _infolayer . select ( '.' + axIds [ i ] + 'title' ) . remove ( ) ;
268
- }
269
279
}
270
280
} ;
271
281
0 commit comments