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

Function findHoverPoints

src/components/fx/hover.js:496–710  ·  view source on GitHub ↗
(customXVal, customYVal)

Source from the content-addressed store, hash-verified

494 // this is minimum dx and/or dy, depending on mode
495 // and the pixel position for the label (labelXpx, labelYpx)
496 function findHoverPoints(customXVal, customYVal) {
497 for (curvenum = 0; curvenum < searchData.length; curvenum++) {
498 cd = searchData[curvenum];
499
500 // filter out invisible or broken data
501 if (!cd || !cd[0] || !cd[0].trace) continue;
502
503 trace = cd[0].trace;
504
505 if (trace.visible !== true || trace._length === 0) continue;
506
507 // Explicitly bail out for these two. I don't know how to otherwise prevent
508 // the rest of this function from running and failing
509 if (['carpet', 'contourcarpet'].indexOf(trace._module.name) !== -1) continue;
510
511 // within one trace mode can sometimes be overridden
512 _mode = hovermode;
513 if (helpers.isUnifiedHover(_mode)) {
514 _mode = _mode.charAt(0);
515 }
516
517 if (trace.type === 'splom') {
518 // splom traces do not generate overlay subplots,
519 // it is safe to assume here splom traces correspond to the 0th subplot
520 subploti = 0;
521 subplotId = subplots[subploti];
522 } else {
523 subplotId = helpers.getSubplot(trace);
524 subploti = subplots.indexOf(subplotId);
525 }
526
527 // container for new point, also used to pass info into module.hoverPoints
528 pointData = {
529 // trace properties
530 cd: cd,
531 trace: trace,
532 xa: xaArray[subploti],
533 ya: yaArray[subploti],
534
535 // max distances for hover and spikes - for points that want to show but do not
536 // want to override other points, set distance/spikeDistance equal to max*Distance
537 // and it will not get filtered out but it will be guaranteed to have a greater
538 // distance than any point that calculated a real distance.
539 maxHoverDistance: hoverdistance,
540 maxSpikeDistance: spikedistance,
541
542 // point properties - override all of these
543 index: false, // point index in trace - only used by plotly.js hoverdata consumers
544 distance: Math.min(distance, hoverdistance), // pixel distance or pseudo-distance
545
546 // distance/pseudo-distance for spikes. This distance should always be calculated
547 // as if in "closest" mode, and should only be set if this point should
548 // generate a spike.
549 spikeDistance: Infinity,
550
551 // in some cases the spikes have different positioning from the hover label
552 // they don't need x0/x1, just one position
553 xSpike: undefined,

Callers 1

_hoverFunction · 0.85

Calls 2

cleanPointFunction · 0.85
fillSpikePointFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…