diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 0c83a476ffa..43caf7464f6 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -1965,6 +1965,7 @@ axes.drawOne = function(gd, ax, opts) { push[s] += offset; } + // TODO won't work for multi-line titles !! if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { push[s] += ax.title.font.size; } diff --git a/test/image/baselines/automargin-mirror-all.png b/test/image/baselines/automargin-mirror-all.png new file mode 100644 index 00000000000..b3580caf29b Binary files /dev/null and b/test/image/baselines/automargin-mirror-all.png differ diff --git a/test/image/baselines/automargin-mirror-allticks.png b/test/image/baselines/automargin-mirror-allticks.png new file mode 100644 index 00000000000..535622e3ea6 Binary files /dev/null and b/test/image/baselines/automargin-mirror-allticks.png differ diff --git a/test/image/baselines/automargin-multiline-titles.png b/test/image/baselines/automargin-multiline-titles.png new file mode 100644 index 00000000000..8c5745afc6d Binary files /dev/null and b/test/image/baselines/automargin-multiline-titles.png differ diff --git a/test/image/baselines/automargin-rangeslider-and-sidepush.png b/test/image/baselines/automargin-rangeslider-and-sidepush.png new file mode 100644 index 00000000000..5af5bb1a9b6 Binary files /dev/null and b/test/image/baselines/automargin-rangeslider-and-sidepush.png differ diff --git a/test/image/mocks/automargin-mirror-all.json b/test/image/mocks/automargin-mirror-all.json new file mode 100644 index 00000000000..87de78e5a19 --- /dev/null +++ b/test/image/mocks/automargin-mirror-all.json @@ -0,0 +1,51 @@ +{ + "data": [ + { + "x": [1, 2, 3], + "y": [4, 5, 6] + }, + { + "x": [20, 30, 40], + "y": [50, 60, 70], + "xaxis": "x2", + "yaxis": "y2" + } + ], + "layout": { + "showlegend": false, + "grid": { + "rows": 1, + "columns": 2, + "pattern": "independent" + }, + "xaxis": { + "automargin": true, + "ticks": "outside", + "showline": true, "linewidth": 5, + "mirror": "all" + }, + "xaxis2": { + "automargin": true, + "ticks": "outside", + "showline": true, + "mirror": "all" + }, + "yaxis": { + "automargin": true, + "ticks": "outside", + "showline": true, + "zeroline": false, + "mirror": "all" + }, + "yaxis2": { + "automargin": true, + "ticks": "outside", + "showline": true, "linewidth": 10, + "zeroline": false, + "mirror": "all" + }, + "margin": {"l": 0, "b": 0, "t": 0, "r": 0}, + "width": 500, + "height": 400 + } +} diff --git a/test/image/mocks/automargin-mirror-allticks.json b/test/image/mocks/automargin-mirror-allticks.json new file mode 100644 index 00000000000..d76fe3bd7f1 --- /dev/null +++ b/test/image/mocks/automargin-mirror-allticks.json @@ -0,0 +1,60 @@ +{ + "data": [ + { + "x": [1, 2, 3], + "y": [4, 5, 6] + }, + { + "x": [20, 30, 40], + "y": [50, 60, 70], + "xaxis": "x2" + }, + { + "x": [1, 2, 3], + "y": [4, 5, 6], + "yaxis": "y2" + }, + { + "x": [20, 30, 40], + "y": [50, 60, 70], + "xaxis": "x2", + "yaxis": "y2" + } + ], + "layout": { + "showlegend": false, + "grid": { + "rows": 2, + "columns": 2 + }, + "xaxis": { + "automargin": true, + "ticks": "outside", + "showline": true, + "mirror": "all" + }, + "xaxis2": { + "automargin": true, + "ticks": "outside", "ticklen": 10, + "showline": true, + "mirror": "allticks" + }, + "yaxis": { + "automargin": true, + "ticks": "outside", + "showline": true, + "zeroline": false, + "mirror": "all" + }, + "yaxis2": { + "automargin": true, + "ticks": "outside", "ticklen": 5, + "showline": true, "linewidth": 5, + "zeroline": false, + "mirror": "allticks" + }, + "margin": {"l": 0, "b": 0, "t": 0, "r": 0}, + "width": 500, + "height": 400 + } +} diff --git a/test/image/mocks/automargin-multiline-titles.json b/test/image/mocks/automargin-multiline-titles.json new file mode 100644 index 00000000000..544d029701e --- /dev/null +++ b/test/image/mocks/automargin-multiline-titles.json @@ -0,0 +1,27 @@ +{ + "data": [ + { + "y": [1, 2, 1] + } + ], + "layout": { + "xaxis": { + "automargin": true, + "nticks": 3, + "tickfont": {"size": 30}, + "title": {"text": "Hello
Bonjour"}, + "zeroline": false + }, + "yaxis": { + "automargin": true, + "title": { + "text": "Hello
Bonjour
Hola", + "font": {"size": 32} + }, + "ticklen": 20 + }, + "width": 400, + "height": 400, + "margin": {"l": 0, "t": 0, "r": 0, "b": 0} + } +} diff --git a/test/image/mocks/automargin-rangeslider-and-sidepush.json b/test/image/mocks/automargin-rangeslider-and-sidepush.json new file mode 100644 index 00000000000..cb941cdf94d --- /dev/null +++ b/test/image/mocks/automargin-rangeslider-and-sidepush.json @@ -0,0 +1,24 @@ +{ + "data": [ + { + "x": ["a", "b", "c", "d", "long category", "another even longer", "the longest one yet!!!!!!"], + "y": [0, 10, 20, 30, 40, 50, 60] + } + ], + "layout": { + "xaxis": { + "title": { + "text": "Bottom X Axis
2nd line", + "font": {"size": 14} + }, + "rangeslider": { "visible": true }, + "automargin": true + }, + "yaxis": { + "automargin": true + }, + "width": 400, + "height": 400, + "margin": {"l": 0, "t": 0, "b": 0, "r": 0} + } +}