UNPKG

2.58 kBTypeScriptView Raw
1/**
2 * @fileOverview concentric layout
3 * @author shiwu.wyy@antfin.com
4 * this algorithm refers to <cytoscape.js> - https://github.com/cytoscape/cytoscape.js/
5 */
6import { OutNode, Edge, PointTuple } from './types';
7import { Base } from './base';
8declare type INode = OutNode & {
9 degree: number;
10 size: number | PointTuple;
11};
12/**
13 * 同心圆布局
14 */
15export declare class ConcentricLayout extends Base {
16 /** 布局中心 */
17 center: PointTuple;
18 nodeSize: number | PointTuple;
19 /** min spacing between outside of nodes (used for radius adjustment) */
20 minNodeSpacing: number;
21 /** prevents node overlap, may overflow boundingBox if not enough space */
22 preventOverlap: boolean;
23 /** how many radians should be between the first and last node (defaults to full circle) */
24 sweep: number | undefined;
25 /** whether levels have an equal radial distance betwen them, may cause bounding box overflow */
26 equidistant: boolean;
27 /** where nodes start in radians */
28 startAngle: number;
29 /** whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) */
30 clockwise: boolean;
31 /** the letiation of concentric values in each level */
32 maxLevelDiff: undefined | number;
33 /** 根据 sortBy 指定的属性进行排布,数值高的放在中心,如果是 sortBy 则会计算节点度数,度数最高的放在中心 */
34 sortBy: string;
35 nodes: INode[];
36 edges: Edge[];
37 width: number;
38 height: number;
39 private maxValueNode;
40 private counterclockwise;
41 constructor(options?: ConcentricLayout.ConcentricLayoutOptions);
42 getDefaultCfg(): {
43 nodeSize: number;
44 minNodeSpacing: number;
45 preventOverlap: boolean;
46 sweep: undefined;
47 equidistant: boolean;
48 startAngle: number;
49 clockwise: boolean;
50 maxLevelDiff: undefined;
51 sortBy: string;
52 };
53 /**
54 * 执行布局
55 */
56 execute(): {
57 nodes: INode[];
58 edges: Edge[];
59 } | undefined;
60 getType(): string;
61}
62export declare namespace ConcentricLayout {
63 interface ConcentricLayoutOptions {
64 type: 'concentric';
65 center?: PointTuple;
66 preventOverlap?: boolean;
67 nodeSize?: number | PointTuple;
68 minNodeSpacing?: number;
69 sweep?: number;
70 equidistant?: boolean;
71 startAngle?: number;
72 clockwise?: boolean;
73 maxLevelDiff?: number;
74 sortBy?: string;
75 workerEnabled?: boolean;
76 width?: number;
77 height?: number;
78 }
79}
80export {};