@@ -1445,7 +1445,8 @@ function storeCurrent(attr, val, newVal, preGUI) {
1445
1445
* of the calling routine.
1446
1446
*
1447
1447
* @param {object } container: the input attributes container (eg `layout` or a `trace`)
1448
- * @param {object } fullContainer: the full partner to `container`
1448
+ * @param {object } preGUI: where original values should be stored, either
1449
+ * `layout._preGUI` or `layout._tracePreGUI[uid]`
1449
1450
* @param {object } edits: the {attr: val} object as normally passed to `relayout` etc
1450
1451
*/
1451
1452
exports . _storeDirectGUIEdit = function ( container , preGUI , edits ) {
@@ -2367,7 +2368,7 @@ exports._guiUpdate = guiEdit(update);
2367
2368
// Ordered by most common edits first, to minimize our search time
2368
2369
var layoutUIControlPatterns = [
2369
2370
{ pattern : / ^ h i d d e n l a b e l s / , attr : 'legend.uirevision' } ,
2370
- { pattern : / ^ ( ( x | y ) a x i s \d * ) \. ( ( a u t o ) ? r a n g e | t i t l e ) / , autofill : true } ,
2371
+ { pattern : / ^ ( ( x | y ) a x i s \d * ) \. ( ( a u t o ) ? r a n g e | t i t l e ) / } ,
2371
2372
2372
2373
// showspikes and modes include those nested inside scenes
2373
2374
{ pattern : / a x i s \d * \. s h o w s p i k e s $ / , attr : 'modebar.uirevision' } ,
@@ -2376,8 +2377,7 @@ var layoutUIControlPatterns = [
2376
2377
{ pattern : / ^ ( s c e n e \d * ) \. c a m e r a / } ,
2377
2378
{ pattern : / ^ ( g e o \d * ) \. ( p r o j e c t i o n | c e n t e r ) / } ,
2378
2379
{ pattern : / ^ ( t e r n a r y \d * \. [ a b c ] a x i s ) \. ( m i n | t i t l e ) $ / } ,
2379
- { pattern : / ^ ( p o l a r \d * \. r a d i a l a x i s ) \. ( a u t o ) ? r a n g e / , autofill : true } ,
2380
- { pattern : / ^ ( p o l a r \d * \. r a d i a l a x i s ) \. ( a n g l e | t i t l e ) / } ,
2380
+ { pattern : / ^ ( p o l a r \d * \. r a d i a l a x i s ) \. ( ( a u t o ) ? r a n g e | a n g l e | t i t l e ) / } ,
2381
2381
{ pattern : / ^ ( p o l a r \d * \. a n g u l a r a x i s ) \. r o t a t i o n / } ,
2382
2382
{ pattern : / ^ ( m a p b o x \d * ) \. ( c e n t e r | z o o m | b e a r i n g | p i t c h ) / } ,
2383
2383
@@ -2411,7 +2411,7 @@ function findUIPattern(key, patternSpecs) {
2411
2411
var spec = patternSpecs [ i ] ;
2412
2412
var match = key . match ( spec . pattern ) ;
2413
2413
if ( match ) {
2414
- return { head : match [ 1 ] , attr : spec . attr , autofill : spec . autofill } ;
2414
+ return { head : match [ 1 ] , attr : spec . attr } ;
2415
2415
}
2416
2416
}
2417
2417
}
@@ -2464,6 +2464,8 @@ function valsMatch(v1, v2) {
2464
2464
function applyUIRevisions ( data , layout , oldFullData , oldFullLayout ) {
2465
2465
var layoutPreGUI = oldFullLayout . _preGUI ;
2466
2466
var key , revAttr , oldRev , newRev , match , preGUIVal , newNP , newVal ;
2467
+ var bothInheritAutorange = [ ] ;
2468
+ var newRangeAccepted = { } ;
2467
2469
for ( key in layoutPreGUI ) {
2468
2470
match = findUIPattern ( key , layoutUIControlPatterns ) ;
2469
2471
if ( match ) {
@@ -2485,8 +2487,11 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
2485
2487
// storing *that* in preGUI... oh well, for now at least I limit
2486
2488
// this to attributes that get autofilled, which AFAICT among
2487
2489
// the GUI-editable attributes is just axis.range/autorange.
2488
- if ( valsMatch ( newVal , preGUIVal ) || ( match . autofill && newVal === undefined ) ) {
2489
- newNP . set ( nestedProperty ( oldFullLayout , key ) . get ( ) ) ;
2490
+ if ( valsMatch ( newVal , preGUIVal ) ) {
2491
+ if ( newVal === undefined && key . substr ( key . length - 9 ) === 'autorange' ) {
2492
+ bothInheritAutorange . push ( key . substr ( 0 , key . length - 10 ) ) ;
2493
+ }
2494
+ newNP . set ( undefinedToNull ( nestedProperty ( oldFullLayout , key ) . get ( ) ) ) ;
2490
2495
continue ;
2491
2496
}
2492
2497
}
@@ -2498,12 +2503,26 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
2498
2503
// point (either because it changed or revision changed)
2499
2504
// so remove it from _preGUI for next time.
2500
2505
delete layoutPreGUI [ key ] ;
2506
+
2507
+ if ( key . substr ( key . length - 8 , 6 ) === 'range[' ) {
2508
+ newRangeAccepted [ key . substr ( 0 , key . length - 9 ) ] = 1 ;
2509
+ }
2510
+ }
2511
+
2512
+ // Special logic for `autorange`, since it interacts with `range`:
2513
+ // If the new figure's matching `range` was kept, and `autorange`
2514
+ // wasn't supplied explicitly in either the original or the new figure,
2515
+ // we shouldn't alter that - but we may just have done that, so fix it.
2516
+ for ( var i = 0 ; i < bothInheritAutorange . length ; i ++ ) {
2517
+ var axAttr = bothInheritAutorange [ i ] ;
2518
+ if ( newRangeAccepted [ axAttr ] ) {
2519
+ var newAx = nestedProperty ( layout , axAttr ) . get ( ) ;
2520
+ if ( newAx ) delete newAx . autorange ;
2521
+ }
2501
2522
}
2502
2523
2503
2524
// Now traces - try to match them up by uid (in case we added/deleted in
2504
2525
// the middle), then fall back on index.
2505
- // var tracei = -1;
2506
- // for(var fulli = 0; fulli < oldFullData.length; fulli++) {
2507
2526
var allTracePreGUI = oldFullLayout . _tracePreGUI ;
2508
2527
for ( var uid in allTracePreGUI ) {
2509
2528
var tracePreGUI = allTracePreGUI [ uid ] ;
@@ -2550,8 +2569,8 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
2550
2569
if ( preGUIVal === null ) preGUIVal = undefined ;
2551
2570
newNP = nestedProperty ( newTrace , key ) ;
2552
2571
newVal = newNP . get ( ) ;
2553
- if ( valsMatch ( newVal , preGUIVal ) || ( match . autofill && newVal === undefined ) ) {
2554
- newNP . set ( nestedProperty ( fullInput , key ) . get ( ) ) ;
2572
+ if ( valsMatch ( newVal , preGUIVal ) ) {
2573
+ newNP . set ( undefinedToNull ( nestedProperty ( fullInput , key ) . get ( ) ) ) ;
2555
2574
continue ;
2556
2575
}
2557
2576
}
0 commit comments