@@ -68,6 +68,9 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
6868 var ySizeMode = coerce ( 'ysizemode' ) ;
6969
7070 // positioning
71+ var dflts = [ 0.25 , 0.75 ] ;
72+ var pixelDflts = [ 0 , 10 ] ;
73+
7174 [ 'x' , 'y' ] . forEach ( axLetter => {
7275 var attrAnchor = axLetter + 'anchor' ;
7376 var sizeMode = axLetter === 'x' ? xSizeMode : ySizeMode ;
@@ -86,8 +89,13 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
8689 var expectedLen = helpers . countDefiningCoords ( shapeType , path , axLetter ) ;
8790 axRef = Axes . coerceRefArray ( shapeIn , shapeOut , gdMock , axLetter , undefined , 'paper' , expectedLen ) ;
8891 shapeOut [ '_' + axLetter + 'refArray' ] = true ;
92+ } else {
93+ // String/undefined case: use coerceRef
94+ axRef = Axes . coerceRef ( shapeIn , shapeOut , gdMock , axLetter , undefined , 'paper' ) ;
95+ }
8996
90- // Need to register the shape with all referenced axes for redrawing purposes
97+ if ( Array . isArray ( axRef ) ) {
98+ // Register the shape with all referenced axes for redrawing purposes
9199 axRef . forEach ( function ( ref ) {
92100 if ( Axes . getRefType ( ref ) === 'range' ) {
93101 ax = Axes . getFromId ( gdMock , ref ) ;
@@ -96,16 +104,8 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
96104 }
97105 }
98106 } ) ;
99- } else {
100- // String/undefined case: use coerceRef
101- axRef = Axes . coerceRef ( shapeIn , shapeOut , gdMock , axLetter , undefined , 'paper' ) ;
102- }
103107
104- if ( Array . isArray ( axRef ) ) {
105108 if ( noPath ) {
106- var dflts = [ 0.25 , 0.75 ] ;
107- var pixelDflts = [ 0 , 10 ] ;
108-
109109 [ 0 , 1 ] . forEach ( function ( i ) {
110110 var ref = axRef [ i ] ;
111111 var refType = Axes . getRefType ( ref ) ;
@@ -160,9 +160,6 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
160160
161161 // Coerce x0, x1, y0, y1
162162 if ( noPath ) {
163- var dflt0 = 0.25 ;
164- var dflt1 = 0.75 ;
165-
166163 // hack until V3.0 when log has regular range behavior - make it look like other
167164 // ranges to send to coerce, then put it back after
168165 // this is all to give reasonable default position behavior on log axes, which is
@@ -175,11 +172,11 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) {
175172 shapeIn [ attr1 ] = pos2r ( shapeIn [ attr1 ] , true ) ;
176173
177174 if ( sizeMode === 'pixel' ) {
178- coerce ( attr0 , 0 ) ;
179- coerce ( attr1 , 10 ) ;
175+ coerce ( attr0 , pixelDflts [ 0 ] ) ;
176+ coerce ( attr1 , pixelDflts [ 1 ] ) ;
180177 } else {
181- Axes . coercePosition ( shapeOut , gdMock , coerce , axRef , attr0 , dflt0 ) ;
182- Axes . coercePosition ( shapeOut , gdMock , coerce , axRef , attr1 , dflt1 ) ;
178+ Axes . coercePosition ( shapeOut , gdMock , coerce , axRef , attr0 , dflts [ 0 ] ) ;
179+ Axes . coercePosition ( shapeOut , gdMock , coerce , axRef , attr1 , dflts [ 1 ] ) ;
183180 }
184181
185182 // hack part 2
0 commit comments