@@ -83,24 +83,29 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
8383 return t . labels [ attr ] + Axes . hoverLabelText ( ya , trace [ attr ] [ i ] ) ;
8484 }
8585
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 ? [
8793 getLabelLine ( 'open' ) ,
8894 getLabelLine ( 'high' ) ,
8995 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>' ) ;
94103
95104 // this puts the label at the midpoint of the box, ie
96105 // halfway between open and close, not between high and low.
97106 // TODO: the spike also links to this point, whereas previously
98107 // it linked to close. Is one better?
99108 pointData . y0 = pointData . y1 = ya . c2p ( di . yc , true ) ;
100109
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-
105110 return [ pointData ] ;
106111} ;
0 commit comments