ag-charts-enterprise
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
62 lines (61 loc) • 3.52 kB
TypeScript
import { _ModuleSupport } from 'ag-charts-community';
type TransactionCollectionState<T> = _ModuleSupport.TransactionCollectionState<T>;
type DataChangeDescriptionListener = _ModuleSupport.DataChangeDescriptionListener;
declare const DataSet: typeof _ModuleSupport.DataSet;
/**
* DataSet subclass that understands hierarchical/nested data (e.g. treemap with `childrenKey`).
* Extends ID-based transaction logic to find, update, and remove items nested within children arrays.
*/
export declare class HierarchyDataSet<T = unknown> extends DataSet<T> {
private readonly childrenKey;
private dfsOrdering?;
constructor(data: T[], dataIdKey: string | undefined, childrenKey: string);
private getDfsOrdering;
private getGroupNumber;
isLeaf(datumIndex: number): boolean;
size(): number;
getDatumAt(datumIndex: number): T | undefined;
/**
* Commits the transaction, then bridges the result to the selection listener in the DFS
* index space it expects.
*
* The base change description is built in root (`this.data`) space, but selection bitsets are
* sized to the DFS-expanded `size()`. Replaying the root-space description against a bitset
* overruns it (the documented `RangeError`). So we suppress the base's listener call, let the
* base mutate `this.data` correctly, then rebuild a DFS-space description by diffing the DFS
* ordering before and after the commit and hand that to the listener instead.
*
* Also removes any root-level items whose IDs already exist nested in the tree — the case
* where the user manually adds an item to a parent's children array and also calls
* `applyTransaction({ add: [item] })`, which would otherwise duplicate it at root level.
*/
commitPendingTransactions(changeDescriptionListener: DataChangeDescriptionListener | undefined): boolean;
/**
* Builds a change description in DFS index space by matching each pre-commit DFS datum to its
* post-commit DFS position by identity (id, or object reference when no `dataIdKey`). Survivors
* keep their selection at the new position; removed nodes drop out; new nodes default to 0.
*/
private buildDfsChangeDescription;
/** Maps each DFS datum (by object reference) to its DFS index. */
private buildDfsRefIndex;
/**
* Expresses the old→new DFS transformation as prepend/mid-insert/append splice operations plus
* removed source indices — the shape `DataChangeDescription.applyToTypedArray` consumes.
*/
private buildDfsIndexMap;
private removeNestedDuplicatesFromRoot;
private collectNestedIds;
/** Recursively indexes all items (root and nested) by ID, mapping each to its DFS order. */
getIdToIndexMap(): Map<string | number, number>;
/** Handles updates for both root-level and nested items. */
protected collectUpdatedOriginalIndicesById(toUpdate: Map<string | number, T>, state: TransactionCollectionState<T>): void;
/** Handles removals for both root-level and nested items. */
protected applyRemovalsById(remove: T[], state: TransactionCollectionState<T>): void;
/** Walks the tree to find and replace a nested item by ID. Returns true if found. */
private replaceNestedItem;
/** Walks the tree to find and splice a nested item by ID. Returns true if found. */
private removeNestedItem;
/** Removes items from groups by matching their ID values. */
private removeFromGroupsByIdForHierarchy;
}
export {};