@@ -135,26 +135,31 @@ axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption
135135 * extraOption: aside from existing axes with this letter, what non-axis value is allowed?
136136 * Only required if it's different from `dflt`
137137 */
138- axes . coerceRefArray = function ( containerIn , containerOut , gd , attr , expectedLen ) {
138+ axes . coerceRefArray = function ( containerIn , containerOut , gd , attr , dflt , extraOption , expectedLen ) {
139139 var axLetter = attr . charAt ( attr . length - 1 ) ;
140140 var axlist = gd . _fullLayout . _subplots [ axLetter + 'axis' ] ;
141- axlist = axlist . concat ( axlist . map ( function ( x ) { return x + ' domain' ; } ) ) ;
142141 var refAttr = attr + 'ref' ;
143142 var axRef = containerIn [ refAttr ] ;
144- var dflt = axlist . length ? axlist [ 0 ] : 'paper' ;
143+
144+ // Build the axis list, which we use to validate the axis references
145+ if ( ! dflt ) dflt = axlist [ 0 ] || ( typeof extraOption === 'string' ? extraOption : extraOption [ 0 ] ) ;
146+ axlist = axlist . concat ( axlist . map ( function ( x ) { return x + ' domain' ; } ) ) ;
147+ axlist = axlist . concat ( extraOption ? extraOption : [ ] ) ;
145148
146149 // Handle array length mismatch
147150 if ( axRef . length > expectedLen ) {
148151 // if the array is longer than the expected length, truncate it
152+ Lib . warn ( 'Array attribute ' + refAttr + ' has more entries than expected, truncating to ' + expectedLen ) ;
149153 axRef = axRef . slice ( 0 , expectedLen ) ;
150154 } else if ( axRef . length < expectedLen ) {
151155 // if the array is shorter than the expected length, extend using the default value
156+ Lib . warn ( 'Array attribute ' + refAttr + ' has fewer entries than expected, extending with default value' ) ;
152157 axRef = axRef . concat ( Array ( expectedLen - axRef . length ) . fill ( dflt ) ) ;
153158 }
154159
155160 // Check all references, replace with default if invalid
156161 for ( var i = 0 ; i < axRef . length ; i ++ ) {
157- if ( ! ( axRef [ i ] === 'paper' || cartesianConstants . idRegex [ axLetter ] . test ( axRef [ i ] ) ) ) {
162+ if ( ! axlist . includes ( axRef [ i ] ) ) {
158163 axRef [ i ] = dflt ;
159164 }
160165 }
@@ -173,7 +178,6 @@ axes.coerceRefArray = function(containerIn, containerOut, gd, attr, expectedLen)
173178 */
174179axes . getRefType = function ( ar ) {
175180 if ( ar === undefined ) { return ar ; }
176- if ( Array . isArray ( ar ) ) { return 'array' ; }
177181 if ( ar === 'paper' ) { return 'paper' ; }
178182 if ( ar === 'pixel' ) { return 'pixel' ; }
179183 if ( / ( d o m a i n ) $ / . test ( ar ) ) { return 'domain' ; } else { return 'range' ; }
0 commit comments