@@ -83,24 +83,29 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
83
83
return t . labels [ attr ] + Axes . hoverLabelText ( ya , trace [ attr ] [ i ] ) ;
84
84
}
85
85
86
- var textParts = [
86
+ var hoverinfo = trace . hoverinfo ;
87
+ var hoverParts = hoverinfo . split ( '+' ) ;
88
+ var isAll = hoverinfo === 'all' ;
89
+ var hasY = isAll || hoverParts . indexOf ( 'y' ) !== - 1 ;
90
+ var hasText = isAll || hoverParts . indexOf ( 'text' ) !== - 1 ;
91
+
92
+ var textParts = hasY ? [
87
93
getLabelLine ( 'open' ) ,
88
94
getLabelLine ( 'high' ) ,
89
95
getLabelLine ( 'low' ) ,
90
- getLabelLine ( 'close' )
91
- ] ;
92
- fillHoverText ( di , trace , textParts ) ;
93
- pointData . text = textParts . join ( '<br>' ) ;
96
+ getLabelLine ( 'close' ) + ' ' + DIRSYMBOL [ dir ]
97
+ ] : [ ] ;
98
+ if ( hasText ) fillHoverText ( di , trace , textParts ) ;
99
+
100
+ // don't make .yLabelVal or .text, since we're managing hoverinfo
101
+ // put it all in .extraText
102
+ pointData . extraText = textParts . join ( '<br>' ) ;
94
103
95
104
// this puts the label at the midpoint of the box, ie
96
105
// halfway between open and close, not between high and low.
97
106
// TODO: the spike also links to this point, whereas previously
98
107
// it linked to close. Is one better?
99
108
pointData . y0 = pointData . y1 = ya . c2p ( di . yc , true ) ;
100
109
101
- // indicate increasing/decreasing in the "name" field
102
- // TODO: only shows up if name is displayed, ie multiple traces.
103
- pointData . name += '<br>' + DIRSYMBOL [ dir ] ;
104
-
105
110
return [ pointData ] ;
106
111
} ;
0 commit comments