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

Function distFn

src/traces/scattergeo/hover.js:20–36  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

18 var project = geo.project;
19
20 function distFn(d) {
21 var lonlat = d.lonlat;
22
23 if(lonlat[0] === BADNUM) return Infinity;
24 if(isLonLatOverEdges(lonlat)) return Infinity;
25
26 var pt = project(lonlat);
27 var px = project([xval, yval]);
28 var dx = Math.abs(pt[0] - px[0]);
29 var dy = Math.abs(pt[1] - px[1]);
30 var rad = Math.max(3, d.mrc || 0);
31
32 // N.B. d.mrc is the calculated marker radius
33 // which is only set for trace with 'markers' mode.
34
35 return Math.max(Math.sqrt(dx * dx + dy * dy) - rad, 1 - 3 / rad);
36 }
37
38 Fx.getClosest(cd, distFn, pointData);
39

Callers

nothing calls this directly

Calls 1

projectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…