Skip to content

Commit afeb782

Browse files
authored
Merge pull request #7935 from my-tien/7933-minor-ticklabel-format
fix: Format date tick labels with minor-tick precision when using `ticklabelindex`
2 parents 4862f62 + 5d6636b commit afeb782

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎draftlogs/7935_fix.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix tick label format sometimes being incompatible with the labeled tick when using `ticklabelindex` [[#7935](https://github.com/plotly/plotly.js/pull/7935)], with thanks to @my-tien for the contribution!

‎src/plots/cartesian/axes.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,12 @@ axes.prepMinorTicks = function(mockAx, ax, opts) {
716716
// ensure identical tick0
717717
mockAx.tick0 = ax.tick0;
718718
}
719+
if (ax._useTicklabelIndex) {
720+
// this could always be done but the additional information on the minor
721+
// axis is just necessary when using ticklabelindex.
722+
autoTickRound(mockAx);
723+
ax.minor._tickround = mockAx._tickround;
724+
}
719725
};
720726

721727
function isMultiple(bigger, smaller) {
@@ -1962,7 +1968,7 @@ function tickTextObj(ax, x, text) {
19621968
}
19631969

19641970
function formatDate(ax, out, hover, extraPrecision) {
1965-
var tr = ax._tickround;
1971+
var tr = ax._useTicklabelIndex ? ax.minor._tickround : ax._tickround;
19661972
var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax);
19671973

19681974
// Only apply extra precision if no explicit format was provided.
19.9 KB
Loading

‎test/image/mocks/date_axes_period2_ticklabelindex.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"layout": {
4545
"showlegend": false,
4646
"width": 600,
47-
"height": 500,
47+
"height": 740,
4848
"yaxis": {
4949
"domain": [0, 0.04]
5050
},

0 commit comments

Comments
 (0)