@@ -29,7 +29,6 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
2929 // coerce the constraint mechanics even if this axis has no scaleanchor
3030 // because it may be the anchor of another axis.
3131 var constrain = coerce ( 'constrain' ) ;
32-
3332 Lib . coerce ( containerIn , containerOut , {
3433 constraintoward : {
3534 valType : 'enumerated' ,
@@ -38,38 +37,41 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
3837 }
3938 } , 'constraintoward' ) ;
4039
41- var scaleOpts = containerIn . scaleanchor && ! ( containerOut . fixedrange && constrain !== 'domain' ) ?
42- getConstraintOpts ( constraintGroups , thisID , allAxisIds , layoutOut , constrain ) :
43- { } ;
40+ var matches , matchOpts ;
4441
45- var matchOpts = ( containerIn . matches || splomStash . matches ) && ! containerOut . fixedrange ?
46- getConstraintOpts ( matchGroups , thisID , allAxisIds , layoutOut ) :
47- { } ;
42+ if ( ( containerIn . matches || splomStash . matches ) && ! containerOut . fixedrange ) {
43+ matchOpts = getConstraintOpts ( matchGroups , thisID , allAxisIds , layoutOut ) ;
44+ matches = Lib . coerce ( containerIn , containerOut , {
45+ matches : {
46+ valType : 'enumerated' ,
47+ values : matchOpts . linkableAxes || [ ] ,
48+ dflt : splomStash . matches
49+ }
50+ } , 'matches' ) ;
51+ }
4852
49- var scaleanchor = Lib . coerce ( containerIn , containerOut , {
50- scaleanchor : {
51- valType : 'enumerated' ,
52- values : scaleOpts . linkableAxes || [ ]
53- }
54- } , 'scaleanchor' ) ;
53+ // 'matches' wins over 'scaleanchor' (for now)
54+ var scaleanchor , scaleOpts ;
5555
56- var matches = Lib . coerce ( containerIn , containerOut , {
57- matches : {
58- valType : 'enumerated' ,
59- values : matchOpts . linkableAxes || [ ] ,
60- dflt : splomStash . matches
61- }
62- } , 'matches' ) ;
56+ if ( ! matches && containerIn . scaleanchor && ! ( containerOut . fixedrange && constrain !== 'domain' ) ) {
57+ scaleOpts = getConstraintOpts ( constraintGroups , thisID , allAxisIds , layoutOut , constrain ) ;
58+ scaleanchor = Lib . coerce ( containerIn , containerOut , {
59+ scaleanchor : {
60+ valType : 'enumerated' ,
61+ values : scaleOpts . linkableAxes || [ ]
62+ }
63+ } , 'scaleanchor' ) ;
64+ }
6365
64- // disallow constraining AND matching range
65- if ( constrain === 'range' && scaleanchor && matches && scaleanchor === matches ) {
66- delete containerOut . scaleanchor ;
66+ if ( matches ) {
6767 delete containerOut . constrain ;
68- scaleanchor = null ;
68+ updateConstraintGroups ( matchGroups , matchOpts . thisGroup , thisID , matches , 1 ) ;
69+ } else if ( allAxisIds . indexOf ( containerIn . matches ) !== - 1 ) {
70+ Lib . warn ( 'ignored ' + containerOut . _name + '.matches: "' +
71+ containerIn . matches + '" to avoid either an infinite loop ' +
72+ 'or because the target axis has fixed range.' ) ;
6973 }
7074
71- var found = false ;
72-
7375 if ( scaleanchor ) {
7476 var scaleratio = coerce ( 'scaleratio' ) ;
7577
@@ -81,19 +83,11 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
8183 if ( ! scaleratio ) scaleratio = containerOut . scaleratio = 1 ;
8284
8385 updateConstraintGroups ( constraintGroups , scaleOpts . thisGroup , thisID , scaleanchor , scaleratio ) ;
84- found = true ;
85- }
86-
87- if ( matches ) {
88- updateConstraintGroups ( matchGroups , matchOpts . thisGroup , thisID , matches , 1 ) ;
89- found = true ;
90- }
91-
92- if ( ! found && allAxisIds . indexOf ( containerIn . scaleanchor ) !== - 1 ) {
86+ } else if ( allAxisIds . indexOf ( containerIn . scaleanchor ) !== - 1 ) {
9387 Lib . warn ( 'ignored ' + containerOut . _name + '.scaleanchor: "' +
9488 containerIn . scaleanchor + '" to avoid either an infinite loop ' +
95- 'and possibly inconsistent scaleratios, or because the target' +
96- 'axis has fixed range.' ) ;
89+ 'and possibly inconsistent scaleratios, or because the target ' +
90+ 'axis has fixed range or this axis declares a *matches* constraint .' ) ;
9791 }
9892} ;
9993
0 commit comments