@@ -679,11 +679,11 @@ axes.calcTicks = function calcTicks(ax) {
679679 // show the exponent only on the last one
680680 ax . _tmax = vals [ vals . length - 1 ] ;
681681
682- // for showing date suffixes: ax._prevSuffix holds what we showed most
683- // recently. Start with it cleared and mark that we're in calcTicks (ie
684- // calculating a whole string of these so we should care what the previous
685- // suffix was!)
686- ax . _prevSuffix = '' ;
682+ // for showing the rest of a date when the main tick label is only the
683+ // latter part: ax._prevDateHead holds what we showed most recently.
684+ // Start with it cleared and mark that we're in calcTicks (ie calculating a
685+ // whole string of these so we should care what the previous date head was!)
686+ ax . _prevDateHead = '' ;
687687 ax . _inCalcTicks = true ;
688688
689689 var ticksOut = new Array ( vals . length ) ;
@@ -1107,10 +1107,10 @@ function formatDate(ax, out, hover, extraPrecision) {
11071107 var x = out . x ,
11081108 tr = ax . _tickround ,
11091109 d = new Date ( x ) ,
1110- // suffix completes the full date info, to be included
1110+ // headPart completes the full date info, to be included
11111111 // with only the first tick or if any info before what's
11121112 // shown has changed
1113- suffix ,
1113+ headPart ,
11141114 tt ;
11151115 if ( hover && ax . hoverformat ) {
11161116 tt = modDateFormat ( ax . hoverformat , x ) ;
@@ -1129,12 +1129,12 @@ function formatDate(ax, out, hover, extraPrecision) {
11291129 else if ( tr === 'm' ) tt = monthFormat ( d ) ;
11301130 else {
11311131 if ( tr === 'd' ) {
1132- suffix = yearFormat ( d ) ;
1132+ headPart = yearFormat ( d ) ;
11331133
11341134 tt = dayFormat ( d ) ;
11351135 }
11361136 else {
1137- suffix = yearMonthDayFormat ( d ) ;
1137+ headPart = yearMonthDayFormat ( d ) ;
11381138
11391139 tt = minuteFormat ( d ) ;
11401140 if ( tr !== 'M' ) {
@@ -1151,8 +1151,8 @@ function formatDate(ax, out, hover, extraPrecision) {
11511151 // we get extra precision in array mode or hover,
11521152 // but it may be useless, strip it off
11531153 if ( tt === '00:00:00' || tt === '00:00' ) {
1154- tt = suffix ;
1155- suffix = '' ;
1154+ tt = headPart ;
1155+ headPart = '' ;
11561156 }
11571157 else if ( tt . length === 8 ) {
11581158 // strip off seconds if they're zero (zero fractional seconds
@@ -1161,16 +1161,16 @@ function formatDate(ax, out, hover, extraPrecision) {
11611161 }
11621162 }
11631163
1164- if ( suffix ) {
1164+ if ( headPart ) {
11651165 if ( hover ) {
1166- // hover puts it all on one line, so suffix works best up front
1167- // except for year suffix : turn this into "Jan 1, 2000" etc.
1168- if ( tr === 'd' ) tt += ', ' + suffix ;
1169- else tt = suffix + ( tt ? ', ' + tt : '' ) ;
1170- }
1171- else if ( ! ax . _inCalcTicks || ( suffix !== ax . _prevSuffix ) ) {
1172- tt += '<br>' + suffix ;
1173- ax . _prevSuffix = suffix ;
1166+ // hover puts it all on one line, so headPart works best up front
1167+ // except for year headPart : turn this into "Jan 1, 2000" etc.
1168+ if ( tr === 'd' ) tt += ', ' + headPart ;
1169+ else tt = headPart + ( tt ? ', ' + tt : '' ) ;
1170+ }
1171+ else if ( ! ax . _inCalcTicks || ( headPart !== ax . _prevDateHead ) ) {
1172+ tt += '<br>' + headPart ;
1173+ ax . _prevDateHead = headPart ;
11741174 }
11751175 }
11761176 out . text = tt ;
0 commit comments