@antv/g6 5.0.0-beta.10 → 5.0.0-beta.12

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 (278) 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/node.js +0 -1
  10. package/esm/item/node.js.map +1 -1
  11. package/esm/runtime/controller/item.js +15 -6
  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/graph.d.ts +1 -1
  16. package/esm/runtime/graph.js +11 -5
  17. package/esm/runtime/graph.js.map +1 -1
  18. package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
  19. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  20. package/esm/stdlib/behavior/shortcuts-call.d.ts +2 -2
  21. package/esm/stdlib/behavior/shortcuts-call.js +12 -5
  22. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -1
  23. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  24. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  25. package/esm/stdlib/index.d.ts +6 -1
  26. package/esm/stdlib/index.js +8 -3
  27. package/esm/stdlib/index.js.map +1 -1
  28. package/esm/stdlib/item/edge/base.js +5 -1
  29. package/esm/stdlib/item/edge/base.js.map +1 -1
  30. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  31. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  32. package/esm/stdlib/item/edge/cubic.js +1 -1
  33. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  34. package/esm/stdlib/item/edge/loop.js +1 -1
  35. package/esm/stdlib/item/edge/loop.js.map +1 -1
  36. package/esm/stdlib/item/node/cube.d.ts +35 -0
  37. package/esm/stdlib/item/node/cube.js +54 -0
  38. package/esm/stdlib/item/node/cube.js.map +1 -0
  39. package/esm/stdlib/item/node/index.d.ts +3 -0
  40. package/esm/stdlib/item/node/index.js +3 -0
  41. package/esm/stdlib/item/node/index.js.map +1 -1
  42. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  43. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  44. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  45. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  46. package/esm/stdlib/plugin/grid/index.js +3 -4
  47. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  48. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  49. package/esm/stdlib/plugin/hull/hullComponent.js +2 -3
  50. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  51. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  52. package/esm/stdlib/plugin/hull/util.js +6 -2
  53. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  54. package/esm/stdlib/plugin/index.d.ts +1 -0
  55. package/esm/stdlib/plugin/index.js +1 -0
  56. package/esm/stdlib/plugin/index.js.map +1 -1
  57. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  58. package/esm/stdlib/plugin/legend/index.js +3 -3
  59. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  60. package/esm/stdlib/plugin/map/index.d.ts +1 -1
  61. package/esm/stdlib/plugin/map/index.js +4 -4
  62. package/esm/stdlib/plugin/map/index.js.map +1 -1
  63. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  64. package/esm/stdlib/plugin/menu/index.js +3 -3
  65. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  66. package/esm/stdlib/plugin/minimap/index.d.ts +1 -1
  67. package/esm/stdlib/plugin/minimap/index.js +3 -3
  68. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  69. package/esm/stdlib/plugin/timebar/index.js +2 -2
  70. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  71. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  72. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  73. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  74. package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
  75. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  76. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  77. package/esm/stdlib/plugin/types.d.ts +1 -0
  78. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  79. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  80. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  81. package/esm/types/plugin.d.ts +1 -1
  82. package/esm/util/bbox.js +4 -5
  83. package/esm/util/bbox.js.map +1 -1
  84. package/esm/util/behavior.d.ts +2 -2
  85. package/esm/util/behavior.js +2 -2
  86. package/esm/util/behavior.js.map +1 -1
  87. package/esm/util/data.d.ts +2 -2
  88. package/esm/util/data.js.map +1 -1
  89. package/esm/util/dom.d.ts +15 -0
  90. package/esm/util/dom.js +29 -0
  91. package/esm/util/dom.js.map +1 -0
  92. package/esm/util/extend.d.ts +1 -1
  93. package/esm/util/extend.js +0 -1
  94. package/esm/util/extend.js.map +1 -1
  95. package/esm/util/index.d.ts +7 -52
  96. package/esm/util/index.js +7 -23
  97. package/esm/util/index.js.map +1 -1
  98. package/esm/util/layout.d.ts +1 -1
  99. package/esm/util/layout.js.map +1 -1
  100. package/esm/util/loop.d.ts +1 -1
  101. package/esm/util/math.d.ts +1 -1
  102. package/esm/util/matrix.d.ts +6 -0
  103. package/esm/util/matrix.js +48 -0
  104. package/esm/util/matrix.js.map +1 -0
  105. package/esm/util/path.js +1 -1
  106. package/esm/util/path.js.map +1 -1
  107. package/esm/util/point.d.ts +1 -1
  108. package/esm/util/polyline.d.ts +2 -1
  109. package/esm/util/polyline.js +2 -1
  110. package/esm/util/polyline.js.map +1 -1
  111. package/esm/util/router.d.ts +1 -1
  112. package/esm/util/shape.js.map +1 -1
  113. package/esm/util/shape3d.js +1 -1
  114. package/esm/util/shape3d.js.map +1 -1
  115. package/lib/api-doc/graph.d.ts +3 -3
  116. package/lib/api-doc/graph.js +27 -7
  117. package/lib/api-doc/graph.js.map +1 -1
  118. package/lib/constant/shape.d.ts +1 -1
  119. package/lib/index.d.ts +12 -62
  120. package/lib/index.js +18 -10
  121. package/lib/index.js.map +1 -1
  122. package/lib/item/node.js +0 -1
  123. package/lib/item/node.js.map +1 -1
  124. package/lib/runtime/controller/item.js +15 -6
  125. package/lib/runtime/controller/item.js.map +1 -1
  126. package/lib/runtime/controller/layout.js +1 -3
  127. package/lib/runtime/controller/layout.js.map +1 -1
  128. package/lib/runtime/graph.d.ts +1 -1
  129. package/lib/runtime/graph.js +12 -5
  130. package/lib/runtime/graph.js.map +1 -1
  131. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
  132. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  133. package/lib/stdlib/behavior/shortcuts-call.d.ts +2 -2
  134. package/lib/stdlib/behavior/shortcuts-call.js +12 -5
  135. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -1
  136. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  137. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  138. package/lib/stdlib/index.d.ts +6 -1
  139. package/lib/stdlib/index.js +8 -3
  140. package/lib/stdlib/index.js.map +1 -1
  141. package/lib/stdlib/item/edge/base.js +5 -1
  142. package/lib/stdlib/item/edge/base.js.map +1 -1
  143. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  144. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  145. package/lib/stdlib/item/edge/cubic.js +2 -2
  146. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  147. package/lib/stdlib/item/edge/loop.js +3 -3
  148. package/lib/stdlib/item/edge/loop.js.map +1 -1
  149. package/lib/stdlib/item/node/cube.d.ts +35 -0
  150. package/lib/stdlib/item/node/cube.js +58 -0
  151. package/lib/stdlib/item/node/cube.js.map +1 -0
  152. package/lib/stdlib/item/node/index.d.ts +3 -0
  153. package/lib/stdlib/item/node/index.js +3 -0
  154. package/lib/stdlib/item/node/index.js.map +1 -1
  155. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  156. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  157. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  158. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  159. package/lib/stdlib/plugin/grid/index.js +6 -7
  160. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  161. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  162. package/lib/stdlib/plugin/hull/hullComponent.js +2 -3
  163. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  164. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  165. package/lib/stdlib/plugin/hull/util.js +26 -22
  166. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  167. package/lib/stdlib/plugin/index.d.ts +1 -0
  168. package/lib/stdlib/plugin/index.js +1 -0
  169. package/lib/stdlib/plugin/index.js.map +1 -1
  170. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  171. package/lib/stdlib/plugin/legend/index.js +3 -3
  172. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  173. package/lib/stdlib/plugin/map/index.d.ts +1 -1
  174. package/lib/stdlib/plugin/map/index.js +6 -6
  175. package/lib/stdlib/plugin/map/index.js.map +1 -1
  176. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  177. package/lib/stdlib/plugin/menu/index.js +6 -6
  178. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  179. package/lib/stdlib/plugin/minimap/index.d.ts +1 -1
  180. package/lib/stdlib/plugin/minimap/index.js +6 -6
  181. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  182. package/lib/stdlib/plugin/timebar/index.js +2 -2
  183. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  184. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  185. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  186. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  187. package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
  188. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  189. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  190. package/lib/stdlib/plugin/types.d.ts +1 -0
  191. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  192. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  193. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  194. package/lib/types/plugin.d.ts +1 -1
  195. package/lib/util/bbox.js +4 -5
  196. package/lib/util/bbox.js.map +1 -1
  197. package/lib/util/behavior.d.ts +2 -2
  198. package/lib/util/behavior.js +2 -2
  199. package/lib/util/behavior.js.map +1 -1
  200. package/lib/util/data.d.ts +2 -2
  201. package/lib/util/data.js.map +1 -1
  202. package/lib/util/dom.d.ts +15 -0
  203. package/lib/util/dom.js +34 -0
  204. package/lib/util/dom.js.map +1 -0
  205. package/lib/util/extend.d.ts +1 -1
  206. package/lib/util/extend.js +0 -1
  207. package/lib/util/extend.js.map +1 -1
  208. package/lib/util/index.d.ts +7 -52
  209. package/lib/util/index.js +23 -23
  210. package/lib/util/index.js.map +1 -1
  211. package/lib/util/layout.d.ts +1 -1
  212. package/lib/util/layout.js.map +1 -1
  213. package/lib/util/loop.d.ts +1 -1
  214. package/lib/util/math.d.ts +1 -1
  215. package/lib/util/matrix.d.ts +6 -0
  216. package/lib/util/matrix.js +52 -0
  217. package/lib/util/matrix.js.map +1 -0
  218. package/lib/util/path.js +2 -2
  219. package/lib/util/path.js.map +1 -1
  220. package/lib/util/point.d.ts +1 -1
  221. package/lib/util/polyline.d.ts +2 -1
  222. package/lib/util/polyline.js +2 -1
  223. package/lib/util/polyline.js.map +1 -1
  224. package/lib/util/router.d.ts +1 -1
  225. package/lib/util/shape.js.map +1 -1
  226. package/lib/util/shape3d.js +1 -1
  227. package/lib/util/shape3d.js.map +1 -1
  228. package/package.json +32 -40
  229. package/src/api-doc/graph.ts +4 -3
  230. package/src/constant/shape.ts +1 -1
  231. package/src/index.ts +5 -6
  232. package/src/item/node.ts +0 -1
  233. package/src/runtime/controller/item.ts +15 -6
  234. package/src/runtime/controller/layout.ts +1 -5
  235. package/src/runtime/graph.ts +12 -6
  236. package/src/stdlib/behavior/drag-canvas.ts +1 -1
  237. package/src/stdlib/behavior/shortcuts-call.ts +13 -4
  238. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  239. package/src/stdlib/index.ts +10 -1
  240. package/src/stdlib/item/edge/base.ts +5 -2
  241. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  242. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  243. package/src/stdlib/item/edge/cubic.ts +1 -1
  244. package/src/stdlib/item/edge/loop.ts +1 -1
  245. package/src/stdlib/item/node/cube.ts +102 -0
  246. package/src/stdlib/item/node/index.ts +3 -0
  247. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  248. package/src/stdlib/plugin/grid/index.ts +6 -6
  249. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  250. package/src/stdlib/plugin/hull/hullComponent.ts +2 -3
  251. package/src/stdlib/plugin/hull/util.ts +6 -2
  252. package/src/stdlib/plugin/index.ts +1 -0
  253. package/src/stdlib/plugin/legend/index.ts +6 -6
  254. package/src/stdlib/plugin/map/index.ts +7 -7
  255. package/src/stdlib/plugin/menu/index.ts +13 -13
  256. package/src/stdlib/plugin/minimap/index.ts +6 -6
  257. package/src/stdlib/plugin/timebar/index.ts +4 -4
  258. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  259. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  260. package/src/stdlib/plugin/types.ts +1 -0
  261. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  262. package/src/types/plugin.ts +1 -1
  263. package/src/util/bbox.ts +4 -5
  264. package/src/util/behavior.ts +4 -4
  265. package/src/util/data.ts +2 -3
  266. package/src/util/dom.ts +33 -0
  267. package/src/util/extend.ts +2 -3
  268. package/src/util/index.ts +7 -24
  269. package/src/util/layout.ts +3 -2
  270. package/src/util/loop.ts +1 -1
  271. package/src/util/math.ts +1 -1
  272. package/src/util/matrix.ts +66 -0
  273. package/src/util/path.ts +1 -1
  274. package/src/util/point.ts +1 -1
  275. package/src/util/polyline.ts +2 -1
  276. package/src/util/router.ts +1 -1
  277. package/src/util/shape.ts +0 -1
  278. package/src/util/shape3d.ts +1 -1
