Skip to content

Commit 9f2fad1

Browse files
committed
disallow constraining AND matching range
1 parent ef256db commit 9f2fad1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: src/plots/cartesian/constraints.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
3030

3131
// coerce the constraint mechanics even if this axis has no scaleanchor
3232
// because it may be the anchor of another axis.
33-
coerce('constrain');
33+
var constrain = coerce('constrain');
3434
Lib.coerce(containerIn, containerOut, {
3535
constraintoward: {
3636
valType: 'enumerated',
@@ -58,6 +58,13 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
5858
}
5959
}, 'matches');
6060

61+
// disallow constraining AND matching range
62+
if(constrain === 'range' && scaleanchor === matches) {
63+
delete containerOut.scaleanchor;
64+
delete containerOut.constrain;
65+
scaleanchor = null;
66+
}
67+
6168
var found = false;
6269

6370
if(scaleanchor) {

Diff for: test/jasmine/tests/axes_test.js

+18
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,24 @@ describe('Test axes', function() {
689689
});
690690
});
691691

692+
it('disallow constraining AND matching range', function() {
693+
layoutIn = {
694+
xaxis: {},
695+
xaxis2: {matches: 'x', scaleanchor: 'x'}
696+
};
697+
layoutOut._subplots.cartesian.push('x2y');
698+
layoutOut._subplots.xaxis.push('x2');
699+
700+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
701+
702+
expect(layoutOut.xaxis2.matches).toBe('x');
703+
expect(layoutOut.xaxis2.scaleanchor).toBe(undefined);
704+
expect(layoutOut.xaxis2.constrain).toBe(undefined);
705+
706+
expect(layoutOut._axisConstraintGroups).toEqual([]);
707+
expect(layoutOut._axisMatchGroups).toEqual([{x: 1, x2: 1}]);
708+
});
709+
692710
it('drops scaleanchor settings if either the axis or target has fixedrange', function() {
693711
// some of these will create warnings... not too important, so not going to test,
694712
// just want to keep the output clean

0 commit comments

Comments
 (0)