@@ -630,12 +630,14 @@ axes.calcTicks = function calcTicks(ax, opts) {
630630 generateTicks ( ) ;
631631
632632 var isPeriod = ax . ticklabelmode === 'period' ;
633- if ( isPeriod ) {
633+ var addedPreTick0Label = false ;
634+ if ( isPeriod && tickVals [ 0 ] ) {
634635 // add one label to show pre tick0 period
635636 tickVals . unshift ( {
636637 minor : false ,
637638 value : axes . tickIncrement ( tickVals [ 0 ] . value , ax . dtick , ! axrev , ax . caldendar )
638639 } ) ;
640+ addedPreTick0Label = true ;
639641 }
640642
641643 if ( ax . rangebreaks ) {
@@ -778,7 +780,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
778780 ticksOut . push ( t ) ;
779781 }
780782
781- if ( isPeriod ) {
783+ if ( isPeriod && addedPreTick0Label ) {
782784 var removedPreTick0Label = false ;
783785
784786 for ( i = 0 ; i < ticksOut . length ; i ++ ) {
@@ -965,7 +967,7 @@ axes.autoTicks = function(ax, roughDTick) {
965967 }
966968
967969 if ( ax . type === 'date' ) {
968- ax . tick0 = Lib . dateTick0 ( ax . calendar ) ;
970+ ax . tick0 = Lib . dateTick0 ( ax . calendar , 0 ) ;
969971 // the criteria below are all based on the rough spacing we calculate
970972 // being > half of the final unit - so precalculate twice the rough val
971973 var roughX2 = 2 * roughDTick ;
@@ -982,14 +984,11 @@ axes.autoTicks = function(ax, roughDTick) {
982984 // get week ticks on sunday
983985 // this will also move the base tick off 2000-01-01 if dtick is
984986 // 2 or 3 days... but that's a weird enough case that we'll ignore it.
985- ax . tick0 = Lib . dateTick0 ( ax . calendar , true ) ;
986-
987987 var tickformat = axes . getTickFormat ( ax ) ;
988988 if ( / % [ u V W ] / . test ( tickformat ) ) {
989- // replace Sunday with Monday for ISO and Monday-based formats
990- var len = ax . tick0 . length ;
991- var lastD = + ax . tick0 [ len - 1 ] ;
992- ax . tick0 = ax . tick0 . substring ( 0 , len - 2 ) + String ( lastD + 1 ) ;
989+ ax . tick0 = Lib . dateTick0 ( ax . calendar , 2 ) ; // Monday
990+ } else {
991+ ax . tick0 = Lib . dateTick0 ( ax . calendar , 1 ) ; // Sunday
993992 }
994993 } else if ( roughX2 > ONEHOUR ) {
995994 ax . dtick = roundDTick ( roughDTick , ONEHOUR , roundBase24 ) ;
0 commit comments