Skip to content

Commit d1bff78

Browse files
authored
chore: correct layout comments and file name (#228)
* docs: fix typo * chore: update comments of layout * chore: update dict * chore: format filename
1 parent 46a2fe2 commit d1bff78

26 files changed

+151
-300
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
.vscode
32
.idea
43
npm-debug.log
54
yarn-error.log

.vscode/settings.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"cSpell.words": [
3+
"acyclicer",
4+
"edgesep",
5+
"Fruchterman",
6+
"graphlib",
7+
"nodesep",
8+
"rankdir",
9+
"ranksep"
10+
]
11+
}

packages/layout-gpu/src/fruchterman.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,9 @@ interface FormattedOptions extends FruchtermanLayoutOptions {
3535
}
3636

3737
/**
38-
* Layout with fructherman force model
38+
* <zh/> Fruchterman 力导向布局(GPU 版)
3939
*
40-
* @example
41-
* // Assign layout options when initialization.
42-
* const layout = new FruchtermanLayout({ center: [100, 100] });
43-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
44-
*
45-
* // Or use different options later.
46-
* const layout = new FruchtermanLayout({ center: [100, 100] });
47-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
48-
*
49-
* // If you want to assign the positions directly to the nodes, use assign method.
50-
* await layout.assign(graph, { center: [100, 100] });
40+
* <en/> Fruchterman force-directed layout(GPU)
5141
*/
5242
export class FruchtermanLayout implements Layout<FruchtermanLayoutOptions> {
5343
id = 'fruchtermanGPU';
@@ -71,7 +61,7 @@ export class FruchtermanLayout implements Layout<FruchtermanLayoutOptions> {
7161
* To directly assign the positions to the nodes.
7262
*/
7363
async assign(graph: Graph, options?: FruchtermanLayoutOptions) {
74-
await this.genericFruchtermanLayout(true, graph, options);
64+
await this.genericFruchtermanLayout(true, graph, options);
7565
}
7666

7767
private async genericFruchtermanLayout(

packages/layout-gpu/src/gforce.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,9 @@ interface FormattedOptions extends ForceLayoutOptions {
4949
}
5050

5151
/**
52-
* Layout with faster force
53-
*
54-
* @example
55-
* // Assign layout options when initialization.
56-
* const layout = new GForceLayout({ center: [100, 100] });
57-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
58-
*
59-
* // Or use different options later.
60-
* const layout = new GForceLayout({ center: [100, 100] });
61-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
62-
*
63-
* // If you want to assign the positions directly to the nodes, use assign method.
64-
* await layout.assign(graph, { center: [100, 100] });
52+
* <zh/> 快速力导向布局
53+
*
54+
* <en/> Fast force-directed layout
6555
*/
6656
export class GForceLayout implements Layout<ForceLayoutOptions> {
6757
id = 'gforce';

packages/layout-wasm/src/force.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,9 @@ interface WASMForceLayoutOptions
3434
WASMLayoutOptions {}
3535

3636
/**
37-
* Layout nodes with force model
38-
*
39-
* @example
40-
* // Assign layout options when initialization.
41-
* const layout = new ForceLayout({ center: [100, 100] });
42-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
43-
*
44-
* // Or use different options later.
45-
* const layout = new ForceLayout({ center: [100, 100] });
46-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
47-
*
48-
* // If you want to assign the positions directly to the nodes, use assign method.
49-
* await layout.assign(graph, { center: [100, 100] });
37+
* <zh/> 力导向布局(WASM 版)
38+
*
39+
* <en/> Force-directed layout(WASM)
5040
*/
5141
export class ForceLayout implements Layout<WASMForceLayoutOptions> {
5242
id = 'forceWASM';

packages/layout-wasm/src/forceatlas2.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,9 @@ interface FormattedOptions extends WASMForceAtlas2LayoutOptions {
5454
speed: number;
5555
}
5656
/**
57-
* Layout nodes with force atlas 2 model
57+
* <zh/> Atlas2 力导向布局(WASM 版)
5858
*
59-
* @example
60-
* // Assign layout options when initialization.
61-
* const layout = new ForceAtlas2Layout({ center: [100, 100] });
62-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
63-
*
64-
* // Or use different options later.
65-
* const layout = new ForceAtlas2Layout({ center: [100, 100] });
66-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
67-
*
68-
* // If you want to assign the positions directly to the nodes, use assign method.
69-
* await layout.assign(graph, { center: [100, 100] });
59+
* <en/> Force Atlas 2 layout(WASM)
7060
*/
7161
export class ForceAtlas2Layout implements Layout<WASMForceAtlas2LayoutOptions> {
7262
id = 'forceAtlas2WASM';
@@ -90,7 +80,7 @@ export class ForceAtlas2Layout implements Layout<WASMForceAtlas2LayoutOptions> {
9080
* To directly assign the positions to the nodes.
9181
*/
9282
async assign(graph: Graph, options?: ForceAtlas2LayoutOptions) {
93-
await this.genericForceAtlas2Layout(true, graph, options);
83+
await this.genericForceAtlas2Layout(true, graph, options);
9484
}
9585

9686
private async genericForceAtlas2Layout(

packages/layout-wasm/src/fruchterman.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,9 @@ interface FormattedOptions extends WASMFruchtermanLayoutOptions {
3939
}
4040

4141
/**
42-
* Layout with fructherman force model
43-
*
44-
* @example
45-
* // Assign layout options when initialization.
46-
* const layout = new FruchtermanLayout({ threads, center: [100, 100] });
47-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
48-
*
49-
* // Or use different options later.
50-
* const layout = new FruchtermanLayout({ center: [100, 100] });
51-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
52-
*
53-
* // If you want to assign the positions directly to the nodes, use assign method.
54-
* await layout.assign(graph, { center: [100, 100] });
42+
* <zh/> Fruchterman 力导向布局(WASM 版)
43+
*
44+
* <en/> Fruchterman force-directed layout(WASM)
5545
*/
5646
export class FruchtermanLayout implements Layout<WASMFruchtermanLayoutOptions> {
5747
id = 'fruchtermanWASM';

packages/layout/src/antv-dagre.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,9 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<AntVDagreLayoutOptions> = {
211211
};
212212

213213
/**
214-
* Layout arranging the nodes in a circle.
214+
* <zh/> AntV 实现的 Dagre 布局
215215
*
216-
* @example
217-
* // Assign layout options when initialization.
218-
* const layout = new CircularLayout({ radius: 10 });
219-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
220-
*
221-
* // Or use different options later.
222-
* const layout = new CircularLayout({ radius: 10 });
223-
* const positions = await layout.execute(graph, { radius: 20 }); // { nodes: [], edges: [] }
224-
*
225-
* // If you want to assign the positions directly to the nodes, use assign method.
226-
* await layout.assign(graph, { radius: 20 });
216+
* <en/> AntV implementation of Dagre layout
227217
*/
228218
export class AntVDagreLayout implements Layout<AntVDagreLayoutOptions> {
229219
id = 'antv-dagre';

packages/layout/src/circular.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,9 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<CircularLayoutOptions> = {
2424
};
2525

2626
/**
27-
* Layout arranging the nodes in a circle.
27+
* <zh/> 环形布局
2828
*
29-
* @example
30-
* // Assign layout options when initialization.
31-
* const layout = new CircularLayout({ radius: 10 });
32-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
33-
*
34-
* // Or use different options later.
35-
* const layout = new CircularLayout({ radius: 10 });
36-
* const positions = await layout.execute(graph, { radius: 20 }); // { nodes: [], edges: [] }
37-
*
38-
* // If you want to assign the positions directly to the nodes, use assign method.
39-
* await layout.assign(graph, { radius: 20 });
29+
* <en/> Circular layout
4030
*/
4131
export class CircularLayout implements Layout<CircularLayoutOptions> {
4232
id = 'circular';

packages/layout/src/comboCombined.ts renamed to packages/layout/src/combo-combined.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,9 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<ComboCombinedLayoutOptions> = {
3333
};
3434

3535
/**
36-
* Layout arranging the nodes and combos with combination of inner and outer layouts.
36+
* <zh/> 组合布局
3737
*
38-
* @example
39-
* // Assign layout options when initialization.
40-
* const layout = new ComboCombinedLayout({});
41-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
42-
*
43-
* // Or use different options later.
44-
* const layout = new ComboCombinedLayout({ radius: 10 });
45-
* const positions = await layout.execute(graph, { radius: 20 }); // { nodes: [], edges: [] }
46-
*
47-
* // If you want to assign the positions directly to the nodes, use assign method.
48-
* await layout.assign(graph, { radius: 20 });
38+
* <en/> Combo-Combined layout
4939
*/
5040
export class ComboCombinedLayout implements Layout<ComboCombinedLayoutOptions> {
5141
id = 'comboCombined';

packages/layout/src/concentric.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,9 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<ConcentricLayoutOptions> = {
2525
};
2626

2727
/**
28-
* Layout arranging the nodes in concentrics
29-
*
30-
* @example
31-
* // Assign layout options when initialization.
32-
* const layout = new ConcentricLayout({ nodeSpacing: 10 });
33-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
34-
*
35-
* // Or use different options later.
36-
* const layout = new ConcentricLayout({ nodeSpacing: 10});
37-
* const positions = await layout.execute(graph, { nodeSpacing: 10 }); // { nodes: [], edges: [] }
38-
*
39-
* // If you want to assign the positions directly to the nodes, use assign method.
40-
* await layout.assign(graph, { nodeSpacing: 10 });
28+
* <zh/> 同心圆布局
29+
*
30+
* <en/> Concentric layout
4131
*/
4232
export class ConcentricLayout implements Layout<ConcentricLayoutOptions> {
4333
id = 'concentric';

packages/layout/src/dagre.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ export interface DagreLayoutOptions extends GraphLabel, NodeConfig, EdgeConfig {
99
}
1010

1111
/**
12-
* Adapt dagre.js layout
13-
* @link https://github.com/dagrejs/dagre
12+
* <zh/> Dagre 布局
13+
*
14+
* <en/> Dagre layout
1415
*/
1516
export class DagreLayout implements Layout<DagreLayoutOptions> {
1617
static defaultOptions: Partial<DagreLayoutOptions> = {};

packages/layout/src/exports.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export * from './antv-dagre';
22
export type { DagreAlign, DagreRankdir } from './antv-dagre/types';
33
export * from './circular';
4-
export * from './comboCombined';
4+
export * from './combo-combined';
55
export * from './concentric';
66
export { D3ForceLayout } from './d3-force';
77
export { D3Force3DLayout } from './d3-force-3d';
88
export type { D3Force3DLayoutOptions } from './d3-force-3d/types';
99
export type { D3ForceLayoutOptions } from './d3-force/types';
1010
export * from './dagre';
1111
export * from './force';
12-
export * from './forceAtlas2';
12+
export * from './force-atlas2';
1313
export * from './fruchterman';
1414
export * from './grid';
1515
export * from './mds';

packages/layout/src/forceAtlas2/index.ts renamed to packages/layout/src/force-atlas2/index.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { cloneFormatData, isArray } from '../util';
1818
import { handleSingleNodeGraph } from '../util/common';
1919
import Body from './body';
2020
import Quad from './quad';
21-
import QuadTree from './quadTree';
21+
import QuadTree from './quad-tree';
2222

2323
const DEFAULTS_LAYOUT_OPTIONS: Partial<ForceAtlas2LayoutOptions> = {
2424
center: [0, 0],
@@ -56,19 +56,9 @@ type SizeMap = { [id: string]: number };
5656
type CalcGraph = GGraph<OutNodeData, EdgeData>;
5757

5858
/**
59-
* Layout nodes with force atlas 2 model
60-
*
61-
* @example
62-
* // Assign layout options when initialization.
63-
* const layout = new ForceAtlas2Layout({ center: [100, 100] });
64-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
65-
*
66-
* // Or use different options later.
67-
* const layout = new ForceAtlas2Layout({ center: [100, 100] });
68-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
69-
*
70-
* // If you want to assign the positions directly to the nodes, use assign method.
71-
* await layout.assign(graph, { center: [100, 100] });
59+
* <zh/> Atlas2 力导向布局
60+
*
61+
* <en/> Force Atlas 2 layout
7262
*/
7363
export class ForceAtlas2Layout implements Layout<ForceAtlas2LayoutOptions> {
7464
id = 'forceAtlas2';

packages/layout/src/force/index.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
Point,
1313
} from '../types';
1414
import { formatNumberFn, isArray } from '../util';
15-
import { forceNBody } from './forceNBody';
15+
import { forceNBody } from './force-n-body';
1616
import {
1717
CalcEdge,
1818
CalcEdgeData,
@@ -41,19 +41,9 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<ForceLayoutOptions> = {
4141
};
4242

4343
/**
44-
* Layout with faster force
45-
*
46-
* @example
47-
* // Assign layout options when initialization.
48-
* const layout = new ForceLayout({ center: [100, 100] });
49-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
50-
*
51-
* // Or use different options later.
52-
* const layout = new ForceLayout({ center: [100, 100] });
53-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
54-
*
55-
* // If you want to assign the positions directly to the nodes, use assign method.
56-
* await layout.assign(graph, { center: [100, 100] });
44+
* <zh/> 力导向布局
45+
*
46+
* <en/> Force-directed layout
5747
*/
5848
export class ForceLayout implements LayoutWithIterations<ForceLayoutOptions> {
5949
id = 'force';

packages/layout/src/fruchterman.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,9 @@ interface FormattedOptions extends FruchtermanLayoutOptions {
5353
}
5454

5555
/**
56-
* Layout with fructherman force model
57-
*
58-
* @example
59-
* // Assign layout options when initialization.
60-
* const layout = new FruchtermanLayout({ center: [100, 100] });
61-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
62-
*
63-
* // Or use different options later.
64-
* const layout = new FruchtermanLayout({ center: [100, 100] });
65-
* const positions = await layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
66-
*
67-
* // If you want to assign the positions directly to the nodes, use assign method.
68-
* await layout.assign(graph, { center: [100, 100] });
56+
* <zh/> Fruchterman 力导向布局
57+
*
58+
* <en/> Fruchterman force-directed layout
6959
*/
7060
export class FruchtermanLayout
7161
implements LayoutWithIterations<FruchtermanLayoutOptions>

packages/layout/src/grid.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,9 @@ const DEFAULTS_LAYOUT_OPTIONS: Partial<GridLayoutOptions> = {
4545
};
4646

4747
/**
48-
* Layout arranging the nodes in a grid.
49-
*
50-
* @example
51-
* // Assign layout options when initialization.
52-
* const layout = new GridLayout({ rows: 10 });
53-
* const positions = await layout.execute(graph); // { nodes: [], edges: [] }
54-
*
55-
* // Or use different options later.
56-
* const layout = new GridLayout({ rows: 10 });
57-
* const positions = await layout.execute(graph, { rows: 20 }); // { nodes: [], edges: [] }
58-
*
59-
* // If you want to assign the positions directly to the nodes, use assign method.
60-
* await layout.assign(graph, { rows: 20 });
48+
* <zh/> 网格布局
49+
*
50+
* <en/> Grid layout
6151
*/
6252
export class GridLayout implements Layout<GridLayoutOptions> {
6353
id = 'grid';

0 commit comments

Comments
 (0)