Skip to content

Commit 9e4b128

Browse files
committed
replace Fx.multiHovers by Fx.loneHover
1 parent 26bc2bf commit 9e4b128

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/components/fx/hover.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -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:

src/components/fx/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ module.exports = {
4646
unhover: dragElement.unhover,
4747

4848
loneHover: hoverModule.loneHover,
49-
multiHovers: hoverModule.multiHovers,
5049
loneUnhover: loneUnhover,
5150

5251
click: require('./click')

src/traces/parcats/parcats.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ function mouseoverCategoryBand(bandViewModel) {
969969
}
970970

971971
if(hoverItems) {
972-
Fx.multiHovers(hoverItems, {
972+
Fx.loneHover(hoverItems, {
973973
container: fullLayout._hoverlayer.node(),
974974
outerContainer: fullLayout._paper.node(),
975975
gd: gd

src/traces/sankey/plot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ module.exports = function plot(gd, calcData) {
221221
});
222222
}
223223

224-
var tooltips = Fx.multiHovers(hoverItems, {
224+
var tooltips = Fx.loneHover(hoverItems, {
225225
container: fullLayout._hoverlayer.node(),
226226
outerContainer: fullLayout._paper.node(),
227227
gd: gd,

0 commit comments

Comments
 (0)