@@ -1207,7 +1207,11 @@ axes.tickText = function(ax, x, hover) {
1207
1207
return showAttr !== 'all' && x !== first_or_last ;
1208
1208
}
1209
1209
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
+ }
1211
1215
1212
1216
if ( ax . type === 'date' ) formatDate ( ax , out , hover , extraPrecision ) ;
1213
1217
else if ( ax . type === 'log' ) formatLog ( ax , out , hover , extraPrecision , hideexp ) ;
@@ -1346,10 +1350,18 @@ function formatCategory(ax, out) {
1346
1350
}
1347
1351
1348
1352
function 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)
1353
1365
hideexp = 'hide' ;
1354
1366
}
1355
1367
out . text = numFormat ( out . x , ax , hideexp , extraPrecision ) ;
0 commit comments