From 28d7b47034caed7921f50e95487aa49ce9e33309 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E8=8D=A3=E7=87=8A?= <1349557306@qq.com>
Date: Sat, 26 Mar 2022 22:16:34 +0800
Subject: [PATCH 01/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=93=88?=
=?UTF-8?q?=E5=B8=8C=E8=A1=A8=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=E8=8A=82?=
=?UTF-8?q?=E7=82=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/RegisteredShape/chainHashTableNode.ts | 74 +++++++++++++++++++
yarn.lock | 87 ++++++++++++-----------
2 files changed, 120 insertions(+), 41 deletions(-)
create mode 100644 src/RegisteredShape/chainHashTableNode.ts
diff --git a/src/RegisteredShape/chainHashTableNode.ts b/src/RegisteredShape/chainHashTableNode.ts
new file mode 100644
index 0000000..cce9ec0
--- /dev/null
+++ b/src/RegisteredShape/chainHashTableNode.ts
@@ -0,0 +1,74 @@
+import { Util } from '../Common/util';
+export default Util.registerShape(
+ 'chain-hashtable-node',
+ {
+ draw(cfg, group) {
+ cfg.size = cfg.size || [30, 30];
+
+ const width = cfg.size[0],
+ height = cfg.size[1];
+
+ const wrapperRect = group.addShape('rect', {
+ attrs: {
+ x: width / 2,
+ y: height / 2,
+ width: width,
+ height: height,
+ stroke: cfg.style.stroke,
+ fill: cfg.style.backgroundFill || '#eee'
+ },
+ name: 'wrapper',
+ draggable: true
+ });
+
+ const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
+
+ if (cfg.label) {
+ group.addShape('text', {
+ attrs: {
+ x: width,
+ y: height,
+ textAlign: 'center',
+ textBaseline: 'middle',
+ text: cfg.label,
+ fill: style.fill || '#000',
+ fontSize: style.fontSize || 16
+ },
+ name: 'text',
+ draggable: true
+ });
+ }
+
+ //节点没有后续指针时
+ if (!cfg.next && !cfg.loopNext) {
+ group.addShape('text', {
+ attrs: {
+ x: width,
+ y: height,
+ textAlign: 'center',
+ textBaseline: 'middle',
+ text: '^',
+ fill: style.fill || '#000',
+ fontSize: 16,
+ cursor: cfg.style.cursor,
+ },
+ name: 'text',
+ draggable: true,
+ });
+ }
+
+ return wrapperRect;
+ },
+
+ getAnchorPoints() {
+ return [
+ [1 / 6, 0],
+ [0.5, 0],
+ [0.5, 0.5],
+ [5 / 6, 0.5],
+ [0.5, 1],
+ [0, 0.5]
+ ];
+ }
+ }
+)
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index d8771fb..6b75601 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -124,10 +124,10 @@
probe.gl "^3.1.1"
reflect-metadata "^0.1.13"
-"@antv/g6-core@0.4.1":
- version "0.4.1"
- resolved "https://registry.yarnpkg.com/@antv/g6-core/-/g6-core-0.4.1.tgz#3351838e8ecfd2588bf48f5ee766f3ddea34f989"
- integrity sha512-ZpugNMz3V76K+cLVpoj5If3yrFq81bKZET3IkG2LWdZ0bvDt5G94XUjcBG7Xi/doerq7cDOJrW6z3t2DqnvvfA==
+"@antv/g6-core@0.6.3":
+ version "0.6.3"
+ resolved "https://registry.yarnpkg.com/@antv/g6-core/-/g6-core-0.6.3.tgz#b6c9b5d53c7dca8f92d0b2d9f14013c82754ebf3"
+ integrity sha512-37RwHTZtJ3IgM+V3dbMnQJ3iRvqf4Th4Dh2aVBmpMsj9yMyRwE04auJefJFedCVITl4YIa9o7iayi+HG7K3oSg==
dependencies:
"@antv/algorithm" "^0.1.8"
"@antv/dom-util" "^2.0.1"
@@ -140,19 +140,19 @@
ml-matrix "^6.5.0"
tslib "^2.1.0"
-"@antv/g6-element@0.4.1":
- version "0.4.1"
- resolved "https://registry.yarnpkg.com/@antv/g6-element/-/g6-element-0.4.1.tgz#0c4eba46ca3f72912bfd13be90ee23d7796f006c"
- integrity sha512-z/N+4mJWWauKuKJWEVtlTcvGYygU2Cin7WgBtOM1vORXKLLwl/UHrdqvg+K/CA3WoZUCymOjwNy4ty+Eb8SLkA==
+"@antv/g6-element@0.6.3":
+ version "0.6.3"
+ resolved "https://registry.yarnpkg.com/@antv/g6-element/-/g6-element-0.6.3.tgz#341a6443345e9f46c704060fd0e6c841abffc1de"
+ integrity sha512-ZWvjSTUqARIHERIC20lDx4UJz3In6WErfiL4yHxMmjo9lIjxuHwUHKJu5Mkkm3JdEZwZOZeJn5HVlJsYuYl7Vg==
dependencies:
"@antv/g-base" "^0.5.1"
- "@antv/g6-core" "0.4.1"
+ "@antv/g6-core" "0.6.3"
"@antv/util" "~2.0.5"
-"@antv/g6-pc@0.4.1":
- version "0.4.1"
- resolved "https://registry.yarnpkg.com/@antv/g6-pc/-/g6-pc-0.4.1.tgz#b7ce223f9d1da2d0fd09e873afdcca59e29baa86"
- integrity sha512-+PQZsmC4M2nm5tnqmUiBSGPZgrObzhTHRODQa1BgodFsqezbw/U/GMK8A752Mhiz/Bz1DkVIHrn4x8dyrLfx7w==
+"@antv/g6-pc@0.6.3":
+ version "0.6.3"
+ resolved "https://registry.yarnpkg.com/@antv/g6-pc/-/g6-pc-0.6.3.tgz#c56f515f6ac16d83fc0cce314a0a582a0ca72d9c"
+ integrity sha512-VE2WvCYEADus8uu9dMVwgY/BAjBLjNZl3K/KNhgQekVmFPMGFFXjwFyfiCTQWWQOrD72arbaetzPojLEN4khvQ==
dependencies:
"@ant-design/colors" "^4.0.5"
"@antv/algorithm" "^0.1.8"
@@ -162,11 +162,11 @@
"@antv/g-canvas" "^0.5.2"
"@antv/g-math" "^0.1.1"
"@antv/g-svg" "^0.5.1"
- "@antv/g6-core" "0.4.1"
- "@antv/g6-element" "0.4.1"
- "@antv/g6-plugin" "0.4.1"
+ "@antv/g6-core" "0.6.3"
+ "@antv/g6-element" "0.6.3"
+ "@antv/g6-plugin" "0.6.3"
"@antv/hierarchy" "^0.6.7"
- "@antv/layout" "0.1.19-beta.5"
+ "@antv/layout" "^0.2.1"
"@antv/matrix-util" "^3.1.0-beta.3"
"@antv/path-util" "^2.0.3"
"@antv/util" "~2.0.5"
@@ -176,27 +176,27 @@
insert-css "^2.0.0"
ml-matrix "^6.5.0"
-"@antv/g6-plugin@0.4.1":
- version "0.4.1"
- resolved "https://registry.yarnpkg.com/@antv/g6-plugin/-/g6-plugin-0.4.1.tgz#4696d27a23efbefa5a290845e45648b9bd11def5"
- integrity sha512-1rOVZ+GkgeHj0VWc9dd6obyvOOVElRCBM7O5QcjOl9jxmAHI6ZQIXkkHZDPyFaUjFo0qIxjBM8Lnrb3+iBqVNw==
+"@antv/g6-plugin@0.6.3":
+ version "0.6.3"
+ resolved "https://registry.yarnpkg.com/@antv/g6-plugin/-/g6-plugin-0.6.3.tgz#8175edb17ce212c873f8f6daa747a9c43bcd77a8"
+ integrity sha512-O7ZSawPPOPILQ+K/AtBbviwHr35i2ebH/qeHNiq6/hZ6FHv3uDNzSIQfDwv8fBgGdNw3QSDz4AkV0GCU+PmbKw==
dependencies:
"@antv/dom-util" "^2.0.2"
"@antv/g-base" "^0.5.1"
"@antv/g-canvas" "^0.5.2"
"@antv/g-svg" "^0.5.2"
- "@antv/g6-core" "0.4.1"
+ "@antv/g6-core" "0.6.3"
"@antv/matrix-util" "^3.1.0-beta.3"
"@antv/scale" "^0.3.4"
"@antv/util" "^2.0.9"
insert-css "^2.0.0"
-"@antv/g6@^4.4.1":
- version "4.4.1"
- resolved "https://registry.yarnpkg.com/@antv/g6/-/g6-4.4.1.tgz#c7290bfae5c6e0a9b0e4349ab4d2c50d3a2f2956"
- integrity sha512-7chX89HuWgGGmSnwlS54xUEI/g+CiH4lB/OrrQ/CG3LedZ+TvFEI22giDr10WsB2SgHrbJpbxxtY57O7FwbKhA==
+"@antv/g6@^4.6.1":
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/@antv/g6/-/g6-4.6.3.tgz#3eff301c92a234354753f3cdce92b2368c876d64"
+ integrity sha512-afRMbymOmCQ+hJtcI5VeiYNM0OxNpMdy1Ldp6hReJiBNVV+lGyLxs1DW0m/ruyZwyaN4tABzreXMSU4pvqVhAA==
dependencies:
- "@antv/g6-pc" "0.4.1"
+ "@antv/g6-pc" "0.6.3"
"@antv/hierarchy@^0.6.7":
version "0.6.8"
@@ -205,14 +205,15 @@
dependencies:
"@antv/util" "^2.0.7"
-"@antv/layout@0.1.19-beta.5":
- version "0.1.19-beta.5"
- resolved "https://registry.yarnpkg.com/@antv/layout/-/layout-0.1.19-beta.5.tgz#41b31ae55ae50a9d72ad8efab253fb8b40049337"
- integrity sha512-t5H9WNoI4werPqjOR1ebZeThwkEofoLyYXEscmU36u0kEa0aXxzFtvdSl6XrYgZRXuEZ+2f6H1FNvGho8jmS7Q==
+"@antv/layout@^0.2.1":
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/@antv/layout/-/layout-0.2.1.tgz#18de7144cebf9e91eaf0b7bedddbbff22aaf474c"
+ integrity sha512-2ed+KBaSOPoiNdNBGUoyaqHPjFMtEBPrd3YOTeobaE80P1cKF9fycHnidgz2QChcvBNacMOyIC3j6cLJ7KizGA==
dependencies:
"@antv/g-webgpu" "0.5.5"
+ "@dagrejs/graphlib" "2.1.4"
d3-force "^2.0.1"
- dagrejs "^0.2.1"
+ dagre-compound "^0.0.11"
ml-matrix "^6.5.0"
"@antv/matrix-util@^3.0.4":
@@ -266,6 +267,13 @@
dependencies:
regenerator-runtime "^0.13.4"
+"@dagrejs/graphlib@2.1.4":
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/@dagrejs/graphlib/-/graphlib-2.1.4.tgz#86c70e4f073844a2f4ada254c8c7b88a6bdacdb1"
+ integrity sha512-QCg9sL4uhjn468FDEsb/S9hS2xUZSrv/+dApb1Ze5VKO96pTXKNJZ6MGhIpgWkc1TVhbVGH9/7rq/Mf8/jWicw==
+ dependencies:
+ lodash "^4.11.1"
+
"@probe.gl/stats@3.4.1":
version "3.4.1"
resolved "https://registry.yarnpkg.com/@probe.gl/stats/-/stats-3.4.1.tgz#5bc0ec5f87ae3195c22a98363e9c15031fbfe8e8"
@@ -1074,6 +1082,11 @@ d3-timer@^1.0.9:
resolved "https://registry.yarnpkg.com/d3-timer/-/d3-timer-1.0.10.tgz#dfe76b8a91748831b13b6d9c793ffbd508dd9de5"
integrity sha512-B1JDm0XDaQC+uvo4DT79H0XmBskgS3l6Ve+1SBCfxgmtIb1AVrPIoqd+nPSv+loMX8szQ0sVUhGngL7D5QPiXw==
+dagre-compound@^0.0.11:
+ version "0.0.11"
+ resolved "https://registry.yarnpkg.com/dagre-compound/-/dagre-compound-0.0.11.tgz#8d3d1004d756f420582d29f28c92045375018987"
+ integrity sha512-UrSgRP9LtOZCYb9e5doolZXpc7xayyszgyOs7uakTK4n4KsLegLVTRRtq01GpQd/iZjYw5fWMapx9ed+c80MAQ==
+
dagre@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/dagre/-/dagre-0.8.5.tgz#ba30b0055dac12b6c1fcc247817442777d06afee"
@@ -1082,14 +1095,6 @@ dagre@^0.8.5:
graphlib "^2.1.8"
lodash "^4.17.15"
-dagrejs@^0.2.1:
- version "0.2.1"
- resolved "https://registry.yarnpkg.com/dagrejs/-/dagrejs-0.2.1.tgz#1d5738c17fe7989ff90983ce845c74599bae6786"
- integrity sha512-4bb1y+4aM1xtkK7ieP0V7Xn/34GQfnCapl0yubrOMX8Qb/PIwM1Dii2uUBv/KtuzrQtxPliSP4r5MQBsnP6gNg==
- dependencies:
- graphlib "^2.1.8"
- lodash "^4.17.19"
-
debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -1913,7 +1918,7 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"
-lodash@^4.17.15, lodash@^4.17.19:
+lodash@^4.11.1, lodash@^4.17.15:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
From 1f9ddfc6721e4fdeace479153c17e0ebb9b3d2ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BB=96=E5=A8=81=E6=95=AC?= <2667902230@qq.com>
Date: Wed, 6 Apr 2022 11:17:34 +0800
Subject: [PATCH 02/10] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=8A=9B?=
=?UTF-8?q?=E5=AF=BC=E5=90=91=E5=B8=83=E5=B1=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
demoV2/Layouter/Force.js | 71 ++++++++++++++++++++++++++++++++++++
src/Model/SVModel.ts | 2 +-
src/RegisteredShape/force.ts | 47 ++++++++++++++++++++++++
src/StructV.ts | 8 ++--
src/View/renderer.ts | 41 +++++++++++++++++++--
src/View/viewContainer.ts | 4 +-
src/engine.ts | 8 ++--
7 files changed, 168 insertions(+), 13 deletions(-)
create mode 100644 demoV2/Layouter/Force.js
create mode 100644 src/RegisteredShape/force.ts
diff --git a/demoV2/Layouter/Force.js b/demoV2/Layouter/Force.js
new file mode 100644
index 0000000..3a5fb4a
--- /dev/null
+++ b/demoV2/Layouter/Force.js
@@ -0,0 +1,71 @@
+
+
+
+SV.registerLayout('Force', {
+ defineOptions() {
+ return {
+ node: {
+ default: {
+ type: 'force-node',
+ label: '[data]',
+ size: 20,
+ labelOptions: {
+ style: { fontSize: 20 }
+ },
+ style: {
+ stroke: 'red',
+ fill: 'red'
+ }
+ }
+ },
+ link: {
+ next: {
+ type: 'line',
+ sourceAnchor: 0,
+ targetAnchor: 0,
+ style: {
+ stroke: '#333',
+ lineAppendWidth: 6,
+ cursor: 'pointer',
+ // endArrow: 'default',
+ startArrow: {
+ path: G6.Arrow.circle(2, -1),
+ fill: '#333'
+ }
+ }
+ }
+ },
+ marker: {
+ headExternal: {
+ type: 'pointer',
+ anchor: 3,
+ style: {
+ fill: '#f08a5d'
+ }
+ },
+ external: {
+ type: 'pointer',
+ anchor: 0,
+ style: {
+ fill: '#f08a5d'
+ }
+ }
+ },
+ indexLabel: {
+ index: { position: 'bottom' },
+ indexRight: { position: 'right' }
+ },
+ behavior: {
+ dragNode: true
+ }
+ };
+ },
+
+ layout(e) {
+ console.log("here is the layout of Force")
+ // e.forEach((item, index) => {
+ // console.log(item.getBound());
+ // })
+ }
+});
+
diff --git a/src/Model/SVModel.ts b/src/Model/SVModel.ts
index cbe9f8e..349d087 100644
--- a/src/Model/SVModel.ts
+++ b/src/Model/SVModel.ts
@@ -2,7 +2,7 @@ import { Util } from "../Common/util";
import { Style } from "../options";
import { BoundingRect } from "../Common/boundingRect";
import { EdgeConfig, Item, NodeConfig } from "@antv/g6-core";
-import { Graph } from "_@antv_g6-pc@0.5.0@@antv/g6-pc";
+import { Graph } from "@antv/g6";
import merge from 'merge';
diff --git a/src/RegisteredShape/force.ts b/src/RegisteredShape/force.ts
new file mode 100644
index 0000000..9bb0725
--- /dev/null
+++ b/src/RegisteredShape/force.ts
@@ -0,0 +1,47 @@
+import { Util } from "../Common/util";
+
+
+export default Util.registerShape('force-node', {
+ draw(cfg, group) {
+ // cfg.size = cfg.size;
+ const size = 15;
+
+ const wrapperRect = group.addShape('circle', {
+ attrs: {
+ r: size,
+ stroke: 'rgb(35, 120, 180)',
+ // cursor: cfg.style.cursor,
+ fill: 'rgb(31, 119, 180)'
+ },
+ name: 'wrapper'
+ });
+
+ if (cfg.label) {
+ const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
+ group.addShape('text', {
+ attrs: {
+ x: 0, // 居中
+ y: 0,
+ textAlign: 'center',
+ textBaseline: 'middle',
+ text: cfg.label,
+ fill: style.fill || '#000',
+ fontSize: style.fontSize || 10,
+ cursor: cfg.style.cursor
+ },
+ name: 'text',
+ draggable: true
+ });
+ }
+
+ return wrapperRect;
+ },
+
+ getAnchorPoints() {
+ return [
+ [0.5, 0.5],
+ [0, 0.5],
+ [1, 0]
+ ];
+ }
+}, 'rect');
\ No newline at end of file
diff --git a/src/StructV.ts b/src/StructV.ts
index a714352..3b2d320 100644
--- a/src/StructV.ts
+++ b/src/StructV.ts
@@ -5,6 +5,7 @@ import G6 from '@antv/g6';
import Pointer from "./RegisteredShape/pointer";
import LinkListNode from "./RegisteredShape/linkListNode";
import BinaryTreeNode from "./RegisteredShape/binaryTreeNode";
+import ForceNode from "./RegisteredShape/force";
import CLenQueuePointer from "./RegisteredShape/clenQueuePointer";
import TwoCellNode from "./RegisteredShape/twoCellNode";
import ArrayNode from "./RegisteredShape/arrayNode";
@@ -20,7 +21,7 @@ import { SVNode } from "./Model/SVNode";
export interface StructV {
- (DOMContainer: HTMLElement, engineOptions: EngineOptions): Engine;
+ (DOMContainer: HTMLElement, engineOptions: EngineOptions, isForce: boolean): Engine;
Group: typeof Group;
Bound: typeof Bound;
Vector: typeof Vector,
@@ -42,8 +43,8 @@ export interface StructV {
}
-export const SV: StructV = function(DOMContainer: HTMLElement, engineOptions: EngineOptions = { }) {
- return new Engine(DOMContainer, engineOptions);
+export const SV: StructV = function(DOMContainer: HTMLElement, engineOptions: EngineOptions = { }, isForce: boolean) {
+ return new Engine(DOMContainer, engineOptions, isForce);
}
SV.Group = Group;
@@ -61,6 +62,7 @@ SV.registeredShape = [
Cursor,
ArrayNode,
CLenQueuePointer,
+ ForceNode
];
SV.registerShape = Util.registerShape;
diff --git a/src/View/renderer.ts b/src/View/renderer.ts
index a81ebc1..29e89ce 100644
--- a/src/View/renderer.ts
+++ b/src/View/renderer.ts
@@ -20,7 +20,7 @@ export class Renderer {
private g6Instance: Graph; // g6 实例
private shadowG6Instance: Graph;
- constructor(engine: Engine, DOMContainer: HTMLElement, behaviorsModes: Modes) {
+ constructor(engine: Engine, DOMContainer: HTMLElement, behaviorsModes: Modes, isForce: boolean) {
this.engine = engine;
const enable: boolean = this.engine.animationOptions.enable,
@@ -41,6 +41,19 @@ export class Renderer {
container: DOMContainer.cloneNode() as HTMLElement
});
+ const forceOption = {
+ type: 'force',
+ linkDistance: 100, // 边长
+ preventOverlap: true, // boolean,防止节点重叠
+ // alphaDecay: 0, // 迭代阈值的衰减率。范围 [0, 1]。默认值0.028
+ workEnabled: true, // 启用以防布局计算时间过长阻塞页面交互
+ nodeStrength: -1, // 节点作用力,正数标识引力,负数表示斥力
+ nodeSpacing: (d) => { // 设置了防止重叠后,节点边缘间距的最小值
+ return 20;
+ },
+ center: [DOMContainer.offsetWidth / 2, DOMContainer.offsetHeight / 3],
+ };
+ const layout = isForce ? forceOption : null;
// 初始化g6实例
this.g6Instance = new Graph({
container: DOMContainer,
@@ -52,10 +65,32 @@ export class Renderer {
duration: duration,
easing: timingFunction
},
- fitView: false,
modes: behaviorsModes,
- plugins: [tooltip]
+ plugins: [tooltip],
+ layout,
});
+ /**
+ * 固定被拖拽节点
+ */
+ function refreshDragedNodePosition(e) {
+ const model = e.item.get('model');
+ model.fx = e.x;
+ model.fy = e.y;
+ }
+ this.g6Instance.on('node:dragstart', (e) => {
+ this.g6Instance.layout();
+ refreshDragedNodePosition(e);
+ });
+ this.g6Instance.on('node:drag', (e) => {
+ refreshDragedNodePosition(e);
+ });
+ if (typeof window !== 'undefined') {
+ window.onresize = () => {
+ if (!this.g6Instance || this.g6Instance.get('destroyed')) return;
+ if (!DOMContainer || !DOMContainer.scrollWidth || !DOMContainer.scrollHeight) return;
+ this.g6Instance.changeSize(DOMContainer.scrollWidth, DOMContainer.scrollHeight);
+ };
+ }
}
/**
diff --git a/src/View/viewContainer.ts b/src/View/viewContainer.ts
index 8cbfcd7..04962af 100644
--- a/src/View/viewContainer.ts
+++ b/src/View/viewContainer.ts
@@ -30,12 +30,12 @@ export class ViewContainer {
public clickSelectNode: SVNode; // 点击选中的节点
- constructor(engine: Engine, DOMContainer: HTMLElement) {
+ constructor(engine: Engine, DOMContainer: HTMLElement, isForce: boolean) {
const behaviorsModes: Modes = InitG6Behaviors(engine, this);
this.engine = engine;
this.layoutProvider = new LayoutProvider(engine, this);
- this.renderer = new Renderer(engine, DOMContainer, behaviorsModes);
+ this.renderer = new Renderer(engine, DOMContainer, behaviorsModes, isForce);
this.reconcile = new Reconcile(engine, this.renderer);
this.layoutGroupTable = new Map();
this.prevModelList = [];
diff --git a/src/engine.ts b/src/engine.ts
index 9b637f6..cafaff5 100644
--- a/src/engine.ts
+++ b/src/engine.ts
@@ -18,7 +18,7 @@ export class Engine {
public animationOptions: AnimationOptions;
public behaviorOptions: BehaviorOptions;
- constructor(DOMContainer: HTMLElement, engineOptions: EngineOptions) {
+ constructor(DOMContainer: HTMLElement, engineOptions: EngineOptions, isForce: boolean) {
this.engineOptions = Object.assign({}, engineOptions);
this.viewOptions = Object.assign({
@@ -43,7 +43,7 @@ export class Engine {
}, engineOptions.behavior);
this.modelConstructor = new ModelConstructor(this);
- this.viewContainer = new ViewContainer(this, DOMContainer);
+ this.viewContainer = new ViewContainer(this, DOMContainer, isForce);
}
/**
@@ -51,13 +51,13 @@ export class Engine {
* @param sources
* @param force
*/
- public render(source: Sources, force: boolean = false) {
+ public render(source: Sources) {
if (source === undefined || source === null) {
return;
}
``
let stringSource = JSON.stringify(source);
- if (force === false && this.prevStringSource === stringSource) {
+ if (this.prevStringSource === stringSource) {
return;
}
From a9e5bcd224043ddcd617f94f609b65ea0d3972b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BB=96=E5=A8=81=E6=95=AC?= <2667902230@qq.com>
Date: Wed, 6 Apr 2022 11:59:24 +0800
Subject: [PATCH 03/10] =?UTF-8?q?fix=EF=BC=9A=E5=8A=9B=E5=AF=BC=E5=90=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
demo/Layouter/Force.js | 5 +-
demo/data.js | 136 +++++++++++++++++++++++++++++++++++++++++
demo/demo.html | 14 +++--
src/View/renderer.ts | 5 +-
src/engine.ts | 10 ---
5 files changed, 150 insertions(+), 20 deletions(-)
diff --git a/demo/Layouter/Force.js b/demo/Layouter/Force.js
index 3a5fb4a..92c264c 100644
--- a/demo/Layouter/Force.js
+++ b/demo/Layouter/Force.js
@@ -62,10 +62,7 @@ SV.registerLayout('Force', {
},
layout(e) {
- console.log("here is the layout of Force")
- // e.forEach((item, index) => {
- // console.log(item.getBound());
- // })
+
}
});
diff --git a/demo/data.js b/demo/data.js
index 2804eef..9b9bd21 100644
--- a/demo/data.js
+++ b/demo/data.js
@@ -289,4 +289,140 @@ const SOURCES_DATA = [{
"isEnterFunction": false,
"isFirstDebug": false
}
+}, {
+ "force0": {
+ "data": [
+ {
+ "id": "0x617eb1",
+ "data": "A",
+ "next": "0x617eb2"
+ },
+ {
+ "id": "0x617eb2",
+ "data": "B",
+ "next": "0x617eb3"
+ },
+ {
+ "id": "0x617eb3",
+ "data": "C",
+ "next": "0x617eb5"
+ },
+ {
+ "id": "0x617eb5",
+ "data": "D",
+ "next": "0x617eb3"
+ },
+ {
+ "id": "0x617eb6",
+ "data": "D",
+ "next": "0x617eb5"
+ },
+ {
+ "id": "0x617eb7",
+ "data": "D",
+ "next": "0x617eb6"
+ },
+ {
+ "id": "0x617eb8",
+ "data": "D",
+ "next": "0x617eb7"
+ },
+ {
+ "id": "0x617eb9",
+ "data": "D",
+ "next": "0x617eb8"
+ },
+ {
+ "id": "0x617eba",
+ "data": "D",
+ "next": "0x617eb9"
+ },
+ {
+ "id": "0x617ebb",
+ "data": "D",
+ "next": "0x617eba"
+ },
+ {
+ "id": "0x617ebc",
+ "data": "D",
+ "next": "0x617ebb"
+ },
+ {
+ "id": "0x617ebd",
+ "data": "D",
+ "next": "0x617ebc"
+ },
+ {
+ "id": "0x617ebe",
+ "data": "D",
+ "next": "0x617ebd"
+ },
+ {
+ "id": "0x627ebe",
+ "data": "D",
+ "next": "0x617ebe"
+ },
+ {
+ "id": "0x637ebe",
+ "data": "D",
+ "next": "0x627ebe"
+ },
+ {
+ "id": "0x647ebe",
+ "data": "D",
+ "next": "0x637ebe"
+ },
+ {
+ "id": "0x657ebe",
+ "data": "D",
+ "next": "0x647ebe"
+ },
+ {
+ "id": "0x667ebe",
+ "data": "D",
+ "next": "0x657ebe"
+ },
+ {
+ "id": "0x677ebe",
+ "data": "D",
+ "next": "0x667ebe"
+ },
+ {
+ "id": "0x687ebe",
+ "data": "D",
+ "next": "0x677ebe"
+ },
+ {
+ "id": "0x697ebe",
+ "data": "D",
+ "next": "0x687ebe"
+ },
+ {
+ "id": "0x6a7ebe",
+ "data": "D",
+ "next": "0x697ebe"
+ },
+ {
+ "id": "0x6b7ebe",
+ "data": "D",
+ "next": "0x6a7ebe"
+ },
+ {
+ "id": "0x6c7ebe",
+ "data": "D",
+ "next": "0x6b7ebe"
+ },
+ {
+ "id": "0x6d7ebe",
+ "data": "X",
+ "next": "0x6c7ebe"
+ },
+ {
+ "id": "0x6e7ebe",
+ "data": "Y",
+ "next": "0x6d7ebe"
+ },
+ ],
+ "layouter": "Force"
+ }
}];
\ No newline at end of file
diff --git a/demo/demo.html b/demo/demo.html
index e4fbadd..a2a37f4 100644
--- a/demo/demo.html
+++ b/demo/demo.html
@@ -86,18 +86,24 @@
+