@@ -34,6 +34,7 @@ var ONEAVGMONTH = constants.ONEAVGMONTH;
3434var ONEMINMONTH = constants . ONEMINMONTH ;
3535var ONEWEEK = constants . ONEWEEK ;
3636var ONEDAY = constants . ONEDAY ;
37+ var HALFDAY = ONEDAY / 2 ;
3738var ONEHOUR = constants . ONEHOUR ;
3839var ONEMIN = constants . ONEMIN ;
3940var ONESEC = constants . ONESEC ;
@@ -503,7 +504,7 @@ function autoShiftMonthBins(binStart, data, dtick, dataMin, calendar) {
503504 // will always give a somewhat odd-looking label, until we do something
504505 // smarter like showing the bin boundaries (or the bounds of the actual
505506 // data in each bin)
506- binStart -= ONEDAY / 2 ;
507+ binStart -= HALFDAY ;
507508 }
508509 var nextBinStart = axes . tickIncrement ( binStart , dtick ) ;
509510
@@ -705,7 +706,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
705706 var tickformat = axes . getTickFormat ( ax ) ;
706707 if ( isPeriod && tickformat ) {
707708 if (
708- ! ( / % [ f L Q s S M H I p X ] / . test ( tickformat ) )
709+ ! ( / % [ f L Q s S M H I X ] / . test ( tickformat ) )
709710 // %f: microseconds as a decimal number [000000, 999999]
710711 // %L: milliseconds as a decimal number [000, 999]
711712 // %Q: milliseconds since UNIX epoch
@@ -714,10 +715,12 @@ axes.calcTicks = function calcTicks(ax, opts) {
714715 // %M: minute as a decimal number [00,59]
715716 // %H: hour (24-hour clock) as a decimal number [00,23]
716717 // %I: hour (12-hour clock) as a decimal number [01,12]
717- // %p: either AM or PM
718718 // %X: the locale’s time, such as %-I:%M:%S %p
719719 ) {
720720 if (
721+ / % p / . test ( tickformat ) // %p: either AM or PM
722+ ) definedDelta = HALFDAY ;
723+ else if (
721724 / % [ A a d e j u w x ] / . test ( tickformat )
722725 // %A: full weekday name
723726 // %a: abbreviated weekday name
@@ -819,6 +822,8 @@ axes.calcTicks = function calcTicks(ax, opts) {
819822 periodLength = ONEWEEK ;
820823 } else if ( delta >= ONEDAY ) {
821824 periodLength = ONEDAY ;
825+ } else if ( definedDelta === HALFDAY && delta >= HALFDAY ) {
826+ periodLength = HALFDAY ;
822827 }
823828
824829 if ( periodLength && ax . rangebreaks ) {
0 commit comments