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

Function updateBinnedReadout

examples/scatter-density-1m/main.ts:139–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137 let lastBinnedText = '';
138 let lastUpdateMs = 0;
139 const updateBinnedReadout = (): void => {
140 const zoom = chart.getZoomRange();
141 const startPct = Math.max(0, Math.min(100, zoom?.start ?? 0));
142 const endPct = Math.max(0, Math.min(100, zoom?.end ?? 100));
143 const a = Math.min(startPct, endPct) / 100;
144 const b = Math.max(startPct, endPct) / 100;
145
146 const visibleXMin = xMin + a * xSpan;
147 const visibleXMax = xMin + b * xSpan;
148 const i0 = lowerBoundByX(points, visibleXMin);
149 const i1 = upperBoundByX(points, visibleXMax);
150 const visibleCount = Math.max(0, i1 - i0);
151
152 const text = fmt.format(visibleCount);
153 if (text !== lastBinnedText) {
154 lastBinnedText = text;
155 binnedPointsEl.textContent = text;
156 }
157 };
158
159 // Update frequently while rendering, but throttle DOM writes.
160 chart.onPerformanceUpdate(() => {

Callers 1

mainFunction · 0.85

Calls 3

lowerBoundByXFunction · 0.85
upperBoundByXFunction · 0.85
getZoomRangeMethod · 0.65

Tested by

no test coverage detected