You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
5.6 KiB

4 months ago
import type { RuntimeContext } from '../runtime/types';
import type { ComboData, EdgeData, NodeData } from '../spec';
import type { Element, ElementDatum, IEvent, NodeCentralityOptions, Padding } from '../types';
import type { BaseBehaviorOptions } from './base-behavior';
import { BaseBehavior } from './base-behavior';
/**
* <zh/>
*
* <en/> Auto Adapt Label Options
*/
export interface AutoAdaptLabelOptions extends BaseBehaviorOptions {
/**
* <zh/>
*
* <en/> Whether to enable
* @defaultValue `true`
*/
enable?: boolean | ((event: IEvent) => boolean);
/**
* <zh/> combo > node > edge
*
* <en/> Sort elements by their importance in descending order; elements with higher importance have higher label display priority; usually combo > node > edge
*/
sort?: (elementA: ElementDatum, elementB: ElementDatum) => -1 | 0 | 1;
/**
* <zh/> `sort` `sortNode`
*
* <en/> Sort nodes by importance in descending order; nodes with higher importance have higher label display priority. Several centrality algorithms are built in, and custom sorting functions can also be defined. It should be noted that if `sort` is set, `sortNode` will not take effect
* @defaultValue { type: 'degree' }
*/
sortNode?: NodeCentralityOptions | ((nodeA: NodeData, nodeB: NodeData) => -1 | 0 | 1);
/**
* <zh/> `sort` `sortEdge`
*
* <en/> Sort edges by importance in descending order; edges with higher importance have higher label display priority. By default, they are sorted according to the data. It should be noted that if `sort` is set, `sortEdge` will not take effect
*/
sortEdge?: (edgeA: EdgeData, edgeB: EdgeData) => -1 | 0 | 1;
/**
* <zh/> `sort` `sortCombo`
*
* <en/> Sort combos by importance in descending order; combos with higher importance have higher label display priority. By default, they are sorted according to the data. It should be noted that if `sort` is set, `sortCombo` will not take effect
*/
sortCombo?: (comboA: ComboData, comboB: ComboData) => -1 | 0 | 1;
/**
* <zh/>
*
* <en/> Set the padding of the label to determine whether the label overlaps to avoid the label being displayed too densely
* @defaultValue 0
*/
padding?: Padding;
/**
* <zh/>
*
* <en/> Throttle time
* @defaultValue 32
*/
throttle?: number;
}
/**
* <zh/>
*
* <en/> Auto Adapt Label
* @remarks
* <zh/>
*
* <en/ >Label Adaptive Display is a dynamic label management strategy designed to intelligently adjust which labels should be shown or hidden based on factors such as the spatial allocation of the current viewport and node importance. By analyzing the visible area in real-time, it ensures that users receive the most relevant and clear information display in various interactive scenarios, while avoiding visual overload and information redundancy.
*/
export declare class AutoAdaptLabel extends BaseBehavior<AutoAdaptLabelOptions> {
static defaultOptions: Partial<AutoAdaptLabelOptions>;
constructor(context: RuntimeContext, options: AutoAdaptLabelOptions);
update(options: Partial<AutoAdaptLabelOptions>): void;
/**
* <zh/>
*
* <en/> Check whether the current bounding box has enough space to display; if it overlaps with the displayed bounding box, it will not be displayed
* @param bbox - bbox
* @param bboxes - occupied bboxes which are already shown
* @returns whether the bbox is overlapping with the bboxes or outside the viewpointBounds
*/
private isOverlapping;
private occupiedBounds;
private detectLabelCollision;
private getLabelElements;
private getLabelElementsInView;
private hideLabelIfExceedViewport;
private nodeCentralities;
private sortNodesByCentrality;
protected sortLabelElementsInView: (labelElements: Element[]) => Element[];
private labelElementsInView;
private isFirstRender;
protected onToggleVisibility: (event: IEvent) => void;
private hiddenElements;
private hideLabel;
private showLabel;
protected onTransform: () => void;
private enableToggle;
private toggle;
private onBeforeRender;
private onAfterRender;
private bindEvents;
private unbindEvents;
private validate;
destroy(): void;
}