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

Function updateTotalPointsDisplay

examples/worker-rendering/main.ts:222–261  ·  view source on GitHub ↗

* Updates the total points display to show actual rendered points or calculated from inputs. * * Behavior: * - When actualCount is provided: Shows the live/actual count from state.totalPointsGenerated * - When actualCount is undefined: Calculates from input fields (pointCount × seriesCount) *

(actualCount?: number)

Source from the content-addressed store, hash-verified

220 * @param actualCount Optional actual count from state. If not provided, calculates from inputs.
221 */
222function updateTotalPointsDisplay(actualCount?: number): void {
223 // Throttle updates to prevent jank during high-frequency streaming
224 const now = performance.now();
225 if (actualCount !== undefined && now - lastDisplayUpdate < DISPLAY_UPDATE_THROTTLE_MS) {
226 return;
227 }
228 lastDisplayUpdate = now;
229
230 const totalPoints = actualCount !== undefined
231 ? actualCount
232 : (parseInt((document.getElementById('pointCount') as HTMLInputElement).value) || 0) *
233 (parseInt((document.getElementById('seriesCount') as HTMLInputElement).value) || 0);
234
235 const valueEl = document.getElementById('totalPointsValue');
236 const hintEl = document.getElementById('totalPointsHint');
237
238 if (!valueEl || !hintEl) return;
239
240 // Format the full number with commas
241 const formattedNumber = formatNumber(totalPoints);
242
243 // Format the abbreviated version
244 const abbreviatedNumber = formatAbbreviatedNumber(totalPoints);
245
246 // Update display
247 valueEl.textContent = formattedNumber;
248 hintEl.textContent = `${abbreviatedNumber} points`;
249
250 // Warning thresholds
251 if (totalPoints > 1_000_000_000) {
252 // Extreme: > 1B points
253 valueEl.setAttribute('data-warning', 'extreme');
254 } else if (totalPoints > 100_000_000) {
255 // High: > 100M points
256 valueEl.setAttribute('data-warning', 'true');
257 } else {
258 // Normal
259 valueEl.setAttribute('data-warning', 'false');
260 }
261}
262
263// ============================================================================
264// Data Generation

Callers 6

handleGenerateFunction · 0.85
streamFrameFunction · 0.85
stopStreamingFunction · 0.85
handleClearFunction · 0.85
handleEmergencyStopFunction · 0.85
initFunction · 0.85

Calls 2

formatAbbreviatedNumberFunction · 0.85
formatNumberFunction · 0.70

Tested by

no test coverage detected