import type { AnyDatapoint, DatapointMetadata, SeriesId, XYChartAxisInternal } from '../../types/xy-chart-internals.js'; import type { AreaDatapoint, BarDatapoint } from '../../types/xy-chart.js'; export interface StackingResult { calcDatapoint: AnyDatapoint; datapointMetadata: DatapointMetadata; shouldContinue: boolean; } export declare class StackableSeriesHelper { private static readonly STARTING_POINT; private readonly stackGroups; private readonly stackDomainData; private readonly axisStats; /** * Per-instance cache of the `xAxisId-yAxisId-orientation` axis-key string, * keyed by the same triple. Instance-scoped (fresh per render, no * cross-render leakage, React-strict-mode safe). */ private readonly axisOrientationKeyCache; constructor(); private getCachedAxisOrientationKey; /** * Accumulates total positive and negative values per stack key. * Should be called during the preprocess phase before processing individual datapoints. * This is needed so that binDomain can be included in metadata for relative stacking. * * Also records which series contributed to each axisKey so that `getStackBinDomain` can * fall back to a cross-bin reference for single-series axes. Single-series stacks would * otherwise collapse to 100% in every bin. */ processStackDomain(datapoint: BarDatapoint | AreaDatapoint, chartOrientation: 'vertical' | 'horizontal', xAxis: XYChartAxisInternal, yAxis: XYChartAxisInternal, seriesId: SeriesId): void; /** * Returns the total bin domain for a given stack key. * * For axes with more than one contributing series the result is the per-bin total height * of the stack (|positive| + |negative| within the bin). For axes with only one contributing * series the result collapses to a cross-bin reference: the largest per-bin absolute total * across all bins of that axis. This keeps single-series stacks consistent with the regular * relative behavior, where the tallest bar represents 100% and the rest scale proportionally. */ getStackBinDomain(stackKey: string): number | undefined; private getOrInitAxisStats; /** * Processes a datapoint for stacking, calculating the offset and updating stack groups. * Returns the calculated datapoint with stacking offsets applied and enriched metadata. */ processStackedDatapoint(datapoint: BarDatapoint | AreaDatapoint, chartOrientation: 'vertical' | 'horizontal', xAxis: XYChartAxisInternal, yAxis: XYChartAxisInternal, datapointMetadata: DatapointMetadata): StackingResult; }