|
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 = { |
15 | 16 | increasing: '▲', |
16 | 17 | decreasing: '▼' |
17 | 18 | }; |
18 | 19 |
|
19 | | -function formatNumber(a) { |
20 | | - return parseFloat(a.toPrecision(10)); |
21 | | -} |
22 | | - |
23 | 20 | module.exports = function hoverPoints(pointData, xval, yval, hovermode) { |
24 | 21 | var point = hoverOnBars(pointData, xval, yval, hovermode); |
25 | 22 | if(!point) return; |
26 | 23 |
|
27 | 24 | var cd = point.cd; |
28 | 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 | + } |
29 | 33 |
|
30 | 34 | // the closest data point |
31 | 35 | var index = point.index; |
32 | 36 | var di = cd[index]; |
33 | 37 |
|
34 | | - var sizeLetter = (trace.orientation === 'h') ? 'x' : 'y'; |
| 38 | + var sizeLetter = isHorizontal ? 'x' : 'y'; |
35 | 39 |
|
36 | 40 | var size = (di.isSum) ? di.b + di.s : di.rawS; |
37 | 41 |
|
@@ -60,6 +64,6 @@ function getTraceColor(trace, di) { |
60 | 64 | var mc = cont.color; |
61 | 65 | var mlc = cont.line.color; |
62 | 66 | var mlw = cont.line.width; |
63 | | - if(Color.opacity(mc)) return mc; |
64 | | - else if(Color.opacity(mlc) && mlw) return mlc; |
| 67 | + if(opacity(mc)) return mc; |
| 68 | + else if(opacity(mlc) && mlw) return mlc; |
65 | 69 | } |
0 commit comments