ag-charts-community
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
78 lines (77 loc) • 2.89 kB
TypeScript
import type { AgActiveItemState } from 'ag-charts-types';
import type { ActiveManager } from '../interaction/activeManager';
import type { DatumIndexType, SeriesNodeDatum } from './seriesTypes';
type ActivationOptsNoArg = {
defaultCbArg?: never;
};
type ActivationOptsWithArg<A> = {
defaultCbArg: A;
};
export type PickedNode = SeriesNodeDatum<DatumIndexType>;
export type PickedNodes = {
matches: PickedNode[];
distance: number;
};
export declare function getItemId(node: PickedNode, dataIdKey?: string): NonNullable<AgActiveItemState['itemId']>;
type TooltipCandidate = {
active?: PickedNode;
paginationState?: {
index: number;
length: number;
};
};
/**
* PickManager mediates the `active` node state between SeriesAreaManager and ActiveManager.
*
* It tracks the active node by:
*
* 1. Listening for `setState` calls from ActiveManager
*
* 2. Notifying ActiveManager of state change (so that `getState` receives the
* correct data)
*
* 3. Track tooltip candidates (if pagination is enabled).
*/
export declare class PickManager {
private readonly activeManager;
private readonly tooltipProperties;
private active;
private candidates;
private pendingPickedNodes?;
private blockEntrance;
private activationPrevented;
constructor(activeManager: ActiveManager, tooltipProperties: {
readonly pagination: boolean;
});
private clear;
private popPendingPickedNodes;
private getActivationArgs;
/**
* Dispatch a preventable `'activeChange'` event.
* If `AgActiveChangeEvent.preventDefault()` was not called, then run `defaultCb(opts.defaultCbArg)`.
*
* Reentrance is not allowed. Example:
*
* pickManager.maybeActivate(myNode, () => {
* if (isValid(myNode)) {
* renderHighlight();
* } else {
* // !!! DO NOT DO THIS !!!
* // It will incorrectly broadcast 2 activeChange API events!
* // Either `myNode` OR `undefined` should be broadcast but not both.
* pickManager.maybeActivate(undefined, () => clearHighlight());
* }
* });
*/
maybeActivate(node: PickedNode | undefined, defaultCb: () => void, opts?: ActivationOptsNoArg): void;
maybeActivate<A>(node: PickedNode | undefined, defaultCb: (a: A) => void, opts: ActivationOptsWithArg<A>): void;
onClearUI(): void;
onClearAPI(): void;
onPickedNodesHighlight(pickedNodes: PickedNodes | undefined): PickedNode | undefined;
onPickedNodesTooltip(pickedNodes: PickedNodes | undefined): TooltipCandidate;
onPickedNodesAPI(debouncedPickedNodes: PickedNodes): PickedNode | undefined;
onPickedNodesAPIDebounced(): TooltipCandidate;
nextCandidate(): TooltipCandidate;
wasActivationPrevented(): boolean;
}
export {};