@@ -129,23 +129,20 @@ exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
129129 // traces are removed
130130 if ( ! Array . isArray ( traces ) ) {
131131 traces = [ ] ;
132-
133- for ( i = 0 ; i < calcdata . length ; i ++ ) {
134- traces . push ( i ) ;
135- }
132+ for ( i = 0 ; i < calcdata . length ; i ++ ) traces . push ( i ) ;
136133 }
137134
138135 for ( i = 0 ; i < subplots . length ; i ++ ) {
139- var subplot = subplots [ i ] ,
140- subplotInfo = fullLayout . _plots [ subplot ] ;
136+ var subplot = subplots [ i ] ;
137+ var subplotInfo = fullLayout . _plots [ subplot ] ;
141138
142139 // Get all calcdata for this subplot:
143140 var cdSubplot = [ ] ;
144141 var pcd ;
145142
146143 for ( var j = 0 ; j < calcdata . length ; j ++ ) {
147- var cd = calcdata [ j ] ,
148- trace = cd [ 0 ] . trace ;
144+ var cd = calcdata [ j ] ;
145+ var trace = cd [ 0 ] . trace ;
149146
150147 // Skip trace if whitelist provided and it's not whitelisted:
151148 // if (Array.isArray(traces) && traces.indexOf(i) === -1) continue;
@@ -285,12 +282,11 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
285282 // delete any titles we don't need anymore
286283 // check if axis list has changed, and if so clear old titles
287284 if ( oldSubplotList . xaxis && oldSubplotList . yaxis ) {
288- var oldAxIDs = oldSubplotList . xaxis . concat ( oldSubplotList . yaxis ) ;
289- var newAxIDs = newSubplotList . xaxis . concat ( newSubplotList . yaxis ) ;
290-
285+ var oldAxIDs = axisIds . listIds ( { _fullLayout : oldFullLayout } ) ;
291286 for ( i = 0 ; i < oldAxIDs . length ; i ++ ) {
292- if ( newAxIDs . indexOf ( oldAxIDs [ i ] ) === - 1 ) {
293- oldFullLayout . _infolayer . selectAll ( '.g-' + oldAxIDs [ i ] + 'title' ) . remove ( ) ;
287+ var oldAxId = oldAxIDs [ i ] ;
288+ if ( ! newFullLayout [ axisIds . id2name ( oldAxId ) ] ) {
289+ oldFullLayout . _infolayer . selectAll ( '.g-' + oldAxId + 'title' ) . remove ( ) ;
294290 }
295291 }
296292 }
@@ -516,11 +512,8 @@ function purgeSubplotLayers(layers, fullLayout) {
516512
517513 // must remove overlaid subplot trace layers 'manually'
518514
519- var subplots = fullLayout . _plots ;
520- var subplotIds = Object . keys ( subplots ) ;
521-
522- for ( var i = 0 ; i < subplotIds . length ; i ++ ) {
523- var subplotInfo = subplots [ subplotIds [ i ] ] ;
515+ for ( var k in fullLayout . _plots ) {
516+ var subplotInfo = fullLayout . _plots [ k ] ;
524517 var overlays = subplotInfo . overlays || [ ] ;
525518
526519 for ( var j = 0 ; j < overlays . length ; j ++ ) {
0 commit comments