diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 25685d5e300..52a56b45903 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -3125,8 +3125,10 @@ axes.drawLabels = function(gd, ax, opts) { TICK_PATH, TICK_TEXT ]).forEach(function(e) { - var isTickText = e.K === 'tick' && e.L === 'text'; - if(isTickText && ax.ticklabelmode === 'period') return; + var isPeriodLabel = + e.K === 'tick' && + e.L === 'text' && + ax.ticklabelmode === 'period'; var sel; if(e.K === ZERO_PATH.K) sel = opts.plotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl'); @@ -3138,7 +3140,9 @@ axes.drawLabels = function(gd, ax, opts) { if(e.L) w = w.selectAll(e.L); w.each(function(d) { - var q = ax.l2p(d.x) + ax._offset; + var q = ax.l2p( + isPeriodLabel ? getPosX(d) : d.x + ) + ax._offset; var t = d3.select(this); if(q < ax._visibleLabelMax && q > ax._visibleLabelMin) { diff --git a/test/image/baselines/ticklabelposition-7.png b/test/image/baselines/ticklabelposition-7.png new file mode 100644 index 00000000000..fa6d9436065 Binary files /dev/null and b/test/image/baselines/ticklabelposition-7.png differ diff --git a/test/image/mocks/ticklabelposition-6.json b/test/image/mocks/ticklabelposition-6.json index 0d3a7464ac8..dc4cbc1b70a 100644 --- a/test/image/mocks/ticklabelposition-6.json +++ b/test/image/mocks/ticklabelposition-6.json @@ -2,25 +2,21 @@ "data": [{ "xaxis": "x", "yaxis": "y", - "orientation": "h", "x": [0.4, 0.5, 0.6, 0.7, 0.8], "y": ["Oo", "Pp", "Qq", "Rr", "Ss"] }, { "xaxis": "x2", "yaxis": "y2", - "orientation": "h", "x": [0.4, 0.5, 0.6, 0.7, 0.8], "y": ["Oo", "Pp", "Qq", "Rr", "Ss"] }, { "xaxis": "x3", "yaxis": "y3", - "orientation": "v", "y": [0.4, 0.5, 0.6, 0.7, 0.8], "x": ["Oo", "Pp", "Qq", "Rr", "Ss"] }, { "xaxis": "x4", "yaxis": "y4", - "orientation": "v", "y": [0.4, 0.5, 0.6, 0.7, 0.8], "x": ["Oo", "Pp", "Qq", "Rr", "Ss"] }], diff --git a/test/image/mocks/ticklabelposition-7.json b/test/image/mocks/ticklabelposition-7.json new file mode 100644 index 00000000000..3d6da28377a --- /dev/null +++ b/test/image/mocks/ticklabelposition-7.json @@ -0,0 +1,111 @@ +{ + "data": [{ + "xaxis": "x", + "yaxis": "y", + "x": ["20-10", "21-03"], + "y": [1e-1, 1e+6] + }, { + "xaxis": "x2", + "yaxis": "y2", + "x": ["21-03", "20-10"], + "y": [1e+6, 1e-1] + }, { + "xaxis": "x3", + "yaxis": "y3", + "x": ["20", "23"], + "y": [1e-1, 1e+6] + }, { + "xaxis": "x4", + "yaxis": "y4", + "x": ["23", "20"], + "y": [1e+6, 1e-1] + }], + "layout": { + "xaxis": { + "anchor": "y", + "domain": [0, 0.475], + "type": "date", + "ticks": "outside", + "ticklabelmode": "period", + "side": "bottom", + "gridcolor": "white" + }, + "yaxis": { + "anchor": "x", + "domain": [0, 0.475], + "type": "log", + "side": "left", + "ticks": "inside", + "ticklabelposition": "inside bottom", + "gridcolor": "white" + }, + "xaxis2": { + "anchor": "y2", + "domain": [0.525, 1], + "autorange": "reversed", + "type": "date", + "ticks": "outside", + "ticklabelmode": "period", + "side": "bottom", + "ticklabelposition": "inside left", + "gridcolor": "white" + }, + "yaxis2": { + "anchor": "x2", + "domain": [0, 0.475], + "type": "log", + "side": "right", + "ticks": "inside", + "ticklabelposition": "inside bottom", + "gridcolor": "white" + }, + "xaxis3": { + "anchor": "y3", + "domain": [0.525, 1], + "type": "date", + "ticks": "outside", + "ticklabelmode": "period", + "side": "top", + "ticklabelposition": "inside right", + "gridcolor": "white" + }, + "yaxis3": { + "anchor": "x3", + "domain": [0.525, 1], + "type": "log", + "side": "right", + "ticks": "inside", + "ticklabelposition": "inside bottom", + "gridcolor": "white" + }, + "xaxis4": { + "anchor": "y4", + "domain": [0, 0.475], + "autorange": "reversed", + "type": "date", + "ticks": "outside", + "ticklabelmode": "period", + "side": "top", + "gridcolor": "white" + }, + "yaxis4": { + "anchor": "x4", + "domain": [0.525, 1], + "type": "log", + "side": "left", + "ticks": "inside", + "ticklabelposition": "inside bottom", + "gridcolor": "white" + }, + "plot_bgcolor": "lightblue", + "showlegend": false, + "width": 500, + "height": 500, + "margin": { + "t": 50, + "b": 50, + "l": 50, + "r": 50 + } + } +} diff --git a/test/jasmine/tests/mock_test.js b/test/jasmine/tests/mock_test.js index 3898625f1b0..acadb9b583a 100644 --- a/test/jasmine/tests/mock_test.js +++ b/test/jasmine/tests/mock_test.js @@ -969,6 +969,9 @@ var list = [ 'ticklabelposition-2', 'ticklabelposition-3', 'ticklabelposition-4', + 'ticklabelposition-5', + 'ticklabelposition-6', + 'ticklabelposition-7', 'ticklabelposition-a', 'ticklabelposition-b', 'ticklabelposition-c', @@ -2058,6 +2061,9 @@ figs['ticklabelposition-1'] = require('@mocks/ticklabelposition-1'); figs['ticklabelposition-2'] = require('@mocks/ticklabelposition-2'); figs['ticklabelposition-3'] = require('@mocks/ticklabelposition-3'); figs['ticklabelposition-4'] = require('@mocks/ticklabelposition-4'); +figs['ticklabelposition-5'] = require('@mocks/ticklabelposition-5'); +figs['ticklabelposition-6'] = require('@mocks/ticklabelposition-6'); +figs['ticklabelposition-7'] = require('@mocks/ticklabelposition-7'); figs['ticklabelposition-a'] = require('@mocks/ticklabelposition-a'); figs['ticklabelposition-b'] = require('@mocks/ticklabelposition-b'); figs['ticklabelposition-c'] = require('@mocks/ticklabelposition-c');