@@ -77,7 +77,7 @@ exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
7777} ;
7878
7979/*
80- * Draw a single hover item in a pre-existing svg container somewhere
80+ * Draw a single hover item or an array of hover item in a pre-existing svg container somewhere
8181 * hoverItem should have keys:
8282 * - x and y (or x0, x1, y0, and y1):
8383 * the pixel position to mark, relative to opts.container
@@ -104,14 +104,15 @@ exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
104104 * - outerContainer:
105105 * normally a parent of `container`, sets the bounding box to use to
106106 * constrain the hover label and determine whether to show it on the left or right
107+ * opts can have optional keys:
108+ * - anchorIndex:
109+ the index of the hover item used as an anchor for positioning.
110+ The other hover items will be pushed up or down to prevent overlap.
107111 */
108- exports . loneHover = function loneHover ( hoverItem , opts ) {
109- var hoverLabel = exports . multiHovers ( hoverItem , opts ) ;
110- return hoverLabel . node ( ) ;
111- } ;
112-
113- exports . multiHovers = function multiHovers ( hoverItems , opts ) {
112+ exports . loneHover = function loneHover ( hoverItems , opts ) {
113+ var multiHover = true ;
114114 if ( ! Array . isArray ( hoverItems ) ) {
115+ multiHover = false ;
115116 hoverItems = [ hoverItems ] ;
116117 }
117118
@@ -190,7 +191,7 @@ exports.multiHovers = function multiHovers(hoverItems, opts) {
190191
191192 alignHoverText ( hoverLabel , fullOpts . rotateLabels ) ;
192193
193- return hoverLabel ;
194+ return multiHover ? hoverLabel : hoverLabel . node ( ) ;
194195} ;
195196
196197// The actual implementation is here:
0 commit comments