(bounds: Bounds | null, points: ReadonlyArray<DataPoint>)
| 210 | }; |
| 211 | |
| 212 | const extendBoundsWithDataPoints = (bounds: Bounds | null, points: ReadonlyArray<DataPoint>): Bounds | null => { |
| 213 | if (points.length === 0) return bounds; |
| 214 | |
| 215 | let b = bounds; |
| 216 | if (!b) { |
| 217 | const seeded = computeRawBoundsFromData(points); |
| 218 | if (!seeded) return bounds; |
| 219 | b = seeded; |
| 220 | } |
| 221 | |
| 222 | let xMin = b.xMin; |
| 223 | let xMax = b.xMax; |
| 224 | let yMin = b.yMin; |
| 225 | let yMax = b.yMax; |
| 226 | |
| 227 | for (let i = 0; i < points.length; i++) { |
| 228 | const { x, y } = getPointXY(points[i]!); |
| 229 | if (!Number.isFinite(x) || !Number.isFinite(y)) continue; |
| 230 | if (x < xMin) xMin = x; |
| 231 | if (x > xMax) xMax = x; |
| 232 | if (y < yMin) yMin = y; |
| 233 | if (y > yMax) yMax = y; |
| 234 | } |
| 235 | |
| 236 | // Keep bounds usable for downstream scale derivation. |
| 237 | if (xMin === xMax) xMax = xMin + 1; |
| 238 | if (yMin === yMax) yMax = yMin + 1; |
| 239 | |
| 240 | return { xMin, xMax, yMin, yMax }; |
| 241 | }; |
| 242 | |
| 243 | const extendBoundsWithOHLCDataPoints = (bounds: Bounds | null, points: ReadonlyArray<OHLCDataPoint>): Bounds | null => { |
| 244 | if (points.length === 0) return bounds; |
no test coverage detected