Skip to content

feat: init scaffold #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open

feat: init scaffold #119

wants to merge 67 commits into from

Conversation

xiaoiver
Copy link
Contributor

@xiaoiver xiaoiver commented Dec 20, 2022

项目结构,基于 yarn workspace 的 monorep:

  • @antv/layout CPU 版本布局实现,更好地组织 WebWorker 相关代码
  • @antv/layout-gpu GPU 版本布局实现
  • @antv/layout-wasm Rust 实现并输出成 WASM 形式

为了方便查看可以过滤掉 Deleted files

依赖 @antv/graphlib,暂时使用 yarn link
antvis/graphlib#6
使用到的 API 包括:

  • getAllNodes
  • getAllEdges
  • updateNodeProperty

WebWorker

目前创建 Worker 是在 G6 代码中完成的,会存在有一些局限性:
https://github.com/antvis/G6/blob/master/packages/pc/src/layout/worker/work.ts#L5

  • 如果想单独使用 @antv/layout,需要重复实现一遍
  • 目前在 Worker 代码中使用 importScripts 直接引用线上的 layout UMD 版本,无网络环境下就无法使用了,也不便于调试(需要把新版本发到线上)。

所以我想把创建 Worker、以及与主线程间通信的代码都放在 layout 里,需要解决以下问题:

  • 不使用 importScripts,通过模版替换的方式引用本地代码,但是需要先编译(模版 tpl.js + 编译后的算法 -> webworker.js 供 Supervisor 使用)
  • 所有布局理论上都可以放在 Worker 中完成,所以需要一个通用的管理器

Supervisor

看到 graphology 中有类似的名字,觉得还挺贴切的。它主要负责:

  • spawnWorker
  • 监听 graph 的变化,例如节点 / 边的添加 / 删除,必要时重新 spawnWorker

使用方式

同步布局:

import { Graph } from "@antv/graphlib";
import { CircularLayout } from "@antv/layout";

const graph = new Graph({ nodes: [], edges: [] });

const circularLayout = new CircularLayout({ radius: 10 });

// 1. Return positions of nodes & edges.
const positions = circularLayout.execute(graph);

// 2. To directly assign the positions to the nodes:
circularLayout.assign(graph);

异步:

import { CircularLayout, Supervisor } from "@antv/layout";

const graph = new Graph({ nodes: [], edges: [] });
const circularLayout = new CircularLayout({ radius: 10 });

const supervisor = new Supervisor(circularLayout);
supervisor.start();
supervisor.stop();
supervisor.kill();

实现一个同步布局:

  • Circular

实现一个 WebWorker 布局,使用模版:

  • Circular

xiaoiver and others added 30 commits December 20, 2022 11:18
* chore: refine types and circular layout

* chore: refine

* chore: circular implement

* feat: add grid layout

* feat: add random layout

* feat: add mds layout

* feat: add concentric layout

* feat: add radial layout

* chore: refine radial

* chore: refine radial

* feat: layoutInvisible to control whether takes the invisible nodes and edges into calculation

* perf: put extra properties of node and edge into data

* chore: refine

* chore: refine types according to graphlib
* chore: backup case-sensitive files

* build: add ESM webpack config

* chore: add lint & coverage script

* chore: add missing lerna dep

* chore: use node 14.x in ci

* chore: add test to ci
* fix: use node's id correctly in grid layout

* fix: external graphlib

* chore: bump version alpha.4
* perf: read and format data

* chore:refine

* chore: test-live script
* fix: concentric layout sort by degree

* chore: bump version alpha.5

* chore: add test case & demo for concentric layout

* fix: get degree using graphlib API
* chore: add tests and demo for mds and radial layout

* chore: lint

* chore: refine
* feat: add d3force and force layout

* chore: add notes for d3Force and force layout

* chore: lint d3force

* fix: format out edge when d3force layout ended

* chore: bump version alpha.6

* chore: bump version alpha.7

* fix: clone edges before calc force layout

* fix: force layout supports stop method

* chore: bump version alpha.9

Co-authored-by: yuqi.pyq <[email protected]>
* feat: add fruchterman layout and its test and demo

