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

Function insert

src/components/fx/hover.js:856–870  ·  view source on GitHub ↗
(newHd)

Source from the content-addressed store, hash-verified

854 var seen = {};
855 var id = 0;
856 var insert = function (newHd) {
857 var key = multipleHoverPoints[newHd.trace.type] ? hoverDataKey(newHd) : newHd.trace.index;
858 if (!seen[key]) {
859 id++;
860 seen[key] = id;
861 finalPoints.push(newHd);
862 } else {
863 var oldId = seen[key] - 1;
864 var oldHd = finalPoints[oldId];
865 if (oldId > 0 && Math.abs(newHd.distance) < Math.abs(oldHd.distance)) {
866 // replace with closest
867 finalPoints[oldId] = newHd;
868 }
869 }
870 };
871
872 var k;
873 // insert the winnig point(s) first

Callers 1

_hoverFunction · 0.70

Calls 1

hoverDataKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…