@@ -225,9 +225,9 @@ export class ItemController {
225
225
 
226
226
  // 0. clear groups on canvas, and create new groups
227
227
  graph.canvas.removeChildren();
228
- const comboGroup = new Group({ id: 'combo-group' });
229
- const edgeGroup = new Group({ id: 'edge-group' });
230
- const nodeGroup = new Group({ id: 'node-group' });
228
+ const comboGroup = new Group({ id: 'combo-group', style: { zIndex: 0 } });
229
+ const edgeGroup = new Group({ id: 'edge-group', style: { zIndex: 1 } });
230
+ const nodeGroup = new Group({ id: 'node-group', style: { zIndex: 2 } });
231
231
  graph.canvas.appendChild(comboGroup);
232
232
  graph.canvas.appendChild(edgeGroup);
233
233
  graph.canvas.appendChild(nodeGroup);
@@ -237,9 +237,18 @@ export class ItemController {
237
237
 
238
238
  // Also create transient groups on transient canvas.
239
239
  transientCanvas.removeChildren();
240
- this.transientComboGroup = new Group({ id: 'combo-group' });
241
- this.transientEdgeGroup = new Group({ id: 'edge-group' });
242
- this.transientNodeGroup = new Group({ id: 'node-group' });
240
+ this.transientComboGroup = new Group({
241
+ id: 'combo-group',
242
+ style: { zIndex: 0 },
243
+ });
244
+ this.transientEdgeGroup = new Group({
245
+ id: 'edge-group',
246
+ style: { zIndex: 1 },
247
+ });
248
+ this.transientNodeGroup = new Group({
249
+ id: 'node-group',
250
+ style: { zIndex: 2 },
251
+ });
243
252
  transientCanvas.appendChild(this.transientComboGroup);
244
253
  transientCanvas.appendChild(this.transientEdgeGroup);
245
254
  transientCanvas.appendChild(this.transientNodeGroup);
@@ -97,8 +97,6 @@ export class LayoutController {
97
97
  });
98
98
  }
