()
| 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(() => { |
no test coverage detected