@@ -190,8 +190,7 @@ Plotly.plot = function(gd, data, layout, config) {
190
190
191
191
return Lib . syncOrAsync ( [
192
192
subroutines . layoutStyles ,
193
- drawAxes ,
194
- initInteractions
193
+ drawAxes
195
194
] , gd ) ;
196
195
}
197
196
@@ -220,19 +219,19 @@ Plotly.plot = function(gd, data, layout, config) {
220
219
221
220
// in case the margins changed, draw margin pushers again
222
221
function marginPushersAgain ( ) {
223
- var seq = JSON . stringify ( fullLayout . _size ) === oldmargins ?
224
- [ ] :
225
- [ marginPushers , subroutines . layoutStyles ] ;
222
+ if ( JSON . stringify ( fullLayout . _size ) === oldmargins ) return ;
226
223
227
- // re-initialize cartesian interaction,
228
- // which are sometimes cleared during marginPushers
229
- seq = seq . concat ( initInteractions ) ;
230
-
231
- return Lib . syncOrAsync ( seq , gd ) ;
224
+ return Lib . syncOrAsync ( [
225
+ marginPushers ,
226
+ subroutines . layoutStyles
227
+ ] , gd ) ;
232
228
}
233
229
234
230
function positionAndAutorange ( ) {
235
- if ( ! recalc ) return ;
231
+ if ( ! recalc ) {
232
+ enforceAxisConstraints ( gd ) ;
233
+ return ;
234
+ }
236
235
237
236
var subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
238
237
modules = fullLayout . _modules ;
@@ -270,7 +269,26 @@ Plotly.plot = function(gd, data, layout, config) {
270
269
271
270
var axList = Plotly . Axes . list ( gd , '' , true ) ;
272
271
for ( var i = 0 ; i < axList . length ; i ++ ) {
273
- Plotly . Axes . doAutoRange ( axList [ i ] ) ;
272
+ // before autoranging, check if this axis was previously constrained
273
+ // by domain but no longer is
274
+ var ax = axList [ i ] ;
275
+ if ( ax . _inputDomain ) {
276
+ var isConstrained = false ;
277
+ var axId = ax . _id ;
278
+ var constraintGroups = gd . _fullLayout . _axisConstraintGroups ;
279
+ for ( var j = 0 ; j < constraintGroups . length ; j ++ ) {
280
+ if ( constraintGroups [ j ] [ axId ] ) {
281
+ isConstrained = true ;
282
+ break ;
283
+ }
284
+ }
285
+ if ( ! isConstrained || ax . constrain !== 'domain' ) {
286
+ ax . _input . domain = ax . domain = ax . _inputDomain ;
287
+ delete ax . _inputDomain ;
288
+ }
289
+ }
290
+
291
+ Plotly . Axes . doAutoRange ( ax ) ;
274
292
}
275
293
276
294
enforceAxisConstraints ( gd ) ;
@@ -370,6 +388,7 @@ Plotly.plot = function(gd, data, layout, config) {
370
388
drawAxes ,
371
389
drawData ,
372
390
finalDraw ,
391
+ initInteractions ,
373
392
Plots . rehover
374
393
] ;
375
394
@@ -1913,10 +1932,12 @@ function _relayout(gd, aobj) {
1913
1932
// we're editing the (auto)range of, so we can tell the others constrained
1914
1933
// to scale with them that it's OK for them to shrink
1915
1934
var rangesAltered = { } ;
1935
+ var axId ;
1916
1936
1917
1937
function recordAlteredAxis ( pleafPlus ) {
1918
1938
var axId = axisIds . name2id ( pleafPlus . split ( '.' ) [ 0 ] ) ;
1919
1939
rangesAltered [ axId ] = 1 ;
1940
+ return axId ;
1920
1941
}
1921
1942
1922
1943
// alter gd.layout
@@ -1959,11 +1980,26 @@ function _relayout(gd, aobj) {
1959
1980
else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. r a n g e ( \[ [ 0 | 1 ] \] ) ? $ / ) ) {
1960
1981
doextra ( ptrunk + '.autorange' , false ) ;
1961
1982
recordAlteredAxis ( pleafPlus ) ;
1983
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
1962
1984
}
1963
1985
else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. a u t o r a n g e $ / ) ) {
1964
1986
doextra ( [ ptrunk + '.range[0]' , ptrunk + '.range[1]' ] ,
1965
1987
undefined ) ;
1966
1988
recordAlteredAxis ( pleafPlus ) ;
1989
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
1990
+ var axFull = Lib . nestedProperty ( fullLayout , ptrunk ) . get ( ) ;
1991
+ if ( axFull . _inputDomain ) {
1992
+ // if we're autoranging and this axis has a constrained domain,
1993
+ // reset it so we don't get locked into a shrunken size
1994
+ axFull . _input . domain = axFull . _inputDomain . slice ( ) ;
1995
+ }
1996
+ }
1997
+ else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. d o m a i n ( \[ [ 0 | 1 ] \] ) ? $ / ) ) {
1998
+ axId = recordAlteredAxis ( pleafPlus ) ;
1999
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputDomain' ) . set ( null ) ;
2000
+ }
2001
+ else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. c o n s t r a i n .* $ / ) ) {
2002
+ flags . docalc = true ;
1967
2003
}
1968
2004
else if ( pleafPlus . match ( / ^ a s p e c t r a t i o \. [ x y z ] $ / ) ) {
1969
2005
doextra ( proot + '.aspectmode' , 'manual' ) ;
@@ -2043,6 +2079,7 @@ function _relayout(gd, aobj) {
2043
2079
// will not make sense, so autorange it.
2044
2080
doextra ( ptrunk + '.autorange' , true ) ;
2045
2081
}
2082
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
2046
2083
}
2047
2084
else if ( pleaf . match ( cartesianConstants . AX_NAME_PATTERN ) ) {
2048
2085
var fullProp = Lib . nestedProperty ( fullLayout , ai ) . get ( ) ,
@@ -2189,7 +2226,7 @@ function _relayout(gd, aobj) {
2189
2226
2190
2227
// figure out if we need to recalculate axis constraints
2191
2228
var constraints = fullLayout . _axisConstraintGroups ;
2192
- for ( var axId in rangesAltered ) {
2229
+ for ( axId in rangesAltered ) {
2193
2230
for ( i = 0 ; i < constraints . length ; i ++ ) {
2194
2231
var group = constraints [ i ] ;
2195
2232
if ( group [ axId ] ) {
0 commit comments