@@ -32,7 +32,9 @@ var manageArrays = require('./manage_arrays');
3232var helpers = require ( './helpers' ) ;
3333var subroutines = require ( './subroutines' ) ;
3434var 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 ;
3638var axisIds = require ( '../plots/cartesian/axis_ids' ) ;
3739
3840
@@ -218,19 +220,19 @@ Plotly.plot = function(gd, data, layout, config) {
218220
219221 // in case the margins changed, draw margin pushers again
220222 function marginPushersAgain ( ) {
221- var seq = JSON . stringify ( fullLayout . _size ) === oldmargins ?
222- [ ] :
223- [ marginPushers , subroutines . layoutStyles ] ;
223+ if ( JSON . stringify ( fullLayout . _size ) === oldmargins ) return ;
224224
225- // re-initialize cartesian interaction,
226- // which are sometimes cleared during marginPushers
227- seq = seq . concat ( initInteractions ) ;
228-
229- return Lib . syncOrAsync ( seq , gd ) ;
225+ return Lib . syncOrAsync ( [
226+ marginPushers ,
227+ subroutines . layoutStyles
228+ ] , gd ) ;
230229 }
231230
232231 function positionAndAutorange ( ) {
233- if ( ! recalc ) return ;
232+ if ( ! recalc ) {
233+ enforceAxisConstraints ( gd ) ;
234+ return ;
235+ }
234236
235237 var subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
236238 modules = fullLayout . _modules ;
@@ -268,7 +270,10 @@ Plotly.plot = function(gd, data, layout, config) {
268270
269271 var axList = Plotly . Axes . list ( gd , '' , true ) ;
270272 for ( var i = 0 ; i < axList . length ; i ++ ) {
271- Plotly . Axes . doAutoRange ( axList [ i ] ) ;
273+ var ax = axList [ i ] ;
274+ cleanAxisConstraints ( gd , ax ) ;
275+
276+ Plotly . Axes . doAutoRange ( ax ) ;
272277 }
273278
274279 enforceAxisConstraints ( gd ) ;
@@ -363,11 +368,13 @@ Plotly.plot = function(gd, data, layout, config) {
363368 drawFramework ,
364369 marginPushers ,
365370 marginPushersAgain ,
371+ initInteractions ,
366372 positionAndAutorange ,
367373 subroutines . layoutStyles ,
368374 drawAxes ,
369375 drawData ,
370376 finalDraw ,
377+ initInteractions ,
371378 Plots . rehover
372379 ] ;
373380
@@ -1915,10 +1922,12 @@ function _relayout(gd, aobj) {
19151922 // we're editing the (auto)range of, so we can tell the others constrained
19161923 // to scale with them that it's OK for them to shrink
19171924 var rangesAltered = { } ;
1925+ var axId ;
19181926
19191927 function recordAlteredAxis ( pleafPlus ) {
19201928 var axId = axisIds . name2id ( pleafPlus . split ( '.' ) [ 0 ] ) ;
19211929 rangesAltered [ axId ] = 1 ;
1930+ return axId ;
19221931 }
19231932
19241933 // alter gd.layout
@@ -1961,11 +1970,25 @@ function _relayout(gd, aobj) {
19611970 else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. r a n g e ( \[ [ 0 | 1 ] \] ) ? $ / ) ) {
19621971 doextra ( ptrunk + '.autorange' , false ) ;
19631972 recordAlteredAxis ( pleafPlus ) ;
1973+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
19641974 }
19651975 else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. a u t o r a n g e $ / ) ) {
19661976 doextra ( [ ptrunk + '.range[0]' , ptrunk + '.range[1]' ] ,
19671977 undefined ) ;
19681978 recordAlteredAxis ( pleafPlus ) ;
1979+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
1980+ var axFull = Lib . nestedProperty ( fullLayout , ptrunk ) . get ( ) ;
1981+ if ( axFull . _inputDomain ) {
1982+ // if we're autoranging and this axis has a constrained domain,
1983+ // reset it so we don't get locked into a shrunken size
1984+ axFull . _input . domain = axFull . _inputDomain . slice ( ) ;
1985+ }
1986+ }
1987+ else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. d o m a i n ( \[ [ 0 | 1 ] \] ) ? $ / ) ) {
1988+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputDomain' ) . set ( null ) ;
1989+ }
1990+ else if ( pleafPlus . match ( / ^ [ x y z ] a x i s [ 0 - 9 ] * \. c o n s t r a i n .* $ / ) ) {
1991+ flags . docalc = true ;
19691992 }
19701993 else if ( pleafPlus . match ( / ^ a s p e c t r a t i o \. [ x y z ] $ / ) ) {
19711994 doextra ( proot + '.aspectmode' , 'manual' ) ;
@@ -2045,6 +2068,7 @@ function _relayout(gd, aobj) {
20452068 // will not make sense, so autorange it.
20462069 doextra ( ptrunk + '.autorange' , true ) ;
20472070 }
2071+ Lib . nestedProperty ( fullLayout , ptrunk + '._inputRange' ) . set ( null ) ;
20482072 }
20492073 else if ( pleaf . match ( cartesianConstants . AX_NAME_PATTERN ) ) {
20502074 var fullProp = Lib . nestedProperty ( fullLayout , ai ) . get ( ) ,
@@ -2191,7 +2215,7 @@ function _relayout(gd, aobj) {
21912215
21922216 // figure out if we need to recalculate axis constraints
21932217 var constraints = fullLayout . _axisConstraintGroups ;
2194- for ( var axId in rangesAltered ) {
2218+ for ( axId in rangesAltered ) {
21952219 for ( i = 0 ; i < constraints . length ; i ++ ) {
21962220 var group = constraints [ i ] ;
21972221 if ( group [ axId ] ) {
0 commit comments