@@ -251,7 +251,7 @@ Plotly.plot = function(gd, data, layout, config) {
251
251
subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
252
252
modules = gd . _modules ;
253
253
254
- var i , j , cd , trace , uid , subplot , subplotInfo ,
254
+ var i , j , trace , subplot , subplotInfo ,
255
255
cdSubplot , cdError , cdModule , _module ;
256
256
257
257
function getCdSubplot ( calcdata , subplot ) {
@@ -293,17 +293,20 @@ Plotly.plot = function(gd, data, layout, config) {
293
293
// in case of traces that were heatmaps or contour maps
294
294
// previously, remove them and their colorbars explicitly
295
295
for ( i = 0 ; i < calcdata . length ; i ++ ) {
296
- cd = calcdata [ i ] ;
297
- trace = cd [ 0 ] . trace ;
298
- if ( trace . visible !== true || ! trace . _module . colorbar ) {
296
+ trace = calcdata [ i ] [ 0 ] . trace ;
297
+
298
+ var isVisible = ( trace . visible === true ) ,
299
299
uid = trace . uid ;
300
300
301
+ if ( ! isVisible || ! Plots . traceIs ( trace , '2dMap' ) ) {
301
302
fullLayout . _paper . selectAll (
302
303
'.hm' + uid +
303
304
',.contour' + uid +
304
305
',#clip' + uid
305
306
) . remove ( ) ;
307
+ }
306
308
309
+ if ( ! isVisible || ! trace . _module . colorbar ) {
307
310
fullLayout . _infolayer . selectAll ( '.cb' + uid ) . remove ( ) ;
308
311
}
309
312
}
0 commit comments