@antv/layout 1.0.0-alpha.14 → 1.0.0-alpha.16
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/README.md +11 -6
- package/dist/0ee54f2e2414f719b33e.worker.js +2 -0
- package/dist/0ee54f2e2414f719b33e.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/esm/0ee54f2e2414f719b33e.worker.js +2 -0
- package/esm/0ee54f2e2414f719b33e.worker.js.map +1 -0
- package/esm/index.esm.js +1 -1
- package/esm/index.esm.js.map +1 -1
- package/lib/Circular.d.ts +5 -5
- package/lib/Supervisor.d.ts +3 -24
- package/lib/concentric.d.ts +5 -5
- package/lib/d3Force/index.d.ts +5 -8
- package/lib/force/index.d.ts +5 -7
- package/lib/forceAtlas2/index.d.ts +7 -10
- package/lib/fruchterman.d.ts +5 -6
- package/lib/grid.d.ts +5 -5
- package/lib/mds.d.ts +5 -5
- package/lib/radial/index.d.ts +5 -5
- package/lib/random.d.ts +5 -5
- package/lib/types.d.ts +3 -11
- package/lib/util/common.d.ts +2 -3
- package/lib/worker.d.ts +1 -1
- package/package.json +2 -2
- package/dist/b6a955aaa104d7ff3f17.worker.js +0 -2
- package/dist/b6a955aaa104d7ff3f17.worker.js.map +0 -1
- package/esm/b6a955aaa104d7ff3f17.worker.js +0 -2
- package/esm/b6a955aaa104d7ff3f17.worker.js.map +0 -1
package/lib/Circular.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, CircularLayoutOptions, Layout, LayoutMapping } from "./type
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new CircularLayout({ radius: 10 });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new CircularLayout({ radius: 10 });
|
|
12
|
-
* const positions = layout.execute(graph, { radius: 20 }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { radius: 20 }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { radius: 20 });
|
|
15
|
+
* await layout.assign(graph, { radius: 20 });
|
|
16
16
|
*/
|
|
17
17
|
export declare class CircularLayout implements Layout<CircularLayoutOptions> {
|
|
18
18
|
options: CircularLayoutOptions;
|
|
@@ -21,10 +21,10 @@ export declare class CircularLayout implements Layout<CircularLayoutOptions> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the positions of nodes and edges(if needed).
|
|
23
23
|
*/
|
|
24
|
-
execute(graph: Graph, options?: CircularLayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: CircularLayoutOptions): Promise<LayoutMapping>;
|
|
25
25
|
/**
|
|
26
26
|
* To directly assign the positions to the nodes.
|
|
27
27
|
*/
|
|
28
|
-
assign(graph: Graph, options?: CircularLayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: CircularLayoutOptions): Promise<void>;
|
|
29
29
|
private genericCircularLayout;
|
|
30
30
|
}
|
package/lib/Supervisor.d.ts
CHANGED
|
@@ -13,16 +13,6 @@ export interface Payload {
|
|
|
13
13
|
nodes: Node<any>[];
|
|
14
14
|
edges: Edge<any>[];
|
|
15
15
|
}
|
|
16
|
-
export declare const SupervisorEvent: {
|
|
17
|
-
/**
|
|
18
|
-
* Get triggerred when each iteration finished.
|
|
19
|
-
*/
|
|
20
|
-
LAYOUT_ITERATION: string;
|
|
21
|
-
/**
|
|
22
|
-
* Get triggerred when layout calculation is done.
|
|
23
|
-
*/
|
|
24
|
-
LAYOUT_END: string;
|
|
25
|
-
};
|
|
26
16
|
interface SupervisorOptions {
|
|
27
17
|
/**
|
|
28
18
|
* Iterations run in algorithm such as d3force, will be passed in `tick()` later.
|
|
@@ -34,21 +24,10 @@ interface SupervisorOptions {
|
|
|
34
24
|
* const graph = new Graph();
|
|
35
25
|
* const layout = new CircularLayout();
|
|
36
26
|
*
|
|
37
|
-
* const supervisor = new Supervisor(graph, layout, {
|
|
38
|
-
* supervisor.
|
|
27
|
+
* const supervisor = new Supervisor(graph, layout, { iterations: 1000 });
|
|
28
|
+
* const positions = await supervisor.execute();
|
|
39
29
|
* supervisor.stop();
|
|
40
30
|
* supervisor.kill();
|
|
41
|
-
*
|
|
42
|
-
* // lifecycle
|
|
43
|
-
* supervisor.on('tick', () => {
|
|
44
|
-
* });
|
|
45
|
-
* supervisor.on('layoutend', () => {
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* // Re-layout when graph changed.
|
|
49
|
-
* graph.addNodes([{ id: 'node1' }, { id: 'node2' }]);
|
|
50
|
-
*
|
|
51
|
-
* // TODO: Custom layout.
|
|
52
31
|
*/
|
|
53
32
|
export declare class Supervisor extends EventEmitter implements LayoutSupervisor {
|
|
54
33
|
private graph;
|
|
@@ -64,7 +43,7 @@ export declare class Supervisor extends EventEmitter implements LayoutSupervisor
|
|
|
64
43
|
private running;
|
|
65
44
|
constructor(graph: Graph<any, any>, layout: Layout<any>, options?: Partial<SupervisorOptions> | undefined);
|
|
66
45
|
spawnWorker(): void;
|
|
67
|
-
|
|
46
|
+
execute(): Promise<any>;
|
|
68
47
|
stop(): this;
|
|
69
48
|
kill(): void;
|
|
70
49
|
isRunning(): boolean;
|
package/lib/concentric.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, LayoutMapping, ConcentricLayoutOptions, Layout } from "./ty
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new ConcentricLayout({ nodeSpacing: 10 });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new ConcentricLayout({ nodeSpacing: 10});
|
|
12
|
-
* const positions = layout.execute(graph, { nodeSpacing: 10 }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { nodeSpacing: 10 }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { nodeSpacing: 10 });
|
|
15
|
+
* await layout.assign(graph, { nodeSpacing: 10 });
|
|
16
16
|
*/
|
|
17
17
|
export declare class ConcentricLayout implements Layout<ConcentricLayoutOptions> {
|
|
18
18
|
options: ConcentricLayoutOptions;
|
|
@@ -21,10 +21,10 @@ export declare class ConcentricLayout implements Layout<ConcentricLayoutOptions>
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the positions of nodes and edges(if needed).
|
|
23
23
|
*/
|
|
24
|
-
execute(graph: Graph, options?: ConcentricLayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: ConcentricLayoutOptions): Promise<LayoutMapping>;
|
|
25
25
|
/**
|
|
26
26
|
* To directly assign the positions to the nodes.
|
|
27
27
|
*/
|
|
28
|
-
assign(graph: Graph, options?: ConcentricLayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: ConcentricLayoutOptions): Promise<void>;
|
|
29
29
|
private genericConcentricLayout;
|
|
30
30
|
}
|
package/lib/d3Force/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { Graph, Node, LayoutMapping, OutNode, D3ForceLayoutOptions, Edge, Layout
|
|
|
6
6
|
* @example
|
|
7
7
|
* // Assign layout options when initialization.
|
|
8
8
|
* const layout = new D3ForceLayout({ center: [100, 100] });
|
|
9
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
10
10
|
*
|
|
11
11
|
* // Or use different options later.
|
|
12
12
|
* const layout = new D3ForceLayout({ center: [100, 100] });
|
|
13
|
-
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
|
+
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
14
14
|
*
|
|
15
15
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
16
|
-
* layout.assign(graph, { center: [100, 100] });
|
|
16
|
+
* await layout.assign(graph, { center: [100, 100] });
|
|
17
17
|
*/
|
|
18
18
|
export declare class D3ForceLayout implements LayoutWithIterations<D3ForceLayoutOptions> {
|
|
19
19
|
options: D3ForceLayoutOptions;
|
|
@@ -23,22 +23,19 @@ export declare class D3ForceLayout implements LayoutWithIterations<D3ForceLayout
|
|
|
23
23
|
private lastLayoutEdges;
|
|
24
24
|
private lastAssign;
|
|
25
25
|
private lastGraph;
|
|
26
|
-
private lastOptions;
|
|
27
|
-
private running;
|
|
28
26
|
constructor(options?: D3ForceLayoutOptions);
|
|
29
27
|
/**
|
|
30
28
|
* Return the positions of nodes and edges(if needed).
|
|
31
29
|
*/
|
|
32
|
-
execute(graph: Graph, options?: D3ForceLayoutOptions): LayoutMapping
|
|
30
|
+
execute(graph: Graph, options?: D3ForceLayoutOptions): Promise<LayoutMapping>;
|
|
33
31
|
/**
|
|
34
32
|
* To directly assign the positions to the nodes.
|
|
35
33
|
*/
|
|
36
|
-
assign(graph: Graph, options?: D3ForceLayoutOptions): void
|
|
34
|
+
assign(graph: Graph, options?: D3ForceLayoutOptions): Promise<void>;
|
|
37
35
|
/**
|
|
38
36
|
* Stop simulation immediately.
|
|
39
37
|
*/
|
|
40
38
|
stop(): void;
|
|
41
|
-
restart(): void;
|
|
42
39
|
/**
|
|
43
40
|
* Manually steps the simulation by the specified number of iterations.
|
|
44
41
|
* When finished it will trigger `onLayoutEnd` callback.
|
package/lib/force/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { CalcGraph, FormatedOptions } from "./types";
|
|
|
6
6
|
* @example
|
|
7
7
|
* // Assign layout options when initialization.
|
|
8
8
|
* const layout = new ForceLayout({ center: [100, 100] });
|
|
9
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
10
10
|
*
|
|
11
11
|
* // Or use different options later.
|
|
12
12
|
* const layout = new ForceLayout({ center: [100, 100] });
|
|
13
|
-
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
|
+
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
14
14
|
*
|
|
15
15
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
16
|
-
* layout.assign(graph, { center: [100, 100] });
|
|
16
|
+
* await layout.assign(graph, { center: [100, 100] });
|
|
17
17
|
*/
|
|
18
18
|
export declare class ForceLayout implements LayoutWithIterations<ForceLayoutOptions> {
|
|
19
19
|
options: ForceLayoutOptions;
|
|
@@ -39,19 +39,17 @@ export declare class ForceLayout implements LayoutWithIterations<ForceLayoutOpti
|
|
|
39
39
|
/**
|
|
40
40
|
* Return the positions of nodes and edges(if needed).
|
|
41
41
|
*/
|
|
42
|
-
execute(graph: Graph, options?: ForceLayoutOptions): LayoutMapping
|
|
42
|
+
execute(graph: Graph, options?: ForceLayoutOptions): Promise<LayoutMapping>;
|
|
43
43
|
/**
|
|
44
44
|
* To directly assign the positions to the nodes.
|
|
45
45
|
*/
|
|
46
|
-
assign(graph: Graph, options?: ForceLayoutOptions): void
|
|
46
|
+
assign(graph: Graph, options?: ForceLayoutOptions): Promise<void>;
|
|
47
47
|
/**
|
|
48
48
|
* Stop simulation immediately.
|
|
49
49
|
*/
|
|
50
50
|
stop(): void;
|
|
51
|
-
restart(): void;
|
|
52
51
|
/**
|
|
53
52
|
* Manually steps the simulation by the specified number of iterations.
|
|
54
|
-
* When finished it will trigger `onLayoutEnd` callback.
|
|
55
53
|
* @see https://github.com/d3/d3-force#simulation_tick
|
|
56
54
|
*/
|
|
57
55
|
tick(iterations?: number): LayoutMapping;
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import type { Graph, LayoutMapping, ForceAtlas2LayoutOptions,
|
|
1
|
+
import type { Graph, LayoutMapping, ForceAtlas2LayoutOptions, Layout } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Layout nodes with force atlas 2 model
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new ForceAtlas2Layout({ center: [100, 100] });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new ForceAtlas2Layout({ center: [100, 100] });
|
|
12
|
-
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { center: [100, 100] });
|
|
15
|
+
* await layout.assign(graph, { center: [100, 100] });
|
|
16
16
|
*/
|
|
17
|
-
export declare class ForceAtlas2Layout implements
|
|
17
|
+
export declare class ForceAtlas2Layout implements Layout<ForceAtlas2LayoutOptions> {
|
|
18
18
|
options: ForceAtlas2LayoutOptions;
|
|
19
19
|
id: string;
|
|
20
20
|
constructor(options?: ForceAtlas2LayoutOptions);
|
|
21
|
-
stop: () => void;
|
|
22
|
-
restart: () => void;
|
|
23
|
-
tick: (iterations?: number | undefined) => LayoutMapping;
|
|
24
21
|
/**
|
|
25
22
|
* Return the positions of nodes and edges(if needed).
|
|
26
23
|
*/
|
|
27
|
-
execute(graph: Graph, options?: ForceAtlas2LayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: ForceAtlas2LayoutOptions): Promise<LayoutMapping>;
|
|
28
25
|
/**
|
|
29
26
|
* To directly assign the positions to the nodes.
|
|
30
27
|
*/
|
|
31
|
-
assign(graph: Graph, options?: ForceAtlas2LayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: ForceAtlas2LayoutOptions): Promise<void>;
|
|
32
29
|
private genericForceAtlas2Layout;
|
|
33
30
|
/**
|
|
34
31
|
* Init the node positions if there is no initial positions.
|
package/lib/fruchterman.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, LayoutMapping, FruchtermanLayoutOptions, LayoutWithIteratio
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new FruchtermanLayout({ center: [100, 100] });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new FruchtermanLayout({ center: [100, 100] });
|
|
12
|
-
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { center: [100, 100] });
|
|
15
|
+
* await layout.assign(graph, { center: [100, 100] });
|
|
16
16
|
*/
|
|
17
17
|
export declare class FruchtermanLayout implements LayoutWithIterations<FruchtermanLayoutOptions> {
|
|
18
18
|
options: FruchtermanLayoutOptions;
|
|
@@ -30,16 +30,15 @@ export declare class FruchtermanLayout implements LayoutWithIterations<Fruchterm
|
|
|
30
30
|
/**
|
|
31
31
|
* Return the positions of nodes and edges(if needed).
|
|
32
32
|
*/
|
|
33
|
-
execute(graph: Graph, options?: FruchtermanLayoutOptions): LayoutMapping
|
|
33
|
+
execute(graph: Graph, options?: FruchtermanLayoutOptions): Promise<LayoutMapping>;
|
|
34
34
|
/**
|
|
35
35
|
* To directly assign the positions to the nodes.
|
|
36
36
|
*/
|
|
37
|
-
assign(graph: Graph, options?: FruchtermanLayoutOptions): void
|
|
37
|
+
assign(graph: Graph, options?: FruchtermanLayoutOptions): Promise<void>;
|
|
38
38
|
/**
|
|
39
39
|
* Stop simulation immediately.
|
|
40
40
|
*/
|
|
41
41
|
stop(): void;
|
|
42
|
-
restart(): void;
|
|
43
42
|
/**
|
|
44
43
|
* Manually steps the simulation by the specified number of iterations.
|
|
45
44
|
* When finished it will trigger `onLayoutEnd` callback.
|
package/lib/grid.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, GridLayoutOptions, LayoutMapping, Layout } from "./types";
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new GridLayout({ rows: 10 });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new GridLayout({ rows: 10 });
|
|
12
|
-
* const positions = layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { rows: 20 });
|
|
15
|
+
* await layout.assign(graph, { rows: 20 });
|
|
16
16
|
*/
|
|
17
17
|
export declare class GridLayout implements Layout<GridLayoutOptions> {
|
|
18
18
|
options: GridLayoutOptions;
|
|
@@ -21,10 +21,10 @@ export declare class GridLayout implements Layout<GridLayoutOptions> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the positions of nodes and edges(if needed).
|
|
23
23
|
*/
|
|
24
|
-
execute(graph: Graph, options?: GridLayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: GridLayoutOptions): Promise<LayoutMapping>;
|
|
25
25
|
/**
|
|
26
26
|
* To directly assign the positions to the nodes.
|
|
27
27
|
*/
|
|
28
|
-
assign(graph: Graph, options?: GridLayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: GridLayoutOptions): Promise<void>;
|
|
29
29
|
private genericGridLayout;
|
|
30
30
|
}
|
package/lib/mds.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, LayoutMapping, MDSLayoutOptions, Layout } from "./types";
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new MDSLayout({ center: [100, 100] });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new MDSLayout({ center: [100, 100] });
|
|
12
|
-
* const positions = layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { center: [100, 100] });
|
|
15
|
+
* await layout.assign(graph, { center: [100, 100] });
|
|
16
16
|
*/
|
|
17
17
|
export declare class MDSLayout implements Layout<MDSLayoutOptions> {
|
|
18
18
|
options: MDSLayoutOptions;
|
|
@@ -21,10 +21,10 @@ export declare class MDSLayout implements Layout<MDSLayoutOptions> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the positions of nodes and edges(if needed).
|
|
23
23
|
*/
|
|
24
|
-
execute(graph: Graph, options?: MDSLayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: MDSLayoutOptions): Promise<LayoutMapping>;
|
|
25
25
|
/**
|
|
26
26
|
* To directly assign the positions to the nodes.
|
|
27
27
|
*/
|
|
28
|
-
assign(graph: Graph, options?: MDSLayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: MDSLayoutOptions): Promise<void>;
|
|
29
29
|
private genericMDSLayout;
|
|
30
30
|
}
|
package/lib/radial/index.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, LayoutMapping, RadialLayoutOptions, Layout } from "../types
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new RadialLayout({ focusNode: 'node0' });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new RadialLayout({ focusNode: 'node0' });
|
|
12
|
-
* const positions = layout.execute(graph, { focusNode: 'node0' }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { focusNode: 'node0' }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { focusNode: 'node0' });
|
|
15
|
+
* await layout.assign(graph, { focusNode: 'node0' });
|
|
16
16
|
*/
|
|
17
17
|
export declare class RadialLayout implements Layout<RadialLayoutOptions> {
|
|
18
18
|
options: RadialLayoutOptions;
|
|
@@ -21,11 +21,11 @@ export declare class RadialLayout implements Layout<RadialLayoutOptions> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the positions of nodes and edges(if needed).
|
|
23
23
|
*/
|
|
24
|
-
execute(graph: Graph, options?: RadialLayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: RadialLayoutOptions): Promise<LayoutMapping>;
|
|
25
25
|
/**
|
|
26
26
|
* To directly assign the positions to the nodes.
|
|
27
27
|
*/
|
|
28
|
-
assign(graph: Graph, options?: RadialLayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: RadialLayoutOptions): Promise<void>;
|
|
29
29
|
private genericRadialLayout;
|
|
30
30
|
private run;
|
|
31
31
|
private oneIteration;
|
package/lib/random.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { Graph, LayoutMapping, RandomLayoutOptions, Layout } from "./types"
|
|
|
5
5
|
* @example
|
|
6
6
|
* // Assign layout options when initialization.
|
|
7
7
|
* const layout = new RandomLayout({ center: [100, 100] });
|
|
8
|
-
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
8
|
+
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
9
|
*
|
|
10
10
|
* // Or use different options later.
|
|
11
11
|
* const layout = new RandomLayout({ center: [100, 100] });
|
|
12
|
-
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
12
|
+
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
13
|
*
|
|
14
14
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
-
* layout.assign(graph, { center: [100, 100] });
|
|
15
|
+
* await layout.assign(graph, { center: [100, 100] });
|
|
16
16
|
*/
|
|
17
17
|
export declare class RandomLayout implements Layout<RandomLayoutOptions> {
|
|
18
18
|
options: RandomLayoutOptions;
|
|
@@ -21,10 +21,10 @@ export declare class RandomLayout implements Layout<RandomLayoutOptions> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the positions of nodes and edges(if needed).
|
|
23
23
|
*/
|
|
24
|
-
execute(graph: Graph, options?: RandomLayoutOptions): LayoutMapping
|
|
24
|
+
execute(graph: Graph, options?: RandomLayoutOptions): Promise<LayoutMapping>;
|
|
25
25
|
/**
|
|
26
26
|
* To directly assign the positions to the nodes.
|
|
27
27
|
*/
|
|
28
|
-
assign(graph: Graph, options?: RandomLayoutOptions): void
|
|
28
|
+
assign(graph: Graph, options?: RandomLayoutOptions): Promise<void>;
|
|
29
29
|
private genericRandomLayout;
|
|
30
30
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Graph as IGraph, Node as INode, Edge as IEdge, PlainObject, GraphView as IGraphView } from "@antv/graphlib";
|
|
2
2
|
export interface NodeData extends PlainObject {
|
|
3
|
-
visible?: boolean;
|
|
4
3
|
size?: number | number[];
|
|
5
4
|
bboxSize?: number[];
|
|
6
5
|
}
|
|
@@ -9,7 +8,6 @@ export interface OutNodeData extends NodeData {
|
|
|
9
8
|
y: number;
|
|
10
9
|
}
|
|
11
10
|
export interface EdgeData extends PlainObject {
|
|
12
|
-
visible?: boolean;
|
|
13
11
|
virtual?: boolean;
|
|
14
12
|
}
|
|
15
13
|
/** input node */
|
|
@@ -42,11 +40,11 @@ export interface Layout<LayoutOptions> {
|
|
|
42
40
|
/**
|
|
43
41
|
* To directly assign the positions to the nodes.
|
|
44
42
|
*/
|
|
45
|
-
assign(graph: Graph, options?: LayoutOptions): void
|
|
43
|
+
assign(graph: Graph, options?: LayoutOptions): Promise<void>;
|
|
46
44
|
/**
|
|
47
45
|
* Return the positions of nodes and edges(if needed).
|
|
48
46
|
*/
|
|
49
|
-
execute(graph: Graph, options?: LayoutOptions): LayoutMapping
|
|
47
|
+
execute(graph: Graph, options?: LayoutOptions): Promise<LayoutMapping>;
|
|
50
48
|
/**
|
|
51
49
|
* Layout options, can be changed in runtime.
|
|
52
50
|
*/
|
|
@@ -64,11 +62,6 @@ export interface LayoutWithIterations<LayoutOptions> extends Layout<LayoutOption
|
|
|
64
62
|
* @see https://github.com/d3/d3-force#simulation_stop
|
|
65
63
|
*/
|
|
66
64
|
stop: () => void;
|
|
67
|
-
/**
|
|
68
|
-
* Restarts the simulation’s internal timer and returns the simulation.
|
|
69
|
-
* @see https://github.com/d3/d3-force#simulation_restart
|
|
70
|
-
*/
|
|
71
|
-
restart: () => void;
|
|
72
65
|
/**
|
|
73
66
|
* Manually steps the simulation by the specified number of iterations.
|
|
74
67
|
* @see https://github.com/d3/d3-force#simulation_tick
|
|
@@ -79,13 +72,12 @@ export interface LayoutConstructor<LayoutOptions> {
|
|
|
79
72
|
new (options?: LayoutOptions): Layout<LayoutOptions>;
|
|
80
73
|
}
|
|
81
74
|
export interface LayoutSupervisor {
|
|
82
|
-
|
|
75
|
+
execute(): Promise<LayoutMapping>;
|
|
83
76
|
stop(): void;
|
|
84
77
|
kill(): void;
|
|
85
78
|
isRunning(): boolean;
|
|
86
79
|
}
|
|
87
80
|
interface CommonOptions {
|
|
88
|
-
layoutInvisibles?: boolean;
|
|
89
81
|
onLayoutEnd?: (data: LayoutMapping) => void;
|
|
90
82
|
}
|
|
91
83
|
export interface CircularLayoutOptions extends CommonOptions {
|
package/lib/util/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PointTuple,
|
|
1
|
+
import { PointTuple, Graph } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Assign or only return the result for the graph who has no nodes or only one node.
|
|
4
4
|
* @param graph original graph
|
|
@@ -7,12 +7,11 @@ import { PointTuple, LayoutMapping, Graph } from "../types";
|
|
|
7
7
|
* @param onLayoutEnd callback for layout end
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare const handleSingleNodeGraph: (graph: Graph, assign: boolean, center: PointTuple
|
|
10
|
+
export declare const handleSingleNodeGraph: (graph: Graph, assign: boolean, center: PointTuple) => {
|
|
11
11
|
nodes: {
|
|
12
12
|
data: {
|
|
13
13
|
x: number;
|
|
14
14
|
y: number;
|
|
15
|
-
visible?: boolean | undefined;
|
|
16
15
|
size?: number | number[] | undefined;
|
|
17
16
|
bboxSize?: number[] | undefined;
|
|
18
17
|
};
|
package/lib/worker.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Payload } from "./supervisor";
|
|
2
2
|
export declare function stopLayout(): void;
|
|
3
|
-
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): Promise<
|
|
3
|
+
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): Promise<(import("./types").LayoutMapping | Float32Array[])[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/layout",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.16",
|
|
4
4
|
"description": "graph layout algorithm",
|
|
5
5
|
"main": "dist/index.min.js",
|
|
6
6
|
"module": "esm/index.esm.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"antv"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@antv/graphlib": "^2.0.0
|
|
24
|
+
"@antv/graphlib": "^2.0.0",
|
|
25
25
|
"@antv/util": "^3.0.0",
|
|
26
26
|
"@naoak/workerize-transferable": "^0.1.0",
|
|
27
27
|
"d3-force": "^3.0.0",
|