MCPcopy Create free account
hub / github.com/ChartGPU/ChartGPU / computeDataBounds

Function computeDataBounds

src/renderers/createScatterRenderer.ts:71–97  ·  view source on GitHub ↗
(
  data: ReadonlyArray<DataPoint>
)

Source from the content-addressed store, hash-verified

69};
70
71const computeDataBounds = (
72 data: ReadonlyArray<DataPoint>
73): { readonly xMin: number; readonly xMax: number; readonly yMin: number; readonly yMax: number } => {
74 let xMin = Number.POSITIVE_INFINITY;
75 let xMax = Number.NEGATIVE_INFINITY;
76 let yMin = Number.POSITIVE_INFINITY;
77 let yMax = Number.NEGATIVE_INFINITY;
78
79 for (let i = 0; i < data.length; i++) {
80 const { x, y } = getPointXY(data[i]);
81 if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
82 if (x < xMin) xMin = x;
83 if (x > xMax) xMax = x;
84 if (y < yMin) yMin = y;
85 if (y > yMax) yMax = y;
86 }
87
88 if (!Number.isFinite(xMin) || !Number.isFinite(xMax) || !Number.isFinite(yMin) || !Number.isFinite(yMax)) {
89 return { xMin: 0, xMax: 1, yMin: 0, yMax: 1 };
90 }
91
92 // Avoid degenerate domains for affine derivation (handled later too, but keep stable samples).
93 if (xMin === xMax) xMax = xMin + 1;
94 if (yMin === yMax) yMax = yMin + 1;
95
96 return { xMin, xMax, yMin, yMax };
97};
98
99const computeClipAffineFromScale = (
100 scale: LinearScale,

Callers 1

prepareFunction · 0.70

Calls 1

getPointXYFunction · 0.70

Tested by

no test coverage detected