@@ -83,7 +83,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
8383
8484 if ( Array . isArray ( inputRef ) && inputRef . length > 0 ) {
8585 // Array case: use coerceRefArray for validation
86- var expectedLen = helpers . countDefiningCoords ( shapeType , path ) ;
86+ var expectedLen = helpers . countDefiningCoords ( shapeType , path , axLetter ) ;
8787 axRef = Axes . coerceRefArray ( shapeIn , shapeOut , gdMock , axLetter , undefined , 'paper' , expectedLen ) ;
8888 shapeOut [ '_' + axLetter + 'refArray' ] = true ;
8989
@@ -102,25 +102,24 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
102102 }
103103
104104 if ( Array . isArray ( axRef ) ) {
105- var dflts = [ 0.25 , 0.75 ] ;
106- var pixelDflts = [ 0 , 10 ] ;
107-
108- // For each coordinate, coerce the position with their respective axis ref
109- [ 0 , 1 ] . forEach ( function ( i ) {
110- var ref = axRef [ i ] ;
111- var refType = Axes . getRefType ( ref ) ;
112- if ( refType === 'range' ) {
113- ax = Axes . getFromId ( gdMock , ref ) ;
114- pos2r = helpers . shapePositionToRange ( ax ) ;
115- r2pos = helpers . rangeToShapePosition ( ax ) ;
116- if ( ax . type === 'category' || ax . type === 'multicategory' ) {
117- coerce ( axLetter + i + 'shift' ) ;
105+ if ( noPath ) {
106+ var dflts = [ 0.25 , 0.75 ] ;
107+ var pixelDflts = [ 0 , 10 ] ;
108+
109+ [ 0 , 1 ] . forEach ( function ( i ) {
110+ var ref = axRef [ i ] ;
111+ var refType = Axes . getRefType ( ref ) ;
112+ if ( refType === 'range' ) {
113+ ax = Axes . getFromId ( gdMock , ref ) ;
114+ pos2r = helpers . shapePositionToRange ( ax ) ;
115+ r2pos = helpers . rangeToShapePosition ( ax ) ;
116+ if ( ax . type === 'category' || ax . type === 'multicategory' ) {
117+ coerce ( axLetter + i + 'shift' ) ;
118+ }
119+ } else {
120+ pos2r = r2pos = Lib . identity ;
118121 }
119- } else {
120- pos2r = r2pos = Lib . identity ;
121- }
122122
123- if ( noPath ) {
124123 var attr = axLetter + i ;
125124 var inValue = shapeIn [ attr ] ;
126125 shapeIn [ attr ] = pos2r ( shapeIn [ attr ] , true ) ;
@@ -133,16 +132,16 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
133132
134133 shapeOut [ attr ] = r2pos ( shapeOut [ attr ] ) ;
135134 shapeIn [ attr ] = inValue ;
136- }
137135
138- if ( i === 0 && sizeMode === 'pixel' ) {
139- var inAnchor = shapeIn [ attrAnchor ] ;
140- shapeIn [ attrAnchor ] = pos2r ( shapeIn [ attrAnchor ] , true ) ;
141- Axes . coercePosition ( shapeOut , gdMock , coerce , ref , attrAnchor , 0.25 ) ;
142- shapeOut [ attrAnchor ] = r2pos ( shapeOut [ attrAnchor ] ) ;
143- shapeIn [ attrAnchor ] = inAnchor ;
144- }
145- } ) ;
136+ if ( i === 0 && sizeMode === 'pixel' ) {
137+ var inAnchor = shapeIn [ attrAnchor ] ;
138+ shapeIn [ attrAnchor ] = pos2r ( shapeIn [ attrAnchor ] , true ) ;
139+ Axes . coercePosition ( shapeOut , gdMock , coerce , ref , attrAnchor , 0.25 ) ;
140+ shapeOut [ attrAnchor ] = r2pos ( shapeOut [ attrAnchor ] ) ;
141+ shapeIn [ attrAnchor ] = inAnchor ;
142+ }
143+ } ) ;
144+ }
146145 } else {
147146 var axRefType = Axes . getRefType ( axRef ) ;
148147
@@ -151,7 +150,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
151150 ax . _shapeIndices . push ( shapeOut . _index ) ;
152151 r2pos = helpers . rangeToShapePosition ( ax ) ;
153152 pos2r = helpers . shapePositionToRange ( ax ) ;
154- if ( ax . type === 'category' || ax . type === 'multicategory' ) {
153+ if ( noPath && ( ax . type === 'category' || ax . type === 'multicategory' ) ) {
155154 coerce ( axLetter + '0shift' ) ;
156155 coerce ( axLetter + '1shift' ) ;
157156 }
0 commit comments