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.

206 lines
8.5 KiB

4 months ago
import { ID } from '@antv/graphlib';
import type { DagreAlign, DagreRankdir } from './antv-dagre/types';
import type { Graph as IGraph, Layout, LayoutMapping, Node, OutNode, PointTuple } from './types';
import type { Size } from './util/size';
/**
* <zh/> /
*
* <en/> The configuration options for the hierarchical/flowchart layout
*/
export interface AntVDagreLayoutOptions {
/**
* <zh/> TtopBbottomLleftRright
* - 'TB':
* - 'BT':
* - 'LR':
* - 'RL':
* <en/> The direction of the layout. T: top; B: bottom; L: left; R: right
* - 'TB':from top to bottom
* - 'BT':from bottom to top
* - 'LR':from left to right
* - 'RL':from right to left
* @defaultValue 'TB'
*/
rankdir?: DagreRankdir;
/**
* <zh/>
*
* <en/> The mode of the layout
*/
ranker?: 'network-simplex' | 'tight-tree' | 'longest-path';
/**
* <zh/> UupperDdownLleftRright
* - 'UL':
* - 'UR':
* - 'DL':
* - 'DR':
* - undefined:
* <en/> The alignment of the nodes U: upper; D: down; L: left; R: right
* - 'UL':align to left top
* - 'UR':align to right top
* - 'DL':align to left bottom
* - 'DR':align to right bottom
* - undefined:default, align to center
* @defaultValue 'UL'
*/
align?: DagreAlign;
/**
* <zh/>
*
* <en/> The position of the layout's top-left corner
* @defaultValue undefined
*/
begin?: PointTuple;
/**
* <zh/>
*
* <en/> The diameter of the node
* @remarks
* <zh/>
*
* <en/> Used for collision detection when nodes overlap
* @defaultValue undefined
*/
nodeSize?: Size | ((nodeData: Node) => Size);
/**
* <zh/> px
*
* <en/> The horizontal gap between nodes (px)
* @remarks
* <zh/> rankdir 'TB' 'BT' rankdir 'LR' 'RL' nodesepFunc
*
* <en/> The horizontal gap between nodes (px) in the case of rankdir is 'TB' or 'BT'. The vertical gap between nodes (px) in the case of rankdir is 'LR' or 'RL'. nodesepFunc has a higher priority
* @defaultValue 50
*/
nodesep?: number;
/**
* <zh/> px
*
* <en/> The vertical gap between levels (px)
* @remarks
* <zh/> rankdir 'TB' 'BT' rankdir 'LR' 'RL' ranksepFunc
*
* <en/> The vertical gap between levels (px) in the case of rankdir is 'TB' or 'BT'. The horizontal gap between levels (px) in the case of rankdir is 'LR' or 'RL'. ranksepFunc has a higher priority
* @defaultValue 50
*/
ranksep?: number;
/**
* <zh/>
*
* <en/> Whether to calculate the control point position of the edge at the same time
* @remarks
* <zh/> 使线type: 'polyline-edge' data.controlPoints data.controlPoints
*
* <en/> It only takes effect when the built-in polyline edge (type: 'polyline-edge') is used in the edge configuration, or any edge that consumes data.controlPoints as the control point position. In essence, it adds data.controlPoints to the edge data
* @defaultValue false
*/
controlPoints?: boolean;
/**
* <zh/> parentId Combo
*
* <en/> Whether to sort nodes in the same layer according to the parentId in each node data to prevent Combo overlapping
* @remarks
* <zh/> Combo
*
* <en/> It is recommended to configure when there is a Combo
* @defaultValue false
*/
sortByCombo?: boolean;
/**
* <zh/> label留位置
*
* <en/> Whether to leave space for the label of the edge
* @remarks
* <zh/> dummy node
*
* <en/> It will affect whether to add a dummy node in the middle of the edge
* @defaultValue true
*/
edgeLabelSpace?: boolean;
/**
* <zh/> id
*
* <en/> The reference array of the order of the nodes in the same layer, storing the node id value
* @remarks
* <zh/> dagre
*
* <en/> If not specified, the same layer node order will be arranged according to the mechanism of dagre itself
* @defaultValue false
*/
nodeOrder?: string[];
/**
* <zh/> dagre
*
* <en/> Whether to use dagre for radial layout
*/
radial?: boolean;
/**
* <zh/>
* - ID: 节点 id
* - Node: 节点实例
* - null:
*
* <en/> The focused node
* - ID: node id
* - Node: node instance
* - null: cancel focus
* @remarks
* <zh/> radial true
*
* <en/> It takes effect when radial is true
*/
focusNode?: ID | Node | null;
/**
* <zh/>
*
* <en/> The reference node position when calculating the layout
* @remarks
* <zh/> G6 使
*
* <en/> It is generally used to ensure the continuity of the layout when switching data. In G6, if you update the data, the existing layout result data will be used as input automatically
* @defaultValue undefined
*/
preset?: OutNode[];
/**
* <zh/> px
*
* <en/> The callback function of the node spacing (px), which can be used to set different node spacing for different nodes
* @remarks
* <zh/> rankdir 'TB' 'BT' rankdir 'LR' 'RL' nodesep nodesepFunc nodesep
*
* <en/> The horizontal spacing of the node in the case of rankdir is 'TB' or 'BT', and the vertical spacing of the node in the case of rankdir is 'LR' or 'RL'. The priority is higher than nodesep, that is, if nodesepFunc is set, nodesep does not take effect
* @param d - <zh/> | <en/> Node instance
*/
nodesepFunc?: (d?: Node) => number;
/**
* <zh/> px
*
* <en/> The callback function of the layer spacing (px)
* @remarks
* <zh/> rankdir 'TB' 'BT' rankdir 'LR' 'RL' nodesep nodesepFunc nodesep
*
* <en/> The vertical spacing of adjacent layers in the case of rankdir is 'TB' or 'BT', and the horizontal spacing of adjacent layers in the case of rankdir is 'LR' or 'RL'. The priority is higher than nodesep, that is, if nodesepFunc is set, nodesep does not take effect
* @param d - <zh/> | <en/> Node instance
*/
ranksepFunc?: (d?: Node) => number;
}
/**
* <zh/> AntV Dagre
*
* <en/> AntV implementation of Dagre layout
*/
export declare class AntVDagreLayout implements Layout<AntVDagreLayoutOptions> {
options: AntVDagreLayoutOptions;
id: string;
constructor(options?: AntVDagreLayoutOptions);
/**
* Return the positions of nodes and edges(if needed).
*/
execute(graph: IGraph, options?: AntVDagreLayoutOptions): Promise<LayoutMapping>;
/**
* To directly assign the positions to the nodes.
*/
assign(graph: IGraph, options?: AntVDagreLayoutOptions): Promise<void>;
private genericDagreLayout;
}