From 394ce6e36ada2f819c25d03453ee6bfd0c44fddf Mon Sep 17 00:00:00 2001 From: Bruno Pommier Date: Fri, 30 Oct 2026 11:10:33 +0100 Subject: [PATCH 1/2] fix(cartesian): preserve axis lines across zorder layers --- draftlogs/PR_NUMBER_fix.md | 1 + src/plot_api/subroutines.js | 2 ++ test/jasmine/tests/cartesian_test.js | 45 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 draftlogs/PR_NUMBER_fix.md diff --git a/draftlogs/PR_NUMBER_fix.md b/draftlogs/PR_NUMBER_fix.md new file mode 100644 index 00000000000..dacc48170a6 --- /dev/null +++ b/draftlogs/PR_NUMBER_fix.md @@ -0,0 +1 @@ + - Fix missing axis lines for traces with different `zorder` values [[#PR_NUMBER](https://github.com/plotly/plotly.js/pull/PR_NUMBER)] diff --git a/src/plot_api/subroutines.js b/src/plot_api/subroutines.js index 666f3e7b6a5..596e12a6fa7 100644 --- a/src/plot_api/subroutines.js +++ b/src/plot_api/subroutines.js @@ -264,6 +264,8 @@ function lsInner(gd) { } for(subplot in fullLayout._plots) { + // Z-order subplots share axis lines with their primary subplot. + if (subplot.indexOf(zindexSeparator) !== -1) continue; plotinfo = fullLayout._plots[subplot]; xa = plotinfo.xaxis; ya = plotinfo.yaxis; diff --git a/test/jasmine/tests/cartesian_test.js b/test/jasmine/tests/cartesian_test.js index 617726c202c..3edf546e084 100644 --- a/test/jasmine/tests/cartesian_test.js +++ b/test/jasmine/tests/cartesian_test.js @@ -347,6 +347,51 @@ describe('relayout', function() { afterEach(destroyGraphDiv); + ['scatter', 'bar'].forEach((type) => { + it(`preserves axis lines across zorder layers for ${type} traces`, async () => { + const assertLineLengths = (layer, xLength, yLength) => { + expect(gd.querySelector(`.xlines-${layer}`).getTotalLength()).toBeCloseTo(xLength, 5); + expect(gd.querySelector(`.ylines-${layer}`).getTotalLength()).toBeCloseTo(yLength, 5); + }; + + await Plotly.newPlot(gd, [ + {type, x: [1, 2], y: [1, 2], zorder: -1}, + {type, x: [1, 2], y: [2, 1]}, + {type, x: [1, 2], y: [3, 2], zorder: 2} + ], { + width: 400, + height: 400, + margin: {l: 50, r: 50, t: 50, b: 50}, + showlegend: false, + xaxis: {range: [0, 4], showline: true, linewidth: 2}, + yaxis: {range: [0, 4], showline: true, linewidth: 2} + }); + assertLineLengths('above', 302, 300); + + await Plotly.restyle(gd, {zorder: [0, 0, 0]}); + assertLineLengths('above', 302, 300); + + await Plotly.restyle(gd, {zorder: [-1, 0, 2]}); + assertLineLengths('above', 302, 300); + + await Plotly.relayout(gd, {'xaxis.showline': false, 'yaxis.showline': false}); + assertLineLengths('above', 0, 0); + + await Plotly.relayout(gd, { + 'xaxis.showline': true, + 'yaxis.showline': true, + 'xaxis.layer': 'below traces', + 'yaxis.layer': 'below traces', + 'xaxis.mirror': true, + 'yaxis.mirror': true + }); + assertLineLengths('below', 608, 600); + + await Plotly.relayout(gd, {width: 500, height: 450}); + assertLineLengths('below', 808, 700); + }); + }); + it('can show and hide axis lines', function(done) { Plotly.newPlot(gd, [{y: [1, 2]}], {width: 400, height: 400}) .then(function() { From eda9009b161a96c5ccaa0e5647a03d42a241fbe8 Mon Sep 17 00:00:00 2001 From: Bruno Pommier Date: Fri, 30 Oct 2026 11:33:35 +0100 Subject: [PATCH 2/2] docs(changelog): link axis-line fix to PR 8156 --- draftlogs/8156_fix.md | 1 + draftlogs/PR_NUMBER_fix.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 draftlogs/8156_fix.md delete mode 100644 draftlogs/PR_NUMBER_fix.md diff --git a/draftlogs/8156_fix.md b/draftlogs/8156_fix.md new file mode 100644 index 00000000000..50cf9ae9af3 --- /dev/null +++ b/draftlogs/8156_fix.md @@ -0,0 +1 @@ + - Fix missing axis lines for traces with different `zorder` values [[#8156](https://github.com/plotly/plotly.js/pull/8156)] diff --git a/draftlogs/PR_NUMBER_fix.md b/draftlogs/PR_NUMBER_fix.md deleted file mode 100644 index dacc48170a6..00000000000 --- a/draftlogs/PR_NUMBER_fix.md +++ /dev/null @@ -1 +0,0 @@ - - Fix missing axis lines for traces with different `zorder` values [[#PR_NUMBER](https://github.com/plotly/plotly.js/pull/PR_NUMBER)]