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

Function computeDataBounds

src/renderers/createLineRenderer.ts:47–73  ·  view source on GitHub ↗
(
  data: ResolvedLineSeriesConfig['data']
)

Source from the content-addressed store, hash-verified

45};
46
47const computeDataBounds = (
48 data: ResolvedLineSeriesConfig['data']
49): { readonly xMin: number; readonly xMax: number; readonly yMin: number; readonly yMax: number } => {
50 let xMin = Number.POSITIVE_INFINITY;
51 let xMax = Number.NEGATIVE_INFINITY;
52 let yMin = Number.POSITIVE_INFINITY;
53 let yMax = Number.NEGATIVE_INFINITY;
54
55 for (let i = 0; i < data.length; i++) {
56 const { x, y } = getPointXY(data[i]);
57 if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
58 if (x < xMin) xMin = x;
59 if (x > xMax) xMax = x;
60 if (y < yMin) yMin = y;
61 if (y > yMax) yMax = y;
62 }
63
64 if (!Number.isFinite(xMin) || !Number.isFinite(xMax) || !Number.isFinite(yMin) || !Number.isFinite(yMax)) {
65 return { xMin: 0, xMax: 1, yMin: 0, yMax: 1 };
66 }
67
68 // Avoid degenerate domains for affine derivation (handled later too, but keep stable samples).
69 if (xMin === xMax) xMax = xMin + 1;
70 if (yMin === yMax) yMax = yMin + 1;
71
72 return { xMin, xMax, yMin, yMax };
73};
74
75const computeClipAffineFromScale = (
76 scale: LinearScale,

Callers 1

prepareFunction · 0.70

Calls 1

getPointXYFunction · 0.70

Tested by

no test coverage detected