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

Function updateReadouts

examples/sampling/main.ts:135–161  ·  view source on GitHub ↗
(
  rawPointCount: number,
  xMax: number,
  controls: SamplingControls,
  zoom: { start: number; end: number } | null
)

Source from the content-addressed store, hash-verified

133};
134
135const updateReadouts = (
136 rawPointCount: number,
137 xMax: number,
138 controls: SamplingControls,
139 zoom: { start: number; end: number } | null
140): void => {
141 const start = zoom?.start ?? 0;
142 const end = zoom?.end ?? 100;
143 const span = Math.max(0, Math.min(100, end) - Math.max(0, start));
144 const spanFrac = Math.max(0, Math.min(1, span / 100));
145
146 // With x = index and an explicit x-domain [0..xMax], visible points are ~ proportional to span.
147 const visibleRaw = Math.max(2, Math.floor(rawPointCount * spanFrac));
148 const target = controls.mode === 'none' ? visibleRaw : computeZoomAwareTarget(controls.threshold, spanFrac);
149 const expectedRendered = controls.mode === 'none' ? visibleRaw : Math.min(visibleRaw, target);
150
151 setText('totalPoints', formatInt(rawPointCount));
152 setText('xDomain', `0 → ${formatInt(xMax)}`);
153 setText('samplingResolved', controls.mode);
154 setText('samplingThresholdResolved', formatInt(controls.threshold));
155
156 setText('zoomRange', `${formatPercent(start)} → ${formatPercent(end)}`);
157 setText('zoomSpan', `${formatPercent(span)} (of full span)`);
158 setText('visibleRawPoints', formatInt(visibleRaw));
159 setText('targetPoints', controls.mode === 'none' ? '— (sampling: none)' : formatInt(target));
160 setText('expectedRendered', formatInt(expectedRendered));
161};
162
163async function main(): Promise<void> {
164 const container = document.getElementById('chart');

Callers 3

applyFunction · 0.85
tickFunction · 0.85
mainFunction · 0.85

Calls 4

formatPercentFunction · 0.85
computeZoomAwareTargetFunction · 0.70
setTextFunction · 0.70
formatIntFunction · 0.70

Tested by

no test coverage detected