import type { AgActiveState } from '../api/activeState'; import type { AgStateGroupingValueType, AgStateValueType } from '../api/stateTypes'; import type { TextOrSegments } from '../series/cartesian/commonOptions'; import type { AgAnnotation } from './annotationsOptions'; import type { AgAxisBoundSeries, AgAxisDirection, AgAxisDomain, AgAxisValue } from './axisOptions'; import type { AgItemType, Listener, SelectionState } from './callbackOptions'; import type { AgNumericValue } from './dataValues'; import type { ContextDefault, DatumDefault, Ratio, ResolvedDatumKey } from './types'; import type { AgAutoScaledAxes } from './zoomOptions'; interface AgChartEvent { type: T; event: Event; /** Callback context for this event. */ context?: TContext; } export interface AgPreventableEvent { /** Prevent the AG Charts built-in default event handlers from running. */ preventDefault(): void; } export interface AgNodeClickEvent extends AgChartEvent { /** Event type. */ type: TEvent; /** Series ID, as specified in `series.id` (or generated if not specified) */ seriesId: string; /** The unique identifier of the picked datum. */ itemId: string | number; /** The data ID key, if set on chart options. When present, `itemId` is a stable identifier. */ dataIdKey?: ResolvedDatumKey; /** Datum from the chart or series data array. */ datum: TDatum; /** Every datum grouped into the bin for histogram series; `undefined` for all other series. */ datums?: TDatum[]; /** Waterfall series only: the type of bar - `positive`, `negative`, `total` or `subtotal`. */ itemType?: AgItemType; /** Waterfall series only: the computed cumulative value for `total` and `subtotal` bars. */ totalValue?: AgNumericValue; /** The current selection state of this datum. Set to `undefined` if the selection module is not enabled. */ selectionState?: SelectionState; /** Whether the clicked item is collapsed. */ isCollapsed?: boolean; /** xKey as specified on series options */ xKey?: ResolvedDatumKey; /** yKey as specified on series options */ yKey?: ResolvedDatumKey; /** sizeKey as specified on series options */ sizeKey?: ResolvedDatumKey; /** labelKey as specified on series options */ labelKey?: ResolvedDatumKey; /** colorKey as specified on series options */ colorKey?: ResolvedDatumKey; /** angleKey as specified on series options */ angleKey?: ResolvedDatumKey; /** calloutLabelKey as specified on series options */ calloutLabelKey?: ResolvedDatumKey; /** sectorLabelKey as specified on series options */ sectorLabelKey?: ResolvedDatumKey; /** radiusKey as specified on series options */ radiusKey?: ResolvedDatumKey; } export interface AgSeriesVisibilityChange { /** Event type. */ type: 'seriesVisibilityChange'; /** Callback context for this event. */ context?: TContext; /** Series id */ seriesId: string; /** Legend item id - usually yKey value for cartesian series. */ itemId?: string | number; /** Human-readable description of the y-values. If supplied, matching items with the same value will be toggled together. */ legendItemName?: string; /** The new visibility status that the series is changing to. */ visible: boolean; } export type AgActiveChangeEventSource = 'state-change' | 'user-interaction'; export interface AgActiveChangeEvent extends AgActiveState, AgPreventableEvent { /** Event type. */ type: 'activeChange'; /** An indication of what triggered this event. */ source: AgActiveChangeEventSource; /** Callback context for this event. */ context?: TContext; /** Datum from the chart or series data array. */ datum?: TDatum; /** Every datum grouped into the bin for histogram series; `undefined` for all other series. */ datums?: TDatum[]; /** The active item's type, for series that distinguish item types (e.g. waterfall, OHLC, candlestick, range area); `undefined` otherwise. */ itemType?: AgItemType; /** Waterfall series only: the computed cumulative value for `total` and `subtotal` bars. */ totalValue?: AgNumericValue; /** The data ID key, if set on chart options. When present, `activeItem.itemId` is a stable identifier. */ dataIdKey?: ResolvedDatumKey; } export interface AgSelectionItemIds { /** Series ID, as specified in `series.id` (or generated if not specified). */ seriesId: string; /** The unique identifier of the datum as specified in `dataIdKey` if set (or generated if not specified). */ itemId: string | number; } export interface AgSelectionItem extends AgSelectionItemIds { /** Datum from the chart or series data array. */ datum: TDatum; } export type AgSelectionChangeEventSource = 'user-interaction' | 'api-call'; export interface AgSelectionChangeEvent extends AgPreventableEvent { /** Event type. */ type: 'selectionChange'; /** An indication of what triggered this event. */ source: AgSelectionChangeEventSource; /** Callback context for this event. */ context?: TContext; /** Items added to the selection in this change. */ added: AgSelectionItem[]; /** Items removed from the selection in this change. */ removed: AgSelectionItem[]; } export interface AgCollapsedChangeItem { /** The unique identifier of the datum as specified in `dataIdKey` if set (or generated if not specified). */ itemId: string | number; /** Datum from the chart or series data array. */ datum: TDatum; } export type AgCollapsedChangeEventSource = 'user-interaction' | 'api-call'; export interface AgCollapsedChangeEvent extends AgPreventableEvent { /** Event type. */ type: 'collapsedChange'; /** An indication of what triggered this event. */ source: AgCollapsedChangeEventSource; /** Callback context for this event. */ context?: TContext; /** Items that will be newly collapsed after this change. */ collapsed: AgCollapsedChangeItem[]; /** Items that will be newly expanded after this change. */ expanded: AgCollapsedChangeItem[]; } export interface AgAnnotationsEvent { type: 'annotations'; annotations?: AgAnnotation[]; context?: TContext; } export type AgZoomEventSource = 'chart-update' | 'data-update' | 'range-check' | 'state-change' | 'sync' | 'user-interaction'; export interface AgZoomEvent { type: 'zoom'; source: AgZoomEventSource; rangeX?: AgZoomEventRange; rangeY?: AgZoomEventRange; ratioX: AgZoomEventRatio; ratioY: AgZoomEventRatio; autoScaledAxes?: AgAutoScaledAxes; context?: TContext; } export interface AgZoomEventRange { start?: AgStateValueType | AgStateGroupingValueType; end?: AgStateValueType | AgStateGroupingValueType; } export interface AgZoomEventRatio { start: Ratio; end: Ratio; } export type AgChartClickEvent = AgChartEvent<'click', TContext>; export type AgChartDoubleClickEvent = AgChartEvent<'doubleClick', TContext>; export type AgChartContextMenuEvent = AgChartEvent<'contextMenuEvent', TContext>; export type AgSeriesAreaContextMenuActionEvent = AgChartEvent<'seriesContextMenuAction', TContext>; export type AgCaptionType = 'title' | 'subtitle' | 'footnote'; export interface AgAxisContextMenuActionEvent extends AgChartEvent<'axisContextMenuAction', TContext> { /** Axis ID, as specified in `axes`. */ axisId: string; /** The scale value of the axis at this point. */ value: AgAxisValue; /** Direction of the axis the title belongs to. */ direction: AgAxisDirection; /** The index of the resolved value */ index: number; /** Metadata about series bound to the axis the title belongs to. */ boundSeries: AgAxisBoundSeries[]; /** Computed domain of the axis */ domain: AgAxisDomain; } export interface AgCrossLineContextMenuActionEvent extends AgChartEvent<'crossLineContextMenuAction', TContext> { /** Cross Line ID (generated if not specified). */ crossLineId: string; /** ID of the axis the Cross Line belongs to, as specified in `axes`. */ axisId: string; /** Direction of the axis the Cross Line belongs to. */ direction: AgAxisDirection; /** Whether the Cross Line is a single `line` or a `range` band. */ crossLineType: 'line' | 'range'; /** The data value of a `line` Cross Line. Undefined for `range` Cross Lines. */ value?: AgAxisValue; /** The `[start, end]` data values of a `range` Cross Line. Undefined for `line` Cross Lines. */ range?: [AgAxisValue, AgAxisValue]; } export interface AgCaptionContextMenuActionEvent extends AgChartEvent<'captionContextMenuAction', TContext> { /** Which type of caption was clicked on. */ captionType: AgCaptionType; /** The text of the clicked caption. */ text: TextOrSegments; } export interface AgNodeContextMenuActionEvent extends AgNodeClickEvent<'nodeContextMenuAction', TDatum, TContext> { /** Histogram series only: zero-based positional index of the bin within the series. */ binIndex?: number; /** Histogram series only: the bin's start and end bounds on the x-axis. */ binRange?: [number, number]; /** Histogram series only: the aggregated `yKey` value for the bin. */ aggregatedValue?: number; /** Histogram series only: the number of source rows within the bin. */ frequency?: number; } export interface AgBaseChartListeners { /** The listener to call when a node (marker, column, bar, tile or a pie sector) in any series is clicked. * Useful for a chart containing multiple series. */ seriesNodeClick?: Listener>; /** The listener to call when a node (marker, column, bar, tile or a pie sector) in any series is double-clicked. * Useful for a chart containing multiple series.*/ seriesNodeDoubleClick?: Listener>; /** The listener to call when a series visibility is changed. */ seriesVisibilityChange?: Listener>; /** The listener to call when the active state (highlight/tooltip) is changed. */ activeChange?: Listener>; /** The listener to call when data selection is changed */ selectionChange?: Listener>; /** The listener to call when collapsed items are changed. */ collapsedChange?: Listener>; /** The listener to call when the chart is clicked. */ click?: Listener>; /** The listener to call when the chart is double-clicked. */ doubleClick?: Listener>; /** The listener to call when the annotations are changed. */ annotations?: Listener>; /** The listener to call when the zoom is changed. */ zoom?: Listener>; } export interface AgSeriesListeners { /** The listener to call when a node (marker, column, bar, tile or a pie sector) in the series is clicked. */ seriesNodeClick?: Listener>; /** The listener to call when a node (marker, column, bar, tile or a pie sector) in the series is double-clicked. */ seriesNodeDoubleClick?: Listener>; } export {};