* chore: lint

* chore: update test

* fix: let Supervisor support layout with iterations such as d3force

* fix: add demo for fruchterman

* chore: bump version alpha.11

* chore: fruchterman test case

* docs: add demo for force & supervisor

* chore: bump version alpha.12

Co-authored-by: yuqi.pyq <[email protected]>
* feat: add force atlas 2 layout and its test and demo; chore: util function for graph without nodes or graph with one node;

* chore: lint

* chore: remove minNodeSpacing and use nodeSpacing istead for concentric layout

* chore: add demo for forceAtlas2

* chore: bump version alpha.13

Co-authored-by: yuqi.pyq <[email protected]>
* feat: add layout-rust & layout-wasm

* chore: use rollup & rollup-plugin-rust to bundle UMD
* docs: add README.md in root dir

* docs: add docs for layout algorithm

* feat: add fruchterman & gforce in layout-gpu

* feat: add fruchterman & gforce in layout-gpu

* fix: remove layout visibility logic, use GraphView instead

* chore: external @antv/layout@alpha
* fix: make execute & assign API async

* docs: update execute & assign API

* chore: bump alpha version

* chore: try to fix fruchterman test case in ci
* fix: d3force should resolve after simulation ended

* fix: remove  option

* chore: bump alpha.17
* feat: migrate order dir from v4

* feat: horizontal coordinate assignment

* feat: layout compound graph

* feat: do dagre layout with compound graph correctly

* chore: lint

* fix: use begin to control layout's top-left corner in dagre

* chore: bump v1.0.0-alpha.19
* feat(rust & wasm): forceatlas2

* chore: use rustfmt as linter
* feat: use vite to preview & deploy benchmark demo

* build: remove jest-electron & modify ci.yml

* chore: commit pnpm-lock.yml

* chore: skip dagre test case temporarily

* chore: skip build QWASM in ci

* chore: update ci.yml

* fix: modify radial filename

* chore: update demo page

* chore: use wee_alloc to reduce compiled code size

* chore: optimizing builds for code size
* fix: add distance threshold mode

* chore: update @antv/layout-wasm readme
* fix: add distance threshold mode

* chore: update @antv/layout-wasm readme

* chore: include packaged wasm files
Yanyan-Wang and others added 30 commits October 7, 2023 11:07
* chore: pass frozen-lockfile on CI

* chore: remove lint on CI

* chore: remove pnpm-lock file

* chore: config prettier

* chore: remove tslint

* chore: adjust package.json

* refactor: execute prettier

* chore: update build.yml

---------

Co-authored-by: yuqi.pyq <[email protected]>
Co-authored-by: hustcc <[email protected]>
* refactor: remove unused function

* refactor: adjust types
* refactor: migrate built-in dagre to antv-dagre

* chore: add layout jest config

* feat: add parseSize util

* chore: set tsc target to es6

* feat: adapt dagrejs

* chore: config scripts

* refactor: adjust antv-dagre test case

* chore: fix build.yml

* test: update dagre test case

* test: add demo

* chore: adjust build script
* chore: use swc jest

* feat: adapt d3-force-3d

* refactor: refactor d3 force

* test: update demo
* refactor: update force types

* refactor: adjust d3-force add setFixedPosition api, support disable default force

* chore: update version to 1.2.14-beta.3
* docs: add layout api doc

---------

Co-authored-by: whf01206399 <[email protected]>
* fix: fix async assign invoke

* fix: fix rust deps

* chore: update version
* perf: config perf env, add combo-combine test case

* perf: add perf test baseline

* perf: optimize combo-combined layout, generate perf report

* refactor: fix cr issue
* docs: fix typo

* chore: update comments of layout

* chore: update dict

* chore: format filename
* fix: d3-force get node data correctly

* chore: update version
* chore: update ts config

* refactor: adapt antv-dagre node size

* refactor: adapt circular node size

* refactor: adapt grid node size

* refactor: adapt radial layout node size

* refactor: adapt force-atlas2 node size

* refactor: adapt force node size

* refactor: adapt concentric node size

* fix: ts

* chore: revert

* fix: adapt formatSizeFn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants