Skip to content

Commit de644bb

Browse files
authored
Merge pull request #7171 from plotly/new-fix7144-zorder-overlay
Fix lower zorder traces behing some gridlines on overlayed suplots
2 parents c3454a5 + 9ede030 commit de644bb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/plots/cartesian/index.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,10 @@ function makeSubplotLayer(gd, plotinfo) {
568568
var yLayer = constants.layerValue2layerClass[plotinfo.yaxis.layer];
569569
var hasOnlyLargeSploms = fullLayout._hasOnlyLargeSploms;
570570

571-
if(!plotinfo.mainplot || fullLayout._zindices.length > 1) {
571+
var hasMultipleZ = fullLayout._zindices.length > 1;
572+
var mainplotinfo = plotinfo.mainplotinfo;
573+
574+
if(!plotinfo.mainplot || hasMultipleZ) {
572575
if(hasOnlyLargeSploms) {
573576
// TODO could do even better
574577
// - we don't need plot (but we would have to mock it in lsInner
@@ -585,9 +588,15 @@ function makeSubplotLayer(gd, plotinfo) {
585588
plotinfo.shapelayer = ensureSingle(backLayer, 'g', 'shapelayer');
586589
plotinfo.imagelayer = ensureSingle(backLayer, 'g', 'imagelayer');
587590

588-
plotinfo.minorGridlayer = ensureSingle(plotgroup, 'g', 'minor-gridlayer');
589-
plotinfo.gridlayer = ensureSingle(plotgroup, 'g', 'gridlayer');
590-
plotinfo.zerolinelayer = ensureSingle(plotgroup, 'g', 'zerolinelayer');
591+
if(mainplotinfo && hasMultipleZ) {
592+
plotinfo.minorGridlayer = mainplotinfo.minorGridlayer;
593+
plotinfo.gridlayer = mainplotinfo.gridlayer;
594+
plotinfo.zerolinelayer = mainplotinfo.zerolinelayer;
595+
} else {
596+
plotinfo.minorGridlayer = ensureSingle(plotgroup, 'g', 'minor-gridlayer');
597+
plotinfo.gridlayer = ensureSingle(plotgroup, 'g', 'gridlayer');
598+
plotinfo.zerolinelayer = ensureSingle(plotgroup, 'g', 'zerolinelayer');
599+
}
591600

592601
var betweenLayer = ensureSingle(plotgroup, 'g', 'layer-between');
593602
plotinfo.shapelayerBetween = ensureSingle(betweenLayer, 'g', 'shapelayer');
@@ -622,7 +631,6 @@ function makeSubplotLayer(gd, plotinfo) {
622631
}
623632
}
624633
} else {
625-
var mainplotinfo = plotinfo.mainplotinfo;
626634
var mainplotgroup = mainplotinfo.plotgroup;
627635
var xId = id + '-x';
628636
var yId = id + '-y';
Loading

0 commit comments

Comments
 (0)