@@ -29,7 +29,6 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
29
29
// coerce the constraint mechanics even if this axis has no scaleanchor
30
30
// because it may be the anchor of another axis.
31
31
var constrain = coerce ( 'constrain' ) ;
32
-
33
32
Lib . coerce ( containerIn , containerOut , {
34
33
constraintoward : {
35
34
valType : 'enumerated' ,
@@ -38,38 +37,41 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
38
37
}
39
38
} , 'constraintoward' ) ;
40
39
41
- var scaleOpts = containerIn . scaleanchor && ! ( containerOut . fixedrange && constrain !== 'domain' ) ?
42
- getConstraintOpts ( constraintGroups , thisID , allAxisIds , layoutOut , constrain ) :
43
- { } ;
40
+ var matches , matchOpts ;
44
41
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
+ }
48
52
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 ;
55
55
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
+ }
63
65
64
- // disallow constraining AND matching range
65
- if ( constrain === 'range' && scaleanchor && matches && scaleanchor === matches ) {
66
- delete containerOut . scaleanchor ;
66
+ if ( matches ) {
67
67
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.' ) ;
69
73
}
70
74
71
- var found = false ;
72
-
73
75
if ( scaleanchor ) {
74
76
var scaleratio = coerce ( 'scaleratio' ) ;
75
77
@@ -81,19 +83,11 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
81
83
if ( ! scaleratio ) scaleratio = containerOut . scaleratio = 1 ;
82
84
83
85
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 ) {
93
87
Lib . warn ( 'ignored ' + containerOut . _name + '.scaleanchor: "' +
94
88
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 .' ) ;
97
91
}
98
92
} ;
99
93
0 commit comments