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

Function computeRawBoundsFromData

src/ChartGPU.ts:186–210  ·  view source on GitHub ↗
(data: ReadonlyArray<DataPoint>)

Source from the content-addressed store, hash-verified

184};
185
186const computeRawBoundsFromData = (data: ReadonlyArray<DataPoint>): Bounds | null => {
187 let xMin = Number.POSITIVE_INFINITY;
188 let xMax = Number.NEGATIVE_INFINITY;
189 let yMin = Number.POSITIVE_INFINITY;
190 let yMax = Number.NEGATIVE_INFINITY;
191
192 for (let i = 0; i < data.length; i++) {
193 const { x, y } = getPointXY(data[i]!);
194 if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
195 if (x < xMin) xMin = x;
196 if (x > xMax) xMax = x;
197 if (y < yMin) yMin = y;
198 if (y > yMax) yMax = y;
199 }
200
201 if (!Number.isFinite(xMin) || !Number.isFinite(xMax) || !Number.isFinite(yMin) || !Number.isFinite(yMax)) {
202 return null;
203 }
204
205 // Keep bounds usable for downstream scale derivation.
206 if (xMin === xMax) xMax = xMin + 1;
207 if (yMin === yMax) yMax = yMin + 1;
208
209 return { xMin, xMax, yMin, yMax };
210};
211
212const extendBoundsWithDataPoints = (bounds: Bounds | null, points: ReadonlyArray<DataPoint>): Bounds | null => {
213 if (points.length === 0) return bounds;

Calls 1

getPointXYFunction · 0.70

Tested by

no test coverage detected