@@ -571,6 +571,10 @@ axes.prepTicks = function(ax, opts) {
571
571
autoTickRound ( ax ) ;
572
572
} ;
573
573
574
+ function nMonths ( dtick ) {
575
+ return + ( dtick . substring ( 1 ) ) ;
576
+ }
577
+
574
578
// calculate the ticks: text, values, positioning
575
579
// if ticks are set to automatic, determine the right values (tick0,dtick)
576
580
// in any case, set tickround to # of digits to round tick labels to,
@@ -663,20 +667,26 @@ axes.calcTicks = function calcTicks(ax, opts) {
663
667
// %m: month as a decimal number [01,12]
664
668
) {
665
669
definedDelta = ONEAVGMONTH ;
666
- if ( noDtick && ax . dtick < ( isMDate ? 'M1' : ONEMINMONTH ) ) ax . dtick = 'M1' ;
670
+ if ( noDtick && (
671
+ isMDate ? nMonths ( ax . dtick ) < 1 : ax . dtick < ONEMINMONTH )
672
+ ) ax . dtick = 'M1' ;
667
673
} else if (
668
674
/ % [ q ] / . test ( tickformat )
669
675
// %q: quarter of the year as a decimal number [1,4]
670
676
) {
671
677
definedDelta = ONEAVGQUARTER ;
672
- if ( noDtick && ax . dtick < ( isMDate ? 'M3' : ONEMINQUARTER ) ) ax . dtick = 'M3' ;
678
+ if ( noDtick && (
679
+ isMDate ? nMonths ( ax . dtick ) < 3 : ax . dtick < ONEMINQUARTER )
680
+ ) ax . dtick = 'M3' ;
673
681
} else if (
674
682
/ % [ Y y ] / . test ( tickformat )
675
683
// %Y: year with century as a decimal number, such as 1999
676
684
// %y: year without century as a decimal number [00,99]
677
685
) {
678
686
definedDelta = ONEAVGYEAR ;
679
- if ( noDtick && ax . dtick < ( isMDate ? 'M12' : ONEMINYEAR ) ) ax . dtick = 'M12' ;
687
+ if ( noDtick && (
688
+ isMDate ? nMonths ( ax . dtick ) < 12 : ax . dtick < ONEMINYEAR )
689
+ ) ax . dtick = 'M12' ;
680
690
}
681
691
}
682
692
}
0 commit comments