@antv/layout 1.0.0-alpha.0 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/03710bc99fe066d705cb.worker.js +2 -0
- package/dist/03710bc99fe066d705cb.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/esm/03710bc99fe066d705cb.worker.js +2 -0
- package/esm/03710bc99fe066d705cb.worker.js.map +1 -0
- package/esm/index.esm.js +2 -0
- package/esm/index.esm.js.map +1 -0
- package/lib/Circular.d.ts +3 -13
- package/lib/Supervisor.d.ts +2 -2
- package/lib/concentric.d.ts +30 -0
- package/lib/grid.d.ts +30 -0
- package/lib/index.d.ts +5 -0
- package/lib/mds.d.ts +30 -0
- package/lib/radial/RadialNonoverlapForce.d.ts +16 -0
- package/lib/radial/index.d.ts +32 -0
- package/lib/radial/mds.d.ts +2 -0
- package/lib/random.d.ts +30 -0
- package/lib/types.d.ts +184 -89
- package/lib/util/math.d.ts +8 -4
- package/lib/worker.d.ts +1 -1
- package/package.json +12 -5
- package/dist/3a54d760230d1933f953.worker.js +0 -2
- package/dist/3a54d760230d1933f953.worker.js.map +0 -1
package/lib/Circular.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import type { Graph } from "
|
|
2
|
-
import type { CircularLayoutOptions, SyncLayout, LayoutMapping, PointTuple, OutNode } from "./types";
|
|
3
|
-
type INodeData = OutNode & {
|
|
4
|
-
degree: number;
|
|
5
|
-
size: number | PointTuple;
|
|
6
|
-
weight: number;
|
|
7
|
-
children: string[];
|
|
8
|
-
parent: string[];
|
|
9
|
-
};
|
|
10
|
-
type IEdgeData = {};
|
|
1
|
+
import type { Graph, CircularLayoutOptions, SyncLayout, LayoutMapping } from "./types";
|
|
11
2
|
/**
|
|
12
3
|
* Layout arranging the nodes in a circle.
|
|
13
4
|
*
|
|
@@ -30,11 +21,10 @@ export declare class CircularLayout implements SyncLayout<CircularLayoutOptions>
|
|
|
30
21
|
/**
|
|
31
22
|
* Return the positions of nodes and edges(if needed).
|
|
32
23
|
*/
|
|
33
|
-
execute(graph: Graph
|
|
24
|
+
execute(graph: Graph, options?: CircularLayoutOptions): LayoutMapping;
|
|
34
25
|
/**
|
|
35
26
|
* To directly assign the positions to the nodes.
|
|
36
27
|
*/
|
|
37
|
-
assign(graph: Graph
|
|
28
|
+
assign(graph: Graph, options?: CircularLayoutOptions): void;
|
|
38
29
|
private genericCircularLayout;
|
|
39
30
|
}
|
|
40
|
-
export {};
|
package/lib/Supervisor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
import { Graph, Node, Edge } from "@antv/graphlib";
|
|
3
|
-
import type { SyncLayout } from "./types";
|
|
3
|
+
import type { SyncLayout, LayoutSupervisor } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* The payload transferred from main thread to the worker.
|
|
6
6
|
*/
|
|
@@ -43,7 +43,7 @@ export declare const SupervisorEvent: {
|
|
|
43
43
|
*
|
|
44
44
|
* // TODO: Custom layout.
|
|
45
45
|
*/
|
|
46
|
-
export declare class Supervisor extends EventEmitter {
|
|
46
|
+
export declare class Supervisor extends EventEmitter implements LayoutSupervisor {
|
|
47
47
|
private graph;
|
|
48
48
|
private layout;
|
|
49
49
|
/**
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Graph, LayoutMapping, ConcentricLayoutOptions, SyncLayout } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Layout arranging the nodes in concentrics
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Assign layout options when initialization.
|
|
7
|
+
* const layout = new ConcentricLayout({ nodeSpacing: 10 });
|
|
8
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
*
|
|
10
|
+
* // Or use different options later.
|
|
11
|
+
* const layout = new ConcentricLayout({ nodeSpacing: 10});
|
|
12
|
+
* const positions = layout.execute(graph, { nodeSpacing: 10 }); // { nodes: [], edges: [] }
|
|
13
|
+
*
|
|
14
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
+
* layout.assign(graph, { nodeSpacing: 10 });
|
|
16
|
+
*/
|
|
17
|
+
export declare class ConcentricLayout implements SyncLayout<ConcentricLayoutOptions> {
|
|
18
|
+
options: ConcentricLayoutOptions;
|
|
19
|
+
id: string;
|
|
20
|
+
constructor(options?: ConcentricLayoutOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Return the positions of nodes and edges(if needed).
|
|
23
|
+
*/
|
|
24
|
+
execute(graph: Graph, options?: ConcentricLayoutOptions): LayoutMapping;
|
|
25
|
+
/**
|
|
26
|
+
* To directly assign the positions to the nodes.
|
|
27
|
+
*/
|
|
28
|
+
assign(graph: Graph, options?: ConcentricLayoutOptions): void;
|
|
29
|
+
private genericConcentricLayout;
|
|
30
|
+
}
|
package/lib/grid.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Graph, GridLayoutOptions, LayoutMapping, SyncLayout } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Layout arranging the nodes in a grid.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Assign layout options when initialization.
|
|
7
|
+
* const layout = new GridLayout({ rows: 10 });
|
|
8
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
*
|
|
10
|
+
* // Or use different options later.
|
|
11
|
+
* const layout = new GridLayout({ rows: 10 });
|
|
12
|
+
* const positions = layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
|
|
13
|
+
*
|
|
14
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
+
* layout.assign(graph, { rows: 20 });
|
|
16
|
+
*/
|
|
17
|
+
export declare class GridLayout implements SyncLayout<GridLayoutOptions> {
|
|
18
|
+
options: GridLayoutOptions;
|
|
19
|
+
id: string;
|
|
20
|
+
constructor(options?: GridLayoutOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Return the positions of nodes and edges(if needed).
|
|
23
|
+
*/
|
|
24
|
+
execute(graph: Graph, options?: GridLayoutOptions): LayoutMapping;
|
|
25
|
+
/**
|
|
26
|
+
* To directly assign the positions to the nodes.
|
|
27
|
+
*/
|
|
28
|
+
assign(graph: Graph, options?: GridLayoutOptions): void;
|
|
29
|
+
private genericGridLayout;
|
|
30
|
+
}
|
package/lib/index.d.ts
CHANGED
package/lib/mds.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Graph, LayoutMapping, MDSLayoutOptions, SyncLayout } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Layout arranging the nodes with multiple dimensional scaling algorithm
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Assign layout options when initialization.
|
|
7
|
+
* const layout = new MDSLayout({ center: [100, 100] });
|
|
8
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
*
|
|
10
|
+
* // Or use different options later.
|
|
11
|
+
* const layout = new MDSLayout({ center: [100, 100] });
|
|
12
|
+
* const positions = layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
|
|
13
|
+
*
|
|
14
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
+
* layout.assign(graph, { center: [100, 100] });
|
|
16
|
+
*/
|
|
17
|
+
export declare class MDSLayout implements SyncLayout<MDSLayoutOptions> {
|
|
18
|
+
options: MDSLayoutOptions;
|
|
19
|
+
id: string;
|
|
20
|
+
constructor(options?: MDSLayoutOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Return the positions of nodes and edges(if needed).
|
|
23
|
+
*/
|
|
24
|
+
execute(graph: Graph, options?: MDSLayoutOptions): LayoutMapping;
|
|
25
|
+
/**
|
|
26
|
+
* To directly assign the positions to the nodes.
|
|
27
|
+
*/
|
|
28
|
+
assign(graph: Graph, options?: MDSLayoutOptions): void;
|
|
29
|
+
private genericMDSLayout;
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Graph, Node, Point } from "../types";
|
|
2
|
+
export type RadialNonoverlapForceOptions = {
|
|
3
|
+
positions: Point[];
|
|
4
|
+
focusIdx: number;
|
|
5
|
+
radii: number[];
|
|
6
|
+
iterations: number;
|
|
7
|
+
height: number;
|
|
8
|
+
width: number;
|
|
9
|
+
k: number;
|
|
10
|
+
strictRadial: boolean;
|
|
11
|
+
nodes: Node[];
|
|
12
|
+
speed?: number;
|
|
13
|
+
gravity?: number;
|
|
14
|
+
nodeSizeFunc: (node: Node) => number;
|
|
15
|
+
};
|
|
16
|
+
export declare const radialNonoverlapForce: (graph: Graph, options: RadialNonoverlapForceOptions) => Point[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Graph, LayoutMapping, RadialLayoutOptions, SyncLayout } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Layout arranging the nodes' on a radial shape
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Assign layout options when initialization.
|
|
7
|
+
* const layout = new RadialLayout({ focusNode: 'node0' });
|
|
8
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
*
|
|
10
|
+
* // Or use different options later.
|
|
11
|
+
* const layout = new RadialLayout({ focusNode: 'node0' });
|
|
12
|
+
* const positions = layout.execute(graph, { focusNode: 'node0' }); // { nodes: [], edges: [] }
|
|
13
|
+
*
|
|
14
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
+
* layout.assign(graph, { focusNode: 'node0' });
|
|
16
|
+
*/
|
|
17
|
+
export declare class RadialLayout implements SyncLayout<RadialLayoutOptions> {
|
|
18
|
+
options: RadialLayoutOptions;
|
|
19
|
+
id: string;
|
|
20
|
+
constructor(options?: RadialLayoutOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Return the positions of nodes and edges(if needed).
|
|
23
|
+
*/
|
|
24
|
+
execute(graph: Graph, options?: RadialLayoutOptions): LayoutMapping;
|
|
25
|
+
/**
|
|
26
|
+
* To directly assign the positions to the nodes.
|
|
27
|
+
*/
|
|
28
|
+
assign(graph: Graph, options?: RadialLayoutOptions): void;
|
|
29
|
+
private genericRadialLayout;
|
|
30
|
+
private run;
|
|
31
|
+
private oneIteration;
|
|
32
|
+
}
|
package/lib/random.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Graph, LayoutMapping, RandomLayoutOptions, SyncLayout } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Layout randomizing the nodes' position
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Assign layout options when initialization.
|
|
7
|
+
* const layout = new RandomLayout({ center: [100, 100] });
|
|
8
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
*
|
|
10
|
+
* // Or use different options later.
|
|
11
|
+
* const layout = new RandomLayout({ center: [100, 100] });
|
|
12
|
+
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
|
+
*
|
|
14
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
+
* layout.assign(graph, { center: [100, 100] });
|
|
16
|
+
*/
|
|
17
|
+
export declare class RandomLayout implements SyncLayout<RandomLayoutOptions> {
|
|
18
|
+
options: RandomLayoutOptions;
|
|
19
|
+
id: string;
|
|
20
|
+
constructor(options?: RandomLayoutOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Return the positions of nodes and edges(if needed).
|
|
23
|
+
*/
|
|
24
|
+
execute(graph: Graph, options?: RandomLayoutOptions): LayoutMapping;
|
|
25
|
+
/**
|
|
26
|
+
* To directly assign the positions to the nodes.
|
|
27
|
+
*/
|
|
28
|
+
assign(graph: Graph, options?: RandomLayoutOptions): void;
|
|
29
|
+
private genericRandomLayout;
|
|
30
|
+
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,102 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
export interface
|
|
3
|
-
|
|
1
|
+
import { Graph as IGraph, Node as INode, Edge as IEdge, PlainObject } from "@antv/graphlib";
|
|
2
|
+
export interface NodeData extends PlainObject {
|
|
3
|
+
visible?: boolean;
|
|
4
|
+
size?: number | number[];
|
|
5
|
+
bboxSize?: number[];
|
|
4
6
|
}
|
|
5
|
-
export interface
|
|
7
|
+
export interface OutNodeData extends NodeData {
|
|
6
8
|
x: number;
|
|
7
9
|
y: number;
|
|
8
|
-
fx?: number;
|
|
9
|
-
fy?: number;
|
|
10
|
-
comboId?: string;
|
|
11
|
-
layer?: number;
|
|
12
|
-
_order?: number;
|
|
13
|
-
layout?: boolean;
|
|
14
|
-
size?: number | number[] | undefined;
|
|
15
|
-
}
|
|
16
|
-
export interface Edge {
|
|
17
|
-
source: string;
|
|
18
|
-
target: string;
|
|
19
|
-
}
|
|
20
|
-
export interface Combo {
|
|
21
|
-
id: string;
|
|
22
|
-
parentId?: string;
|
|
23
|
-
x?: number;
|
|
24
|
-
y?: number;
|
|
25
|
-
name?: string | number;
|
|
26
|
-
cx?: number;
|
|
27
|
-
cy?: number;
|
|
28
|
-
count?: number;
|
|
29
|
-
depth?: number;
|
|
30
|
-
children?: any[];
|
|
31
|
-
empty?: boolean;
|
|
32
|
-
minX?: number;
|
|
33
|
-
maxX?: number;
|
|
34
|
-
minY?: number;
|
|
35
|
-
maxY?: number;
|
|
36
|
-
size?: number;
|
|
37
|
-
r?: number;
|
|
38
|
-
itemType?: string;
|
|
39
|
-
collapsed?: boolean;
|
|
40
|
-
}
|
|
41
|
-
export interface Model {
|
|
42
|
-
nodes?: Node[];
|
|
43
|
-
edges?: Edge[];
|
|
44
|
-
combos?: Combo[];
|
|
45
|
-
comboEdges?: Edge[];
|
|
46
|
-
hiddenNodes?: Node[];
|
|
47
|
-
hiddenEdges?: Edge[];
|
|
48
|
-
hiddenCombos?: Combo[];
|
|
49
|
-
vedges?: Edge[];
|
|
50
|
-
}
|
|
51
|
-
export interface OutModel extends Model {
|
|
52
|
-
nodes?: OutNode[];
|
|
53
|
-
}
|
|
54
|
-
export interface Size {
|
|
55
|
-
width: number;
|
|
56
|
-
height: number;
|
|
57
10
|
}
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export type
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
export type Matrix = number[];
|
|
69
|
-
export type Point = {
|
|
70
|
-
x: number;
|
|
71
|
-
y: number;
|
|
72
|
-
};
|
|
11
|
+
export interface EdgeData extends PlainObject {
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
virtual?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** input node */
|
|
16
|
+
export type Node = INode<NodeData>;
|
|
17
|
+
/** output node */
|
|
18
|
+
export type OutNode = INode<OutNodeData>;
|
|
19
|
+
/** input and output edge */
|
|
20
|
+
export type Edge = IEdge<EdgeData>;
|
|
73
21
|
export type Degree = {
|
|
74
22
|
in: number;
|
|
75
23
|
out: number;
|
|
76
24
|
all: number;
|
|
77
25
|
};
|
|
78
|
-
export
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
parentId?: string;
|
|
83
|
-
itemType?: "node" | "combo";
|
|
84
|
-
[key: string]: unknown;
|
|
85
|
-
}
|
|
86
|
-
export interface ComboConfig {
|
|
87
|
-
id: string;
|
|
88
|
-
parentId?: string;
|
|
89
|
-
children?: ComboTree[];
|
|
90
|
-
depth?: number;
|
|
91
|
-
}
|
|
26
|
+
export type IndexMap = {
|
|
27
|
+
[nodeId: string]: number;
|
|
28
|
+
};
|
|
29
|
+
export type Graph = IGraph<NodeData, EdgeData>;
|
|
92
30
|
export type PointTuple = [number, number];
|
|
31
|
+
export type Point = {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
};
|
|
35
|
+
export type Matrix = number[];
|
|
93
36
|
export type LayoutMapping = {
|
|
94
37
|
nodes: OutNode[];
|
|
95
38
|
edges: Edge[];
|
|
96
39
|
};
|
|
97
40
|
export interface SyncLayout<LayoutOptions> {
|
|
98
|
-
assign(graph: Graph
|
|
99
|
-
execute(graph: Graph
|
|
41
|
+
assign(graph: Graph, options?: LayoutOptions): void;
|
|
42
|
+
execute(graph: Graph, options?: LayoutOptions): LayoutMapping;
|
|
100
43
|
options: LayoutOptions;
|
|
101
44
|
id: string;
|
|
102
45
|
}
|
|
@@ -107,8 +50,13 @@ export interface LayoutSupervisor {
|
|
|
107
50
|
start(): void;
|
|
108
51
|
stop(): void;
|
|
109
52
|
kill(): void;
|
|
53
|
+
isRunning(): boolean;
|
|
110
54
|
}
|
|
111
|
-
|
|
55
|
+
interface CommonOptions {
|
|
56
|
+
layoutInvisibles?: boolean;
|
|
57
|
+
onLayoutEnd?: (data: LayoutMapping) => void;
|
|
58
|
+
}
|
|
59
|
+
export interface CircularLayoutOptions extends CommonOptions {
|
|
112
60
|
center?: PointTuple;
|
|
113
61
|
width?: number;
|
|
114
62
|
height?: number;
|
|
@@ -119,10 +67,157 @@ export interface CircularLayoutOptions {
|
|
|
119
67
|
divisions?: number;
|
|
120
68
|
ordering?: "topology" | "topology-directed" | "degree" | null;
|
|
121
69
|
angleRatio?: number;
|
|
122
|
-
workerEnabled?: boolean;
|
|
123
70
|
startAngle?: number;
|
|
124
71
|
endAngle?: number;
|
|
125
|
-
nodeSpacing?: ((
|
|
126
|
-
nodeSize?: number;
|
|
127
|
-
|
|
72
|
+
nodeSpacing?: ((node?: Node) => number) | number;
|
|
73
|
+
nodeSize?: number | number[];
|
|
74
|
+
}
|
|
75
|
+
export interface GridLayoutOptions extends CommonOptions {
|
|
76
|
+
width?: number;
|
|
77
|
+
height?: number;
|
|
78
|
+
begin?: PointTuple;
|
|
79
|
+
preventOverlap?: boolean;
|
|
80
|
+
nodeSize?: number | number[];
|
|
81
|
+
preventOverlapPadding?: number;
|
|
82
|
+
condense?: boolean;
|
|
83
|
+
rows?: number;
|
|
84
|
+
cols?: number;
|
|
85
|
+
sortBy?: string;
|
|
86
|
+
columns?: number | undefined;
|
|
87
|
+
position?: ((node?: Node) => {
|
|
88
|
+
row?: number;
|
|
89
|
+
col?: number;
|
|
90
|
+
}) | undefined;
|
|
91
|
+
nodeSpacing?: ((node?: Node) => number) | number | undefined;
|
|
92
|
+
}
|
|
93
|
+
export interface RandomLayoutOptions extends CommonOptions {
|
|
94
|
+
center?: PointTuple;
|
|
95
|
+
width?: number;
|
|
96
|
+
height?: number;
|
|
97
|
+
}
|
|
98
|
+
export interface MDSLayoutOptions extends CommonOptions {
|
|
99
|
+
center?: PointTuple;
|
|
100
|
+
linkDistance?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface ConcentricLayoutOptions extends CommonOptions {
|
|
103
|
+
center?: PointTuple;
|
|
104
|
+
preventOverlap?: boolean;
|
|
105
|
+
nodeSize?: number | PointTuple;
|
|
106
|
+
minNodeSpacing?: number;
|
|
107
|
+
sweep?: number;
|
|
108
|
+
equidistant?: boolean;
|
|
109
|
+
startAngle?: number;
|
|
110
|
+
clockwise?: boolean;
|
|
111
|
+
maxLevelDiff?: number;
|
|
112
|
+
sortBy?: string;
|
|
113
|
+
width?: number;
|
|
114
|
+
height?: number;
|
|
115
|
+
nodeSpacing: number | number[] | ((node?: Node) => number) | undefined;
|
|
116
|
+
}
|
|
117
|
+
export interface RadialLayoutOptions extends CommonOptions {
|
|
118
|
+
center?: PointTuple;
|
|
119
|
+
width?: number;
|
|
120
|
+
height?: number;
|
|
121
|
+
linkDistance?: number;
|
|
122
|
+
maxIteration?: number;
|
|
123
|
+
focusNode?: string | Node | null;
|
|
124
|
+
unitRadius?: number | null;
|
|
125
|
+
preventOverlap?: boolean;
|
|
126
|
+
nodeSize?: number | number[] | undefined;
|
|
127
|
+
nodeSpacing?: number | Function | undefined;
|
|
128
|
+
maxPreventOverlapIteration?: number;
|
|
129
|
+
strictRadial?: boolean;
|
|
130
|
+
sortBy?: string | undefined;
|
|
131
|
+
sortStrength?: number;
|
|
132
|
+
}
|
|
133
|
+
export interface DagreLayoutOptions extends CommonOptions {
|
|
134
|
+
rankdir?: "TB" | "BT" | "LR" | "RL";
|
|
135
|
+
align?: "UL" | "UR" | "DL" | "DR";
|
|
136
|
+
begin?: PointTuple;
|
|
137
|
+
nodeSize?: number | number[] | undefined;
|
|
138
|
+
nodesep?: number;
|
|
139
|
+
ranksep?: number;
|
|
140
|
+
controlPoints?: boolean;
|
|
141
|
+
sortByCombo?: boolean;
|
|
142
|
+
edgeLabelSpace?: boolean;
|
|
143
|
+
nodeOrder?: string[];
|
|
144
|
+
radial?: boolean;
|
|
145
|
+
focusNode: string | Node | null;
|
|
146
|
+
preset?: {
|
|
147
|
+
nodes: OutNode[];
|
|
148
|
+
edges: Edge[];
|
|
149
|
+
};
|
|
150
|
+
nodesepFunc?: ((d?: Node) => number) | undefined;
|
|
151
|
+
ranksepFunc?: ((d?: Node) => number) | undefined;
|
|
152
|
+
}
|
|
153
|
+
export interface D3ForceLayoutOptions extends CommonOptions {
|
|
154
|
+
center?: PointTuple;
|
|
155
|
+
linkDistance?: number | ((d?: Edge) => number) | undefined;
|
|
156
|
+
edgeStrength?: number | ((d?: Edge) => number) | undefined;
|
|
157
|
+
nodeStrength?: number | ((d?: Node) => number) | undefined;
|
|
158
|
+
preventOverlap?: boolean;
|
|
159
|
+
collideStrength?: number;
|
|
160
|
+
nodeSize?: number | number[] | ((d?: Node) => number) | undefined;
|
|
161
|
+
nodeSpacing?: number | number[] | ((d?: Node) => number) | undefined;
|
|
162
|
+
alpha?: number;
|
|
163
|
+
alphaDecay?: number;
|
|
164
|
+
alphaMin?: number;
|
|
165
|
+
clustering?: boolean;
|
|
166
|
+
clusterNodeStrength?: number;
|
|
167
|
+
clusterEdgeStrength?: number;
|
|
168
|
+
clusterEdgeDistance?: number;
|
|
169
|
+
clusterNodeSize?: number;
|
|
170
|
+
clusterFociStrength?: number;
|
|
171
|
+
forceSimulation?: any;
|
|
172
|
+
onTick?: (data: LayoutMapping) => void;
|
|
173
|
+
}
|
|
174
|
+
export interface CentripetalOptions {
|
|
175
|
+
/** Force strength for leaf nodes. */
|
|
176
|
+
leaf?: number | ((node: Node, nodes: Node[], edges: Edge[]) => number);
|
|
177
|
+
/** Force strength for single nodes. */
|
|
178
|
+
single?: number | ((node: Node) => number);
|
|
179
|
+
/** Force strength for other nodes. */
|
|
180
|
+
others?: number | ((node: Node) => number);
|
|
181
|
+
/** Centri force's position and sterngth, points to the canvas center by default */
|
|
182
|
+
center?: (node: Node, nodes: Node[], edges: Edge[], width: number, height: number) => {
|
|
183
|
+
x: number;
|
|
184
|
+
y: number;
|
|
185
|
+
centerStrength?: number;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
export interface ForceLayoutOptions extends CommonOptions {
|
|
189
|
+
center?: PointTuple;
|
|
190
|
+
width?: number;
|
|
191
|
+
height?: number;
|
|
192
|
+
linkDistance?: number | ((edge?: Edge, source?: any, target?: any) => number) | undefined;
|
|
193
|
+
nodeStrength?: number | ((d?: Node) => number) | undefined;
|
|
194
|
+
edgeStrength?: number | ((d?: Edge) => number) | undefined;
|
|
195
|
+
preventOverlap?: boolean;
|
|
196
|
+
nodeSize?: number | number[] | ((d?: Node) => number) | undefined;
|
|
197
|
+
nodeSpacing?: number | number[] | ((d?: Node) => number) | undefined;
|
|
198
|
+
minMovement?: number;
|
|
199
|
+
maxIteration?: number;
|
|
200
|
+
damping?: number;
|
|
201
|
+
maxSpeed?: number;
|
|
202
|
+
coulombDisScale?: number;
|
|
203
|
+
gravity?: number;
|
|
204
|
+
factor?: number;
|
|
205
|
+
centripetalOptions?: CentripetalOptions;
|
|
206
|
+
leafCluster?: boolean;
|
|
207
|
+
clustering?: boolean;
|
|
208
|
+
nodeClusterBy?: string;
|
|
209
|
+
clusterNodeStrength?: number | ((node: Node) => number);
|
|
210
|
+
collideStrength?: number;
|
|
211
|
+
distanceThresholdMode?: "mean" | "max" | "min";
|
|
212
|
+
animate?: boolean;
|
|
213
|
+
onTick?: (data: LayoutMapping) => void;
|
|
214
|
+
getMass?: ((d?: Node) => number) | undefined;
|
|
215
|
+
getCenter?: ((d?: Node, degree?: number) => number[]) | undefined;
|
|
216
|
+
monitor?: (params: {
|
|
217
|
+
energy: number;
|
|
218
|
+
nodes: Node[];
|
|
219
|
+
edge: Edge[];
|
|
220
|
+
iterations: number;
|
|
221
|
+
}) => void;
|
|
128
222
|
}
|
|
223
|
+
export {};
|
package/lib/util/math.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Matrix,
|
|
2
|
-
export declare const getEdgeTerminal: (edge: Edge, type: "source" | "target") => any;
|
|
1
|
+
import type { Matrix, IndexMap, Edge, Node, OutNode, Degree } from "../types";
|
|
3
2
|
export declare const getDegree: (n: number, nodeIdxMap: IndexMap, edges: Edge[] | null) => Degree[];
|
|
4
3
|
export declare const getDegreeMap: (nodes: Node[], edges: Edge[] | null) => {
|
|
5
4
|
[id: string]: Degree;
|
|
6
5
|
};
|
|
7
6
|
export declare const floydWarshall: (adjMatrix: Matrix[]) => Matrix[];
|
|
8
|
-
export declare const getAdjMatrix: (data:
|
|
7
|
+
export declare const getAdjMatrix: (data: {
|
|
8
|
+
nodes: Node[];
|
|
9
|
+
edges: Edge[];
|
|
10
|
+
}, directed: boolean) => Matrix[];
|
|
9
11
|
/**
|
|
10
12
|
* scale matrix
|
|
11
13
|
* @param matrix [ [], [], [] ]
|
|
@@ -41,7 +43,9 @@ export declare const getAvgNodePosition: (nodes: OutNode[]) => {
|
|
|
41
43
|
};
|
|
42
44
|
export declare const getCoreNodeAndRelativeLeafNodes: (type: "leaf" | "all", node: Node, edges: Edge[], nodeClusterBy: string, degreesMap: {
|
|
43
45
|
[id: string]: Degree;
|
|
44
|
-
}, nodeMap:
|
|
46
|
+
}, nodeMap: {
|
|
47
|
+
[id: string]: Node;
|
|
48
|
+
}) => {
|
|
45
49
|
coreNode: Node;
|
|
46
50
|
relativeLeafNodes: Node[];
|
|
47
51
|
sameTypeLeafNodes: Node[];
|
package/lib/worker.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Payload } from "./supervisor";
|
|
2
2
|
import type { LayoutMapping } from "./types";
|
|
3
|
-
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): (Float32Array[]
|
|
3
|
+
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): (LayoutMapping | Float32Array[])[];
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/layout",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "graph layout algorithm",
|
|
5
5
|
"main": "dist/index.min.js",
|
|
6
|
-
"module": "
|
|
6
|
+
"module": "esm/index.esm.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
8
|
"unpkg": "dist/index.min.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"package.json",
|
|
11
11
|
"dist",
|
|
12
|
+
"esm",
|
|
12
13
|
"lib",
|
|
13
14
|
"LICENSE",
|
|
14
15
|
"README.md"
|
|
@@ -20,9 +21,10 @@
|
|
|
20
21
|
"antv"
|
|
21
22
|
],
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@antv/graphlib": "^2.0.0-alpha.
|
|
24
|
+
"@antv/graphlib": "^2.0.0-alpha.1",
|
|
24
25
|
"@naoak/workerize-transferable": "^0.1.0",
|
|
25
|
-
"eventemitter3": "^4.0.0"
|
|
26
|
+
"eventemitter3": "^4.0.0",
|
|
27
|
+
"ml-matrix": "^6.10.4"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@babel/core": "^7.7.7",
|
|
@@ -36,6 +38,11 @@
|
|
|
36
38
|
"workerize-loader": "^2.0.2"
|
|
37
39
|
},
|
|
38
40
|
"scripts": {
|
|
39
|
-
"
|
|
41
|
+
"dev": "webpack --config webpack.dev.config.js --mode development",
|
|
42
|
+
"build": "npm run build:esm && npm run build:umd",
|
|
43
|
+
"build:esm": "webpack --config webpack.esm.config.js --mode production",
|
|
44
|
+
"build:umd": "webpack --config webpack.config.js --mode production",
|
|
45
|
+
"publish:alpha": "npm publish --tag alpha",
|
|
46
|
+
"test": "jest"
|
|
40
47
|
}
|
|
41
48
|
}
|