@@ -850,7 +850,8 @@ function autoTickRound(ax) {
850
850
// not necessarily *all* the information in tick0 though, if it's really odd
851
851
// minimal string length for tick0: 'd' is 10, 'M' is 16, 'S' is 19
852
852
// take off a leading minus (year < 0 so length is consistent)
853
- var tick0str = Lib . ms2DateTime ( Lib . dateTime2ms ( ax . tick0 ) ) . replace ( / ^ - / , '' ) ,
853
+ var tick0ms = Lib . dateTime2ms ( ax . tick0 ) ,
854
+ tick0str = Lib . ms2DateTime ( tick0ms ) . replace ( / ^ - / , '' ) ,
854
855
tick0len = tick0str . length ;
855
856
856
857
if ( String ( dtick ) . charAt ( 0 ) === 'M' ) {
@@ -862,7 +863,12 @@ function autoTickRound(ax) {
862
863
else if ( ( dtick >= ONEDAY && tick0len <= 10 ) || ( dtick >= ONEDAY * 15 ) ) ax . _tickround = 'd' ;
863
864
else if ( ( dtick >= ONEMIN && tick0len <= 16 ) || ( dtick >= ONEHOUR ) ) ax . _tickround = 'M' ;
864
865
else if ( ( dtick >= ONESEC && tick0len <= 19 ) || ( dtick >= ONEMIN ) ) ax . _tickround = 'S' ;
865
- else ax . _tickround = Math . max ( 3 - Math . round ( Math . log ( dtick / 2 ) / Math . LN10 ) , tick0len - 20 ) ;
866
+ else {
867
+ // of any two adjacent ticks, at least one will have the maximum fractional digits
868
+ // of all possible ticks - so take the max. length of tick0 and the next one
869
+ var tick1len = Lib . ms2DateTime ( tick0ms + dtick ) . replace ( / ^ - / , '' ) . length ;
870
+ ax . _tickround = Math . max ( tick0len , tick1len ) - 20 ;
871
+ }
866
872
}
867
873
else if ( isNumeric ( dtick ) || dtick . charAt ( 0 ) === 'L' ) {
868
874
// linear or log (except D1, D2)
@@ -1112,7 +1118,7 @@ function formatDate(ax, out, hover, extraPrecision) {
1112
1118
if ( tr !== 'M' ) {
1113
1119
tt += secondFormat ( d ) ;
1114
1120
if ( tr !== 'S' ) {
1115
- tt += numFormat ( mod ( x / 1000 , 1 ) , ax , 'none' , hover )
1121
+ tt += numFormat ( d3 . round ( mod ( x / 1000 , 1 ) , 4 ) , ax , 'none' , hover )
1116
1122
. substr ( 1 ) ;
1117
1123
}
1118
1124
}
0 commit comments