diff --git a/draftlogs/7935_fix.md b/draftlogs/7935_fix.md new file mode 100644 index 00000000000..bc146a686b0 --- /dev/null +++ b/draftlogs/7935_fix.md @@ -0,0 +1 @@ +- Fix tick label format sometimes being incompatible with the labeled tick when using `ticklabelindex` [[#7935](https://github.com/plotly/plotly.js/pull/7935)] diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index a341f18291a..1661d8c115c 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -716,6 +716,12 @@ axes.prepMinorTicks = function(mockAx, ax, opts) { // ensure identical tick0 mockAx.tick0 = ax.tick0; } + if (ax._useTicklabelIndex) { + // this could always be done but the additional information on the minor + // axis is just necessary when using ticklabelindex. + autoTickRound(mockAx); + ax.minor._tickround = mockAx._tickround; + } }; function isMultiple(bigger, smaller) { @@ -1962,7 +1968,7 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround; + var tr = ax._useTicklabelIndex ? ax.minor._tickround : ax._tickround; var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); // Only apply extra precision if no explicit format was provided. diff --git a/test/image/baselines/date_axes_period2_ticklabelindex.png b/test/image/baselines/date_axes_period2_ticklabelindex.png index 08033c74bbf..dfac053357e 100644 Binary files a/test/image/baselines/date_axes_period2_ticklabelindex.png and b/test/image/baselines/date_axes_period2_ticklabelindex.png differ diff --git a/test/image/mocks/date_axes_period2_ticklabelindex.json b/test/image/mocks/date_axes_period2_ticklabelindex.json index da103bb7bf1..7de1c602f60 100644 --- a/test/image/mocks/date_axes_period2_ticklabelindex.json +++ b/test/image/mocks/date_axes_period2_ticklabelindex.json @@ -44,7 +44,7 @@ "layout": { "showlegend": false, "width": 600, - "height": 500, + "height": 740, "yaxis": { "domain": [0, 0.04] },