From c647db410ae5a7b15d666d0bd0079d2e1c6ca2af Mon Sep 17 00:00:00 2001 From: Adrian Borrmann Date: Tue, 15 Sep 2026 16:07:08 -0600 Subject: [PATCH 1/2] Fix plot shifting on axis when automargin applied to title --- draftlogs/XXXX_fix.md | 1 + src/plot_api/plot_api.js | 2 +- test/jasmine/tests/plot_api_react_test.js | 4 +- test/jasmine/tests/titles_test.js | 47 +++++++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 draftlogs/XXXX_fix.md diff --git a/draftlogs/XXXX_fix.md b/draftlogs/XXXX_fix.md new file mode 100644 index 00000000000..f549e524b87 --- /dev/null +++ b/draftlogs/XXXX_fix.md @@ -0,0 +1 @@ +- Keep cartesian traces aligned with their axes when an automargin title is combined with any component that expands the margins [[#XXXX](https://github.com/plotly/plotly.js/pull/XXXX)] diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index f48d808425b..bdb32daed6d 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -328,7 +328,7 @@ function _doPlot(gd, data, layout, config) { function marginPushersAgain() { if (!Plots.didMarginChange(oldMargins, fullLayout._size)) return; - return Lib.syncOrAsync([marginPushers, subroutines.layoutStyles], gd); + return marginPushers(); } function positionAndAutorange() { diff --git a/test/jasmine/tests/plot_api_react_test.js b/test/jasmine/tests/plot_api_react_test.js index 270284209b4..9ebd0a70b66 100644 --- a/test/jasmine/tests/plot_api_react_test.js +++ b/test/jasmine/tests/plot_api_react_test.js @@ -210,9 +210,7 @@ describe('@noCIdep Plotly.react', function() { return Plotly.react(gd, data, layout); }) .then(function() { - // we get an extra call to layoutStyles from marginPushersAgain due to the colorbar. - // Really need to simplify that pipeline... - countCalls({plot: 1, layoutStyles: 1}); + countCalls({plot: 1}); layout.scene.camera = {up: {x: 1, y: 0, z: -1}}; diff --git a/test/jasmine/tests/titles_test.js b/test/jasmine/tests/titles_test.js index 9744a517248..27152d7d3c4 100644 --- a/test/jasmine/tests/titles_test.js +++ b/test/jasmine/tests/titles_test.js @@ -882,6 +882,53 @@ describe('Title automargining', function() { afterEach(destroyGraphDiv); + it('keeps cartesian traces aligned with axes when controls also expand margins', function(done) { + Plotly.newPlot(gd, [{ + x: [1, 2, 3], + y: [2, 1, 3], + mode: 'lines+markers', + line: {simplify: false} + }], { + margin: {autoexpand: true, t: 0}, + title: { + text: 'Title', + automargin: true, + font: {size: 36} + }, + sliders: [{ + pad: {t: 30}, + x: 0.05, + len: 0.95, + steps: [ + {label: '0', method: 'update', args: [{}, {}]}, + {label: '1', method: 'update', args: [{}, {}]} + ] + }], + updatemenus: [{ + type: 'buttons', + x: 0.05, + y: 0, + xanchor: 'right', + yanchor: 'top', + direction: 'left', + pad: {t: 60, r: 20}, + buttons: [{label: 'Play', method: 'skip'}] + }] + }).then(function() { + var plot = d3Select(gd); + var point = plot.select('.scatterlayer .point').node(); + var yTick; + + plot.selectAll('.ytick').each(function() { + if(d3Select(this).select('text').text() === '2') yTick = this; + }); + + expect(point).not.toBeNull(); + expect(yTick).toBeDefined(); + expect(point.getCTM().f).toBeCloseTo(yTick.querySelector('text').getCTM().f, 6); + }).then(done, done.fail); + }); + it('should avoid overlap with container for yref=paper and allow padding', function(done) { Plotly.newPlot(gd, data, { margin: {t: 0, b: 0, l: 0, r: 0}, From d06de0a4bc0ff3317495f5a0586ec3c116a67c0f Mon Sep 17 00:00:00 2001 From: Adrian Borrmann Date: Tue, 15 Sep 2026 16:25:21 -0600 Subject: [PATCH 2/2] Add PR# to draftlog --- draftlogs/{XXXX_fix.md => 8045_fix.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename draftlogs/{XXXX_fix.md => 8045_fix.md} (68%) diff --git a/draftlogs/XXXX_fix.md b/draftlogs/8045_fix.md similarity index 68% rename from draftlogs/XXXX_fix.md rename to draftlogs/8045_fix.md index f549e524b87..7b44189921e 100644 --- a/draftlogs/XXXX_fix.md +++ b/draftlogs/8045_fix.md @@ -1 +1 @@ -- Keep cartesian traces aligned with their axes when an automargin title is combined with any component that expands the margins [[#XXXX](https://github.com/plotly/plotly.js/pull/XXXX)] +- Keep cartesian traces aligned with their axes when an automargin title is combined with any component that expands the margins [[#8045](https://github.com/plotly/plotly.js/pull/8045)]