@@ -697,48 +697,50 @@ axes.calcTicks = function calcTicks(ax, opts) {
697
697
698
698
var definedDelta ;
699
699
if ( isPeriod && ax . tickformat ) {
700
- var _has = function ( str ) {
701
- return ax . tickformat . indexOf ( str ) !== - 1 ;
702
- } ;
703
-
704
700
if (
705
- ! _has ( '%f' ) && // microseconds as a decimal number [000000, 999999]
706
- ! _has ( '%L' ) && // milliseconds as a decimal number [000, 999]
707
- ! _has ( '%Q' ) && // milliseconds since UNIX epoch
708
- ! _has ( '%s' ) && // seconds since UNIX epoch
709
- ! _has ( '%S' ) && // second as a decimal number [00,61]
710
- ! _has ( '%M' ) && // minute as a decimal number [00,59]
711
- ! _has ( '%H' ) && // hour (24-hour clock) as a decimal number [00,23]
712
- ! _has ( '%I' ) && // hour (12-hour clock) as a decimal number [01,12]
713
- ! _has ( '%p' ) && // either AM or PM
714
- ! _has ( '%X' ) // the locale’s time, such as %-I:%M:%S %p
701
+ ! ( / % [ f L Q s S M H I p X ] / . test ( ax . tickformat ) )
702
+ // %f: microseconds as a decimal number [000000, 999999]
703
+ // %L: milliseconds as a decimal number [000, 999]
704
+ // %Q: milliseconds since UNIX epoch
705
+ // %s: seconds since UNIX epoch
706
+ // %S: second as a decimal number [00,61]
707
+ // %M: minute as a decimal number [00,59]
708
+ // %H: hour (24-hour clock) as a decimal number [00,23]
709
+ // %I: hour (12-hour clock) as a decimal number [01,12]
710
+ // %p: either AM or PM
711
+ // %X: the locale’s time, such as %-I:%M:%S %p
715
712
) {
716
713
if (
717
- _has ( '%A' ) || // full weekday name
718
- _has ( '%a' ) || // abbreviated weekday name
719
- _has ( '%d' ) || // zero-padded day of the month as a decimal number [01,31]
720
- _has ( '%e' ) || // space-padded day of the month as a decimal number [ 1,31]
721
- _has ( '%j' ) || // day of the year as a decimal number [001,366]
722
- _has ( '%u' ) || // Monday-based (ISO 8601) weekday as a decimal number [1,7]
723
- _has ( '%w' ) || // Sunday-based weekday as a decimal number [0,6]
724
- _has ( '%x' ) // the locale’s date, such as %-m/%-d/%Y
714
+ / % [ A a d e j u w x ] / . test ( ax . tickformat )
715
+ // %A: full weekday name
716
+ // %a: abbreviated weekday name
717
+ // %d: zero-padded day of the month as a decimal number [01,31]
718
+ // %e: space-padded day of the month as a decimal number [ 1,31]
719
+ // %j: day of the year as a decimal number [001,366]
720
+ // %u: Monday-based (ISO 8601) weekday as a decimal number [1,7]
721
+ // %w: Sunday-based weekday as a decimal number [0,6]
722
+ // %x: the locale’s date, such as %-m/%-d/%Y
725
723
) definedDelta = ONEDAY ;
726
724
else if (
727
- _has ( '%U' ) || // Sunday-based week of the year as a decimal number [00,53]
728
- _has ( '%V' ) || // ISO 8601 week of the year as a decimal number [01, 53]
729
- _has ( '%W' ) // Monday-based week of the year as a decimal number [00,53]
725
+ / % [ U V W ] / . test ( ax . tickformat )
726
+ // %U: Sunday-based week of the year as a decimal number [00,53]
727
+ // %V: ISO 8601 week of the year as a decimal number [01, 53]
728
+ // %W: Monday-based week of the year as a decimal number [00,53]
730
729
) definedDelta = ONEWEEK ;
731
730
else if (
732
- _has ( '%B' ) || // full month name
733
- _has ( '%b' ) || // abbreviated month name
734
- _has ( '%m' ) // month as a decimal number [01,12]
731
+ / % [ B b m ] / . test ( ax . tickformat )
732
+ // %B: full month name
733
+ // %b: abbreviated month name
734
+ // %m: month as a decimal number [01,12]
735
735
) definedDelta = ONEAVGMONTH ;
736
736
else if (
737
- _has ( '%q' ) // quarter of the year as a decimal number [1,4]
737
+ / % [ q ] / . test ( ax . tickformat )
738
+ // %q: quarter of the year as a decimal number [1,4]
738
739
) definedDelta = ONEAVGQUARTER ;
739
740
else if (
740
- _has ( '%Y' ) || // year with century as a decimal number, such as 1999
741
- _has ( '%y' ) // year without century as a decimal number [00,99]
741
+ / % [ Y y ] / . test ( ax . tickformat )
742
+ // %Y: year with century as a decimal number, such as 1999
743
+ // %y: year without century as a decimal number [00,99]
742
744
) definedDelta = ONEAVGYEAR ;
743
745
}
744
746
}
0 commit comments