| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import type { IDocument } from '@antv/g';
- import type { AnimationResult } from '../animation';
- import type { DisplayObject, IAnimation } from '../shapes';
- import { Group } from '../shapes';
- export type _Element = DisplayObject & {
- __data__?: any;
- __toData__?: any[];
- __fromElements__?: DisplayObject[];
- __facet__?: boolean;
- };
- /**
- * A simple implementation of d3-selection for @antv/g.
- * It has the core features of d3-selection and extended ability.
- * Every methods of selection returns new selection if elements
- * are mutated(e.g. append, remove), otherwise return the selection itself(e.g. attr, style).
- * @see https://github.com/d3/d3-selection
- * @see https://github.com/antvis/g
- * @todo Nested selections.
- * @todo More useful functor.
- */
- export declare class Selection<T = any> {
- #private;
- static registry: Record<string, new () => _Element>;
- private _elements;
- private _parent;
- private _data;
- private _enter;
- private _exit;
- private _update;
- private _merge;
- private _split;
- private _document;
- private _transitions;
- private _facetElements;
- constructor(elements?: Iterable<_Element>, data?: T[] | [T, _Element[]][], parent?: _Element, document?: IDocument | null, selections?: [Selection, Selection, Selection, Selection, Selection], transitions?: Promise<void>[], updateElements?: _Element[]);
- selectAll(selector: string | _Element[]): Selection<T>;
- selectFacetAll(selector: string | _Element[]): Selection<T>;
- /**
- * @todo Replace with querySelector which has bug now.
- */
- select(selector: string | _Element): Selection<T>;
- append(node: string | ((data: T, i: number) => _Element)): Selection<T>;
- maybeAppend<T = DisplayObject>(id: string, node: string | (() => _Element)): Selection<T>;
- maybeAppendByClassName<T = DisplayObject>(className: any, node: string | (() => _Element)): Selection<T>;
- maybeAppendByName<T = DisplayObject>(name: string, node: string | (() => _Element)): Selection<T>;
- /**
- * Bind data to elements, and produce three selection:
- * Enter: Selection with empty elements and data to be bind to elements.
- * Update: Selection with elements to be updated.
- * Exit: Selection with elements to be removed.
- */
- data<T = any>(data: T[], id?: (d: T, index?: number) => any, groupId?: (d: T, index?: number) => any): Selection<T>;
- merge(other: Selection<T>): Selection<T>;
- createElement(type: string): _Element;
- /**
- * Apply callback for each selection(enter, update, exit)
- * and merge them into one selection.
- */
- join(enter?: (selection: Selection<T>) => any, update?: (selection: Selection<T>) => any, exit?: (selection: Selection<T>) => any, merge?: (selection: Selection<T>) => any, split?: (selection: Selection<T>) => any): Selection<T>;
- remove(): Selection<T>;
- each(callback: (datum: T, index: number) => any): Selection<T>;
- attr(key: string, value: any): Selection<T>;
- style(key: string, value: any, callbackable?: boolean): Selection<T>;
- styles(style?: Record<string, any>, callbackable?: boolean): Selection<T>;
- update(option: any, callbackable?: boolean): Selection<T>;
- /** if current stage is maybeAppend, skip update stage */
- maybeUpdate(option: any, callbackable?: boolean): Selection<T>;
- transition(callback?: (datum: T, index: number) => (null | IAnimation) | (null | IAnimation)[]): Selection<T>;
- on(event: string, handler: any): this;
- call(callback: (selection: Selection<T>, ...args: any[]) => any, ...args: any[]): Selection<T>;
- node<T extends _Element = _Element>(): T;
- nodes(): _Element[];
- transitions(): AnimationResult[];
- parent(): DisplayObject;
- }
- export declare function select<T = any>(node: DisplayObject): Selection<T>;
- export declare function maybeAppend<T>(parent: Group, selector: string, node: string | ((data: T, i: number) => _Element)): Selection<T>;
|