Skip to content

Commit 8ddfcc3

Browse files
Reorder axes with dependency tickmode sync
1 parent 92281af commit 8ddfcc3

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/plots/cartesian/axes.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,16 +2296,35 @@ axes.draw = function(gd, arg, opts) {
22962296
var id = d[0];
22972297
var plotinfo = fullLayout._plots[id];
22982298
if(plotinfo) {
2299+
var xa = plotinfo.xaxis;
22992300
var ya = plotinfo.yaxis;
2300-
if(ya.tickmode === 'sync' && ya.overlaying === arg[0]) {
2301-
arg.push(ya._id);
2302-
}
2301+
isSyncAxis(xa, arg[0]);
2302+
isSyncAxis(ya, arg[0]);
23032303
}
23042304
});
23052305
}
23062306

2307+
function isSyncAxis(ax, idToValidate) {
2308+
if(ax.tickmode === 'sync' && ax.overlaying === idToValidate) {
2309+
arg.push(ax._id);
2310+
}
2311+
}
2312+
23072313
var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg;
23082314

2315+
// order axes that have dependency to other axes
2316+
axList.map(function(axId) {
2317+
var ax = axes.getFromId(gd, axId);
2318+
2319+
if(ax.tickmode === 'sync' && ax.overlaying) {
2320+
var overlayingIndex = axList.findIndex(function(axis) {return axis === ax.overlaying;});
2321+
2322+
if(overlayingIndex >= 0) {
2323+
axList.unshift(axList.splice(overlayingIndex, 1).shift());
2324+
}
2325+
}
2326+
});
2327+
23092328
return Lib.syncOrAsync(axList.map(function(axId) {
23102329
return function() {
23112330
if(!axId) return;

0 commit comments

Comments
 (0)