import type { Point } from "../../../../Core/Point"; import { Rect } from "../../../../Core/Rect"; import type { EColumnType } from "../../../../types/ColumnType"; import type { EDataLabelProviderType } from "../../../../types/DataLabelProviderType"; import type { TDataLabelStyle } from "../../../../types/TDataLabelStyle"; import type { SCRTStringDictionary, TSciChart, TSRTextBounds } from "../../../../types/TSciChart"; import type { WebGlRenderContext2D } from "../../../Drawing/WebGlRenderContext2D"; import type { RenderPassData } from "../../../Services/RenderPassData"; import type { IThemeProvider } from "../../../Themes/IThemeProvider"; import type { IRenderableSeries } from "../IRenderableSeries"; export type TDataLabel = { text: string; /** Native by-code draw (grid string columns, opt-in): when set, the label is drawn straight * from the dictionary by code — no per-frame JS string — instead of using {@link text}. */ textCode?: number; textDict?: SCRTStringDictionary; /** The start point for text drawing. * This is not the top left of the text rectangle, since the y value for text is on the alphabetic baseline * Difference is bounds.GetLineBounds(0).m_fHeight */ position: Point; /** The Rectangle that contains the label, relative to the seriesViewRect */ rect: Rect; color?: number; dataX: number; dataY: number; rotationAngle: number; rotationCenter: Point; }; export interface IBaseDataLabelProviderOptions { /** * Sets the text style used for data labels. The style must be set, with fontFamily and fontSize set, in order for text to be drawn. */ style?: TDataLabelStyle; /** * Sets the color for data labels. Defaults to axis label color */ color?: string; /** * Draws immediately, set this True when using sub-surfaces for proper data label layering */ drawImmediate?: boolean; /** * When set, this provider's labels are drawn immediately after generation (during the series draw), * clipped to the returned rect (surface coordinates), instead of in the deferred global text pass. * Consequences: clipped labels draw at the series-layer z-order and are excluded from * {@link DataLabelLayoutManager} global text layout. Return undefined to skip drawing clipped for a pass. * Use {@link getYRangeClipRect} to clip to the series' y-axis range (e.g. one grid column). */ getClipRect?: (renderPassData: RenderPassData) => Rect; } export declare abstract class BaseDataLabelProvider { readonly type: EDataLabelProviderType; /** * The text to draw, along with the sizes and positions. Usually generated, but can be updated before final drawing */ dataLabels: TDataLabel[]; /** * Draws immediately, set this True when using sub-surfaces for proper data label layering */ drawImmediate: boolean; /** * When set, this provider's labels are drawn immediately after generation (during the series draw), * clipped to the returned rect (surface coordinates), instead of in the deferred global text pass. * See {@link IBaseDataLabelProviderOptions.getClipRect} */ getClipRect: ((renderPassData: RenderPassData) => Rect) | undefined; /** * The {@link TSciChart | SciChart 2D WebAssembly Context} containing native methods and * access to our WebGL2 Engine and WebAssembly numerical methods */ protected webAssemblyContext: TSciChart; /** * The Parent {@link IRenderableSeries | RenderableSeries} */ protected parentSeries: IRenderableSeries; /** * Reusable native text-bounds buffer, allocated once at attach time. * Hoisted here so allocation never happens on the render path — first-time * native allocation can grow the WASM heap and detach any Float64Array * views captured earlier in the same frame (e.g. inside a DataLabelState). */ protected textBounds: TSRTextBounds; protected styleProperty: TDataLabelStyle; protected colorProperty: string; protected get useRotation(): boolean; /** * Resolves the declared {@link EColumnType} of the data-series column whose values this provider * is turning into text, or `undefined` when there is none. Supplies the formatting DEFAULT that an * unset `numericFormat`/`precision` (or `labelFormat`/`labelPrecision`) falls back to — see * {@link DEFAULT_FORMAT_FOR_COLUMN_TYPE}. An explicit setting always wins over it. * * `getColumnType` is optional-called as a CAPABILITY, matching how `getTextAt` is reached on this * path: any DataSeries able to declare column types serves one, and anything else (a plain * XyDataSeries, a third-party IDataSeries) simply falls through to the class default. * * @param parentSeries the renderable series the labels are being drawn for * @param field the column the provider was explicitly pointed at (a name, or an index into * `valueNames`), or `undefined` to use the series' own y selection */ protected resolveColumnType(parentSeries: IRenderableSeries, field?: string | number): EColumnType | undefined; private getstyleProxy; /** * Creates an instance of the {@link DataLabelProvider} */ constructor(options?: IBaseDataLabelProviderOptions); /** * Called when a DataLabelProvider is attached to a parent {@link IRenderableSeries | RenderableSeries} * @param webAssemblyContext * @param parentSeries */ onAttach(webAssemblyContext: TSciChart, parentSeries: IRenderableSeries): void; onDetach(): void; delete(): void; /** * Gets or sets the text style used for data labels. The style must be set, with fontFamily and fontSize set, in order for text to be drawn. */ get style(): TDataLabelStyle; /** * Gets or sets the text style used for data labels. The style must be set, with fontFamily and fontSize set, in order for text to be drawn. */ set style(value: TDataLabelStyle); /** * Gets or sets the color for data labels. Defaults to axis label color */ get color(): string; /** * Gets or sets the color for data labels. Defaults to axis label color */ set color(value: string); /** Update the style. Only the properties passed will be updated */ updateStyle(value: TDataLabelStyle): void; /** * Base behaviour is to do nothing. Labels will only be drawn if they have been manually set */ generateDataLabels(renderContext: WebGlRenderContext2D, renderPassData: RenderPassData): void; draw(renderContext: WebGlRenderContext2D): void; /** * Draws this provider's labels immediately, clipped to the given rect (surface coordinates). * Pre-flushes any pending font batches under the state they expect (identity transform + surface clip) * so the clip cannot apply to text batched by others, then sets the label clip and force-ends the font * so the clip applies to exactly this provider's labels, then restores the seriesViewRect transform + clip. */ drawClipped(renderContext: WebGlRenderContext2D, clipRect: Rect): void; protected drawLabels(renderContext: WebGlRenderContext2D, endFont: boolean): void; resolveAutoColors(index: number, maxSeries: number, theme: IThemeProvider): void; toJSON(): { type: EDataLabelProviderType; options: { style: TDataLabelStyle; color: string; }; }; protected invalidateParent(): void; protected getLineSpacing(): number; }