(
rawPointCount: number,
xMax: number,
controls: SamplingControls,
zoom: { start: number; end: number } | null
)
| 133 | }; |
| 134 | |
| 135 | const 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 | |
| 163 | async function main(): Promise<void> { |
| 164 | const container = document.getElementById('chart'); |
no test coverage detected