88
99'use strict' ;
1010
11- var Color = require ( '../../components/color' ) ;
11+ var hoverLabelText = require ( '../../plots/cartesian/axes' ) . hoverLabelText ;
12+ var opacity = require ( '../../components/color' ) . opacity ;
1213var hoverOnBars = require ( '../bar/hover' ) . hoverOnBars ;
1314
1415var DIRSYMBOL = {
@@ -22,28 +23,35 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
2223
2324 var cd = point . cd ;
2425 var trace = cd [ 0 ] . trace ;
26+ var isHorizontal = ( trace . orientation === 'h' ) ;
27+
28+ var vAxis = isHorizontal ? pointData . xa : pointData . ya ;
29+
30+ function formatNumber ( a ) {
31+ return hoverLabelText ( vAxis , a ) ;
32+ }
2533
2634 // the closest data point
2735 var index = point . index ;
2836 var di = cd [ index ] ;
2937
30- var sizeLetter = ( trace . orientation === 'h' ) ? 'x' : 'y' ;
38+ var sizeLetter = isHorizontal ? 'x' : 'y' ;
3139
3240 var size = ( di . isSum ) ? di . b + di . s : di . rawS ;
3341
3442 if ( ! di . isSum ) {
3543 // format delta numbers:
3644 if ( size > 0 ) {
37- point . extraText = size + ' ' + DIRSYMBOL . increasing ;
45+ point . extraText = formatNumber ( size ) + ' ' + DIRSYMBOL . increasing ;
3846 } else if ( size < 0 ) {
39- point . extraText = '(' + ( - size ) + ') ' + DIRSYMBOL . decreasing ;
47+ point . extraText = '(' + ( formatNumber ( - size ) ) + ') ' + DIRSYMBOL . decreasing ;
4048 } else {
4149 return ;
4250 }
4351 // display initial value
44- point . extraText += '<br>Initial: ' + ( di . b + di . s - size ) ;
52+ point . extraText += '<br>Initial: ' + formatNumber ( di . b + di . s - size ) ;
4553 } else {
46- point [ sizeLetter + 'LabelVal' ] = size ;
54+ point [ sizeLetter + 'LabelVal' ] = formatNumber ( size ) ;
4755 }
4856
4957 point . color = getTraceColor ( trace , di ) ;
@@ -56,6 +64,6 @@ function getTraceColor(trace, di) {
5664 var mc = cont . color ;
5765 var mlc = cont . line . color ;
5866 var mlw = cont . line . width ;
59- if ( Color . opacity ( mc ) ) return mc ;
60- else if ( Color . opacity ( mlc ) && mlw ) return mlc ;
67+ if ( opacity ( mc ) ) return mc ;
68+ else if ( opacity ( mlc ) && mlw ) return mlc ;
6169}
0 commit comments