(baseThreshold: number, spanFrac: number)
| 118 | const formatPercent = (n: number): string => `${n.toFixed(2)}%`; |
| 119 | |
| 120 | const computeZoomAwareTarget = (baseThreshold: number, spanFrac: number): number => { |
| 121 | // Mirrors createRenderCoordinator’s behavior: |
| 122 | // - baseline target is samplingThreshold at full span |
| 123 | // - zooming in increases target ~ 1/spanFrac |
| 124 | // - capped to avoid pathological allocations |
| 125 | const MIN_TARGET_POINTS = 2; |
| 126 | const MAX_TARGET_POINTS_ABS = 200_000; |
| 127 | const MAX_TARGET_MULTIPLIER = 32; |
| 128 | const spanFracSafe = Math.max(1e-3, Math.min(1, spanFrac)); |
| 129 | |
| 130 | const baseT = Number.isFinite(baseThreshold) ? Math.max(1, baseThreshold | 0) : 1; |
| 131 | const maxTarget = Math.min(MAX_TARGET_POINTS_ABS, Math.max(MIN_TARGET_POINTS, baseT * MAX_TARGET_MULTIPLIER)); |
| 132 | return clampInt(Math.round(baseT / spanFracSafe), MIN_TARGET_POINTS, maxTarget); |
| 133 | }; |
| 134 | |
| 135 | const updateReadouts = ( |
| 136 | rawPointCount: number, |
no test coverage detected