@antv/g6 5.0.0-beta.11 → 5.0.0-beta.13

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.
Files changed (315) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/graph.d.ts +3 -3
  3. package/esm/api-doc/graph.js +3 -3
  4. package/esm/api-doc/graph.js.map +1 -1
  5. package/esm/constant/shape.d.ts +1 -1
  6. package/esm/index.d.ts +12 -62
  7. package/esm/index.js +4 -5
  8. package/esm/index.js.map +1 -1
  9. package/esm/item/item.js +2 -1
  10. package/esm/item/item.js.map +1 -1
  11. package/esm/runtime/controller/item.js +34 -16
  12. package/esm/runtime/controller/item.js.map +1 -1
  13. package/esm/runtime/controller/layout.js +1 -3
  14. package/esm/runtime/controller/layout.js.map +1 -1
  15. package/esm/runtime/controller/plugin.js +8 -3
  16. package/esm/runtime/controller/plugin.js.map +1 -1
  17. package/esm/runtime/graph.d.ts +1 -1
  18. package/esm/runtime/graph.js +11 -5
  19. package/esm/runtime/graph.js.map +1 -1
  20. package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
  21. package/esm/stdlib/behavior/drag-canvas.js +12 -5
  22. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  23. package/esm/stdlib/behavior/shortcuts-call.d.ts +2 -2
  24. package/esm/stdlib/behavior/shortcuts-call.js +12 -5
  25. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -1
  26. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  27. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  28. package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -0
  29. package/esm/stdlib/behavior/zoom-canvas.js +8 -2
  30. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  31. package/esm/stdlib/index.d.ts +6 -1
  32. package/esm/stdlib/index.js +8 -3
  33. package/esm/stdlib/index.js.map +1 -1
  34. package/esm/stdlib/item/edge/base.js +5 -1
  35. package/esm/stdlib/item/edge/base.js.map +1 -1
  36. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  37. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  38. package/esm/stdlib/item/edge/cubic.js +1 -1
  39. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  40. package/esm/stdlib/item/edge/loop.js +1 -1
  41. package/esm/stdlib/item/edge/loop.js.map +1 -1
  42. package/esm/stdlib/item/node/base.d.ts +1 -0
  43. package/esm/stdlib/item/node/base.js +5 -2
  44. package/esm/stdlib/item/node/base.js.map +1 -1
  45. package/esm/stdlib/item/node/cube.d.ts +35 -0
  46. package/esm/stdlib/item/node/cube.js +54 -0
  47. package/esm/stdlib/item/node/cube.js.map +1 -0
  48. package/esm/stdlib/item/node/index.d.ts +3 -0
  49. package/esm/stdlib/item/node/index.js +3 -0
  50. package/esm/stdlib/item/node/index.js.map +1 -1
  51. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  52. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  53. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  54. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  55. package/esm/stdlib/plugin/grid/index.js +3 -4
  56. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  57. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  58. package/esm/stdlib/plugin/hull/hullComponent.js +2 -3
  59. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  60. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  61. package/esm/stdlib/plugin/hull/util.js +6 -2
  62. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  63. package/esm/stdlib/plugin/index.d.ts +1 -0
  64. package/esm/stdlib/plugin/index.js +1 -0
  65. package/esm/stdlib/plugin/index.js.map +1 -1
  66. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  67. package/esm/stdlib/plugin/legend/index.js +3 -3
  68. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  69. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  70. package/esm/stdlib/plugin/menu/index.js +3 -3
  71. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  72. package/esm/stdlib/plugin/minimap/index.d.ts +1 -1
  73. package/esm/stdlib/plugin/minimap/index.js +3 -3
  74. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  75. package/esm/stdlib/plugin/timebar/index.js +2 -2
  76. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  77. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  78. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  79. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  80. package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
  81. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  82. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  83. package/esm/stdlib/plugin/types.d.ts +1 -0
  84. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  85. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  86. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  87. package/esm/types/index.d.ts +2 -1
  88. package/esm/types/index.js +1 -0
  89. package/esm/types/index.js.map +1 -1
  90. package/esm/types/plugin.d.ts +1 -1
  91. package/esm/util/bbox.js +4 -5
  92. package/esm/util/bbox.js.map +1 -1
  93. package/esm/util/behavior.d.ts +2 -2
  94. package/esm/util/behavior.js +2 -2
  95. package/esm/util/behavior.js.map +1 -1
  96. package/esm/util/data.d.ts +2 -2
  97. package/esm/util/data.js.map +1 -1
  98. package/esm/util/dom.d.ts +15 -0
  99. package/esm/util/dom.js +29 -0
  100. package/esm/util/dom.js.map +1 -0
  101. package/esm/util/extend.d.ts +1 -1
  102. package/esm/util/extend.js +0 -1
  103. package/esm/util/extend.js.map +1 -1
  104. package/esm/util/index.d.ts +7 -52
  105. package/esm/util/index.js +7 -23
  106. package/esm/util/index.js.map +1 -1
  107. package/esm/util/layout.d.ts +1 -1
  108. package/esm/util/layout.js.map +1 -1
  109. package/esm/util/loop.d.ts +1 -1
  110. package/esm/util/math.d.ts +1 -1
  111. package/esm/util/matrix.d.ts +6 -0
  112. package/esm/util/matrix.js +48 -0
  113. package/esm/util/matrix.js.map +1 -0
  114. package/esm/util/path.js +1 -1
  115. package/esm/util/path.js.map +1 -1
  116. package/esm/util/point.d.ts +1 -1
  117. package/esm/util/polyline.d.ts +2 -1
  118. package/esm/util/polyline.js +2 -1
  119. package/esm/util/polyline.js.map +1 -1
  120. package/esm/util/router.d.ts +1 -1
  121. package/esm/util/shape.js +12 -12
  122. package/esm/util/shape.js.map +1 -1
  123. package/esm/util/shape3d.js +15 -11
  124. package/esm/util/shape3d.js.map +1 -1
  125. package/esm/util/text.d.ts +1 -1
  126. package/esm/util/text.js +3 -2
  127. package/esm/util/text.js.map +1 -1
  128. package/lib/api-doc/graph.d.ts +3 -3
  129. package/lib/api-doc/graph.js +27 -7
  130. package/lib/api-doc/graph.js.map +1 -1
  131. package/lib/constant/shape.d.ts +1 -1
  132. package/lib/index.d.ts +12 -62
  133. package/lib/index.js +18 -10
  134. package/lib/index.js.map +1 -1
  135. package/lib/item/item.js +2 -1
  136. package/lib/item/item.js.map +1 -1
  137. package/lib/runtime/controller/item.js +34 -16
  138. package/lib/runtime/controller/item.js.map +1 -1
  139. package/lib/runtime/controller/layout.js +1 -3
  140. package/lib/runtime/controller/layout.js.map +1 -1
  141. package/lib/runtime/controller/plugin.js +8 -3
  142. package/lib/runtime/controller/plugin.js.map +1 -1
  143. package/lib/runtime/graph.d.ts +1 -1
  144. package/lib/runtime/graph.js +12 -5
  145. package/lib/runtime/graph.js.map +1 -1
  146. package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
  147. package/lib/stdlib/behavior/drag-canvas.js +12 -5
  148. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  149. package/lib/stdlib/behavior/shortcuts-call.d.ts +2 -2
  150. package/lib/stdlib/behavior/shortcuts-call.js +12 -5
  151. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -1
  152. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  153. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  154. package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -0
  155. package/lib/stdlib/behavior/zoom-canvas.js +8 -2
  156. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  157. package/lib/stdlib/index.d.ts +6 -1
  158. package/lib/stdlib/index.js +8 -3
  159. package/lib/stdlib/index.js.map +1 -1
  160. package/lib/stdlib/item/edge/base.js +5 -1
  161. package/lib/stdlib/item/edge/base.js.map +1 -1
  162. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  163. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  164. package/lib/stdlib/item/edge/cubic.js +2 -2
  165. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  166. package/lib/stdlib/item/edge/loop.js +3 -3
  167. package/lib/stdlib/item/edge/loop.js.map +1 -1
  168. package/lib/stdlib/item/node/base.d.ts +1 -0
  169. package/lib/stdlib/item/node/base.js +5 -2
  170. package/lib/stdlib/item/node/base.js.map +1 -1
  171. package/lib/stdlib/item/node/cube.d.ts +35 -0
  172. package/lib/stdlib/item/node/cube.js +58 -0
  173. package/lib/stdlib/item/node/cube.js.map +1 -0
  174. package/lib/stdlib/item/node/index.d.ts +3 -0
  175. package/lib/stdlib/item/node/index.js +3 -0
  176. package/lib/stdlib/item/node/index.js.map +1 -1
  177. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  178. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  179. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  180. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  181. package/lib/stdlib/plugin/grid/index.js +6 -7
  182. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  183. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  184. package/lib/stdlib/plugin/hull/hullComponent.js +2 -3
  185. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  186. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  187. package/lib/stdlib/plugin/hull/util.js +26 -22
  188. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  189. package/lib/stdlib/plugin/index.d.ts +1 -0
  190. package/lib/stdlib/plugin/index.js +1 -0
  191. package/lib/stdlib/plugin/index.js.map +1 -1
  192. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  193. package/lib/stdlib/plugin/legend/index.js +3 -3
  194. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  195. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  196. package/lib/stdlib/plugin/menu/index.js +6 -6
  197. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  198. package/lib/stdlib/plugin/minimap/index.d.ts +1 -1
  199. package/lib/stdlib/plugin/minimap/index.js +6 -6
  200. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  201. package/lib/stdlib/plugin/timebar/index.js +2 -2
  202. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  203. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  204. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  205. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  206. package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
  207. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  208. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  209. package/lib/stdlib/plugin/types.d.ts +1 -0
  210. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  211. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  212. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  213. package/lib/types/index.d.ts +2 -1
  214. package/lib/types/index.js +3 -1
  215. package/lib/types/index.js.map +1 -1
  216. package/lib/types/plugin.d.ts +1 -1
  217. package/lib/util/bbox.js +4 -5
  218. package/lib/util/bbox.js.map +1 -1
  219. package/lib/util/behavior.d.ts +2 -2
  220. package/lib/util/behavior.js +2 -2
  221. package/lib/util/behavior.js.map +1 -1
  222. package/lib/util/data.d.ts +2 -2
  223. package/lib/util/data.js.map +1 -1
  224. package/lib/util/dom.d.ts +15 -0
  225. package/lib/util/dom.js +34 -0
  226. package/lib/util/dom.js.map +1 -0
  227. package/lib/util/extend.d.ts +1 -1
  228. package/lib/util/extend.js +0 -1
  229. package/lib/util/extend.js.map +1 -1
  230. package/lib/util/index.d.ts +7 -52
  231. package/lib/util/index.js +23 -23
  232. package/lib/util/index.js.map +1 -1
  233. package/lib/util/layout.d.ts +1 -1
  234. package/lib/util/layout.js.map +1 -1
  235. package/lib/util/loop.d.ts +1 -1
  236. package/lib/util/math.d.ts +1 -1
  237. package/lib/util/matrix.d.ts +6 -0
  238. package/lib/util/matrix.js +52 -0
  239. package/lib/util/matrix.js.map +1 -0
  240. package/lib/util/path.js +2 -2
  241. package/lib/util/path.js.map +1 -1
  242. package/lib/util/point.d.ts +1 -1
  243. package/lib/util/polyline.d.ts +2 -1
  244. package/lib/util/polyline.js +2 -1
  245. package/lib/util/polyline.js.map +1 -1
  246. package/lib/util/router.d.ts +1 -1
  247. package/lib/util/shape.js +12 -12
  248. package/lib/util/shape.js.map +1 -1
  249. package/lib/util/shape3d.js +15 -11
  250. package/lib/util/shape3d.js.map +1 -1
  251. package/lib/util/text.d.ts +1 -1
  252. package/lib/util/text.js +3 -2
  253. package/lib/util/text.js.map +1 -1
  254. package/package.json +34 -41
  255. package/src/api-doc/graph.ts +4 -3
  256. package/src/constant/shape.ts +1 -1
  257. package/src/index.ts +5 -6
  258. package/src/item/item.ts +2 -0
  259. package/src/runtime/controller/item.ts +33 -14
  260. package/src/runtime/controller/layout.ts +1 -5
  261. package/src/runtime/controller/plugin.ts +14 -3
  262. package/src/runtime/graph.ts +12 -6
  263. package/src/stdlib/behavior/drag-canvas.ts +19 -7
  264. package/src/stdlib/behavior/shortcuts-call.ts +13 -4
  265. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  266. package/src/stdlib/behavior/zoom-canvas.ts +15 -2
  267. package/src/stdlib/index.ts +10 -1
  268. package/src/stdlib/item/edge/base.ts +5 -2
  269. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  270. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  271. package/src/stdlib/item/edge/cubic.ts +1 -1
  272. package/src/stdlib/item/edge/loop.ts +1 -1
  273. package/src/stdlib/item/node/base.ts +5 -1
  274. package/src/stdlib/item/node/cube.ts +102 -0
  275. package/src/stdlib/item/node/index.ts +3 -0
  276. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  277. package/src/stdlib/plugin/grid/index.ts +6 -6
  278. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  279. package/src/stdlib/plugin/hull/hullComponent.ts +2 -3
  280. package/src/stdlib/plugin/hull/util.ts +6 -2
  281. package/src/stdlib/plugin/index.ts +1 -0
  282. package/src/stdlib/plugin/legend/index.ts +6 -6
  283. package/src/stdlib/plugin/menu/index.ts +13 -13
  284. package/src/stdlib/plugin/minimap/index.ts +6 -6
  285. package/src/stdlib/plugin/timebar/index.ts +4 -4
  286. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  287. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  288. package/src/stdlib/plugin/types.ts +1 -0
  289. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  290. package/src/types/index.ts +2 -1
  291. package/src/types/plugin.ts +1 -1
  292. package/src/util/bbox.ts +4 -5
  293. package/src/util/behavior.ts +4 -4
  294. package/src/util/data.ts +2 -3
  295. package/src/util/dom.ts +33 -0
  296. package/src/util/extend.ts +2 -3
  297. package/src/util/index.ts +7 -24
  298. package/src/util/layout.ts +3 -2
  299. package/src/util/loop.ts +1 -1
  300. package/src/util/math.ts +1 -1
  301. package/src/util/matrix.ts +66 -0
  302. package/src/util/path.ts +1 -1
  303. package/src/util/point.ts +1 -1
  304. package/src/util/polyline.ts +2 -1
  305. package/src/util/router.ts +1 -1
  306. package/src/util/shape.ts +16 -12
  307. package/src/util/shape3d.ts +19 -10
  308. package/src/util/text.ts +3 -1
  309. package/esm/stdlib/plugin/map/index.d.ts +0 -118
  310. package/esm/stdlib/plugin/map/index.js +0 -683
  311. package/esm/stdlib/plugin/map/index.js.map +0 -1
  312. package/lib/stdlib/plugin/map/index.d.ts +0 -118
  313. package/lib/stdlib/plugin/map/index.js +0 -687
  314. package/lib/stdlib/plugin/map/index.js.map +0 -1
  315. package/src/stdlib/plugin/map/index.ts +0 -808
