UNPKG

ag-charts-community

Version:

Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue

41 lines (40 loc) 2.4 kB
import type { Callback, CallbackParam, DynamicContext, IsAny, Point } from 'ag-charts-core'; import type { AgChartLabelStyleOptions, HighlightState, PixelSize, TextOrSegments } from 'ag-charts-types'; import type { HighlightNodeDatum } from '../core/eventsHub'; import type { ChartRegistry } from '../module/moduleContext'; import type { Text } from '../scene/shape/text'; import type { Label } from './label'; import type { DatumIndexType, SeriesNodeDatum } from './series/seriesTypes'; interface SeriesLike<TDatumIndex extends DatumIndexType> { id: string; ctx: DynamicContext<ChartRegistry>; declarationOrder: number; get visible(): boolean; cachedCallWithContext<F extends Callback>(fn: F, params: CallbackParam<F>): ReturnType<F> | undefined; isSeriesHighlighted(highlightedDatum: HighlightNodeDatum | undefined): boolean; getHighlightStateString(datum: HighlightNodeDatum | undefined, isHighlight?: boolean, datumIndex?: TDatumIndex): HighlightState; } type Bounds = { x: number; y: number; width: number; height: number; }; export type BarLabelPlacement = 'inside-center' | 'inside-start' | 'inside-end' | 'outside-start' | 'outside-end'; type LabelDatum = Point & { text: TextOrSegments; textAlign: CanvasTextAlign; textBaseline: CanvasTextBaseline; }; export declare function getLabelStyles<TParams, TDatumIndex extends DatumIndexType = DatumIndexType>(series: SeriesLike<TDatumIndex>, nodeDatum: SeriesNodeDatum<TDatumIndex> | undefined, params: TParams, label: Label<TParams>, isHighlight: boolean, activeHighlight: HighlightNodeDatum<TDatumIndex> | undefined, labelPath?: string[]): AgChartLabelStyleOptions & { fontSize: number; }; export declare function updateLabelNode<TParams, D extends LabelDatum>(series: IsAny<D> extends false ? SeriesLike<DatumIndexType> : never, textNode: IsAny<D> extends false ? Text : never, params: IsAny<D> extends false ? TParams : never, label: IsAny<D> extends false ? Label<TParams, unknown> : never, labelDatum: D | undefined, isHighlight: boolean, activeHighlight: HighlightNodeDatum<DatumIndexType> | undefined): void; export declare function adjustLabelPlacement({ isUpward, isVertical, placement, spacing, rect, }: { placement: BarLabelPlacement; isUpward: boolean; isVertical: boolean; spacing?: PixelSize; rect: Bounds; }): Omit<LabelDatum, 'text'>; export {};