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