@@ -14,9 +14,9 @@ var Axes = require('../../plots/cartesian/axes');
14
14
var BADNUM = require ( '../../constants/numerical' ) . BADNUM ;
15
15
16
16
var getTraceColor = require ( '../scatter/get_trace_color' ) ;
17
+ var fillHoverText = require ( '../scatter/fill_hover_text' ) ;
17
18
var attributes = require ( './attributes' ) ;
18
19
19
-
20
20
module . exports = function hoverPoints ( pointData , xval , yval ) {
21
21
var cd = pointData . cd ;
22
22
var trace = cd [ 0 ] . trace ;
@@ -71,39 +71,34 @@ module.exports = function hoverPoints(pointData, xval, yval) {
71
71
} ;
72
72
73
73
function getExtraText ( trace , pt , axis ) {
74
- var hoverinfo = trace . hoverinfo ;
74
+ var hoverinfo = pt . hi || trace . hoverinfo ;
75
75
76
- var parts = ( hoverinfo === 'all' ) ?
76
+ var parts = hoverinfo === 'all' ?
77
77
attributes . hoverinfo . flags :
78
78
hoverinfo . split ( '+' ) ;
79
79
80
- var hasLocation = parts . indexOf ( 'location' ) !== - 1 && Array . isArray ( trace . locations ) ,
81
- hasLon = ( parts . indexOf ( 'lon' ) !== - 1 ) ,
82
- hasLat = ( parts . indexOf ( 'lat' ) !== - 1 ) ,
83
- hasText = ( parts . indexOf ( 'text' ) !== - 1 ) ;
84
-
80
+ var hasLocation = parts . indexOf ( 'location' ) !== - 1 && Array . isArray ( trace . locations ) ;
81
+ var hasLon = ( parts . indexOf ( 'lon' ) !== - 1 ) ;
82
+ var hasLat = ( parts . indexOf ( 'lat' ) !== - 1 ) ;
83
+ var hasText = ( parts . indexOf ( 'text' ) !== - 1 ) ;
85
84
var text = [ ] ;
86
85
87
86
function format ( val ) {
88
87
return Axes . tickText ( axis , axis . c2l ( val ) , 'hover' ) . text + '\u00B0' ;
89
88
}
90
89
91
- if ( hasLocation ) text . push ( pt . loc ) ;
92
- else if ( hasLon && hasLat ) {
90
+ if ( hasLocation ) {
91
+ text . push ( pt . loc ) ;
92
+ } else if ( hasLon && hasLat ) {
93
93
text . push ( '(' + format ( pt . lonlat [ 0 ] ) + ', ' + format ( pt . lonlat [ 1 ] ) + ')' ) ;
94
+ } else if ( hasLon ) {
95
+ text . push ( 'lon: ' + format ( pt . lonlat [ 0 ] ) ) ;
96
+ } else if ( hasLat ) {
97
+ text . push ( 'lat: ' + format ( pt . lonlat [ 1 ] ) ) ;
94
98
}
95
- else if ( hasLon ) text . push ( 'lon: ' + format ( pt . lonlat [ 0 ] ) ) ;
96
- else if ( hasLat ) text . push ( 'lat: ' + format ( pt . lonlat [ 1 ] ) ) ;
97
99
98
100
if ( hasText ) {
99
- var tx ;
100
-
101
- if ( pt . htx ) tx = pt . htx ;
102
- else if ( trace . hovertext ) tx = trace . hovertext ;
103
- else if ( pt . tx ) tx = pt . tx ;
104
- else if ( trace . text ) tx = trace . text ;
105
-
106
- if ( ! Array . isArray ( tx ) ) text . push ( tx ) ;
101
+ fillHoverText ( pt , trace , text ) ;
107
102
}
108
103
109
104
return text . join ( '<br>' ) ;
0 commit comments