import type { SeriesQueryResult } from '../context/XYChartOverlayPerformance.context.js'; import type { AxisIdToScales } from '../context/XYChartScales.context.js'; import type { AreaSeriesWithDatapoints, AxisIdToScaleDomain, BarSeriesWithDatapoints, LineSeriesWithDatapoints, MapDatapoints, SeriesToMetadata } from '../types/xy-chart-internals.js'; import type { AreaDatapoint, BarDatapoint, LineDatapoint } from '../types/xy-chart.js'; export type SortedEntry = { xPixel: number; yPixel: number; /** * Stable cluster identifier built from the datapoint's x-domain * (`x0-x1`). Entries sharing the same `boundaries` belong to the same * stack / same start-end domain group. */ boundaries: string; result: SeriesQueryResult; }; /** * Sorted-entry buckets keyed by shape. `bar`, `line`, and `area` are each * sorted ascending by `xPixel`. `combined` is the concatenation of all three, * also sorted ascending by `xPixel`, and is used for the cross-shape binary- * search cluster lookup that spans all shapes. * * Selection state in the shared tooltip is tracked per shape, so the * underlying data structure separates entries by shape even when only one is * in use. */ export type SortedEntriesPerShape = { bar: SortedEntry[]; line: SortedEntry[]; area: SortedEntry[]; combined: SortedEntry[]; }; export type BarPixelCenter = { xPixel: number; yPixel: number; boundaries: string; }; /** * Maps a (series, datapoint) pair to its bar's pixel center and * stack/cluster boundary. Used to anchor cluster lookups around the * hovered bar's exact pixel position instead of the cursor's. */ export type GetBarPixelCenter = (series: BarSeriesWithDatapoints, datapoint: BarDatapoint) => BarPixelCenter; /** * Maps a (series, datapoint) pair to its line or area pixel center. * Handles both line and area series with a single builder — the accessor * selection (`yMiddleBandAccessor` for bands, `y1AreaAccessor` for plain * areas, etc.) is delegated to `getLinearAccessors`. */ export type GetLinearSeriesPixelCenter = (series: LineSeriesWithDatapoints | AreaSeriesWithDatapoints, datapoint: LineDatapoint | AreaDatapoint) => BarPixelCenter; /** * Build a per-series-cached `GetBarPixelCenter`. Accessor construction * is non-trivial, so we memoize per series id to keep tight loops fast. */ export declare function buildGetBarPixelCenter(axisIdToScales: AxisIdToScales, seriesToMetadata: SeriesToMetadata, axisIdToScaleDomain: AxisIdToScaleDomain, datapointMetadataMap: MapDatapoints): GetBarPixelCenter; /** * Build a per-series-cached `GetLinearSeriesPixelCenter` for both line and * area series. Uses the display accessors from `getLinearAccessors` — x * centers time bands and uses x0 for numeric/categorical; y resolves to * `yMiddleBandAccessor` for bands (AC4 mid(y0,y1)) or `y1AreaAccessor` for * plain areas. Memoizes per series id to keep tight loops fast. */ export declare function buildGetLinearSeriesPixelCenter(axisIdToScales: AxisIdToScales, seriesToMetadata: SeriesToMetadata, axisIdToScaleDomain: AxisIdToScaleDomain, datapointMetadataMap: MapDatapoints): GetLinearSeriesPixelCenter; /** * Build the per-shape sorted entries used by the shared tooltip query. * * Bar, line, and area series are each processed into their own bucket. * Each datapoint becomes one entry positioned at the series' pixel center, * with a `boundaries` key that groups entries sharing the same `x0-x1`. * Gap datapoints are skipped. * * Each per-shape bucket is sorted ascending by `xPixel`. `combined` merges * all three buckets and is also sorted ascending by `xPixel`, ready for a * cross-shape binary search cluster lookup. */ export declare function buildSortedEntries(barSeries: BarSeriesWithDatapoints[], lineSeries: LineSeriesWithDatapoints[], areaSeries: AreaSeriesWithDatapoints[], datapointMetadataMap: MapDatapoints, getBarPixelCenter: GetBarPixelCenter, getLinearSeriesPixelCenter: GetLinearSeriesPixelCenter): SortedEntriesPerShape;