@@ -32,7 +32,9 @@ var manageArrays = require('./manage_arrays');
32
32
var helpers = require ( './helpers' ) ;
33
33
var subroutines = require ( './subroutines' ) ;
34
34
var cartesianConstants = require ( '../plots/cartesian/constants' ) ;
35
- var enforceAxisConstraints = require ( '../plots/cartesian/constraints' ) ;
35
+ var axisConstraints = require ( '../plots/cartesian/constraints' ) ;
36
+ var enforceAxisConstraints = axisConstraints . enforce ;
37
+ var cleanAxisConstraints = axisConstraints . clean ;
36
38
var axisIds = require ( '../plots/cartesian/axis_ids' ) ;
37
39
38
40
@@ -190,8 +192,7 @@ Plotly.plot = function(gd, data, layout, config) {
190
192
191
193
return Lib . syncOrAsync ( [
192
194
subroutines . layoutStyles ,
193
- drawAxes ,
194
- initInteractions
195
+ drawAxes
195
196
] , gd ) ;
196
197
}
197
198
@@ -220,19 +221,19 @@ Plotly.plot = function(gd, data, layout, config) {
220
221
221
222
// in case the margins changed, draw margin pushers again
222
223
function marginPushersAgain ( ) {
223
- var seq = JSON . stringify ( fullLayout . _size ) === oldmargins ?
224
- [ ] :
225
- [ marginPushers , subroutines . layoutStyles ] ;
224
+ if ( JSON . stringify ( fullLayout . _size ) === oldmargins ) return ;
226
225
227
- // re-initialize cartesian interaction,
228
- // which are sometimes cleared during marginPushers
229
- seq = seq . concat ( initInteractions ) ;
230
-
231
- return Lib . syncOrAsync ( seq , gd ) ;
226
+ return Lib . syncOrAsync ( [
227
+ marginPushers ,
228
+ subroutines . layoutStyles
229
+ ] , gd ) ;
232
230
}
233
231
234
232
function positionAndAutorange ( ) {
235
- if ( ! recalc ) return ;
233
+ if ( ! recalc ) {
234
+ enforceAxisConstraints ( gd ) ;
235
+ return ;
236
+ }
236
237
237
238
var subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
238
239
modules = fullLayout . _modules ;
@@ -270,7 +271,10 @@ Plotly.plot = function(gd, data, layout, config) {
270
271
271
272
var axList = Plotly . Axes . list ( gd , '' , true ) ;
272
273
for ( var i = 0 ; i < axList . length ; i ++ ) {
273
- Plotly . Axes . doAutoRange ( axList [ i ] ) ;
274
+ var ax = axList [ i ] ;
275
+ cleanAxisConstraints ( gd , ax ) ;
276
+
277
+ Plotly . Axes . doAutoRange ( ax ) ;
274
278
}
275
279
276
280
enforceAxisConstraints ( gd ) ;
@@ -365,11 +369,13 @@ Plotly.plot = function(gd, data, layout, config) {
365
369
drawFramework ,
366
370
marginPushers ,
367
371
marginPushersAgain ,
372
+ initInteractions ,
368
373
positionAndAutorange ,
369
374
subroutines . layoutStyles ,
370
375
drawAxes ,
371
376
drawData ,
372
377
finalDraw ,
378
+ initInteractions ,
373
379
Plots . rehover
374
380
] ;
375
381
@@ -1917,10 +1923,12 @@ function _relayout(gd, aobj) {
1917
1923
// we're editing the (auto)range of, so we can tell the others constrained
1918
1924
// to scale with them that it's OK for them to shrink
1919
1925
var rangesAltered = { } ;
1926
+ var axId ;
1920
1927
1921
1928
function recordAlteredAxis ( pleafPlus ) {
1922
1929
var axId = axisIds . name2id ( pleafPlus . split ( '.' ) [ 0 ] ) ;
1923
1930
rangesAltered [ axId ] = 1 ;
1931
+ return axId ;
1924
1932
}
1925
1933
1926
1934
// alter gd.layout
@@ -1963,11 +1971,25 @@ function _relayout(gd, aobj) {
1963
1971
else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. r a n g e ( \[ [ 0 | 1 ] \] ) ? $ / ) ) {
1964
1972
doextra ( ptrunk + '.autorange' , false ) ;
1965
1973
recordAlteredAxis ( pleafPlus ) ;
1974
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
1966
1975
}
1967
1976
else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. a u t o r a n g e $ / ) ) {
1968
1977
doextra ( [ ptrunk + '.range[0]' , ptrunk + '.range[1]' ] ,
1969
1978
undefined ) ;
1970
1979
recordAlteredAxis ( pleafPlus ) ;
1980
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
1981
+ var axFull = Lib . nestedProperty ( fullLayout , ptrunk ) . get ( ) ;
1982
+ if ( axFull . _inputDomain ) {
1983
+ // if we're autoranging and this axis has a constrained domain,
1984
+ // reset it so we don't get locked into a shrunken size
1985
+ axFull . _input . domain = axFull . _inputDomain . slice ( ) ;
1986
+ }
1987
+ }
1988
+ else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. d o m a i n ( \[ [ 0 | 1 ] \] ) ? $ / ) ) {
1989
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputDomain' ) . set ( null ) ;
1990
+ }
1991
+ else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. c o n s t r a i n .* $ / ) ) {
1992
+ flags . docalc = true ;
1971
1993
}
1972
1994
else if ( pleafPlus . match ( / ^ a s p e c t r a t i o \. [ x y z ] $ / ) ) {
1973
1995
doextra ( proot + '.aspectmode' , 'manual' ) ;
@@ -2047,6 +2069,7 @@ function _relayout(gd, aobj) {
2047
2069
// will not make sense, so autorange it.
2048
2070
doextra ( ptrunk + '.autorange' , true ) ;
2049
2071
}
2072
+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
2050
2073
}
2051
2074
else if ( pleaf . match ( cartesianConstants . AX_NAME_PATTERN ) ) {
2052
2075
var fullProp = Lib . nestedProperty ( fullLayout , ai ) . get ( ) ,
@@ -2193,7 +2216,7 @@ function _relayout(gd, aobj) {
2193
2216
2194
2217
// figure out if we need to recalculate axis constraints
2195
2218
var constraints = fullLayout . _axisConstraintGroups ;
2196
- for ( var axId in rangesAltered ) {
2219
+ for ( axId in rangesAltered ) {
2197
2220
for ( i = 0 ; i < constraints . length ; i ++ ) {
2198
2221
var group = constraints [ i ] ;
2199
2222
if ( group [ axId ] ) {
0 commit comments