@antv/g6 5.0.0-alpha.8 → 5.0.0-alpha.9
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/dist/g6.min.js +6 -19
- package/esm/index.d.ts +26 -6
- package/esm/item/combo.d.ts +72 -2
- package/esm/item/combo.js +122 -2
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +3 -3
- package/esm/item/edge.js +4 -5
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +4 -4
- package/esm/item/item.js +38 -9
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +20 -16
- package/esm/item/node.js +14 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +12 -4
- package/esm/runtime/controller/data.js +354 -62
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/interaction.js +16 -4
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +11 -2
- package/esm/runtime/controller/item.js +344 -52
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +19 -5
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/graph.d.ts +54 -17
- package/esm/runtime/graph.js +165 -34
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.d.ts +3 -0
- package/esm/stdlib/behavior/click-select.js +13 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/collapse-expand-combo.d.ts +29 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js +35 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-combo.d.ts +99 -0
- package/esm/stdlib/behavior/drag-combo.js +341 -0
- package/esm/stdlib/behavior/drag-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +14 -10
- package/esm/stdlib/behavior/drag-node.js +134 -37
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/hover-activate.d.ts +3 -1
- package/esm/stdlib/behavior/hover-activate.js +3 -1
- package/esm/stdlib/behavior/hover-activate.js.map +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/esm/stdlib/index.d.ts +25 -3
- package/esm/stdlib/index.js +25 -3
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/combo/circle.d.ts +29 -0
- package/esm/stdlib/item/combo/circle.js +56 -0
- package/esm/stdlib/item/combo/circle.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +2 -2
- package/esm/stdlib/item/edge/base.js +3 -0
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizon.d.ts +37 -0
- package/esm/stdlib/item/edge/cubic-horizon.js +71 -0
- package/esm/stdlib/item/edge/cubic-horizon.js.map +1 -0
- package/esm/stdlib/item/edge/cubic-vertical.d.ts +37 -0
- package/esm/stdlib/item/edge/cubic-vertical.js +71 -0
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/esm/stdlib/item/edge/cubic.d.ts +60 -0
- package/esm/stdlib/item/edge/cubic.js +99 -0
- package/esm/stdlib/item/edge/cubic.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +1 -0
- package/esm/stdlib/item/edge/index.js +1 -0
- package/esm/stdlib/item/edge/index.js.map +1 -1
- package/esm/stdlib/item/edge/line.d.ts +1 -1
- package/esm/stdlib/item/edge/quadratic.d.ts +41 -0
- package/esm/stdlib/item/edge/quadratic.js +66 -0
- package/esm/stdlib/item/edge/quadratic.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +38 -37
- package/esm/stdlib/item/node/base.js +4 -4
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/item/node/rect.d.ts +31 -0
- package/esm/stdlib/item/node/rect.js +59 -0
- package/esm/stdlib/item/node/rect.js.map +1 -0
- package/esm/stdlib/plugin/fisheye/index.d.ts +102 -0
- package/esm/stdlib/plugin/fisheye/index.js +487 -0
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.d.ts +42 -0
- package/esm/stdlib/plugin/menu/index.js +236 -0
- package/esm/stdlib/plugin/menu/index.js.map +1 -0
- package/esm/stdlib/plugin/tooltip/index.d.ts +75 -0
- package/esm/stdlib/plugin/tooltip/index.js +377 -0
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -0
- package/esm/stdlib/theme/dark.js +4 -0
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +54 -9
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/types/combo.d.ts +52 -3
- package/esm/types/data.d.ts +4 -4
- package/esm/types/edge.d.ts +2 -3
- package/esm/types/event.d.ts +9 -1
- package/esm/types/event.js +8 -8
- package/esm/types/event.js.map +1 -1
- package/esm/types/graph.d.ts +49 -13
- package/esm/types/hook.d.ts +8 -1
- package/esm/types/item.d.ts +4 -4
- package/esm/types/node.d.ts +4 -5
- package/esm/types/theme.d.ts +1 -1
- package/esm/util/animate.js.map +1 -1
- package/esm/util/canvas.js +8 -0
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/data.d.ts +65 -0
- package/esm/util/data.js +150 -0
- package/esm/util/data.js.map +1 -0
- package/esm/util/event.d.ts +8 -0
- package/esm/util/event.js +16 -0
- package/esm/util/event.js.map +1 -1
- package/esm/util/item.d.ts +2 -1
- package/esm/util/item.js +36 -13
- package/esm/util/item.js.map +1 -1
- package/esm/util/shape.d.ts +39 -4
- package/esm/util/shape.js +101 -1
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +2 -2
- package/lib/index.d.ts +26 -6
- package/lib/item/combo.d.ts +72 -2
- package/lib/item/combo.js +122 -2
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +3 -3
- package/lib/item/edge.js +4 -5
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +4 -4
- package/lib/item/item.js +37 -8
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +20 -16
- package/lib/item/node.js +14 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +12 -4
- package/lib/runtime/controller/data.js +353 -61
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/interaction.js +15 -3
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +11 -2
- package/lib/runtime/controller/item.js +342 -50
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +19 -5
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/graph.d.ts +54 -17
- package/lib/runtime/graph.js +165 -34
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.d.ts +3 -0
- package/lib/stdlib/behavior/click-select.js +13 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/collapse-expand-combo.d.ts +29 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js +38 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-combo.d.ts +99 -0
- package/lib/stdlib/behavior/drag-combo.js +344 -0
- package/lib/stdlib/behavior/drag-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +14 -10
- package/lib/stdlib/behavior/drag-node.js +134 -37
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/hover-activate.d.ts +3 -1
- package/lib/stdlib/behavior/hover-activate.js +3 -2
- package/lib/stdlib/behavior/hover-activate.js.map +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.js +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.js +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/lib/stdlib/index.d.ts +25 -3
- package/lib/stdlib/index.js +25 -3
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/combo/circle.d.ts +29 -0
- package/lib/stdlib/item/combo/circle.js +60 -0
- package/lib/stdlib/item/combo/circle.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +2 -2
- package/lib/stdlib/item/edge/base.js +3 -0
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizon.d.ts +37 -0
- package/lib/stdlib/item/edge/cubic-horizon.js +75 -0
- package/lib/stdlib/item/edge/cubic-horizon.js.map +1 -0
- package/lib/stdlib/item/edge/cubic-vertical.d.ts +37 -0
- package/lib/stdlib/item/edge/cubic-vertical.js +75 -0
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/lib/stdlib/item/edge/cubic.d.ts +60 -0
- package/lib/stdlib/item/edge/cubic.js +103 -0
- package/lib/stdlib/item/edge/cubic.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +1 -0
- package/lib/stdlib/item/edge/index.js +1 -0
- package/lib/stdlib/item/edge/index.js.map +1 -1
- package/lib/stdlib/item/edge/line.d.ts +1 -1
- package/lib/stdlib/item/edge/quadratic.d.ts +41 -0
- package/lib/stdlib/item/edge/quadratic.js +70 -0
- package/lib/stdlib/item/edge/quadratic.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +38 -37
- package/lib/stdlib/item/node/base.js +4 -4
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/item/node/rect.d.ts +31 -0
- package/lib/stdlib/item/node/rect.js +63 -0
- package/lib/stdlib/item/node/rect.js.map +1 -0
- package/lib/stdlib/plugin/fisheye/index.d.ts +102 -0
- package/lib/stdlib/plugin/fisheye/index.js +490 -0
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.d.ts +42 -0
- package/lib/stdlib/plugin/menu/index.js +242 -0
- package/lib/stdlib/plugin/menu/index.js.map +1 -0
- package/lib/stdlib/plugin/tooltip/index.d.ts +75 -0
- package/lib/stdlib/plugin/tooltip/index.js +383 -0
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -0
- package/lib/stdlib/theme/dark.js +4 -0
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +54 -9
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/types/combo.d.ts +52 -3
- package/lib/types/data.d.ts +4 -4
- package/lib/types/edge.d.ts +2 -3
- package/lib/types/event.d.ts +9 -1
- package/lib/types/event.js +10 -10
- package/lib/types/event.js.map +1 -1
- package/lib/types/graph.d.ts +49 -13
- package/lib/types/hook.d.ts +8 -1
- package/lib/types/item.d.ts +4 -4
- package/lib/types/item.js +1 -1
- package/lib/types/item.js.map +1 -1
- package/lib/types/node.d.ts +4 -5
- package/lib/types/theme.d.ts +1 -1
- package/lib/util/animate.js.map +1 -1
- package/lib/util/canvas.js +8 -0
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/data.d.ts +65 -0
- package/lib/util/data.js +161 -0
- package/lib/util/data.js.map +1 -0
- package/lib/util/event.d.ts +8 -0
- package/lib/util/event.js +18 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/item.d.ts +2 -1
- package/lib/util/item.js +36 -13
- package/lib/util/item.js.map +1 -1
- package/lib/util/shape.d.ts +39 -4
- package/lib/util/shape.js +105 -2
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +2 -2
- package/package.json +13 -13
- package/src/item/combo.ts +220 -2
- package/src/item/edge.ts +7 -8
- package/src/item/item.ts +58 -15
- package/src/item/node.ts +47 -24
- package/src/runtime/controller/data.ts +390 -68
- package/src/runtime/controller/interaction.ts +23 -3
- package/src/runtime/controller/item.ts +444 -64
- package/src/runtime/controller/layout.ts +24 -5
- package/src/runtime/graph.ts +225 -38
- package/src/stdlib/behavior/click-select.ts +15 -2
- package/src/stdlib/behavior/collapse-expand-combo.ts +59 -0
- package/src/stdlib/behavior/drag-combo.ts +533 -0
- package/src/stdlib/behavior/drag-node.ts +195 -62
- package/src/stdlib/behavior/hover-activate.ts +4 -5
- package/src/stdlib/behavior/orbit-canvas-3d.ts +1 -1
- package/src/stdlib/behavior/track-canvas-3d.ts +1 -1
- package/src/stdlib/index.ts +25 -3
- package/src/stdlib/item/combo/circle.ts +113 -0
- package/src/stdlib/item/edge/base.ts +5 -2
- package/src/stdlib/item/edge/cubic-horizon.ts +114 -0
- package/src/stdlib/item/edge/cubic-vertical.ts +116 -0
- package/src/stdlib/item/edge/cubic.ts +198 -0
- package/src/stdlib/item/edge/index.ts +1 -0
- package/src/stdlib/item/edge/quadratic.ts +136 -0
- package/src/stdlib/item/node/base.ts +79 -41
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/item/node/rect.ts +124 -0
- package/src/stdlib/plugin/fisheye/index.ts +578 -0
- package/src/stdlib/plugin/menu/index.ts +260 -0
- package/src/stdlib/plugin/tooltip/index.ts +424 -0
- package/src/stdlib/theme/dark.ts +4 -0
- package/src/stdlib/theme/light.ts +77 -9
- package/src/types/combo.ts +61 -3
- package/src/types/data.ts +6 -4
- package/src/types/edge.ts +2 -2
- package/src/types/event.ts +8 -8
- package/src/types/graph.ts +73 -16
- package/src/types/hook.ts +8 -1
- package/src/types/item.ts +10 -9
- package/src/types/node.ts +4 -4
- package/src/types/theme.ts +1 -1
- package/src/util/animate.ts +2 -3
- package/src/util/canvas.ts +10 -0
- package/src/util/data.ts +178 -0
- package/src/util/event.ts +29 -0
- package/src/util/item.ts +75 -12
- package/src/util/shape.ts +142 -5
- package/src/util/zoom.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g6",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.9",
|
|
4
4
|
"description": "A Graph Visualization Framework in JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm",
|
|
36
36
|
"build": "run-p build:*",
|
|
37
37
|
"bundle-vis": "cross-env BUNDLE_VIS=1 run-p build:umd",
|
|
38
|
-
"prepublishOnly": "npm run ci",
|
|
39
38
|
"ci": "run-s lint build",
|
|
40
39
|
"clean": "rimraf es lib",
|
|
41
40
|
"coverage": "jest --coverage",
|
|
@@ -45,7 +44,7 @@
|
|
|
45
44
|
"fix": "eslint ./src ./tests --fix && prettier ./src ./tests --write ",
|
|
46
45
|
"test": "jest",
|
|
47
46
|
"size": "limit-size",
|
|
48
|
-
"test-live": "DEBUG_MODE=1 jest --watch ./tests/unit/
|
|
47
|
+
"test-live": "DEBUG_MODE=1 jest --watch ./tests/unit/edge-spec.ts",
|
|
49
48
|
"test-behavior": "DEBUG_MODE=1 jest --watch ./tests/unit/item-3d-spec.ts"
|
|
50
49
|
},
|
|
51
50
|
"lint-staged": {
|
|
@@ -63,9 +62,10 @@
|
|
|
63
62
|
"@antv/g-canvas": "^1.9.28",
|
|
64
63
|
"@antv/g-plugin-3d": "^1.7.45",
|
|
65
64
|
"@antv/g-plugin-control": "^1.7.43",
|
|
65
|
+
"@antv/g-plugin-dragndrop": "^1.8.1",
|
|
66
66
|
"@antv/g-svg": "^1.8.36",
|
|
67
67
|
"@antv/g-webgl": "^1.7.44",
|
|
68
|
-
"@antv/graphlib": "^2.0.
|
|
68
|
+
"@antv/graphlib": "^2.0.2",
|
|
69
69
|
"@antv/gui": "^0.5.0-alpha.16",
|
|
70
70
|
"@antv/layout": "^1.2.0",
|
|
71
71
|
"@antv/layout-gpu": "^1.0.0",
|
|
@@ -74,38 +74,38 @@
|
|
|
74
74
|
"@antv/util": "~2.0.5",
|
|
75
75
|
"color": "^4.2.3",
|
|
76
76
|
"tslib": "^2.5.0",
|
|
77
|
-
"typedoc-plugin-markdown": "^3.14.0"
|
|
77
|
+
"typedoc-plugin-markdown": "^3.14.0",
|
|
78
|
+
"typescript": "^5.1.6"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@antv/g6": "^4.8.13",
|
|
82
|
+
"@kayahr/jest-electron-runner": "^5.1.1",
|
|
83
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
81
84
|
"@types/jest": "^29.5.1",
|
|
82
85
|
"@types/node": "13.11.1",
|
|
83
86
|
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
84
87
|
"@typescript-eslint/parser": "^4.18.0",
|
|
85
88
|
"@umijs/fabric": "^2.0.0",
|
|
86
|
-
"awesome-typescript-loader": "^5.2.1",
|
|
87
89
|
"babel-loader": "^8.0.6",
|
|
88
90
|
"eslint": "^7.22.0",
|
|
89
91
|
"eslint-plugin-import": "^2.22.1",
|
|
90
92
|
"father": "^2.29.1",
|
|
91
|
-
"jest": "^
|
|
92
|
-
"jest-electron": "^0.1.7",
|
|
93
|
+
"jest": "^28.1.3",
|
|
93
94
|
"jest-extended": "^0.11.2",
|
|
94
95
|
"limit-size": "^0.1.4",
|
|
95
96
|
"lint-staged": "^10.5.4",
|
|
96
97
|
"npm-run-all": "^4.1.5",
|
|
97
98
|
"prettier": "^2.2.1",
|
|
98
99
|
"rimraf": "^3.0.0",
|
|
99
|
-
"rollup": "^2.
|
|
100
|
+
"rollup": "^2.79.1",
|
|
100
101
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
101
102
|
"rollup-plugin-polyfill-node": "^0.8.0",
|
|
102
103
|
"rollup-plugin-typescript": "^1.0.1",
|
|
103
|
-
"rollup-plugin-uglify": "^6.0.4",
|
|
104
104
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
105
105
|
"stats.js": "^0.17.0",
|
|
106
|
-
"ts-jest": "^
|
|
107
|
-
"typedoc": "^0.
|
|
108
|
-
"typescript": "^4.
|
|
106
|
+
"ts-jest": "^28.0.8",
|
|
107
|
+
"typedoc": "^0.24.0",
|
|
108
|
+
"typescript": "^4.9.5",
|
|
109
109
|
"vite": "^4.2.2"
|
|
110
110
|
},
|
|
111
111
|
"limit-size": [
|
package/src/item/combo.ts
CHANGED
|
@@ -1,5 +1,223 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComboDisplayModel, ComboModel } from 'types';
|
|
2
|
+
import { Group, Tuple3Number } from '@antv/g';
|
|
3
|
+
import { clone } from '@antv/util';
|
|
4
|
+
import { DisplayMapper, LodStrategyObj, State } from '../types/item';
|
|
5
|
+
import { ComboStyleSet } from '../types/theme';
|
|
6
|
+
import Node from './node';
|
|
7
|
+
import {
|
|
8
|
+
ComboModelData,
|
|
9
|
+
ComboUserModel,
|
|
10
|
+
ComboUserModelData,
|
|
11
|
+
} from '../types/combo';
|
|
12
|
+
import { throttle } from '@antv/util';
|
|
13
|
+
import { Point } from '../types/common';
|
|
2
14
|
|
|
3
|
-
|
|
15
|
+
interface IProps {
|
|
16
|
+
model: ComboModel;
|
|
17
|
+
renderExtensions: any;
|
|
18
|
+
containerGroup: Group;
|
|
19
|
+
mapper: DisplayMapper;
|
|
20
|
+
stateMapper: {
|
|
21
|
+
[stateName: string]: DisplayMapper;
|
|
22
|
+
};
|
|
23
|
+
zoom?: number;
|
|
24
|
+
theme: {
|
|
25
|
+
styles: ComboStyleSet;
|
|
26
|
+
lodStrategy: LodStrategyObj;
|
|
27
|
+
};
|
|
28
|
+
device?: any; // for 3d shapes
|
|
29
|
+
onframe?: Function;
|
|
30
|
+
onfinish?: Function;
|
|
31
|
+
getCombinedBounds?: () =>
|
|
32
|
+
| {
|
|
33
|
+
center: Tuple3Number;
|
|
34
|
+
min: Tuple3Number;
|
|
35
|
+
max: Tuple3Number;
|
|
36
|
+
size: Tuple3Number;
|
|
37
|
+
}
|
|
38
|
+
| false;
|
|
39
|
+
getChildren?: () => (Node | Combo)[];
|
|
40
|
+
}
|
|
41
|
+
export default class Combo extends Node {
|
|
4
42
|
public type: 'combo';
|
|
43
|
+
|
|
44
|
+
private cacheCombinedBounds?:
|
|
45
|
+
| {
|
|
46
|
+
center: Tuple3Number;
|
|
47
|
+
min: Tuple3Number;
|
|
48
|
+
max: Tuple3Number;
|
|
49
|
+
size: Tuple3Number;
|
|
50
|
+
}
|
|
51
|
+
| false;
|
|
52
|
+
|
|
53
|
+
private getCombinedBounds: () =>
|
|
54
|
+
| {
|
|
55
|
+
center: Tuple3Number;
|
|
56
|
+
min: Tuple3Number;
|
|
57
|
+
max: Tuple3Number;
|
|
58
|
+
size: Tuple3Number;
|
|
59
|
+
}
|
|
60
|
+
| false;
|
|
61
|
+
|
|
62
|
+
private getChildren: () => (Combo | Node)[];
|
|
63
|
+
|
|
64
|
+
constructor(props: IProps) {
|
|
65
|
+
super({ ...props, type: 'combo' });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public init(props) {
|
|
69
|
+
this.getCombinedBounds = props.getCombinedBounds;
|
|
70
|
+
this.getChildren = props.getChildren;
|
|
71
|
+
super.init(props);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public draw(
|
|
75
|
+
displayModel: ComboDisplayModel,
|
|
76
|
+
diffData?: { previous: ComboUserModelData; current: ComboUserModelData },
|
|
77
|
+
diffState?: { previous: State[]; current: State[] },
|
|
78
|
+
onfinish: Function = () => {},
|
|
79
|
+
) {
|
|
80
|
+
if (displayModel.data.collapsed) {
|
|
81
|
+
Object.keys(this.themeStyles.collapsed).forEach((shapeId) => {
|
|
82
|
+
displayModel.data[shapeId] = displayModel.data[shapeId] || {};
|
|
83
|
+
displayModel.data[shapeId] = {
|
|
84
|
+
...(displayModel.data[shapeId] as object),
|
|
85
|
+
...this.themeStyles.collapsed[shapeId],
|
|
86
|
+
};
|
|
87
|
+
if (this.themeStyles.collapsed[shapeId].contentType === 'childCount') {
|
|
88
|
+
(displayModel.data[shapeId] as any).text = `${this.getChildren().length || 0}`;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
super.draw(displayModel, diffData, diffState, onfinish);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Sometimes no changes on edge data, but need to re-draw it
|
|
97
|
+
* e.g. source and target nodes' position changed
|
|
98
|
+
*/
|
|
99
|
+
public forceUpdate = throttle(
|
|
100
|
+
() => {
|
|
101
|
+
this.updateModelByBounds(this.displayModel as ComboDisplayModel);
|
|
102
|
+
if (!this.destroyed) this.draw(this.displayModel as ComboDisplayModel);
|
|
103
|
+
},
|
|
104
|
+
16,
|
|
105
|
+
{
|
|
106
|
+
leading: true,
|
|
107
|
+
trailing: true,
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Maps (mapper will be function, value, or encode format) model to displayModel and find out the shapes to be update for incremental updating.
|
|
113
|
+
* @param model inner model
|
|
114
|
+
* @param diffData changes from graphCore changed event
|
|
115
|
+
* @param isReplace whether replace the whole data or partial update
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
public getDisplayModelAndChanges(
|
|
119
|
+
innerModel: ComboModel,
|
|
120
|
+
diffData?: { previous: ComboModelData; current: ComboModelData },
|
|
121
|
+
isReplace?: boolean,
|
|
122
|
+
): {
|
|
123
|
+
model: ComboDisplayModel;
|
|
124
|
+
typeChange?: boolean;
|
|
125
|
+
} {
|
|
126
|
+
const superResult = super.getDisplayModelAndChanges(
|
|
127
|
+
innerModel,
|
|
128
|
+
diffData,
|
|
129
|
+
isReplace,
|
|
130
|
+
);
|
|
131
|
+
const model = superResult.model as ComboDisplayModel;
|
|
132
|
+
return {
|
|
133
|
+
model: this.updateModelByBounds(model),
|
|
134
|
+
typeChange: superResult.typeChange,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private updateModelByBounds(model: ComboDisplayModel): ComboDisplayModel {
|
|
139
|
+
const bounds = this.getCombinedBounds();
|
|
140
|
+
this.cacheCombinedBounds = bounds;
|
|
141
|
+
if (bounds) {
|
|
142
|
+
const { size, center } = bounds;
|
|
143
|
+
model.data.x = center[0];
|
|
144
|
+
model.data.y = center[1];
|
|
145
|
+
model.data.z = center[2];
|
|
146
|
+
if (!model.data.collapsed) {
|
|
147
|
+
model.data.keyShape = model.data.keyShape || {};
|
|
148
|
+
const { padding = [0, 0, 0, 0] } = model.data.keyShape;
|
|
149
|
+
const width = size[0] + padding[1] + padding[3];
|
|
150
|
+
const height = size[1] + padding[0] + padding[2];
|
|
151
|
+
model.data.keyShape.width = width;
|
|
152
|
+
model.data.keyShape.height = height;
|
|
153
|
+
const diag = Math.sqrt(width * width + height * height);
|
|
154
|
+
model.data.keyShape.r = diag / 2;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return model;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public getPosition(): Point {
|
|
161
|
+
const { x = 0, y = 0, z = 0 } = this.model.data;
|
|
162
|
+
this.cacheCombinedBounds =
|
|
163
|
+
this.cacheCombinedBounds || this.getCombinedBounds();
|
|
164
|
+
const { center } = this.cacheCombinedBounds || {};
|
|
165
|
+
return center
|
|
166
|
+
? {
|
|
167
|
+
x: center[0],
|
|
168
|
+
y: center[1],
|
|
169
|
+
z: center[2],
|
|
170
|
+
}
|
|
171
|
+
: {
|
|
172
|
+
x: x as number,
|
|
173
|
+
y: y as number,
|
|
174
|
+
z: z as number,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public clone(
|
|
179
|
+
containerGroup: Group,
|
|
180
|
+
onlyKeyShape?: boolean,
|
|
181
|
+
disableAnimate?: boolean,
|
|
182
|
+
getCombinedBounds?: () =>
|
|
183
|
+
| {
|
|
184
|
+
center: Tuple3Number;
|
|
185
|
+
min: Tuple3Number;
|
|
186
|
+
max: Tuple3Number;
|
|
187
|
+
size: Tuple3Number;
|
|
188
|
+
}
|
|
189
|
+
| false,
|
|
190
|
+
getChildren?: () => (Node | Combo)[],
|
|
191
|
+
) {
|
|
192
|
+
if (onlyKeyShape) {
|
|
193
|
+
const clonedKeyShape = this.shapeMap.keyShape.cloneNode();
|
|
194
|
+
const { x, y } = this.group.attributes;
|
|
195
|
+
const clonedGroup = new Group();
|
|
196
|
+
clonedGroup.setPosition([x, y]);
|
|
197
|
+
clonedGroup.appendChild(clonedKeyShape);
|
|
198
|
+
containerGroup.appendChild(clonedGroup);
|
|
199
|
+
return clonedGroup;
|
|
200
|
+
}
|
|
201
|
+
const clonedModel = clone(this.model);
|
|
202
|
+
clonedModel.data.disableAnimate = disableAnimate;
|
|
203
|
+
const clonedNode = new Combo({
|
|
204
|
+
model: clonedModel,
|
|
205
|
+
renderExtensions: this.renderExtensions,
|
|
206
|
+
containerGroup,
|
|
207
|
+
mapper: this.mapper,
|
|
208
|
+
stateMapper: this.stateMapper,
|
|
209
|
+
zoom: this.zoom,
|
|
210
|
+
theme: {
|
|
211
|
+
styles: this.themeStyles,
|
|
212
|
+
lodStrategy: this.lodStrategy,
|
|
213
|
+
},
|
|
214
|
+
getCombinedBounds: getCombinedBounds || this.getCombinedBounds,
|
|
215
|
+
getChildren: getChildren || this.getChildren,
|
|
216
|
+
});
|
|
217
|
+
Object.keys(this.shapeMap).forEach((shapeId) => {
|
|
218
|
+
if (!this.shapeMap[shapeId].isVisible())
|
|
219
|
+
clonedNode.shapeMap[shapeId].hide();
|
|
220
|
+
});
|
|
221
|
+
return clonedNode;
|
|
222
|
+
}
|
|
5
223
|
}
|
package/src/item/edge.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { Group } from '@antv/g';
|
|
|
2
2
|
import { clone, throttle } from '@antv/util';
|
|
3
3
|
import { EdgeDisplayModel, EdgeModel, NodeModelData } from '../types';
|
|
4
4
|
import { EdgeModelData } from '../types/edge';
|
|
5
|
-
import { DisplayMapper, State,
|
|
5
|
+
import { DisplayMapper, State, LodStrategyObj } from '../types/item';
|
|
6
6
|
import { updateShapes } from '../util/shape';
|
|
7
|
-
import Item from './item';
|
|
8
|
-
import Node from './node';
|
|
9
7
|
import { animateShapes } from '../util/animate';
|
|
10
8
|
import { EdgeStyleSet } from '../types/theme';
|
|
9
|
+
import Item from './item';
|
|
10
|
+
import Node from './node';
|
|
11
11
|
|
|
12
12
|
interface IProps {
|
|
13
13
|
model: EdgeModel;
|
|
@@ -22,7 +22,7 @@ interface IProps {
|
|
|
22
22
|
zoom?: number;
|
|
23
23
|
theme: {
|
|
24
24
|
styles: EdgeStyleSet;
|
|
25
|
-
lodStrategy:
|
|
25
|
+
lodStrategy: LodStrategyObj;
|
|
26
26
|
};
|
|
27
27
|
onframe?: Function;
|
|
28
28
|
}
|
|
@@ -40,8 +40,7 @@ export default class Edge extends Item {
|
|
|
40
40
|
|
|
41
41
|
constructor(props: IProps) {
|
|
42
42
|
super(props);
|
|
43
|
-
this.type
|
|
44
|
-
this.init(props);
|
|
43
|
+
this.init({ ...props, type: 'edge' });
|
|
45
44
|
const { sourceItem, targetItem } = props;
|
|
46
45
|
this.sourceItem = sourceItem;
|
|
47
46
|
this.targetItem = targetItem;
|
|
@@ -54,8 +53,8 @@ export default class Edge extends Item {
|
|
|
54
53
|
onfinish: Function = () => {},
|
|
55
54
|
) {
|
|
56
55
|
// get the end points
|
|
57
|
-
const { x: sx, y: sy, z: sz } = this.sourceItem.
|
|
58
|
-
const { x: tx, y: ty, z: tz } = this.targetItem.
|
|
56
|
+
const { x: sx, y: sy, z: sz } = this.sourceItem.getPosition();
|
|
57
|
+
const { x: tx, y: ty, z: tz } = this.targetItem.getPosition();
|
|
59
58
|
const sourcePoint = this.sourceItem.getAnchorPoint({ x: tx, y: ty, z: tz });
|
|
60
59
|
const targetPoint = this.targetItem.getAnchorPoint({ x: sx, y: sy, z: sz });
|
|
61
60
|
this.renderExt.mergeStyles(displayModel);
|
package/src/item/item.ts
CHANGED
|
@@ -11,12 +11,17 @@ import {
|
|
|
11
11
|
ItemShapeStyles,
|
|
12
12
|
ITEM_TYPE,
|
|
13
13
|
State,
|
|
14
|
-
|
|
14
|
+
LodStrategyObj,
|
|
15
15
|
} from '../types/item';
|
|
16
16
|
import { NodeShapeMap } from '../types/node';
|
|
17
17
|
import { EdgeStyleSet, NodeStyleSet } from '../types/theme';
|
|
18
18
|
import { isArrayOverlap } from '../util/array';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
combineBounds,
|
|
21
|
+
getShapeLocalBoundsByStyle,
|
|
22
|
+
mergeStyles,
|
|
23
|
+
updateShapes,
|
|
24
|
+
} from '../util/shape';
|
|
20
25
|
import { isEncode } from '../util/type';
|
|
21
26
|
import { DEFAULT_MAPPER } from '../util/mapper';
|
|
22
27
|
import {
|
|
@@ -61,7 +66,7 @@ export default abstract class Item implements IItem {
|
|
|
61
66
|
/** Set to different value in implements. */
|
|
62
67
|
public type: ITEM_TYPE;
|
|
63
68
|
/** The flag of transient item. */
|
|
64
|
-
public transient
|
|
69
|
+
public transient = false;
|
|
65
70
|
public renderExtensions: any; // TODO
|
|
66
71
|
/** Cache the animation instances to stop at next lifecycle. */
|
|
67
72
|
public animations: IAnimation[];
|
|
@@ -71,7 +76,7 @@ export default abstract class Item implements IItem {
|
|
|
71
76
|
[stateName: string]: ItemShapeStyles;
|
|
72
77
|
};
|
|
73
78
|
/** The zoom strategy to show and hide shapes according to their lod. */
|
|
74
|
-
public lodStrategy:
|
|
79
|
+
public lodStrategy: LodStrategyObj;
|
|
75
80
|
/** Last zoom ratio. */
|
|
76
81
|
public zoom: number;
|
|
77
82
|
/** Cache the chaging states which are not consomed by draw */
|
|
@@ -101,8 +106,10 @@ export default abstract class Item implements IItem {
|
|
|
101
106
|
renderExtensions,
|
|
102
107
|
zoom = 1,
|
|
103
108
|
theme = {},
|
|
109
|
+
type: itemType,
|
|
104
110
|
} = props;
|
|
105
|
-
this.
|
|
111
|
+
this.type = itemType;
|
|
112
|
+
this.group = new Group({ style: { zIndex: 0 } });
|
|
106
113
|
this.group.setAttribute('data-item-type', this.type);
|
|
107
114
|
this.group.setAttribute('data-item-id', props.model.id);
|
|
108
115
|
containerGroup.appendChild(this.group);
|
|
@@ -113,7 +120,7 @@ export default abstract class Item implements IItem {
|
|
|
113
120
|
this.displayModel = this.getDisplayModelAndChanges(model).model;
|
|
114
121
|
this.renderExtensions = renderExtensions;
|
|
115
122
|
const {
|
|
116
|
-
type = this.type === '
|
|
123
|
+
type = this.type === 'edge' ? 'line-edge' : `circle-${this.type}`,
|
|
117
124
|
lodStrategy: modelLodStrategy,
|
|
118
125
|
} = this.displayModel.data;
|
|
119
126
|
const RenderExtension = renderExtensions.find((ext) => ext.type === type);
|
|
@@ -121,6 +128,21 @@ export default abstract class Item implements IItem {
|
|
|
121
128
|
const lodStrategy = modelLodStrategy
|
|
122
129
|
? formatLodStrategy(modelLodStrategy)
|
|
123
130
|
: theme.lodStrategy;
|
|
131
|
+
if (!RenderExtension) {
|
|
132
|
+
if (this.type === 'node') {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`TypeError: RenderExtension is not a constructor. The '${type}' in your data haven't been registered. You can use built-in node types like 'rect-node', 'circle-node' or create a custom node type as you like.`,
|
|
135
|
+
);
|
|
136
|
+
} else if (this.type == 'edge') {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`TypeError: RenderExtension is not a constructor. The '${type}' in your data haven't been registered. You can use built-in edge types like 'line-edge', 'quadratic-edge','cubic-edge' or create a custom edge type as you like.`,
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`TypeError: RenderExtension is not a constructor. The '${type}' haven't been registered.`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
124
146
|
this.renderExt = new RenderExtension({
|
|
125
147
|
themeStyles: this.themeStyles.default,
|
|
126
148
|
lodStrategy,
|
|
@@ -173,7 +195,7 @@ export default abstract class Item implements IItem {
|
|
|
173
195
|
isReplace?: boolean,
|
|
174
196
|
itemTheme?: {
|
|
175
197
|
styles: NodeStyleSet | EdgeStyleSet;
|
|
176
|
-
lodStrategy:
|
|
198
|
+
lodStrategy: LodStrategyObj;
|
|
177
199
|
},
|
|
178
200
|
onlyMove?: boolean,
|
|
179
201
|
onfinish?: Function,
|
|
@@ -262,29 +284,30 @@ export default abstract class Item implements IItem {
|
|
|
262
284
|
|
|
263
285
|
const { data: innerModelData, ...otherFields } = innerModel;
|
|
264
286
|
const { current = innerModelData, previous } = diffData || {};
|
|
287
|
+
const firstRendering = !this.shapeMap?.keyShape;
|
|
265
288
|
|
|
266
289
|
// === no mapper, displayModel = model ===
|
|
267
290
|
if (!mapper) {
|
|
268
|
-
this.displayModel = defaultMapper(innerModel);
|
|
269
291
|
// compare the previous data and current data to find shape changes
|
|
270
292
|
let typeChange = false;
|
|
271
293
|
if (current) {
|
|
272
294
|
typeChange = Boolean(current.type);
|
|
273
295
|
}
|
|
274
296
|
return {
|
|
275
|
-
model:
|
|
297
|
+
model: defaultMapper(innerModel),
|
|
276
298
|
typeChange,
|
|
277
299
|
};
|
|
278
300
|
}
|
|
279
301
|
|
|
280
302
|
// === mapper is function, displayModel is mapper(model), cannot diff the displayModel, so all the shapes need to be updated ===
|
|
281
|
-
if (isFunction(mapper))
|
|
303
|
+
if (isFunction(mapper)) {
|
|
282
304
|
return {
|
|
283
305
|
model: {
|
|
284
306
|
...defaultMapper(innerModel),
|
|
285
307
|
...(mapper as Function)(innerModel),
|
|
286
308
|
},
|
|
287
309
|
};
|
|
310
|
+
}
|
|
288
311
|
|
|
289
312
|
// === fields' values in mapper are final value or Encode ===
|
|
290
313
|
const dataChangedFields = isReplace
|
|
@@ -353,12 +376,11 @@ export default abstract class Item implements IItem {
|
|
|
353
376
|
});
|
|
354
377
|
}
|
|
355
378
|
});
|
|
356
|
-
const displayModel = {
|
|
357
|
-
...otherProps,
|
|
358
|
-
data: displayModelData,
|
|
359
|
-
};
|
|
360
379
|
return {
|
|
361
|
-
model:
|
|
380
|
+
model: {
|
|
381
|
+
...otherProps,
|
|
382
|
+
data: displayModelData,
|
|
383
|
+
},
|
|
362
384
|
typeChange,
|
|
363
385
|
};
|
|
364
386
|
}
|
|
@@ -679,6 +701,27 @@ export default abstract class Item implements IItem {
|
|
|
679
701
|
* @returns item's rendering bounding box
|
|
680
702
|
*/
|
|
681
703
|
public getBBox(): AABB {
|
|
704
|
+
if (this.animations?.length) {
|
|
705
|
+
// during animations, estimate the final bounds by the styles in displayModel
|
|
706
|
+
const { keyShape, labelShape } = this.shapeMap;
|
|
707
|
+
const {
|
|
708
|
+
keyShape: keyShapeStyle,
|
|
709
|
+
labelShape: labelShapeStyle,
|
|
710
|
+
x = 0,
|
|
711
|
+
y = 0,
|
|
712
|
+
z = 0,
|
|
713
|
+
} = this.displayModel.data;
|
|
714
|
+
const estimateBounds = combineBounds([
|
|
715
|
+
getShapeLocalBoundsByStyle(keyShape, keyShapeStyle),
|
|
716
|
+
getShapeLocalBoundsByStyle(labelShape, labelShapeStyle),
|
|
717
|
+
]);
|
|
718
|
+
[x, y, z].forEach((val: number, i) => {
|
|
719
|
+
estimateBounds.max[i] += val;
|
|
720
|
+
estimateBounds.min[i] += val;
|
|
721
|
+
estimateBounds.center[i] += val;
|
|
722
|
+
});
|
|
723
|
+
return estimateBounds as AABB;
|
|
724
|
+
}
|
|
682
725
|
return this.group.getRenderBounds();
|
|
683
726
|
}
|
|
684
727
|
|
package/src/item/node.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { Group } from '@antv/g';
|
|
2
2
|
import { clone } from '@antv/util';
|
|
3
3
|
import { Point } from '../types/common';
|
|
4
|
-
import { NodeModel } from '../types';
|
|
5
|
-
import { DisplayMapper, State,
|
|
4
|
+
import { ComboDisplayModel, ComboModel, NodeModel } from '../types';
|
|
5
|
+
import { DisplayMapper, State, LodStrategyObj } from '../types/item';
|
|
6
6
|
import { NodeDisplayModel, NodeModelData } from '../types/node';
|
|
7
|
-
import { NodeStyleSet } from '../types/theme';
|
|
7
|
+
import { ComboStyleSet, NodeStyleSet } from '../types/theme';
|
|
8
8
|
import { updateShapes } from '../util/shape';
|
|
9
9
|
import { animateShapes, getAnimatesExcludePosition } from '../util/animate';
|
|
10
|
-
import Item from './item';
|
|
11
10
|
import {
|
|
12
11
|
getCircleIntersectByPoint,
|
|
13
12
|
getEllipseIntersectByPoint,
|
|
14
13
|
getNearestPoint,
|
|
15
14
|
getRectIntersectByPoint,
|
|
16
15
|
} from '../util/point';
|
|
16
|
+
import Item from './item';
|
|
17
|
+
import { ComboModelData } from '../types/combo';
|
|
17
18
|
|
|
18
19
|
interface IProps {
|
|
19
|
-
model: NodeModel;
|
|
20
|
+
model: NodeModel | ComboModel;
|
|
20
21
|
renderExtensions: any;
|
|
21
22
|
containerGroup: Group;
|
|
22
23
|
mapper: DisplayMapper;
|
|
@@ -25,38 +26,39 @@ interface IProps {
|
|
|
25
26
|
};
|
|
26
27
|
zoom?: number;
|
|
27
28
|
theme: {
|
|
28
|
-
styles: NodeStyleSet;
|
|
29
|
-
lodStrategy:
|
|
29
|
+
styles: NodeStyleSet | ComboStyleSet;
|
|
30
|
+
lodStrategy: LodStrategyObj;
|
|
30
31
|
};
|
|
31
32
|
device?: any; // for 3d shapes
|
|
32
33
|
onframe?: Function;
|
|
33
34
|
onfinish?: Function;
|
|
35
|
+
type?: 'node' | 'combo';
|
|
34
36
|
}
|
|
35
37
|
export default class Node extends Item {
|
|
36
|
-
public type: 'node';
|
|
38
|
+
public type: 'node' | 'combo';
|
|
37
39
|
private anchorPointsCache: Point[];
|
|
38
40
|
|
|
39
41
|
constructor(props: IProps) {
|
|
40
42
|
super(props);
|
|
41
|
-
this.type
|
|
42
|
-
this.init(props);
|
|
43
|
+
this.init({ ...props, type: props.type || 'node' });
|
|
43
44
|
this.draw(
|
|
44
|
-
this.displayModel as NodeDisplayModel,
|
|
45
|
+
this.displayModel as NodeDisplayModel | ComboDisplayModel,
|
|
45
46
|
undefined,
|
|
46
47
|
undefined,
|
|
47
48
|
props.onfinish,
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
public draw(
|
|
51
|
-
displayModel: NodeDisplayModel,
|
|
52
|
-
diffData?: {
|
|
52
|
+
displayModel: NodeDisplayModel | ComboDisplayModel,
|
|
53
|
+
diffData?: {
|
|
54
|
+
previous: NodeModelData | ComboModelData;
|
|
55
|
+
current: NodeModelData | ComboModelData;
|
|
56
|
+
},
|
|
53
57
|
diffState?: { previous: State[]; current: State[] },
|
|
54
58
|
onfinish: Function = () => {},
|
|
55
59
|
) {
|
|
56
60
|
const { group, renderExt, shapeMap: prevShapeMap, model } = this;
|
|
57
61
|
renderExt.mergeStyles(displayModel);
|
|
58
|
-
this.group.setAttribute('data-item-type', 'node');
|
|
59
|
-
this.group.setAttribute('data-item-id', model.id);
|
|
60
62
|
|
|
61
63
|
const firstRendering = !this.shapeMap?.keyShape;
|
|
62
64
|
const shapeMap = renderExt.draw(
|
|
@@ -109,11 +111,14 @@ export default class Node extends Item {
|
|
|
109
111
|
|
|
110
112
|
public update(
|
|
111
113
|
model: NodeModel,
|
|
112
|
-
diffData?: {
|
|
114
|
+
diffData?: {
|
|
115
|
+
previous: NodeModelData | ComboModelData;
|
|
116
|
+
current: NodeModelData | ComboModelData;
|
|
117
|
+
},
|
|
113
118
|
isReplace?: boolean,
|
|
114
119
|
theme?: {
|
|
115
120
|
styles: NodeStyleSet;
|
|
116
|
-
lodStrategy:
|
|
121
|
+
lodStrategy: LodStrategyObj;
|
|
117
122
|
},
|
|
118
123
|
onlyMove?: boolean,
|
|
119
124
|
onfinish?: Function,
|
|
@@ -126,12 +131,16 @@ export default class Node extends Item {
|
|
|
126
131
|
* do not update other styles which leads to better performance than updating position by updateData.
|
|
127
132
|
*/
|
|
128
133
|
public updatePosition(
|
|
129
|
-
displayModel: NodeDisplayModel,
|
|
130
|
-
diffData?: {
|
|
134
|
+
displayModel: NodeDisplayModel | ComboDisplayModel,
|
|
135
|
+
diffData?: {
|
|
136
|
+
previous: NodeModelData | ComboModelData;
|
|
137
|
+
current: NodeModelData | ComboModelData;
|
|
138
|
+
},
|
|
131
139
|
onfinish: Function = () => {},
|
|
132
140
|
) {
|
|
133
141
|
const { group } = this;
|
|
134
|
-
const { x
|
|
142
|
+
const { x, y, z = 0, animates, disableAnimate } = displayModel.data;
|
|
143
|
+
if (isNaN(x) || isNaN(y) || isNaN(z)) return;
|
|
135
144
|
if (!disableAnimate && animates?.update) {
|
|
136
145
|
const groupAnimates = animates.update.filter(
|
|
137
146
|
({ shapeId, fields }) =>
|
|
@@ -191,12 +200,21 @@ export default class Node extends Item {
|
|
|
191
200
|
}
|
|
192
201
|
|
|
193
202
|
public getAnchorPoint(point: Point) {
|
|
194
|
-
const {
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
const { anchorPoints = [] } = this.model.data as
|
|
204
|
+
| NodeModelData
|
|
205
|
+
| ComboModelData;
|
|
197
206
|
|
|
198
|
-
return
|
|
207
|
+
return this.getIntersectPoint(point, this.getPosition(), anchorPoints);
|
|
208
|
+
}
|
|
199
209
|
|
|
210
|
+
public getIntersectPoint(
|
|
211
|
+
point: Point,
|
|
212
|
+
innerPoint: Point,
|
|
213
|
+
anchorPoints: number[][],
|
|
214
|
+
) {
|
|
215
|
+
const { keyShape } = this.shapeMap;
|
|
216
|
+
const shapeType = keyShape.nodeName;
|
|
217
|
+
const { x, y, z } = innerPoint;
|
|
200
218
|
let intersectPoint: Point | null;
|
|
201
219
|
switch (shapeType) {
|
|
202
220
|
case 'circle':
|
|
@@ -271,4 +289,9 @@ export default class Node extends Item {
|
|
|
271
289
|
}
|
|
272
290
|
return linkPoint;
|
|
273
291
|
}
|
|
292
|
+
|
|
293
|
+
public getPosition(): Point {
|
|
294
|
+
const { x = 0, y = 0, z = 0 } = this.model.data;
|
|
295
|
+
return { x: x as number, y: y as number, z: z as number };
|
|
296
|
+
}
|
|
274
297
|
}
|