99
99
 
100
- this.graph.emit('startlayout');
101
-
102
100
  const [width, height] = this.graph.getSize();
103
101
  const center = [width / 2, height / 2];
104
102
 
@@ -227,8 +225,6 @@ export class LayoutController {
227
225
  }
228
226
  }
229
227
 
230
- this.graph.emit('endlayout');
231
-
232
228
  // Update nodes' positions.
233
229
  this.updateNodesPosition(positions, animate);
234
230
  }
@@ -279,7 +275,7 @@ export class LayoutController {
279
275
  animationEffectTiming,
280
276
  );
281
277
  }
282
- this.graph.emit('endlayout');
278
+ this.graph.emit('afterlayout');
283
279
  this.updateNodesPosition(
284
280
  { nodes: nodePositions, edges: [] },
285
281
  animated || animate,
@@ -21,7 +21,6 @@ import {
21
21
  isString,
22
22
  map,
23
23
  } from '@antv/util';
24
- import { createDom } from '@antv/dom-util';
25
24
  import { History } from '../stdlib/plugin/history';
26
25
  import { Command } from '../stdlib/plugin/history/command';
27
26
  import type {
@@ -57,6 +56,7 @@ import { FitViewRules, GraphTransformOptions } from '../types/view';
57
56
  import { changeRenderer, createCanvas } from '../util/canvas';
58
57
  import { formatPadding } from '../util/shape';
59
58
  import { getLayoutBounds } from '../util/layout';
59
+ import { createDOM } from '../util/dom';
60
60
  import { Plugin as PluginBase } from '../types/plugin';
61
61
  import { ComboMapper, EdgeMapper, NodeMapper } from '../types/spec';
62
62
  import {
@@ -71,7 +71,7 @@ import {
71
71
  import { PluginController } from './controller/plugin';
72
72
  import Hook from './hooks';
73
73
 
74
- export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
74
+ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
75
75
  extends EventEmitter
76
76
  implements IGraph<B, T>
77
77
  {
@@ -180,7 +180,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
180
180
  this.canvas = canvas;
181
181
  this.backgroundCanvas = backgroundCanvas;
182
182
  this.transientCanvas = transientCanvas;
183
- this.container = container as HTMLDivElement;
183
+ this.container = container as HTMLElement;
184
184
  } else {
185
185
  const containerDOM = isString(container)
186
186
  ? document.getElementById(container as string)
@@ -236,7 +236,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
236
236
  .getContextService()
237
237
  .getDomElement() as unknown as HTMLElement;
238
238
  if ($domElement && $domElement.style) {
239
- $domElement.style.position = 'fixed';
239
+ // Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
240
+ $domElement.style.position = 'absolute';
240
241
  $domElement.style.outline = 'none';
241
242
  $domElement.tabIndex = 1; // Enable keyboard events
242
243
  // Transient canvas should let interactive events go through.
@@ -881,9 +882,14 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
881
882
  );
882
883
  return;
883
884
  }
885
+ const oldSize = [this.specification.width, this.specification.height];
886
+ this.emit('beforesetsize', { oldSize, size: size });
884
887
  this.specification.width = size[0];
885
888
  this.specification.height = size[1];
886
889
  this.canvas.resize(size[0], size[1]);
890
+ this.transientCanvas.resize(size[0], size[1]);
891
+ this.backgroundCanvas.resize(size[0], size[1]);
892
+ this.emit('aftersetsize', { oldSize, size: size });
887
893
  }
888
894
 
889
895
  public getCanvasRange(): Bounds {
@@ -2188,7 +2194,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2188
2194
  const width = this.getSize()[0];
2189
2195
  const height = this.getSize()[1];
2190
2196
 
2191
- const vContainerDOM: HTMLDivElement = createDom(
2197
+ const vContainerDOM: HTMLElement = createDOM(
2192
2198
  '<div id="virtual-image"></div>',
2193
2199
  );
2194
2200
  const vCanvas = createCanvas(
@@ -2296,7 +2302,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2296
2302
  typeof window !== 'undefined' ? window.devicePixelRatio : 1;
2297
2303
  const vWidth = halfX * 2;
2298
2304
  const vHeight = halfY * 2;
2299
- const vContainerDOM: HTMLDivElement = createDom(
2305
+ const vContainerDOM: HTMLElement = createDOM(
2300
2306
  '<div id="virtual-image"></div>',
2301
2307
  );
2302
2308
  const vCanvas = createCanvas(
@@ -1,7 +1,7 @@
1
1
  import { isNumber } from '@antv/util';
2
- import { ID, IG6GraphEvent } from '../../types';
3
2
  import { Behavior } from '../../types/behavior';
4
3
  import { Point } from '../../types/common';
4
+ import { ID, IG6GraphEvent } from '../../types';
5
5
 
6
6
  const VALID_TRIGGERS = ['drag', 'directionKeys'];
7
7
  export interface DragCanvasOptions {
@@ -78,8 +78,6 @@ export class ShortcutsCall extends Behavior {
78
78
  (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
79
79
  ) {
80
80
  this.triggerKeydown = true;
81
- } else {
82
- this.triggerKeydown = false;
83
81
  }
84
82
  }
85
83
 
@@ -114,7 +112,18 @@ export class ShortcutsCall extends Behavior {
114
112
  }
115
113
  }
116
114
 
117
- public onKeyUp() {
118
- this.triggerKeydown = false;
115
+ public onKeyUp(e) {
116
+ const code = e.key;
117
+ if (!code) return;
118
+ const { trigger } = this.options;
119
+ const triggerLowerCase = trigger.toLowerCase();
120
+ const codeLowerCase = code.toLowerCase();
121
+ if (
122
+ codeLowerCase === triggerLowerCase ||
123
+ (codeLowerCase === 'control' && triggerLowerCase === 'ctrl') ||
124
+ (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
125
+ ) {
126
+ this.triggerKeydown = false;
127
+ }
119
128
  }
120
129
  }
@@ -123,7 +123,10 @@ export class ZoomCanvas3D extends Behavior {
123
123
  ((100 * sign * sensitivity) / currentDistance) *
124
124
  Math.sqrt(currentDistance);
125
125
  const toDistance = currentDistance + dolly;
126
- const cameraFrontOfFocalPoint = camera.getDistanceVector()[2] < 0;
126
+ const azimuth = camera.getAzimuth();
127
+ const isFlipped = azimuth < 90 && azimuth > -90 ? 1 : -1;
128
+ const distancePositive = camera.getDistanceVector()[2] < 0 ? 1 : -1;
129
+ const cameraFrontOfFocalPoint = isFlipped * distancePositive > 0;
127
130
 
128
131
  // zoom out constraint
129
132
  if (
@@ -32,6 +32,9 @@ const {
32
32
  EllipseNode,
33
33
  ModelRectNode,
34
34
  ImageNode,
35
+ CubeNode,
36
+ BaseNode,
37
+ BaseNode3D,
35
38
  } = Nodes;
36
39
 
37
40
  const {
@@ -76,6 +79,7 @@ const {
76
79
  Toolbar,
77
80
  Timebar,
78
81
  Snapline,
82
+ EdgeFilterLens,
79
83
  } = Plugins;
80
84
 
81
85
  const {
@@ -96,6 +100,7 @@ const {
96
100
  import lassoSelector from './selector/lasso';
97
101
  import rectSelector from './selector/rect';
98
102
  import Hull from './plugin/hull';
103
+ import { WaterMarker } from './plugin/watermaker';
99
104
 
100
105
  const stdLib = {
101
106
  transforms: {
@@ -123,7 +128,6 @@ const stdLib = {
123
128
  'zoom-canvas': ZoomCanvas,
124
129
  'drag-node': DragNode,
125
130
  'drag-combo': DragCombo,
126
- 'create-edge': CreateEdge,
127
131
  'collapse-expand-combo': CollapseExpandCombo,
128
132
  'collapse-expand-tree': CollapseExpandTree,
129
133
  'click-select': ClickSelect,
@@ -246,6 +250,9 @@ const Extensions = {
246
250
  TriangleNode,
247
251
  EllipseNode,
248
252
  ModelRectNode,
253
+ CubeNode,
254
+ BaseNode,
255
+ BaseNode3D,
249
256
  // edges
250
257
  LineEdge,
251
258
  CubicEdge,
@@ -289,6 +296,8 @@ const Extensions = {
289
296
  Timebar,
290
297
  Hull,
291
298
  Snapline,
299
+ EdgeFilterLens,
300
+ WaterMarker,
292
301
  };
293
302
 
294
303
  export default registery;
@@ -289,9 +289,10 @@ export abstract class BaseEdge {
289
289
  const pointOffset = (keyShape as Line | Polyline).getPoint(
290
290
  positionPreset.pointRatio[1],
291
291
  );
292
- const angle = Math.atan(
292
+ let angle = Math.atan(
293
293
  (point.y - pointOffset.y) / (point.x - pointOffset.x),
294
- ); // TODO: NaN
294
+ );
295
+ if (isNaN(angle)) angle = 0;
295
296
 
296
297
  // revert
297
298
  isRevert = pointOffset.x < point.x;
@@ -331,6 +332,7 @@ export abstract class BaseEdge {
331
332
  maxWidth,
332
333
  this.zoomCache.zoom,
333
334
  );
335
+ this.zoomCache.wordWrapWidth = wordWrapWidth;
334
336
  const style = {
335
337
  ...this.defaultStyles.labelShape,
336
338
  textAlign: positionPreset.textAlign,
@@ -339,6 +341,7 @@ export abstract class BaseEdge {
339
341
  ...positionStyle,
340
342
  ...otherStyle,
341
343
  };
344
+ this.boundsCache.labelShapeTransform = style.transform;
342
345
  return this.upsertShape('text', 'labelShape', style, shapeMap, model);
343
346
  }
344
347
 
@@ -1,4 +1,3 @@
1
- import { vec2 } from '@antv/matrix-util';
2
1
  import { Point } from '../../../types/common';
3
2
 
4
3
  import { CubicEdge } from './cubic';
@@ -1,4 +1,3 @@
1
- import { vec2 } from '@antv/matrix-util';
2
1
  import { Point } from '../../../types/common';
3
2
  import { CubicEdge } from './cubic';
4
3
 
@@ -1,5 +1,5 @@
1
1
  import { DisplayObject } from '@antv/g';
2
- import { vec2 } from '@antv/matrix-util';
2
+ import { vec2 } from 'gl-matrix';
3
3
  import { Point } from '../../../types/common';
4
4
  import { EdgeModelData, EdgeShapeMap } from '../../../types/edge';
5
5
  import { State } from '../../../types/item';
@@ -1,4 +1,4 @@
1
- import { vec2 } from '@antv/matrix-util';
1
+ import { vec2 } from 'gl-matrix';
2
2
  import { getBBoxHeight, getBBoxWidth } from '../../../util/bbox';
3
3
  import { distanceVec } from '../../../util/point';
4
4
  import {
@@ -0,0 +1,102 @@
1
+ import { DisplayObject } from '@antv/g';
2
+ import { NodeDisplayModel } from '../../../types';
3
+ import { State } from '../../../types/item';
4
+ import {
5
+ NodeModelData,
6
+ NodeShapeMap,
7
+ NodeShapeStyles,
8
+ } from '../../../types/node';
9
+ import { BaseNode3D } from './base3d';
10
+
11
+ export class CubeNode extends BaseNode3D {
12
+ override defaultStyles = {
13
+ keyShape: {
14
+ latitudeBands: 32,
15
+ longitudeBands: 32,
16
+ width: 10,
17
+ height: 10,
18
+ depth: 10,
19
+ x: 0,
20
+ y: 0,
21
+ z: 0,
22
+ },
23
+ };
24
+ mergedStyles: NodeShapeStyles;
25
+ constructor(props) {
26
+ super(props);
27
+ }
28
+ public draw(
29
+ model: NodeDisplayModel,
30
+ shapeMap: NodeShapeMap,
31
+ diffData?: { previous: NodeModelData; current: NodeModelData },
32
+ diffState?: { previous: State[]; current: State[] },
33
+ ): NodeShapeMap {
34
+ const { data = {} } = model;
35
+
36
+ let shapes: NodeShapeMap = { keyShape: undefined };
37
+
38
+ // keyShape
39
+ shapes.keyShape = this.drawKeyShape(model, shapeMap, diffData);
40
+
41
+ // haloShape
42
+ if (data.haloShape && this.drawHaloShape) {
43
+ shapes.haloShape = this.drawHaloShape(model, shapeMap, diffData);
44
+ }
45
+
46
+ // labelShape
47
+ if (data.labelShape) {
48
+ shapes.labelShape = this.drawLabelShape(model, shapeMap, diffData);
49
+ }
50
+
51
+ // labelBackgroundShape
52
+ if (data.labelBackgroundShape) {
53
+ shapes.labelBackgroundShape = this.drawLabelBackgroundShape(
54
+ model,
55
+ shapeMap,
56
+ diffData,
57
+ );
58
+ }
59
+
60
+ // iconShape
61
+ if (data.iconShape) {
62
+ shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
63
+ }
64
+
65
+ // badgeShape
66
+ if (data.badgeShapes) {
67
+ const badgeShapes = this.drawBadgeShapes(
68
+ model,
69
+ shapeMap,
70
+ diffData,
71
+ diffState,
72
+ );
73
+ shapes = {
74
+ ...shapes,
75
+ ...badgeShapes,
76
+ };
77
+ }
78
+
79
+ // otherShapes
80
+ if (data.otherShapes && this.drawOtherShapes) {
81
+ shapes = {
82
+ ...shapes,
83
+ ...this.drawOtherShapes(model, shapeMap, diffData),
84
+ };
85
+ }
86
+ return shapes;
87
+ }
88
+
89
+ public drawKeyShape(
90
+ model: NodeDisplayModel,
91
+ shapeMap: NodeShapeMap,
92
+ diffData?: { previous: NodeModelData; current: NodeModelData },
93
+ diffState?: { previous: State[]; current: State[] },
94
+ ): DisplayObject {
95
+ return this.upsertShape(
96
+ 'cube',
97
+ 'keyShape',
98
+ this.mergedStyles.keyShape,
99
+ shapeMap,
100
+ );
101
+ }
102
+ }
@@ -9,3 +9,6 @@ export * from './donut';
9
9
  export * from './diamond';
10
10
  export * from './modelRect';
11
11
  export * from './image';
12
+ export * from './cube';
13
+ export * from './base';
14
+ export * from './base3d';