@@ -0,0 +1,66 @@
1
+ import { mat3 } from 'gl-matrix';
2
+
3
+ type mat3Type = [
4
+ number,
5
+ number,
6
+ number,
7
+ number,
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ ];
14
+
15
+ function leftTranslate(out, a, v) {
16
+ const transMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
17
+ mat3.fromTranslation(transMat, v);
18
+ return mat3.multiply(out, transMat, a);
19
+ }
20
+
21
+ function leftRotate(out, a, rad) {
22
+ const rotateMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
23
+ mat3.fromRotation(rotateMat, rad);
24
+ return mat3.multiply(out, rotateMat, a);
25
+ }
26
+
27
+ function leftScale(out, a, v) {
28
+ const scaleMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
29
+ mat3.fromScaling(scaleMat, v);
30
+ return mat3.multiply(out, scaleMat, a);
31
+ }
32
+
33
+ function leftMultiply(out, a, a1) {
34
+ return mat3.multiply(out, a1, a);
35
+ }
36
+
37
+ /**
38
+ * 根据 actions 来做 transform
39
+ * @param m
40
+ * @param actions
41
+ */
42
+ export function transform(m: number[], actions: any[][]) {
43
+ const matrix = m ? [].concat(m) : [1, 0, 0, 0, 1, 0, 0, 0, 1];
44
+
45
+ for (let i = 0, len = actions.length; i < len; i++) {
46
+ const action = actions[i];
47
+ switch (action[0]) {
48
+ case 't':
49
+ leftTranslate(matrix, matrix, [action[1], action[2]]);
50
+ break;
51
+ case 's':
52
+ leftScale(matrix, matrix, [action[1], action[2]]);
53
+ break;
54
+ case 'r':
55
+ leftRotate(matrix, matrix, action[1]);
56
+ break;
57
+ case 'm':
58
+ leftMultiply(matrix, matrix, action[1]);
59
+ break;
60
+ default:
61
+ break;
62
+ }
63
+ }
64
+
65
+ return matrix;
66
+ }
package/src/util/path.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { vec2 } from '@antv/matrix-util';
1
+ import { vec2 } from 'gl-matrix';
2
2
  import { Point } from '../types/common';
