@@ -215,7 +215,7 @@ function insertShape(gd, index, newShape) {
215
215
}
216
216
217
217
function updateShape ( gd , index , opt , value ) {
218
- var i ;
218
+ var i , n ;
219
219
220
220
// remove the existing shape if there is one
221
221
getShapeLayer ( gd , index )
@@ -298,25 +298,33 @@ function updateShape(gd, index, opt, value) {
298
298
'fill-rule' : 'evenodd' ,
299
299
d : shapePath ( gd , options )
300
300
} ,
301
- clipAxes = ( options . xref + options . yref ) . replace ( / p a p e r / g , '' ) ;
301
+ clipAxes ;
302
302
303
303
var lineColor = options . line . width ? options . line . color : 'rgba(0,0,0,0)' ;
304
304
305
305
if ( options . layer !== 'below' ) {
306
+ clipAxes = ( options . xref + options . yref ) . replace ( / p a p e r / g, '' ) ;
306
307
drawShape ( gd . _fullLayout . _shapeUpperLayer ) ;
307
308
}
308
309
else if ( options . xref === 'paper' && options . yref === 'paper' ) {
310
+ clipAxes = '' ;
309
311
drawShape ( gd . _fullLayout . _shapeLowerLayer ) ;
310
- } else {
311
- forEachSubplot ( gd , function ( plotinfo ) {
312
+ }
313
+ else {
314
+ var plots = gd . _fullLayout . _plots || { } ,
315
+ subplots = Object . keys ( plots ) ,
316
+ plotinfo ;
317
+
318
+ for ( i = 0 , n = subplots . length ; i < n ; i ++ ) {
319
+ plotinfo = plots [ subplots [ i ] ] ;
320
+ clipAxes = subplots [ i ] ;
321
+
312
322
if ( isShapeInSubplot ( gd , options , plotinfo . id ) ) {
313
323
drawShape ( plotinfo . shapelayer ) ;
314
324
}
315
- } ) ;
325
+ }
316
326
}
317
327
318
- return ;
319
-
320
328
function drawShape ( shapeLayer ) {
321
329
var path = shapeLayer . append ( 'path' )
322
330
. attr ( attrs )
@@ -354,15 +362,6 @@ function isShapeInSubplot(gd, shape, subplot) {
354
362
return shape . layer === 'below' && ( xa === shape . xref || ya === shape . yref ) ;
355
363
}
356
364
357
- function forEachSubplot ( gd , fn ) {
358
- var plots = gd . _fullLayout . _plots || { } ,
359
- subplots = Object . getOwnPropertyNames ( plots ) ;
360
-
361
- for ( var i = 0 , n = subplots . length ; i < n ; i ++ ) {
362
- fn ( plots [ subplots [ i ] ] ) ;
363
- }
364
- }
365
-
366
365
function decodeDate ( convertToPx ) {
367
366
return function ( v ) { return convertToPx ( v . replace ( '_' , ' ' ) ) ; } ;
368
367
}
0 commit comments