MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / tryUpdate

Function tryUpdate

src/interaction/findPointsAtX.ts:287–295  ·  view source on GitHub ↗
(idx: number, dxSq: number)

Source from the content-addressed store, hash-verified

285 let bestDxSq = maxDxSq;
286
287 const tryUpdate = (idx: number, dxSq: number) => {
288 if (!Number.isFinite(dxSq)) return;
289 const isBetter =
290 dxSq < bestDxSq || (dxSq === bestDxSq && (bestDataIndex < 0 || idx < bestDataIndex));
291 if (!isBetter) return;
292 bestDxSq = dxSq;
293 bestDataIndex = idx;
294 bestPoint = data[idx] as DataPoint;
295 };
296
297 // If the series contains NaN x values, binary search cannot be trusted (NaN breaks ordering).
298 // Fall back to a linear scan for correctness. Cached per data array for performance.

Callers 1

findPointsAtXFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected