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

Function inferPlotHeightPxForBarHitTesting

src/interaction/findNearestPoint.ts:351–369  ·  view source on GitHub ↗
(
  seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>,
  yScale: LinearScale,
)

Source from the content-addressed store, hash-verified

349};
350
351export function inferPlotHeightPxForBarHitTesting(
352 seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>,
353 yScale: LinearScale,
354): number {
355 // We don't have direct access to the scale range endpoints, so infer the plot height in range-space.
356 // In the common ChartGPU interaction setup, yScale.range(plotHeightCss, 0), so max(scaledY) should
357 // approximate plotHeightCss (or be <= plotHeightCss if axis min/max are overridden).
358 let maxY = 0;
359 for (let s = 0; s < seriesConfigs.length; s++) {
360 const data = seriesConfigs[s].data;
361 for (let i = 0; i < data.length; i++) {
362 const { y } = getPointXY(data[i]);
363 if (!Number.isFinite(y)) continue;
364 const py = yScale.scale(y);
365 if (Number.isFinite(py) && py > maxY) maxY = py;
366 }
367 }
368 return Math.max(0, maxY);
369}
370
371export function computeBaselineDomainAndPx(
372 seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>,

Callers 1

findNearestPointFunction · 0.85

Calls 2

getPointXYFunction · 0.70
scaleMethod · 0.65

Tested by

no test coverage detected