@@ -215,7 +215,7 @@ function insertShape(gd, index, newShape) {
215215}
216216
217217function updateShape ( gd , index , opt , value ) {
218- var i ;
218+ var i , n ;
219219
220220 // remove the existing shape if there is one
221221 getShapeLayer ( gd , index )
@@ -298,25 +298,33 @@ function updateShape(gd, index, opt, value) {
298298 'fill-rule' : 'evenodd' ,
299299 d : shapePath ( gd , options )
300300 } ,
301- clipAxes = ( options . xref + options . yref ) . replace ( / p a p e r / g , '' ) ;
301+ clipAxes ;
302302
303303 var lineColor = options . line . width ? options . line . color : 'rgba(0,0,0,0)' ;
304304
305305 if ( options . layer !== 'below' ) {
306+ clipAxes = ( options . xref + options . yref ) . replace ( / p a p e r / g, '' ) ;
306307 drawShape ( gd . _fullLayout . _shapeUpperLayer ) ;
307308 }
308309 else if ( options . xref === 'paper' && options . yref === 'paper' ) {
310+ clipAxes = '' ;
309311 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+
312322 if ( isShapeInSubplot ( gd , options , plotinfo . id ) ) {
313323 drawShape ( plotinfo . shapelayer ) ;
314324 }
315- } ) ;
325+ }
316326 }
317327
318- return ;
319-
320328 function drawShape ( shapeLayer ) {
321329 var path = shapeLayer . append ( 'path' )
322330 . attr ( attrs )
@@ -354,15 +362,6 @@ function isShapeInSubplot(gd, shape, subplot) {
354362 return shape . layer === 'below' && ( xa === shape . xref || ya === shape . yref ) ;
355363}
356364
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-
366365function decodeDate ( convertToPx ) {
367366 return function ( v ) { return convertToPx ( v . replace ( '_' , ' ' ) ) ; } ;
368367}
0 commit comments