@@ -12,13 +12,13 @@ var Lib = require('../../lib');
12
12
13
13
// look for either subplot or xaxis and yaxis attributes
14
14
// does not handle splom case
15
- exports . getSubplot = function getSubplot ( trace ) {
15
+ exports . getSubplot = function ( trace ) {
16
16
return trace . subplot || ( trace . xaxis + trace . yaxis ) || trace . geo ;
17
17
} ;
18
18
19
19
// is trace in given list of subplots?
20
20
// does handle splom case
21
- exports . isTraceInSubplots = function isTraceInSubplots ( trace , subplots ) {
21
+ exports . isTraceInSubplots = function ( trace , subplots ) {
22
22
if ( trace . type === 'splom' ) {
23
23
var xaxes = trace . xaxes || [ ] ;
24
24
var yaxes = trace . yaxes || [ ] ;
@@ -36,28 +36,28 @@ exports.isTraceInSubplots = function isTraceInSubplots(trace, subplots) {
36
36
} ;
37
37
38
38
// convenience functions for mapping all relevant axes
39
- exports . flat = function flat ( subplots , v ) {
39
+ exports . flat = function ( subplots , v ) {
40
40
var out = new Array ( subplots . length ) ;
41
41
for ( var i = 0 ; i < subplots . length ; i ++ ) {
42
42
out [ i ] = v ;
43
43
}
44
44
return out ;
45
45
} ;
46
46
47
- exports . p2c = function p2c ( axArray , v ) {
47
+ exports . p2c = function ( axArray , v ) {
48
48
var out = new Array ( axArray . length ) ;
49
49
for ( var i = 0 ; i < axArray . length ; i ++ ) {
50
50
out [ i ] = axArray [ i ] . p2c ( v ) ;
51
51
}
52
52
return out ;
53
53
} ;
54
54
55
- exports . getDistanceFunction = function getDistanceFunction ( mode , dx , dy , dxy ) {
55
+ exports . getDistanceFunction = function ( mode , dx , dy , dxy ) {
56
56
if ( mode === 'closest' ) return dxy || exports . quadrature ( dx , dy ) ;
57
57
return mode . charAt ( 0 ) === 'x' ? dx : dy ;
58
58
} ;
59
59
60
- exports . getClosest = function getClosest ( cd , distfn , pointData ) {
60
+ exports . getClosest = function ( cd , distfn , pointData ) {
61
61
// do we already have a point number? (array mode only)
62
62
if ( pointData . index !== false ) {
63
63
if ( pointData . index >= 0 && pointData . index < cd . length ) {
@@ -87,11 +87,11 @@ exports.getClosest = function getClosest(cd, distfn, pointData) {
87
87
* @param {number } v1: signed difference between the current position and the right edge
88
88
* @param {number } passVal: the value to return on success
89
89
*/
90
- exports . inbox = function inbox ( v0 , v1 , passVal ) {
90
+ exports . inbox = function ( v0 , v1 , passVal ) {
91
91
return ( v0 * v1 < 0 || v0 === 0 ) ? passVal : Infinity ;
92
92
} ;
93
93
94
- exports . quadrature = function quadrature ( dx , dy ) {
94
+ exports . quadrature = function ( dx , dy ) {
95
95
return function ( di ) {
96
96
var x = dx ( di ) ;
97
97
var y = dy ( di ) ;
@@ -114,7 +114,7 @@ exports.quadrature = function quadrature(dx, dy) {
114
114
* @param {object } cd
115
115
* @return {object }
116
116
*/
117
- exports . makeEventData = function makeEventData ( pt , trace , cd ) {
117
+ exports . makeEventData = function ( pt , trace , cd ) {
118
118
// hover uses 'index', select uses 'pointNumber'
119
119
var pointNumber = 'index' in pt ? pt . index : pt . pointNumber ;
120
120
@@ -238,3 +238,23 @@ function getPointData(val, pointNumber) {
238
238
return val [ pointNumber ] ;
239
239
}
240
240
}
241
+
242
+ var xyHoverMode = {
243
+ x : true ,
244
+ y : true
245
+ } ;
246
+
247
+ var unifiedHoverMode = {
248
+ 'x unified' : true ,
249
+ 'y unified' : true
250
+ } ;
251
+
252
+ exports . isUnifiedHover = function ( hovermode ) {
253
+ if ( typeof hovermode !== 'string' ) return false ;
254
+ return ! ! unifiedHoverMode [ hovermode ] ;
255
+ } ;
256
+
257
+ exports . isXYhover = function ( hovermode ) {
258
+ if ( typeof hovermode !== 'string' ) return false ;
259
+ return ! ! xyHoverMode [ hovermode ] ;
260
+ } ;
0 commit comments