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

Function extendBoundsWithOHLCDataPoints

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

Source from the content-addressed store, hash-verified

241};
242
243const extendBoundsWithOHLCDataPoints = (bounds: Bounds | null, points: ReadonlyArray<OHLCDataPoint>): Bounds | null => {
244 if (points.length === 0) return bounds;
245
246 let xMin = bounds?.xMin ?? Number.POSITIVE_INFINITY;
247 let xMax = bounds?.xMax ?? Number.NEGATIVE_INFINITY;
248 let yMin = bounds?.yMin ?? Number.POSITIVE_INFINITY;
249 let yMax = bounds?.yMax ?? Number.NEGATIVE_INFINITY;
250
251 for (let i = 0; i < points.length; i++) {
252 const p = points[i]!;
253 const timestamp = getOHLCTimestamp(p);
254 const low = isTupleOHLCDataPoint(p) ? p[3] : p.low;
255 const high = isTupleOHLCDataPoint(p) ? p[4] : p.high;
256
257 if (!Number.isFinite(timestamp) || !Number.isFinite(low) || !Number.isFinite(high)) continue;
258 if (timestamp < xMin) xMin = timestamp;
259 if (timestamp > xMax) xMax = timestamp;
260 if (low < yMin) yMin = low;
261 if (high > yMax) yMax = high;
262 }
263
264 if (!Number.isFinite(xMin) || !Number.isFinite(xMax) || !Number.isFinite(yMin) || !Number.isFinite(yMax)) {
265 return bounds;
266 }
267
268 // Keep bounds usable for downstream scale derivation.
269 if (xMin === xMax) xMax = xMin + 1;
270 if (yMin === yMax) yMax = yMin + 1;
271
272 return { xMin, xMax, yMin, yMax };
273};
274
275const computeGlobalBounds = (
276 series: ResolvedChartGPUOptions['series'],

Callers 1

appendDataFunction · 0.70

Calls 2

getOHLCTimestampFunction · 0.85
isTupleOHLCDataPointFunction · 0.70

Tested by

no test coverage detected