import { BBox, type CandidateStyleResolver, type LabelObstacle, type NormalisedPaddingOptions, type PlacedLabel, type PointLabelDatum, type PositionedCandidateResolver, type SeriesLabelDefaults } from 'ag-charts-core'; /** * Anything taking part in a label solve. A source contributes obstacles whether or not it places * labels of its own, so a module owning fixed, user-authored labels can reserve their space without * pretending to be a series. * * `id` shares a namespace with series ids and keys the placement result, so a registered source must * qualify its own (e.g. `crossLines:`). */ export interface LabelSource { readonly id: string; readonly usesPlacedLabels: boolean; /** Increments on every invalidation of the label inputs; lets placement skip unchanged ones. */ readonly nodeDataVersion: number; /** `seriesRect` is the placement space's canvas origin; series already work in it and ignore it. */ getLabelObstacles?(seriesRect: BBox): LabelObstacle[] | undefined; /** Its obstacles are axis labels, which only opted-in labels avoid, so other solves skip the source. */ readonly axisLabelObstacles?: boolean; } /** * A source whose own labels the engine places. `ISeries` satisfies it structurally; a source reaches * this path only via {@link LabelSource.usesPlacedLabels}. */ export interface PlacedLabelSource extends LabelSource { getLabelData(seriesRect: BBox): PointLabelDatum[]; getLabelDefaults?(): SeriesLabelDefaults | undefined; getLabelCandidateStyler?(): CandidateStyleResolver | undefined; getLabelCandidateResolver?(): PositionedCandidateResolver | undefined; /** Returns `true` when the placement invalidates the layout it was solved in. */ updatePlacedLabelData?(labels: PlacedLabel[], seriesRect: BBox): boolean | void; /** Freezes what the re-layout for an invalidating placement must not decide again. */ holdLabelPlacements?(hold: boolean): void; } export declare class LabelManager { private labelData; private lastPlacementSignature?; private lastPlacedLabels?; private readonly sources; private holdingPlacements; private avoidsAxisLabels; registerSource(source: LabelSource): void; /** A source may only drop its own entry: a mini-chart axis shares its id with the live main-chart one. */ unregisterSource(id: string, source?: LabelSource): void; /** Returns whether the chart must lay out again for a placement that invalidated its layout. */ updateLabels(visibleSources: PlacedLabelSource[], padding: NormalisedPaddingOptions, seriesRect?: BBox): boolean; /** * Solves `source`'s labels on their own, for a layout that must reserve room for them before the * chart-wide solve runs. Leaves the cached placement untouched. */ measureLabels(source: PlacedLabelSource, seriesRect: BBox): PlacedLabel[]; private computePlacement; }