Skip to content

Commit 137d73d

Browse files
committed
coerce axes referenced by matches in layout
1 parent 2d5370c commit 137d73d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/plots/cartesian/layout_defaults.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ function appendList(cont, k, item) {
3333
else cont[k] = [item];
3434
}
3535

36+
function addMatchesInLayout(axNames, list, layoutIn) {
37+
for(var j = 0; j < list.length; j++) {
38+
for(var i = 0; i < list.length; i++) {
39+
if(i === j) continue;
40+
var e = list[i];
41+
if(e === layoutIn[list[j]].matches + 'axis' && axNames.indexOf(e) === -1) {
42+
// add item e to the start of the array
43+
axNames = [e].concat(axNames);
44+
break;
45+
}
46+
}
47+
}
48+
49+
return axNames;
50+
}
51+
3652
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
3753
var ax2traces = {};
3854
var xaMayHide = {};
@@ -122,6 +138,14 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
122138
var yIds = subplots.yaxis;
123139
var xNames = Lib.simpleMap(xIds, id2name);
124140
var yNames = Lib.simpleMap(yIds, id2name);
141+
142+
// add axes that are referenced in the layout by other axes
143+
var allKeys = Object.getOwnPropertyNames(layoutIn);
144+
var xaxisKeys = allKeys.filter(function(e) { return e.indexOf('xaxis') === 0; });
145+
var yaxisKeys = allKeys.filter(function(e) { return e.indexOf('yaxis') === 0; });
146+
xNames = addMatchesInLayout(xNames, xaxisKeys, layoutIn);
147+
yNames = addMatchesInLayout(yNames, yaxisKeys, layoutIn);
148+
125149
var axNames = xNames.concat(yNames);
126150

127151
// plot_bgcolor only makes sense if there's a (2D) plot!

0 commit comments

Comments
 (0)