(bounds: Bounds | null, points: ReadonlyArray<DataPoint>)
| 313 | }; |
| 314 | |
| 315 | const extendBoundsWithDataPoints = (bounds: Bounds | null, points: ReadonlyArray<DataPoint>): Bounds | null => { |
| 316 | if (points.length === 0) return bounds; |
| 317 | |
| 318 | let b = bounds; |
| 319 | if (!b) { |
| 320 | // Try to seed from the appended points. |
| 321 | const seeded = computeRawBoundsFromData(points); |
| 322 | if (!seeded) return bounds; |
| 323 | b = seeded; |
| 324 | } |
| 325 | |
| 326 | let xMin = b.xMin; |
| 327 | let xMax = b.xMax; |
| 328 | let yMin = b.yMin; |
| 329 | let yMax = b.yMax; |
| 330 | |
| 331 | for (let i = 0; i < points.length; i++) { |
| 332 | const { x, y } = getPointXY(points[i]!); |
| 333 | if (!Number.isFinite(x) || !Number.isFinite(y)) continue; |
| 334 | if (x < xMin) xMin = x; |
| 335 | if (x > xMax) xMax = x; |
| 336 | if (y < yMin) yMin = y; |
| 337 | if (y > yMax) yMax = y; |
| 338 | } |
| 339 | |
| 340 | // Keep bounds usable for downstream scale derivation. |
| 341 | if (xMin === xMax) xMax = xMin + 1; |
| 342 | if (yMin === yMax) yMax = yMin + 1; |
| 343 | |
| 344 | return { xMin, xMax, yMin, yMax }; |
| 345 | }; |
| 346 | |
| 347 | const extendBoundsWithOHLCDataPoints = (bounds: Bounds | null, points: ReadonlyArray<OHLCDataPoint>): Bounds | null => { |
| 348 | if (points.length === 0) return bounds; |
no test coverage detected