3
3
 
4
4
  /**
package/src/util/point.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { vec2 } from '@antv/matrix-util';
1
+ import { vec2 } from 'gl-matrix';
2
2
  import { Point } from '../types/common';
3
3
  import { isBetween } from './math';
4
4
 
@@ -55,7 +55,8 @@ export const simplifyPolylinePoints = (points: PolyPoint[]): PolyPoint[] => {
55
55
  };
56
56
 
57
57
  /**
58
- * Use the A* path-finding algorithm to obtain the shortest path. Considering that there is no need to implement automatic obstacle avoidance, use waypoints to plan the path
58
+ * Use the A* path-finding algorithm to obtain the shortest path.
59
+ * Considering that there is no need to implement automatic obstacle avoidance, use waypoints to plan the path.
59
60
  */
60
61
  export const simplePathFinder = (
61
62
  start: PolyPoint,
@@ -24,7 +24,7 @@ export interface RouterCfg {
24
24
  /** Allowed edge directions */
25
25
  directions?: any[];
26
26
  /** Penalties */
27
- penalties?: {};
27
+ penalties?: Record<string, any>;
28
28
  /** Determine if use simple router for polyline when no obstacles */
29
29
  simple?: boolean;
30
30
  /** Function to calculate the distance between two points */
package/src/util/shape.ts CHANGED
@@ -24,7 +24,6 @@ import {
24
24
  ItemShapeStyles,
25
25
  ShapeStyle,
26
26
  SHAPE_TYPE_3D,
27
- ItemModel,
28
27
  } from '../types/item';
29
28
  import { NodeDisplayModel, NodeShapeMap } from '../types/node';
30
29
  import { ComboDisplayModel, IGraph } from '../types';
@@ -212,22 +211,27 @@ export const updateShapes = (
212
211
  const prevShape = prevShapeMap[id];
213
212
  const newShape = newShapeMap[id];
214
213
  if (newShape && !shouldUpdate(id)) return;
215
- if (prevShape && newShape) {
216
- // update intersaction
217
- finalShapeMap[id] = newShape;
218
- if (prevShape !== newShape) {
214
+
215
+ if (newShape) {
216
+ // Remove dirty shape first.
217
+ if (prevShape && prevShape !== newShape) {
219
218
  prevShape.remove();
220
219
  }
221
- if (!newShape.destroyed && newShape.style.display !== 'none') {
222
- group.appendChild(newShape);
223
- }
224
- } else if (!prevShape && newShape) {
225
- // add newShapeMap - prevShapeMap
226
220
  finalShapeMap[id] = newShape;
227
- if (!newShape.destroyed && newShape.style.display !== 'none') {
221
+ if (
222
+ // NewShape is already in the group, no need to reappend.
223
+ // Note: If the given child is a reference to an existing node in the document,
224
+ // appendChild() moves it from its current position to the new position.
225
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
226
+ newShape.parentElement !== group &&
227
+ !newShape.destroyed &&
228
+ newShape.style.display !== 'none'
229
+ ) {
228
230
  group.appendChild(newShape);
229
231
  }
230
- } else if (prevShape && !newShape && removeDiff) {
232
+ }
233
+
234
+ if (prevShape && !newShape && removeDiff) {
231
235
  // remove prevShapeMap - newShapeMap
232
236
  delete finalShapeMap[id];
233
237
  prevShape.remove();
@@ -19,7 +19,7 @@ import {
19
19
 
20
20
  const GeometryTagMap = {
21
21
  sphere: SphereGeometry,
22
- cubic: CubeGeometry,
22
+ cube: CubeGeometry,
23
23
  plane: PlaneGeometry,
24
24
  };
25
25
 
@@ -182,18 +182,27 @@ export const updateShapes3D = (
182
182
  const prevShape = prevShapeMap[id];
183
183
  const newShape = newShapeMap[id];
184
184
  if (newShape && !shouldUpdate(id)) return;
185
- if (prevShape && newShape) {
186
- // update intersaction
187
- finalShapeMap[id] = newShape;
188
- if (prevShape !== newShape) {
185
+
186
+ if (newShape) {
187
+ // Remove dirty shape first.
188
+ if (prevShape && prevShape !== newShape) {
189
189
  prevShape.remove();
190
190
  }
191
- group.appendChild(newShape);
192
- } else if (!prevShape && newShape) {
193
- // add newShapeMap - prevShapeMap
194
191
  finalShapeMap[id] = newShape;
195
- group.appendChild(newShape);
196
- } else if (prevShape && !newShape && removeDiff) {
192
+ if (
193
+ // NewShape is already in the group, no need to reappend.
194
+ // Note: If the given child is a reference to an existing node in the document,
195
+ // appendChild() moves it from its current position to the new position.
196
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
197
+ newShape.parentElement !== group &&
198
+ !newShape.destroyed &&
199
+ newShape.style.display !== 'none'
200
+ ) {
201
+ group.appendChild(newShape);
202
+ }
203
+ }
204
+
205
+ if (prevShape && !newShape && removeDiff) {
197
206
  // remove prevShapeMap - newShapeMap
198
207
  delete finalShapeMap[id];
199
208
  prevShape.remove();
package/src/util/text.ts CHANGED
@@ -13,8 +13,10 @@ export const getWordWrapWidthByBox = (
13
13
  keyShapeBox: AABB,
14
14
  maxWidth: string | number,
15
15
  zoom = 1,
16
+ enableBalanceShape = false,
16
17
  ) => {
17
- const keyShapeWidth = (keyShapeBox.max[0] - keyShapeBox.min[0]) * zoom;
18
+ const balanceZoom = enableBalanceShape ? zoom : 1;
19
+ const keyShapeWidth = (keyShapeBox.max[0] - keyShapeBox.min[0]) * balanceZoom;
18
20
  return getWordWrapWidthWithBase(keyShapeWidth, maxWidth);
19
21
  };
20
22
 
@@ -1,118 +0,0 @@
1
- import { Canvas } from '@antv/g';
2
- import { IGraph } from '../../../types';
3
- import { ShapeStyle } from '../../../types/item';
4
- import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
5
- export interface MiniMapConfig extends IPluginBaseConfig {
6
- /** Class name of viewport */
7
- viewportClassName?: string;
8
- /** Class name of minimap */
9
- className?: string;
10
- /** Mode of minimap */
11
- mode?: 'default' | 'keyShape' | 'delegate';
12
- /** Size of minimap */
13
- size?: number[];
14
- /** Style of delegate shape */
15
- delegateStyle?: ShapeStyle;
16
- /** Whether to refresh minimap */
17
- refresh?: boolean;
18
- /** Padding of minimap */
19
- padding?: number;
20
- /** Whether to hide edges on minimap to enhance performance */
21
- hideEdge?: boolean;
22
- /** Container for minimap */
23
- container?: HTMLDivElement | null;
24
- }
25
- export declare class Minimap extends Base {
26
- private canvas;
27
- /** The viewport DOM on the minimap. */
28
- private viewport;
29
- /** Cache the mapping of graphics of nodes/edges/combos on main graph and minimap graph. */
30
- private itemMap;
31
- private container;
32
- /** Ratio of (minimap graph size / main graph size). */
33
- private ratio;
34
- /** Distance from top of minimap graph to the top of minimap container. */
35
- private dx;
36
- /** Distance from left of minimap graph to the left of minimap container. */
37
- private dy;
38
- /** Cache the visibility while items' visibility changed. And apply them onto the minimap with debounce. */
39
- private visibleCache;
40
- constructor(options?: MiniMapConfig);
41
- getDefaultCfgs(): MiniMapConfig;
42
- getEvents(): {
43
- afteritemstatechange: () => void;
44
- afterlayout: () => void;
45
- viewportchange: () => void;
46
- afteritemchange: () => void;
47
- afteritemvisibilitychange: (params: any) => void;
48
- };
49
- /**
50
- * If it is animating, disable refresh.
51
- */
52
- protected disableRefresh(): void;
53
- protected enableRefresh(): void;
54
- private initViewport;
55
- /**
56
- * Update the viewport DOM.
57
- */
58
- private updateViewport;
59
- /**
60
- * Clone all the graphic from main graph to the minimap graph.
61
- */
62
- private updateGraphShapes;
63
- /**
64
- * Only draw keyShapes on the minimap.
65
- */
66
- private updateKeyShapes;
67
- /**
68
- * Add or update keyShape of one node.
69
- * @param nodeModel node data model
70
- * @param group container graphics group on minimap
71
- */
72
- private updateOneNodeKeyShape;
73
- /**
74
- * Draw the delegate rects for nodes and line edges on minimap.
75
- */
76
- private updateDelegateShapes;
77
- private clearDestroyedShapes;
78
- /**
79
- * Add or update keyShape of one edge.
80
- * @param edgeModel edge data model
81
- * @param group container graphics group on minimap
82
- */
83
- private updateOneEdgeKeyShape;
84
- /**
85
- * Add or update delegate rect of one node.
86
- * @param nodeModel node data model
87
- * @param group container graphics group on minimap
88
- */
89
- private updateOneNodeDelegateShape;
90
- /**
91
- * Listener for main graph updating, update the viewport DOM.
92
- */
93
- private handleUpdateCanvas;
94
- private handleVisibilityChange;
95
- private debounceCloneVisibility;
96
- init(graph: IGraph): void;
97
- /**
98
- * Init the DOM container for minimap.
99
- */
100
- initContainer(): Promise<any>;
101
- updateCanvas(): void;
102
- /**
103
- * Get the canvas of the minimap.
104
- * @return {Canvas} G Canvas
105
- */
106
- getCanvas(): Canvas;
107
- /**
108
- * Get the viewport DOM of the minimap.
109
- * @return {HTMLElement} viewport DOM
110
- */
111
- getViewport(): HTMLElement;
112
- /**
113
- * Get the container DOM of the minimap.
114
- * @return {HTMLElement} container DOM
115
- */
116
- getContainer(): HTMLElement;
117
- destroy(): void;
118
- }