Skip to content

Commit df1c59f

Browse files
committed
make interactions for matched group w/ missing axes work
- do not consider 'missing' axes during autorange sync-up operation - do not attempt to update missing axes on drag and other relayout calls that reference missing axes
1 parent 33078b0 commit df1c59f

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

src/plot_api/subroutines.js

+6
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,15 @@ exports.doAutoRangeAndConstraints = function(gd) {
670670
var fullLayout = gd._fullLayout;
671671
var axList = Axes.list(gd, '', true);
672672
var matchGroups = fullLayout._axisMatchGroups || [];
673+
var axLookup = {};
673674
var ax;
674675
var axRng;
675676

676677
for(var i = 0; i < axList.length; i++) {
677678
ax = axList[i];
678679
cleanAxisConstraints(gd, ax);
679680
doAutoRange(gd, ax);
681+
axLookup[ax._id] = 1;
680682
}
681683

682684
enforceAxisConstraints(gd);
@@ -689,6 +691,10 @@ exports.doAutoRangeAndConstraints = function(gd) {
689691

690692
for(id in group) {
691693
ax = Axes.getFromId(gd, id);
694+
695+
// skip over 'missing' axes which do not pass through doAutoRange
696+
if(!axLookup[ax._id]) continue;
697+
// if one axis has autorange false, we're done
692698
if(ax.autorange === false) continue groupLoop;
693699

694700
axRng = Lib.simpleMap(ax.range, ax.r2l);

src/plots/cartesian/axes.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1669,10 +1669,14 @@ axes.drawOne = function(gd, ax, opts) {
16691669
var axId = ax._id;
16701670
var axLetter = axId.charAt(0);
16711671
var counterLetter = axes.counterLetter(axId);
1672-
var mainLinePosition = ax._mainLinePosition;
1673-
var mainMirrorPosition = ax._mainMirrorPosition;
16741672
var mainPlotinfo = fullLayout._plots[ax._mainSubplot];
1673+
1674+
// this happens when updating matched group with 'missing' axes
1675+
if(!mainPlotinfo) return;
1676+
16751677
var mainAxLayer = mainPlotinfo[axLetter + 'axislayer'];
1678+
var mainLinePosition = ax._mainLinePosition;
1679+
var mainMirrorPosition = ax._mainMirrorPosition;
16761680

16771681
var vals = ax._vals = axes.calcTicks(ax);
16781682

test/jasmine/tests/cartesian_interact_test.js

+53
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,59 @@ describe('axis zoom/pan and main plot zoom', function() {
15351535
.catch(failTest)
15361536
.then(done);
15371537
});
1538+
1539+
it('panning a matching axes with references to *missing* axes', function(done) {
1540+
var data = [
1541+
// N.B. no traces on subplot xy
1542+
{ x: [1, 2, 3], y: [1, 2, 1], xaxis: 'x2', yaxis: 'y2'},
1543+
{ x: [1, 2, 3], y: [1, 2, 1], xaxis: 'x3', yaxis: 'y3'},
1544+
{ x: [1, 2, 3], y: [1, 2, 1], xaxis: 'x4', yaxis: 'y4'}
1545+
];
1546+
1547+
var layout = {
1548+
xaxis: {domain: [0, 0.48]},
1549+
xaxis2: {anchor: 'y2', domain: [0.52, 1], matches: 'x'},
1550+
xaxis3: {anchor: 'y3', domain: [0, 0.48], matches: 'x'},
1551+
xaxis4: {anchor: 'y4', domain: [0.52, 1], matches: 'x'},
1552+
yaxis: {domain: [0, 0.48]},
1553+
yaxis2: {anchor: 'x2', domain: [0.52, 1], matches: 'y'},
1554+
yaxis3: {anchor: 'x3', domain: [0.52, 1], matches: 'y'},
1555+
yaxis4: {anchor: 'x4', domain: [0, 0.48], matches: 'y'},
1556+
width: 400,
1557+
height: 400,
1558+
margin: {t: 50, l: 50, b: 50, r: 50},
1559+
showlegend: false,
1560+
dragmode: 'pan'
1561+
};
1562+
1563+
makePlot(data, layout).then(function() {
1564+
assertRanges('base', [
1565+
[['xaxis', 'xaxis2', 'xaxis3', 'xaxis4'], [0.8206, 3.179]],
1566+
[['yaxis', 'yaxis2', 'yaxis3', 'yaxis4'], [0.9103, 2.0896]]
1567+
]);
1568+
})
1569+
.then(function() {
1570+
var drag = makeDragFns('x2y2', 'nsew', 30, 30);
1571+
return drag.start().then(function() {
1572+
assertRanges('during drag', [
1573+
[['xaxis', 'xaxis2', 'xaxis3', 'xaxis4'], [0.329, 2.687], {skipInput: true}],
1574+
[['yaxis', 'yaxis2', 'yaxis3', 'yaxis4'], [1.156, 2.335], {skipInput: true}]
1575+
]);
1576+
})
1577+
.then(drag.end);
1578+
})
1579+
.then(_assert('after drag on x2y2 subplot', [
1580+
[['xaxis', 'xaxis2', 'xaxis3', 'xaxis4'], [0.329, 2.687], {dragged: true}],
1581+
[['yaxis', 'yaxis2', 'yaxis3', 'yaxis4'], [1.156, 2.335], {dragged: true}]
1582+
]))
1583+
.then(doDblClick('x3y3', 'nsew'))
1584+
.then(_assert('after double-click on x3y3 subplot', [
1585+
[['xaxis', 'xaxis2', 'xaxis3', 'xaxis4'], [0.8206, 3.179], {autorange: true}],
1586+
[['yaxis', 'yaxis2', 'yaxis3', 'yaxis4'], [0.9103, 2.0896], {autorange: true}]
1587+
]))
1588+
.catch(failTest)
1589+
.then(done);
1590+
});
15381591
});
15391592

15401593
describe('redrag behavior', function() {

0 commit comments

Comments
 (0)