@@ -14,9 +14,9 @@ var Axes = require('../../plots/cartesian/axes');
1414var BADNUM = require ( '../../constants/numerical' ) . BADNUM ;
1515
1616var getTraceColor = require ( '../scatter/get_trace_color' ) ;
17+ var fillHoverText = require ( '../scatter/fill_hover_text' ) ;
1718var attributes = require ( './attributes' ) ;
1819
19-
2020module . exports = function hoverPoints ( pointData , xval , yval ) {
2121 var cd = pointData . cd ;
2222 var trace = cd [ 0 ] . trace ;
@@ -71,39 +71,34 @@ module.exports = function hoverPoints(pointData, xval, yval) {
7171} ;
7272
7373function getExtraText ( trace , pt , axis ) {
74- var hoverinfo = trace . hoverinfo ;
74+ var hoverinfo = pt . hi || trace . hoverinfo ;
7575
76- var parts = ( hoverinfo === 'all' ) ?
76+ var parts = hoverinfo === 'all' ?
7777 attributes . hoverinfo . flags :
7878 hoverinfo . split ( '+' ) ;
7979
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 ) ;
8584 var text = [ ] ;
8685
8786 function format ( val ) {
8887 return Axes . tickText ( axis , axis . c2l ( val ) , 'hover' ) . text + '\u00B0' ;
8988 }
9089
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 ) {
9393 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 ] ) ) ;
9498 }
95- else if ( hasLon ) text . push ( 'lon: ' + format ( pt . lonlat [ 0 ] ) ) ;
96- else if ( hasLat ) text . push ( 'lat: ' + format ( pt . lonlat [ 1 ] ) ) ;
9799
98100 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 ) ;
107102 }
108103
109104 return text . join ( '<br>' ) ;
0 commit comments