@@ -124,6 +124,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
124
124
}
125
125
126
126
var counterAxes = { x : getCounterAxes ( 'x' ) , y : getCounterAxes ( 'y' ) } ;
127
+ var allAxisIds = counterAxes . x . concat ( counterAxes . y ) ;
127
128
128
129
function getOverlayableAxes ( axLetter , axName ) {
129
130
var list = ( axLetter === 'x' ) ? xNames : yNames ;
@@ -199,14 +200,12 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
199
200
delete axLayoutOut . spikesnap ;
200
201
}
201
202
202
- var positioningOptions = {
203
+ handlePositionDefaults ( axLayoutIn , axLayoutOut , coerce , {
203
204
letter : axLetter ,
204
205
counterAxes : counterAxes [ axLetter ] ,
205
206
overlayableAxes : overlayableAxes ,
206
207
grid : layoutOut . grid
207
- } ;
208
-
209
- handlePositionDefaults ( axLayoutIn , axLayoutOut , coerce , positioningOptions ) ;
208
+ } ) ;
210
209
211
210
axLayoutOut . _input = axLayoutIn ;
212
211
}
@@ -247,22 +246,56 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
247
246
coerce ( 'fixedrange' , fixedRangeDflt ) ;
248
247
}
249
248
250
- // Finally, handle scale constraints. We need to do this after all axes have
251
- // coerced both `type` (so we link only axes of the same type) and
249
+ // Finally, handle scale constraints and matching axes.
250
+ //
251
+ // We need to do this after all axes have coerced both `type`
252
+ // (so we link only axes of the same type) and
252
253
// `fixedrange` (so we can avoid linking from OR TO a fixed axis).
253
254
254
255
// sets of axes linked by `scaleanchor` along with the scaleratios compounded
255
256
// together, populated in handleConstraintDefaults
256
257
layoutOut . _axisConstraintGroups = [ ] ;
257
- var allAxisIds = counterAxes . x . concat ( counterAxes . y ) ;
258
+ // similar to _axisConstraintGroups, but for matching axes
259
+ layoutOut . _axisMatchGroups = [ ] ;
258
260
259
261
for ( i = 0 ; i < axNames . length ; i ++ ) {
260
262
axName = axNames [ i ] ;
261
263
axLetter = axName . charAt ( 0 ) ;
262
-
263
264
axLayoutIn = layoutIn [ axName ] ;
264
265
axLayoutOut = layoutOut [ axName ] ;
265
266
266
267
handleConstraintDefaults ( axLayoutIn , axLayoutOut , coerce , allAxisIds , layoutOut ) ;
267
268
}
269
+
270
+ for ( i = 0 ; i < layoutOut . _axisMatchGroups . length ; i ++ ) {
271
+ var group = layoutOut . _axisMatchGroups [ i ] ;
272
+ var rng = null ;
273
+ var autorange = null ;
274
+ var axId ;
275
+
276
+ for ( axId in group ) {
277
+ axLayoutOut = layoutOut [ id2name ( axId ) ] ;
278
+ if ( ! axLayoutOut . matches ) {
279
+ rng = axLayoutOut . range ;
280
+ autorange = axLayoutOut . autorange ;
281
+ }
282
+ }
283
+
284
+ if ( rng === null || autorange === null ) {
285
+ for ( axId in group ) {
286
+ axLayoutOut = layoutOut [ id2name ( axId ) ] ;
287
+ rng = axLayoutOut . range ;
288
+ autorange = axLayoutOut . autorange ;
289
+ break ;
290
+ }
291
+ }
292
+
293
+ for ( axId in group ) {
294
+ axLayoutOut = layoutOut [ id2name ( axId ) ] ;
295
+ if ( axLayoutOut . matches ) {
296
+ axLayoutOut . range = rng . slice ( ) ;
297
+ axLayoutOut . autorange = autorange ;
298
+ }
299
+ }
300
+ }
268
301
} ;
0 commit comments