Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/8156_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix missing axis lines for traces with different `zorder` values [[#8156](https://github.com/plotly/plotly.js/pull/8156)]
2 changes: 2 additions & 0 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
45 changes: 45 additions & 0 deletions test/jasmine/tests/cartesian_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down