@@ -77,7 +77,7 @@ exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
77
77
} ;
78
78
79
79
/*
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
81
81
* hoverItem should have keys:
82
82
* - x and y (or x0, x1, y0, and y1):
83
83
* the pixel position to mark, relative to opts.container
@@ -104,14 +104,15 @@ exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
104
104
* - outerContainer:
105
105
* normally a parent of `container`, sets the bounding box to use to
106
106
* 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.
107
111
*/
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 ;
114
114
if ( ! Array . isArray ( hoverItems ) ) {
115
+ multiHover = false ;
115
116
hoverItems = [ hoverItems ] ;
116
117
}
117
118
@@ -190,7 +191,7 @@ exports.multiHovers = function multiHovers(hoverItems, opts) {
190
191
191
192
alignHoverText ( hoverLabel , fullOpts . rotateLabels ) ;
192
193
193
- return hoverLabel ;
194
+ return multiHover ? hoverLabel : hoverLabel . node ( ) ;
194
195
} ;
195
196
196
197
// The actual implementation is here:
0 commit comments