8
8
9
9
'use strict' ;
10
10
11
- var Color = require ( '../../components/color' ) ;
11
+ var hoverLabelText = require ( '../../plots/cartesian/axes' ) . hoverLabelText ;
12
+ var opacity = require ( '../../components/color' ) . opacity ;
12
13
var hoverOnBars = require ( '../bar/hover' ) . hoverOnBars ;
13
14
14
15
var DIRSYMBOL = {
@@ -22,28 +23,35 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
22
23
23
24
var cd = point . cd ;
24
25
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
+ }
25
33
26
34
// the closest data point
27
35
var index = point . index ;
28
36
var di = cd [ index ] ;
29
37
30
- var sizeLetter = ( trace . orientation === 'h' ) ? 'x' : 'y' ;
38
+ var sizeLetter = isHorizontal ? 'x' : 'y' ;
31
39
32
40
var size = ( di . isSum ) ? di . b + di . s : di . rawS ;
33
41
34
42
if ( ! di . isSum ) {
35
43
// format delta numbers:
36
44
if ( size > 0 ) {
37
- point . extraText = size + ' ' + DIRSYMBOL . increasing ;
45
+ point . extraText = formatNumber ( size ) + ' ' + DIRSYMBOL . increasing ;
38
46
} else if ( size < 0 ) {
39
- point . extraText = '(' + ( - size ) + ') ' + DIRSYMBOL . decreasing ;
47
+ point . extraText = '(' + ( formatNumber ( - size ) ) + ') ' + DIRSYMBOL . decreasing ;
40
48
} else {
41
49
return ;
42
50
}
43
51
// display initial value
44
- point . extraText += '<br>Initial: ' + ( di . b + di . s - size ) ;
52
+ point . extraText += '<br>Initial: ' + formatNumber ( di . b + di . s - size ) ;
45
53
} else {
46
- point [ sizeLetter + 'LabelVal' ] = size ;
54
+ point [ sizeLetter + 'LabelVal' ] = formatNumber ( size ) ;
47
55
}
48
56
49
57
point . color = getTraceColor ( trace , di ) ;
@@ -56,6 +64,6 @@ function getTraceColor(trace, di) {
56
64
var mc = cont . color ;
57
65
var mlc = cont . line . color ;
58
66
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 ;
61
69
}
0 commit comments