Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 126ce26

Browse files
committed
ensure minor dtick get round months
1 parent 524a330 commit 126ce26

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/plots/cartesian/axes.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,13 +1257,19 @@ axes.autoTicks = function(ax, roughDTick, isMinor) {
12571257
// being > half of the final unit - so precalculate twice the rough val
12581258
var roughX2 = 2 * roughDTick;
12591259

1260+
var months;
12601261
if(roughX2 > ONEAVGYEAR) {
12611262
roughDTick /= ONEAVGYEAR;
12621263
base = getBase(10);
1263-
ax.dtick = 'M' + (12 * mayRound(roughDTick, base, roundBase10));
1264+
months = 12 * mayRound(roughDTick, base, roundBase10);
1265+
months = Math.round(months);
1266+
ax.dtick = 'M' + months;
12641267
} else if(roughX2 > ONEAVGMONTH) {
12651268
roughDTick /= ONEAVGMONTH;
1266-
ax.dtick = 'M' + mayRound(roughDTick, 1, roundBase24);
1269+
months = mayRound(roughDTick, 1, roundBase24);
1270+
months = Math.round(months);
1271+
if(months < 1) months = 1;
1272+
ax.dtick = 'M' + months;
12671273
} else if(roughX2 > ONEDAY) {
12681274
ax.dtick = mayRound(roughDTick, ONEDAY, _roundDays);
12691275
if(!isMinor) {

0 commit comments

Comments
 (0)