@@ -1207,7 +1207,11 @@ axes.tickText = function(ax, x, hover) {
12071207 return showAttr !== 'all' && x !== first_or_last ;
12081208 }
12091209
1210- hideexp = ax . exponentformat !== 'none' && isHidden ( ax . showexponent ) ? 'hide' : '' ;
1210+ if ( hover ) {
1211+ hideexp = 'never' ;
1212+ } else {
1213+ hideexp = ax . exponentformat !== 'none' && isHidden ( ax . showexponent ) ? 'hide' : '' ;
1214+ }
12111215
12121216 if ( ax . type === 'date' ) formatDate ( ax , out , hover , extraPrecision ) ;
12131217 else if ( ax . type === 'log' ) formatLog ( ax , out , hover , extraPrecision , hideexp ) ;
@@ -1346,10 +1350,18 @@ function formatCategory(ax, out) {
13461350}
13471351
13481352function formatLinear ( ax , out , hover , extraPrecision , hideexp ) {
1349- // don't add an exponent to zero if we're showing all exponents
1350- // so the only reason you'd show an exponent on zero is if it's the
1351- // ONLY tick to get an exponent (first or last)
1352- if ( ax . showexponent === 'all' && Math . abs ( out . x / ax . dtick ) < 1e-6 ) {
1353+ if ( hideexp === 'never' ) {
1354+ // If this is a hover label, then we must *never* hide the exponent
1355+ // for the sake of display, which could give the wrong value by
1356+ // potentially many orders of magnitude. If hideexp was 'never', then
1357+ // it's now succeeded by preventing the other condition from automating
1358+ // this choice. Thus we can unset it so that the axis formatting takes
1359+ // precedence.
1360+ hideexp = '' ;
1361+ } else if ( ax . showexponent === 'all' && Math . abs ( out . x / ax . dtick ) < 1e-6 ) {
1362+ // don't add an exponent to zero if we're showing all exponents
1363+ // so the only reason you'd show an exponent on zero is if it's the
1364+ // ONLY tick to get an exponent (first or last)
13531365 hideexp = 'hide' ;
13541366 }
13551367 out . text = numFormat ( out . x , ax , hideexp , extraPrecision ) ;
0 commit comments