(
gridArea: GridArea,
domains: { readonly xDomain: { readonly min: number; readonly max: number }; readonly yDomain: { readonly min: number; readonly max: number } }
)
| 2341 | }; |
| 2342 | |
| 2343 | const computeInteractionScalesGridCssPx = ( |
| 2344 | gridArea: GridArea, |
| 2345 | domains: { readonly xDomain: { readonly min: number; readonly max: number }; readonly yDomain: { readonly min: number; readonly max: number } } |
| 2346 | ): |
| 2347 | | { |
| 2348 | readonly xScale: LinearScale; |
| 2349 | readonly yScale: LinearScale; |
| 2350 | readonly plotWidthCss: number; |
| 2351 | readonly plotHeightCss: number; |
| 2352 | } |
| 2353 | | null => { |
| 2354 | const canvas = gpuContext.canvas; |
| 2355 | // Support both HTMLCanvasElement and OffscreenCanvas for worker thread compatibility |
| 2356 | if (!canvas) return null; |
| 2357 | |
| 2358 | const plotSize = getPlotSizeCssPx(canvas, gridArea); |
| 2359 | if (!plotSize) return null; |
| 2360 | |
| 2361 | // IMPORTANT: grid-local CSS px ranges (0..plotWidth/Height), for interaction hit-testing. |
| 2362 | const xScale = createLinearScale().domain(domains.xDomain.min, domains.xDomain.max).range(0, plotSize.plotWidthCss); |
| 2363 | const yScale = createLinearScale().domain(domains.yDomain.min, domains.yDomain.max).range(plotSize.plotHeightCss, 0); |
| 2364 | |
| 2365 | const result = { xScale, yScale, plotWidthCss: plotSize.plotWidthCss, plotHeightCss: plotSize.plotHeightCss }; |
| 2366 | console.log('[computeInteractionScalesGridCssPx] Computed interaction scales:', { |
| 2367 | canvasType: isHTMLCanvasElement(canvas) ? 'HTMLCanvasElement' : 'OffscreenCanvas', |
| 2368 | plotWidthCss: result.plotWidthCss, |
| 2369 | plotHeightCss: result.plotHeightCss, |
| 2370 | xDomain: domains.xDomain, |
| 2371 | yDomain: domains.yDomain, |
| 2372 | xRange: [0, plotSize.plotWidthCss], |
| 2373 | yRange: [plotSize.plotHeightCss, 0] |
| 2374 | }); |
| 2375 | |
| 2376 | return result; |
| 2377 | }; |
| 2378 | |
| 2379 | const buildTooltipParams = (seriesIndex: number, dataIndex: number, point: DataPoint): TooltipParams => { |
| 2380 | const s = currentOptions.series[seriesIndex]; |
no test coverage detected