MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / extendBoundsWithDataPoints

Function extendBoundsWithDataPoints

src/ChartGPU.ts:212–241  ·  view source on GitHub ↗
(bounds: Bounds | null, points: ReadonlyArray<DataPoint>)

Source from the content-addressed store, hash-verified

210};
211
212const 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
243const extendBoundsWithOHLCDataPoints = (bounds: Bounds | null, points: ReadonlyArray<OHLCDataPoint>): Bounds | null => {
244 if (points.length === 0) return bounds;

Callers 1

appendDataFunction · 0.70

Calls 2

computeRawBoundsFromDataFunction · 0.70
getPointXYFunction · 0.70

Tested by

no test coverage detected