@@ -124,6 +124,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
124124 }
125125
126126 var counterAxes = { x : getCounterAxes ( 'x' ) , y : getCounterAxes ( 'y' ) } ;
127+ var allAxisIds = counterAxes . x . concat ( counterAxes . y ) ;
127128
128129 function getOverlayableAxes ( axLetter , axName ) {
129130 var list = ( axLetter === 'x' ) ? xNames : yNames ;
@@ -199,14 +200,12 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
199200 delete axLayoutOut . spikesnap ;
200201 }
201202
202- var positioningOptions = {
203+ handlePositionDefaults ( axLayoutIn , axLayoutOut , coerce , {
203204 letter : axLetter ,
204205 counterAxes : counterAxes [ axLetter ] ,
205206 overlayableAxes : overlayableAxes ,
206207 grid : layoutOut . grid
207- } ;
208-
209- handlePositionDefaults ( axLayoutIn , axLayoutOut , coerce , positioningOptions ) ;
208+ } ) ;
210209
211210 axLayoutOut . _input = axLayoutIn ;
212211 }
@@ -247,22 +246,56 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
247246 coerce ( 'fixedrange' , fixedRangeDflt ) ;
248247 }
249248
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
252253 // `fixedrange` (so we can avoid linking from OR TO a fixed axis).
253254
254255 // sets of axes linked by `scaleanchor` along with the scaleratios compounded
255256 // together, populated in handleConstraintDefaults
256257 layoutOut . _axisConstraintGroups = [ ] ;
257- var allAxisIds = counterAxes . x . concat ( counterAxes . y ) ;
258+ // similar to _axisConstraintGroups, but for matching axes
259+ layoutOut . _axisMatchGroups = [ ] ;
258260
259261 for ( i = 0 ; i < axNames . length ; i ++ ) {
260262 axName = axNames [ i ] ;
261263 axLetter = axName . charAt ( 0 ) ;
262-
263264 axLayoutIn = layoutIn [ axName ] ;
264265 axLayoutOut = layoutOut [ axName ] ;
265266
266267 handleConstraintDefaults ( axLayoutIn , axLayoutOut , coerce , allAxisIds , layoutOut ) ;
267268 }
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+ }
268301} ;
0 commit comments