MCPcopy Index your code
hub / github.com/plotly/plotly.js / _hover

Function _hover

src/components/fx/hover.js:267–984  ·  view source on GitHub ↗
(gd, evt, subplot, noHoverEvent, eventTarget)

Source from the content-addressed store, hash-verified

265
266// The actual implementation is here:
267function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
268 if (!subplot) subplot = 'xy';
269
270 if (typeof subplot === 'string') {
271 // drop zindex from subplot id
272 subplot = subplot.split(zindexSeparator)[0];
273 }
274
275 // if the user passed in an array of subplots,
276 // use those instead of finding overlayed plots
277 var subplots = Array.isArray(subplot) ? subplot : [subplot];
278
279 var spId;
280
281 var fullLayout = gd._fullLayout;
282 var hoversubplots = fullLayout.hoversubplots;
283 var plots = fullLayout._plots || [];
284 var plotinfo = plots[subplot];
285 var hasCartesian = fullLayout._has('cartesian');
286
287 var hovermode = evt.hovermode || fullLayout.hovermode;
288 var hovermodeHasX = (hovermode || '').charAt(0) === 'x';
289 var hovermodeHasY = (hovermode || '').charAt(0) === 'y';
290
291 var firstXaxis;
292 var firstYaxis;
293
294 if (hasCartesian && (hovermodeHasX || hovermodeHasY) && hoversubplots === 'axis') {
295 var subplotsLength = subplots.length;
296 for (var p = 0; p < subplotsLength; p++) {
297 spId = subplots[p];
298 if (plots[spId]) {
299 // 'cartesian' case
300
301 firstXaxis = Axes.getFromId(gd, spId, 'x');
302 firstYaxis = Axes.getFromId(gd, spId, 'y');
303
304 var subplotsWith = (hovermodeHasX ? firstXaxis : firstYaxis)._subplotsWith;
305
306 if (subplotsWith && subplotsWith.length) {
307 for (var q = 0; q < subplotsWith.length; q++) {
308 pushUnique(subplots, subplotsWith[q]);
309 }
310 }
311 }
312 }
313 }
314
315 // list of all overlaid subplots to look at
316 if (plotinfo && hoversubplots !== 'single') {
317 var overlayedSubplots = plotinfo.overlays.map(function (pi) {
318 return pi.id;
319 });
320
321 subplots = subplots.concat(overlayedSubplots);
322 }
323
324 var len = subplots.length;

Callers 1

hover.jsFile · 0.70

Calls 15

findHoverPointsFunction · 0.85
sortHoverDataFunction · 0.85
selectClosestPointFunction · 0.85
fillSpikePointFunction · 0.85
spikesChangedFunction · 0.85
createSpikelinesFunction · 0.85
emitHoverFunction · 0.85
getCoordFunction · 0.85
getTopOffsetFunction · 0.85
getLeftOffsetFunction · 0.85
createHoverTextFunction · 0.85
hoverAvoidOverlapsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…