diff --git a/.changeset/README.md b/.changeset/README.md
deleted file mode 100644
index e5b6d8d6..00000000
--- a/.changeset/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Changesets
-
-Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
-with multi-package repos, or single-package repos to help you version and publish your code. You can
-find the full documentation for it [in our repository](https://github.com/changesets/changesets)
-
-We have a quick list of common questions to get you started engaging with this project in
-[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
diff --git a/.changeset/config.json b/.changeset/config.json
deleted file mode 100644
index bdf0c312..00000000
--- a/.changeset/config.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
- "changelog": "@changesets/cli/changelog",
- "commit": false,
- "fixed": [],
- "linked": [],
- "access": "restricted",
- "baseBranch": "v5",
- "updateInternalDependencies": "patch",
- "ignore": []
-}
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 29883c83..e377f869 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,16 +1,16 @@
name: build
-on: ["push", "pull_request"]
+on: ['push', 'pull_request']
jobs:
- ci:
+ build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
- node-version: 20
+ node-version: 24
- name: Install Dependencies
run: npm install
@@ -24,5 +24,5 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
- token: ${{ secrets.CODECOV_TOKEN }}
- slug: antvis/layout
+ token: ${{ secrets.CODECOV_TOKEN }}
+ slug: antvis/layout
diff --git a/README.md b/README.md
index f3e07980..89b3167e 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,9 @@ Basic layout algorithms for visualization
|
[D3Force3D](https://layout.antv.vision/guide/api/force/d3-force-3d) |
| 3D force layout based on d3-force-3d with z-axis forces and z output. |
|
[Dagre](https://layout.antv.vision/guide/api/hierarchy/dagre) |
| Layered directed layout for DAGs, workflows, and dependency graphs. |
|
[AntVDagre](https://layout.antv.vision/guide/api/hierarchy/antv-dagre) |
| Production-oriented hierarchical layout with spacing, alignment, and path info. |
+|
[Fishbone](https://layout.antv.vision/guide/api/hierarchy/fishbone) | — | Arrange root, categories, and items in a fishbone diagram. |
+|
[Indented](https://layout.antv.vision/guide/api/hierarchy/indented) | — | Display tree nodes in DFS order with depth-based indentation. |
+|
[Mindmap](https://layout.antv.vision/guide/api/hierarchy/mindmap) | — | Arrange branches on one or both sides of a central root. |
|
[Circular](https://layout.antv.vision/guide/api/radial/circular) |
| Place nodes on a circle (or spiral) with ordering, angle, and radius controls. |
|
[Concentric](https://layout.antv.vision/guide/api/radial/concentric) |
| Layer nodes by an importance score (default: degree), pulling higher scores inward. |
|
[Radial](https://layout.antv.vision/guide/api/radial/radial) |
| Focus-centered rings based on shortest-path distance for relationship exploration. |
diff --git a/__tests__/demos/antv-dagre.ts b/__tests__/demos/antv-dagre.ts
index b56dcc5e..626fdd0d 100644
--- a/__tests__/demos/antv-dagre.ts
+++ b/__tests__/demos/antv-dagre.ts
@@ -1,4 +1,5 @@
import { AntVDagreLayout } from '@/src';
+import { parseSize } from '@/src/util';
import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
import type { GUI } from 'lil-gui';
@@ -171,11 +172,12 @@ export function render(gui?: GUI) {
});
dagre.forEachNode((node) => {
+ const [nodeWidth, nodeHeight] = parseSize(node.size);
renderer.updateNodeAttributes(node.id, {
- x: node.x - node.size[0] / 2,
- y: node.y - node.size[1] / 2,
- width: node.size[0],
- height: node.size[1],
+ x: node.x - nodeWidth / 2,
+ y: node.y - nodeHeight / 2,
+ width: nodeWidth,
+ height: nodeHeight,
zIndex: node._original.isCombo ? 0 : 1,
fillOpacity: node._original.isCombo ? 0.3 : 1,
});
diff --git a/__tests__/demos/circular.ts b/__tests__/demos/circular.ts
index c55a864a..e5a8a515 100644
--- a/__tests__/demos/circular.ts
+++ b/__tests__/demos/circular.ts
@@ -1,8 +1,10 @@
-import { CircularLayout } from '@/src';
+import { CircularLayout, type CircularLayoutOptions } from '@/src';
import type { GUI } from 'lil-gui';
import { radial as data } from '../dataset';
import { GraphRenderer } from '../utils/renderer';
+type CircularOrdering = NonNullable;
+
export function render(gui?: GUI) {
const renderer = new GraphRenderer();
@@ -10,10 +12,10 @@ export function render(gui?: GUI) {
center: [250, 250],
radius: 200,
nodeSize: 20,
- startAngle: Math.PI / 4,
- endAngle: Math.PI,
- divisions: 5,
- ordering: 'degree',
+ startAngle: Math.PI / 4,
+ endAngle: Math.PI,
+ divisions: 5,
+ ordering: 'degree',
});
const relayout = async (options = {}) => {
@@ -39,7 +41,7 @@ export function render(gui?: GUI) {
endAngle: 2 * Math.PI,
clockwise: true,
divisions: 1,
- ordering: 'original',
+ ordering: 'original' as CircularOrdering,
};
folder.add(config, 'centerX', 0, 500).onChange((centerX: number) => {
relayout({ ...config, center: [centerX, config.centerY] });
@@ -94,7 +96,7 @@ export function render(gui?: GUI) {
'topology',
'topology-directed',
])
- .onChange((ordering) => {
+ .onChange((ordering: CircularOrdering) => {
relayout({ ...config, ordering });
});
}
diff --git a/__tests__/demos/combo-combined.ts b/__tests__/demos/combo-combined.ts
index e838d162..8aed60c6 100644
--- a/__tests__/demos/combo-combined.ts
+++ b/__tests__/demos/combo-combined.ts
@@ -1,4 +1,5 @@
import { ComboCombinedLayout } from '@/src';
+import { parseSize } from '@/src/util';
import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
import type { GUI } from 'lil-gui';
@@ -12,7 +13,7 @@ data.combos.forEach((combo: any) => {
isCombo: true,
});
});
-delete data.combos;
+Reflect.deleteProperty(data, 'combos');
console.log('combo combined data:', data);
export function render(gui?: GUI) {
@@ -47,7 +48,7 @@ export function render(gui?: GUI) {
renderer.updateNodeAttributes(node.id, {
cx: node.x,
cy: node.y,
- r: Math.max(...node.size) / 2,
+ r: Math.max(...parseSize(node.size)) / 2,
zIndex: node.isCombo ? 0 : 1,
fillOpacity: node.isCombo ? 0.3 : 1,
fill: node.isCombo ? '#91D5FF' : '#FFD666',
diff --git a/__tests__/demos/combo-combined2.ts b/__tests__/demos/combo-combined2.ts
index c71be899..f98768a9 100644
--- a/__tests__/demos/combo-combined2.ts
+++ b/__tests__/demos/combo-combined2.ts
@@ -141,7 +141,7 @@ data.combos.forEach((combo: any) => {
isCombo: true,
});
});
-delete data.combos;
+Reflect.deleteProperty(data, 'combos');
console.log('combo combined data:', data);
export function render(gui?: GUI) {
diff --git a/__tests__/demos/d3-force-3d.ts b/__tests__/demos/d3-force-3d.ts
index 9cd5abdc..71120616 100644
--- a/__tests__/demos/d3-force-3d.ts
+++ b/__tests__/demos/d3-force-3d.ts
@@ -1,5 +1,5 @@
import { D3Force3DLayout } from '@/src';
-import { Layout } from '@/src/core/types';
+import type { Layout } from '@/src/algorithm/types';
import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
import type { GUI } from 'lil-gui';
diff --git a/__tests__/demos/d3-force.ts b/__tests__/demos/d3-force.ts
index 831a966e..50c9e642 100644
--- a/__tests__/demos/d3-force.ts
+++ b/__tests__/demos/d3-force.ts
@@ -1,4 +1,5 @@
import { D3ForceLayout } from '@/src';
+import type { NodeData } from '@/src/types';
import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
import type { GUI } from 'lil-gui';
@@ -21,7 +22,7 @@ export async function render(gui?: GUI) {
layout.execute(data, {
width,
height,
- nodeSize: (d) => d.size || 10,
+ nodeSize: (d: NodeData) => d.size || 10,
x: {},
y: {},
// linkDistance: 100,
diff --git a/__tests__/demos/dagre.ts b/__tests__/demos/dagre.ts
index 2eb581b3..003f7a7d 100644
--- a/__tests__/demos/dagre.ts
+++ b/__tests__/demos/dagre.ts
@@ -1,4 +1,5 @@
import { DagreLayout } from '@/src';
+import { parseSize } from '@/src/util';
import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
import type { GUI } from 'lil-gui';
@@ -58,11 +59,12 @@ export function render(gui?: GUI) {
});
dagre.forEachNode((node) => {
+ const [nodeWidth, nodeHeight] = parseSize(node.size);
renderer.updateNodeAttributes(node.id, {
- x: node.x - node.size[0] / 2,
- y: node.y - node.size[1] / 2,
- width: node.size[0],
- height: node.size[1],
+ x: node.x - nodeWidth / 2,
+ y: node.y - nodeHeight / 2,
+ width: nodeWidth,
+ height: nodeHeight,
zIndex: node._original.isCombo ? 0 : 1,
fillOpacity: node._original.isCombo ? 0.3 : 1,
});
diff --git a/__tests__/demos/force-atlas2.ts b/__tests__/demos/force-atlas2.ts
index cb59689b..b6237454 100644
--- a/__tests__/demos/force-atlas2.ts
+++ b/__tests__/demos/force-atlas2.ts
@@ -57,8 +57,6 @@ export async function render(gui?: GUI) {
// },
// });
- console.log('Total ticks:', tickCount2);
-
renderer.setDragCallbacks({
onDragStart: (nodeId, position) => {
console.log(`🎯 Start dragging node: ${nodeId}`);
diff --git a/__tests__/demos/force.ts b/__tests__/demos/force.ts
index 98cfa1c6..90be9327 100644
--- a/__tests__/demos/force.ts
+++ b/__tests__/demos/force.ts
@@ -47,17 +47,17 @@ export async function render(gui?: GUI) {
renderer.setDragCallbacks({
onDragStart: (nodeId, position) => {
console.log(`🎯 Start dragging node: ${nodeId}`);
- layout.setFixedPosition(nodeId, [position.x, position.y]);
+ layout.setFixedPosition(String(nodeId), [position.x, position.y]);
},
onDrag: (nodeId, position) => {
console.log(`🚚 Dragging node: ${position}`);
- layout.setFixedPosition(nodeId, [position.x, position.y]);
+ layout.setFixedPosition(String(nodeId), [position.x, position.y]);
layout.tick(10);
},
onDragEnd: (nodeId) => {
- layout.setFixedPosition(nodeId, null);
+ layout.setFixedPosition(String(nodeId), null);
},
});
diff --git a/__tests__/demos/grid.ts b/__tests__/demos/grid.ts
index 420012f6..e96d0ecb 100644
--- a/__tests__/demos/grid.ts
+++ b/__tests__/demos/grid.ts
@@ -1,4 +1,4 @@
-import { GridLayout } from '@/src';
+import { GridLayout, type GridLayoutOptions } from '@/src';
import type { GUI } from 'lil-gui';
import { GraphRenderer } from '../utils/renderer';
@@ -14,11 +14,11 @@ export function render(gui?: GUI) {
preventOverlap: true,
preventOverlapPadding: 10,
condense: false,
- rows: undefined,
- cols: undefined,
- sortBy: 'degree',
+ rows: undefined as number | undefined,
+ cols: undefined as number | undefined,
+ sortBy: 'degree' as 'degree' | 'id',
nodeSize: 30,
- nodeSpacing: undefined,
+ nodeSpacing: undefined as number | undefined,
};
let options = { ...defaultOptions };
@@ -38,7 +38,7 @@ export function render(gui?: GUI) {
});
const relayout = async () => {
- const _options = {
+ const _options: Partial = {
width: options.width,
height: options.height,
begin: [options.beginX, options.beginY],
diff --git a/__tests__/main.ts b/__tests__/main.ts
index c50dd61f..df57cab6 100644
--- a/__tests__/main.ts
+++ b/__tests__/main.ts
@@ -2,7 +2,7 @@ import * as lil from 'lil-gui';
import * as demos from './demos';
// GUI
-const $container = document.getElementById('container');
+const $container = document.getElementById('container')!;
let gui = new lil.GUI({ autoPlace: false });
$container.appendChild(gui.domElement);
diff --git a/__tests__/setup.ts b/__tests__/setup.ts
index 5a365be9..50edf248 100644
--- a/__tests__/setup.ts
+++ b/__tests__/setup.ts
@@ -1,2 +1,2 @@
-import 'jest-canvas-mock';
+import 'vitest-canvas-mock';
import './utils/use-snapshot-matchers';
diff --git a/__tests__/snapshots/circular/counterclockwise-radius-range.svg b/__tests__/snapshots/circular/counterclockwise-radius-range.svg
index 1deed5ca..bc8f67c1 100644
--- a/__tests__/snapshots/circular/counterclockwise-radius-range.svg
+++ b/__tests__/snapshots/circular/counterclockwise-radius-range.svg
@@ -1,4 +1,4 @@
-