@@ -1127,3 +1127,34 @@ lib.pseudoRandom = function() {
11271127 if ( Math . abs ( randSeed - lastVal ) < 429496729 ) return lib . pseudoRandom ( ) ;
11281128 return randSeed / 4294967296 ;
11291129} ;
1130+
1131+
1132+ /** Fill hover 'pointData' container with 'correct' hover text value
1133+ *
1134+ * - If trace hoverinfo contains a 'text' flag and hovertext is not set,
1135+ * the text elements will be seen in the hover labels.
1136+ *
1137+ * - If trace hoverinfo contains a 'text' flag and hovertext is set,
1138+ * hovertext takes precedence over text
1139+ * i.e. the hoverinfo elements will be seen in the hover labels
1140+ *
1141+ * @param {object } calcPt
1142+ * @param {object } trace
1143+ * @param {object || array } contOut (mutated here)
1144+ */
1145+ lib . fillText = function ( calcPt , trace , contOut ) {
1146+ var fill = Array . isArray ( contOut ) ?
1147+ function ( v ) { contOut . push ( v ) ; } :
1148+ function ( v ) { contOut . text = v ; } ;
1149+
1150+ var htx = lib . extractOption ( calcPt , trace , 'htx' , 'hovertext' ) ;
1151+ if ( lib . isValidTextValue ( htx ) ) return fill ( htx ) ;
1152+
1153+ var tx = lib . extractOption ( calcPt , trace , 'tx' , 'text' ) ;
1154+ if ( lib . isValidTextValue ( tx ) ) return fill ( tx ) ;
1155+ } ;
1156+
1157+ // accept all truthy values and 0 (which gets cast to '0' in the hover labels)
1158+ lib . isValidTextValue = function ( v ) {
1159+ return v || v === 0 ;
1160+ } ;
0 commit comments