UNPKG

ag-charts-community

Version:

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

50 lines (49 loc) 2.62 kB
import type { Callback, CallbackParam, DynamicContext, IsAny, NormalisedTextOrSegments, Point } from 'ag-charts-core'; import { type NormalisedChartLabelStyleOptions } from 'ag-charts-core'; import type { HighlightState, PixelSize, SelectionState } 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 { DatumIndex, SeriesNodeDatum } from './series/seriesTypes'; interface SeriesLike { id: string; ctx: DynamicContext<ChartRegistry>; declarationOrder: number; readonly data?: { readonly dataIdKey?: string; }; 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?: DatumIndex): HighlightState; getSelectionStateString(datumIndex: DatumIndex | undefined): SelectionState | undefined; getCandidateStateString(datumIndex: DatumIndex | undefined): SelectionState | undefined; } 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: NormalisedTextOrSegments; textAlign: CanvasTextAlign; textBaseline: CanvasTextBaseline; }; export declare function getLabelStyles<TParams>(series: SeriesLike, nodeDatum: SeriesNodeDatum | undefined, params: TParams, label: Label<TParams>, isHighlight: boolean, activeHighlight: HighlightNodeDatum | undefined, labelPath?: string[]): NormalisedChartLabelStyleOptions & { fontSize: number; }; export declare function updateLabelNode<TParams, D extends LabelDatum>(series: IsAny<D> extends false ? SeriesLike : 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, highlight: { isHighlight: boolean; activeHighlight: HighlightNodeDatum | undefined; }, labelPath?: string[]): void; export declare function adjustLabelPlacement({ isUpward, isVertical, placement, spacing, rect, }: { placement: BarLabelPlacement; isUpward: boolean; isVertical: boolean; spacing?: PixelSize; rect: Bounds; }): Omit<LabelDatum, 'text'>; export {};