@antv/g6 5.0.0-beta.25 → 5.0.0-beta.27

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 (329) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/constant/shape.d.ts +1 -1
  3. package/esm/index.d.ts +3 -1
  4. package/esm/index.js +1 -1
  5. package/esm/item/combo.d.ts +6 -4
  6. package/esm/item/combo.js +10 -3
  7. package/esm/item/combo.js.map +1 -1
  8. package/esm/item/edge.d.ts +12 -4
  9. package/esm/item/edge.js +100 -17
  10. package/esm/item/edge.js.map +1 -1
  11. package/esm/item/item.d.ts +18 -8
  12. package/esm/item/item.js +121 -62
  13. package/esm/item/item.js.map +1 -1
  14. package/esm/item/node.d.ts +10 -4
  15. package/esm/item/node.js +92 -8
  16. package/esm/item/node.js.map +1 -1
  17. package/esm/runtime/controller/data.d.ts +5 -1
  18. package/esm/runtime/controller/data.js +38 -1
  19. package/esm/runtime/controller/data.js.map +1 -1
  20. package/esm/runtime/controller/index.d.ts +1 -1
  21. package/esm/runtime/controller/index.js +1 -1
  22. package/esm/runtime/controller/index.js.map +1 -1
  23. package/esm/runtime/controller/item.d.ts +22 -11
  24. package/esm/runtime/controller/item.js +241 -96
  25. package/esm/runtime/controller/item.js.map +1 -1
  26. package/esm/runtime/controller/layout.d.ts +3 -0
  27. package/esm/runtime/controller/layout.js +178 -98
  28. package/esm/runtime/controller/layout.js.map +1 -1
  29. package/esm/runtime/controller/plugin.d.ts +3 -0
  30. package/esm/runtime/controller/plugin.js +66 -24
  31. package/esm/runtime/controller/plugin.js.map +1 -1
  32. package/esm/runtime/controller/viewport.js +9 -2
  33. package/esm/runtime/controller/viewport.js.map +1 -1
  34. package/esm/runtime/graph.d.ts +57 -26
  35. package/esm/runtime/graph.js +263 -139
  36. package/esm/runtime/graph.js.map +1 -1
  37. package/esm/stdlib/behavior/click-select.js +9 -3
  38. package/esm/stdlib/behavior/click-select.js.map +1 -1
  39. package/esm/stdlib/behavior/drag-canvas.js +6 -3
  40. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  41. package/esm/stdlib/behavior/drag-combo.js +8 -8
  42. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  43. package/esm/stdlib/behavior/drag-node.d.ts +4 -0
  44. package/esm/stdlib/behavior/drag-node.js +121 -27
  45. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  46. package/esm/stdlib/behavior/scroll-canvas.js +3 -3
  47. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
  48. package/esm/stdlib/behavior/zoom-canvas.js +3 -3
  49. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  50. package/esm/stdlib/data/mapNodeSize.js +2 -2
  51. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  52. package/esm/stdlib/data/validateData.js +2 -2
  53. package/esm/stdlib/data/validateData.js.map +1 -1
  54. package/esm/stdlib/index.d.ts +2 -0
  55. package/esm/stdlib/index.js +3 -1
  56. package/esm/stdlib/index.js.map +1 -1
  57. package/esm/stdlib/item/edge/base.d.ts +2 -11
  58. package/esm/stdlib/item/edge/base.js +12 -105
  59. package/esm/stdlib/item/edge/base.js.map +1 -1
  60. package/esm/stdlib/item/node/base.d.ts +2 -20
  61. package/esm/stdlib/item/node/base.js +10 -150
  62. package/esm/stdlib/item/node/base.js.map +1 -1
  63. package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
  64. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
  65. package/esm/stdlib/plugin/fisheye/index.js +3 -2
  66. package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
  67. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  68. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  69. package/esm/stdlib/plugin/hull/index.d.ts +1 -1
  70. package/esm/stdlib/plugin/index.d.ts +1 -0
  71. package/esm/stdlib/plugin/index.js +1 -0
  72. package/esm/stdlib/plugin/index.js.map +1 -1
  73. package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
  74. package/esm/stdlib/plugin/lodController/index.js +556 -0
  75. package/esm/stdlib/plugin/lodController/index.js.map +1 -0
  76. package/esm/stdlib/plugin/menu/index.js +2 -1
  77. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  78. package/esm/stdlib/plugin/minimap/index.js +12 -14
  79. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  80. package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
  81. package/esm/stdlib/plugin/toolbar/index.js +27 -29
  82. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  83. package/esm/stdlib/theme/dark.js +32 -35
  84. package/esm/stdlib/theme/dark.js.map +1 -1
  85. package/esm/stdlib/theme/light.js +27 -30
  86. package/esm/stdlib/theme/light.js.map +1 -1
  87. package/esm/stdlib/themeSolver/spec.js +2 -2
  88. package/esm/stdlib/themeSolver/spec.js.map +1 -1
  89. package/esm/types/animate.d.ts +1 -1
  90. package/esm/types/combo.d.ts +2 -2
  91. package/esm/types/edge.d.ts +2 -2
  92. package/esm/types/graph.d.ts +62 -43
  93. package/esm/types/hook.d.ts +5 -0
  94. package/esm/types/item.d.ts +9 -15
  95. package/esm/types/layout.d.ts +7 -2
  96. package/esm/types/layout.js.map +1 -1
  97. package/esm/types/node.d.ts +3 -2
  98. package/esm/types/plugin.d.ts +1 -0
  99. package/esm/types/plugin.js +1 -0
  100. package/esm/types/plugin.js.map +1 -1
  101. package/esm/types/spec.d.ts +1 -0
  102. package/esm/types/theme.d.ts +7 -7
  103. package/esm/util/animate.d.ts +7 -2
  104. package/esm/util/animate.js +40 -23
  105. package/esm/util/animate.js.map +1 -1
  106. package/esm/util/bbox.d.ts +7 -1
  107. package/esm/util/bbox.js +16 -0
  108. package/esm/util/bbox.js.map +1 -1
  109. package/esm/util/data.d.ts +7 -1
  110. package/esm/util/data.js +17 -5
  111. package/esm/util/data.js.map +1 -1
  112. package/esm/util/dom.js +5 -5
  113. package/esm/util/dom.js.map +1 -1
  114. package/esm/util/item.d.ts +1 -1
  115. package/esm/util/item.js +8 -8
  116. package/esm/util/item.js.map +1 -1
  117. package/esm/util/mapper.js +1 -1
  118. package/esm/util/mapper.js.map +1 -1
  119. package/esm/util/path.d.ts +6 -1
  120. package/esm/util/path.js +72 -1
  121. package/esm/util/path.js.map +1 -1
  122. package/esm/util/polyline.d.ts +10 -0
  123. package/esm/util/polyline.js +22 -17
  124. package/esm/util/polyline.js.map +1 -1
  125. package/esm/util/router.d.ts +1 -1
  126. package/esm/util/router.js +19 -18
  127. package/esm/util/router.js.map +1 -1
  128. package/esm/util/shape.d.ts +1 -1
  129. package/esm/util/shape.js +28 -13
  130. package/esm/util/shape.js.map +1 -1
  131. package/esm/util/zoom.d.ts +5 -8
  132. package/esm/util/zoom.js +15 -20
  133. package/esm/util/zoom.js.map +1 -1
  134. package/lib/constant/shape.d.ts +1 -1
  135. package/lib/index.d.ts +3 -1
  136. package/lib/index.js +1 -1
  137. package/lib/item/combo.d.ts +6 -4
  138. package/lib/item/combo.js +10 -3
  139. package/lib/item/combo.js.map +1 -1
  140. package/lib/item/edge.d.ts +12 -4
  141. package/lib/item/edge.js +99 -16
  142. package/lib/item/edge.js.map +1 -1
  143. package/lib/item/item.d.ts +18 -8
  144. package/lib/item/item.js +119 -60
  145. package/lib/item/item.js.map +1 -1
  146. package/lib/item/node.d.ts +10 -4
  147. package/lib/item/node.js +92 -8
  148. package/lib/item/node.js.map +1 -1
  149. package/lib/runtime/controller/data.d.ts +5 -1
  150. package/lib/runtime/controller/data.js +38 -1
  151. package/lib/runtime/controller/data.js.map +1 -1
  152. package/lib/runtime/controller/index.d.ts +1 -1
  153. package/lib/runtime/controller/index.js +1 -1
  154. package/lib/runtime/controller/index.js.map +1 -1
  155. package/lib/runtime/controller/item.d.ts +22 -11
  156. package/lib/runtime/controller/item.js +238 -93
  157. package/lib/runtime/controller/item.js.map +1 -1
  158. package/lib/runtime/controller/layout.d.ts +3 -0
  159. package/lib/runtime/controller/layout.js +178 -98
  160. package/lib/runtime/controller/layout.js.map +1 -1
  161. package/lib/runtime/controller/plugin.d.ts +3 -0
  162. package/lib/runtime/controller/plugin.js +66 -24
  163. package/lib/runtime/controller/plugin.js.map +1 -1
  164. package/lib/runtime/controller/viewport.js +9 -2
  165. package/lib/runtime/controller/viewport.js.map +1 -1
  166. package/lib/runtime/graph.d.ts +57 -26
  167. package/lib/runtime/graph.js +263 -139
  168. package/lib/runtime/graph.js.map +1 -1
  169. package/lib/stdlib/behavior/click-select.js +9 -3
  170. package/lib/stdlib/behavior/click-select.js.map +1 -1
  171. package/lib/stdlib/behavior/drag-canvas.js +6 -3
  172. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  173. package/lib/stdlib/behavior/drag-combo.js +8 -8
  174. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  175. package/lib/stdlib/behavior/drag-node.d.ts +4 -0
  176. package/lib/stdlib/behavior/drag-node.js +121 -27
  177. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  178. package/lib/stdlib/behavior/scroll-canvas.js +3 -3
  179. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
  180. package/lib/stdlib/behavior/zoom-canvas.js +3 -3
  181. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  182. package/lib/stdlib/data/mapNodeSize.js +2 -2
  183. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  184. package/lib/stdlib/data/validateData.js +2 -2
  185. package/lib/stdlib/data/validateData.js.map +1 -1
  186. package/lib/stdlib/index.d.ts +2 -0
  187. package/lib/stdlib/index.js +3 -1
  188. package/lib/stdlib/index.js.map +1 -1
  189. package/lib/stdlib/item/edge/base.d.ts +2 -11
  190. package/lib/stdlib/item/edge/base.js +12 -105
  191. package/lib/stdlib/item/edge/base.js.map +1 -1
  192. package/lib/stdlib/item/node/base.d.ts +2 -20
  193. package/lib/stdlib/item/node/base.js +10 -150
  194. package/lib/stdlib/item/node/base.js.map +1 -1
  195. package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
  196. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
  197. package/lib/stdlib/plugin/fisheye/index.js +2 -1
  198. package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
  199. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  200. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  201. package/lib/stdlib/plugin/hull/index.d.ts +1 -1
  202. package/lib/stdlib/plugin/index.d.ts +1 -0
  203. package/lib/stdlib/plugin/index.js +1 -0
  204. package/lib/stdlib/plugin/index.js.map +1 -1
  205. package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
  206. package/lib/stdlib/plugin/lodController/index.js +560 -0
  207. package/lib/stdlib/plugin/lodController/index.js.map +1 -0
  208. package/lib/stdlib/plugin/menu/index.js +2 -1
  209. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  210. package/lib/stdlib/plugin/minimap/index.js +12 -14
  211. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  212. package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
  213. package/lib/stdlib/plugin/toolbar/index.js +27 -29
  214. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  215. package/lib/stdlib/theme/dark.js +32 -35
  216. package/lib/stdlib/theme/dark.js.map +1 -1
  217. package/lib/stdlib/theme/light.js +27 -30
  218. package/lib/stdlib/theme/light.js.map +1 -1
  219. package/lib/stdlib/themeSolver/spec.js +2 -2
  220. package/lib/stdlib/themeSolver/spec.js.map +1 -1
  221. package/lib/types/animate.d.ts +1 -1
  222. package/lib/types/combo.d.ts +2 -2
  223. package/lib/types/edge.d.ts +2 -2
  224. package/lib/types/graph.d.ts +62 -43
  225. package/lib/types/hook.d.ts +5 -0
  226. package/lib/types/item.d.ts +9 -15
  227. package/lib/types/layout.d.ts +7 -2
  228. package/lib/types/layout.js.map +1 -1
  229. package/lib/types/node.d.ts +3 -2
  230. package/lib/types/plugin.d.ts +1 -0
  231. package/lib/types/plugin.js +1 -0
  232. package/lib/types/plugin.js.map +1 -1
  233. package/lib/types/spec.d.ts +1 -0
  234. package/lib/types/theme.d.ts +7 -7
  235. package/lib/util/animate.d.ts +7 -2
  236. package/lib/util/animate.js +40 -23
  237. package/lib/util/animate.js.map +1 -1
  238. package/lib/util/bbox.d.ts +7 -1
  239. package/lib/util/bbox.js +18 -1
  240. package/lib/util/bbox.js.map +1 -1
  241. package/lib/util/data.d.ts +7 -1
  242. package/lib/util/data.js +19 -6
  243. package/lib/util/data.js.map +1 -1
  244. package/lib/util/dom.js +5 -5
  245. package/lib/util/dom.js.map +1 -1
  246. package/lib/util/item.d.ts +1 -1
  247. package/lib/util/item.js +8 -8
  248. package/lib/util/item.js.map +1 -1
  249. package/lib/util/mapper.js +1 -1
  250. package/lib/util/mapper.js.map +1 -1
  251. package/lib/util/path.d.ts +6 -1
  252. package/lib/util/path.js +72 -1
  253. package/lib/util/path.js.map +1 -1
  254. package/lib/util/polyline.d.ts +10 -0
  255. package/lib/util/polyline.js +25 -18
  256. package/lib/util/polyline.js.map +1 -1
  257. package/lib/util/router.d.ts +1 -1
  258. package/lib/util/router.js +19 -18
  259. package/lib/util/router.js.map +1 -1
  260. package/lib/util/shape.d.ts +1 -1
  261. package/lib/util/shape.js +27 -12
  262. package/lib/util/shape.js.map +1 -1
  263. package/lib/util/zoom.d.ts +5 -8
  264. package/lib/util/zoom.js +17 -22
  265. package/lib/util/zoom.js.map +1 -1
  266. package/package.json +1 -1
  267. package/src/index.ts +1 -1
  268. package/src/item/combo.ts +13 -5
  269. package/src/item/edge.ts +126 -17
  270. package/src/item/item.ts +140 -57
  271. package/src/item/node.ts +109 -12
  272. package/src/runtime/controller/data.ts +64 -3
  273. package/src/runtime/controller/index.ts +1 -1
  274. package/src/runtime/controller/item.ts +321 -135
  275. package/src/runtime/controller/layout.ts +254 -113
  276. package/src/runtime/controller/plugin.ts +86 -33
  277. package/src/runtime/controller/viewport.ts +8 -2
  278. package/src/runtime/graph.ts +383 -158
  279. package/src/stdlib/behavior/click-select.ts +8 -3
  280. package/src/stdlib/behavior/drag-canvas.ts +6 -3
  281. package/src/stdlib/behavior/drag-combo.ts +8 -8
  282. package/src/stdlib/behavior/drag-node.ts +165 -50
  283. package/src/stdlib/behavior/scroll-canvas.ts +3 -3
  284. package/src/stdlib/behavior/zoom-canvas.ts +3 -3
  285. package/src/stdlib/data/mapNodeSize.ts +2 -2
  286. package/src/stdlib/data/validateData.ts +2 -2
  287. package/src/stdlib/index.ts +3 -0
  288. package/src/stdlib/item/edge/base.ts +15 -139
  289. package/src/stdlib/item/node/base.ts +20 -215
  290. package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
  291. package/src/stdlib/plugin/fisheye/index.ts +3 -2
  292. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  293. package/src/stdlib/plugin/index.ts +1 -0
  294. package/src/stdlib/plugin/lodController/index.ts +602 -0
  295. package/src/stdlib/plugin/menu/index.ts +1 -1
  296. package/src/stdlib/plugin/minimap/index.ts +12 -14
  297. package/src/stdlib/plugin/toolbar/index.ts +29 -31
  298. package/src/stdlib/theme/dark.ts +32 -34
  299. package/src/stdlib/theme/light.ts +27 -29
  300. package/src/stdlib/themeSolver/spec.ts +2 -2
  301. package/src/types/animate.ts +1 -1
  302. package/src/types/combo.ts +2 -2
  303. package/src/types/edge.ts +2 -2
  304. package/src/types/graph.ts +65 -53
  305. package/src/types/hook.ts +5 -0
  306. package/src/types/item.ts +8 -14
  307. package/src/types/layout.ts +20 -15
  308. package/src/types/node.ts +3 -2
  309. package/src/types/plugin.ts +2 -0
  310. package/src/types/spec.ts +1 -0
  311. package/src/types/theme.ts +7 -7
  312. package/src/util/animate.ts +104 -75
  313. package/src/util/bbox.ts +26 -1
  314. package/src/util/data.ts +15 -6
  315. package/src/util/dom.ts +6 -6
  316. package/src/util/item.ts +15 -1
  317. package/src/util/mapper.ts +1 -1
  318. package/src/util/path.ts +72 -2
  319. package/src/util/polyline.ts +30 -23
  320. package/src/util/router.ts +21 -19
  321. package/src/util/shape.ts +27 -12
  322. package/src/util/zoom.ts +19 -25
  323. package/esm/runtime/controller/extension.d.ts +0 -9
  324. package/esm/runtime/controller/extension.js +0 -11
  325. package/esm/runtime/controller/extension.js.map +0 -1
  326. package/lib/runtime/controller/extension.d.ts +0 -9
  327. package/lib/runtime/controller/extension.js +0 -15
  328. package/lib/runtime/controller/extension.js.map +0 -1
  329. package/src/runtime/controller/extension.ts +0 -14
@@ -8,7 +8,7 @@ import { BehaviorOptionsOf, BehaviorRegistry } from './behavior';
8
8
  import { ComboModel, ComboUserModel } from './combo';
9
9
  import { Padding, Point } from './common';
10
10
  import { GraphData } from './data';
11
- import { EdgeModel, EdgeUserModel } from './edge';
11
+ import { EdgeDisplayModel, EdgeModel, EdgeUserModel } from './edge';
12
12
  import type { StackType } from './history';
13
13
  import { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from './item';
14
14
  import { LayoutOptions } from './layout';
@@ -25,6 +25,7 @@ export interface IGraph<
25
25
  [x: string]: any;
26
26
  hooks: Hooks;
27
27
  canvas: Canvas;
28
+ labelCanvas: Canvas;
28
29
  transientCanvas: Canvas;
29
30
  destroyed: boolean;
30
31
  container: HTMLElement;
@@ -116,6 +117,15 @@ export interface IGraph<
116
117
  nodeId: ID,
117
118
  direction?: 'in' | 'out' | 'both',
118
119
  ) => EdgeModel[];
120
+ /**
121
+ * Get nearby edges from a start node using quadtree collision detection.
122
+ * @param nodeId id of the start node
123
+ * @returns nearby edges' data array
124
+ */
125
+ getNearEdgesData: (
126
+ nodeId: ID,
127
+ shouldBegin?: (edge: EdgeDisplayModel) => boolean,
128
+ ) => EdgeModel[];
119
129
  /**
120
130
  * Get one-hop node ids from a start node.
121
131
  * @param nodeId id of the start node
@@ -126,12 +136,6 @@ export interface IGraph<
126
136
  nodeId: ID,
127
137
  direction?: 'in' | 'out' | 'both',
128
138
  ) => NodeModel[];
129
- /**
130
- * Retrieve the nearby edges for a given node using quadtree collision detection.
131
- * @param nodeId target node's id
132
- * @returns edges
133
- */
134
- getNearEdgesForNode: (nodeId: ID) => EdgeModel[];
135
139
  /*
136
140
  * Get the children's data of a combo.
137
141
  * @param comboId combo id
@@ -157,10 +161,15 @@ export interface IGraph<
157
161
  * Change graph data.
158
162
  * @param data new data
159
163
  * @param type the way to change data, 'replace' means discard the old data and use the new one; 'mergeReplace' means merge the common part, remove (old - new), add (new - old)
164
+ * @param relayout whether relayout the nodes after data changing
160
165
  * @returns
161
166
  * @group Data
162
167
  */
163
- changeData: (data: GraphData, type: 'replace' | 'mergeReplace') => void;
168
+ changeData: (
169
+ data: GraphData,
170
+ type?: 'replace' | 'mergeReplace',
171
+ relayout?: boolean,
172
+ ) => void;
164
173
  /**
165
174
  * Clear the graph, means remove all the items on the graph.
166
175
  * @returns
@@ -185,7 +194,6 @@ export interface IGraph<
185
194
  * Add one or more node/edge/combo data to the graph.
186
195
  * @param itemType item type
187
196
  * @param model user data
188
- * @param stack whether push this operation to stack
189
197
  * @returns whehter success
190
198
  * @group Data
191
199
  */
@@ -198,7 +206,6 @@ export interface IGraph<
198
206
  | NodeUserModel[]
199
207
  | EdgeUserModel[]
200
208
  | ComboUserModel[],
201
- stack?: boolean,
202
209
  ) =>
203
210
  | NodeModel
204
211
  | EdgeModel
@@ -208,17 +215,16 @@ export interface IGraph<
208
215
  | ComboModel[];
209
216
  /**
210
217
  * Remove one or more node/edge/combo data from the graph.
211
- * @param item the item to be removed
212
- * @param stack whether push this operation to stack
218
+ * @param itemType the type the item(s) to be removed.
219
+ * @param id the id or the ids' array of the items to be removed.
213
220
  * @returns whehter success
214
221
  * @group Data
215
222
  */
216
- removeData: (itemType: ITEM_TYPE, id: ID | ID[], stack?: boolean) => void;
223
+ removeData: (itemType: ITEM_TYPE, id: ID | ID[]) => void;
217
224
  /**
218
225
  * Update one or more node/edge/combo data on the graph.
219
- * @param item the item to be updated
220
- * @param model update configs
221
- * @param {boolean} stack whether push this operation to stack
226
+ * @param itemType the type the item(s) to be udated.
227
+ * @param models update configs.
222
228
  * @group Data
223
229
  */
224
230
  updateData: (
@@ -232,7 +238,6 @@ export interface IGraph<
232
238
  | Partial<EdgeUserModel>[]
233
239
  | Partial<ComboUserModel>[]
234
240
  >,
235
- stack?: boolean,
236
241
  ) =>
237
242
  | NodeModel
238
243
  | EdgeModel
@@ -244,8 +249,10 @@ export interface IGraph<
244
249
  /**
245
250
  * Update one or more nodes' positions,
246
251
  * do not update other styles which leads to better performance than updating positions by updateData.
247
- * @param models new configurations with x and y for every node, which has id field to indicate the specific item
248
- * @param {boolean} stack whether push this operation into graph's stack, true by default
252
+ * @param models new configurations with x and y for every node, which has id field to indicate the specific item.
253
+ * @param upsertAncestors whether update the ancestors in combo tree.
254
+ * @param disableAnimate whether disable the animation for this call.
255
+ * @param callback callback function after update nodes done.
249
256
  * @group Data
250
257
  */
251
258
  updateNodePosition: (
@@ -260,14 +267,15 @@ export interface IGraph<
260
267
  model: NodeModel | EdgeModel | ComboModel,
261
268
  canceled?: boolean,
262
269
  ) => void,
263
- stack?: boolean,
264
270
  ) => NodeModel | ComboModel | NodeModel[] | ComboModel[];
265
271
 
266
272
  /**
267
273
  * Update one or more combos' positions, it is achieved by move the succeed nodes.
268
274
  * Do not update other styles which leads to better performance than updating positions by updateData.
269
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
270
- * @param {boolean} stack whether push this operation into graph's stack, true by default
275
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
276
+ * @param upsertAncestors whether update the ancestors in combo tree.
277
+ * @param disableAnimate whether disable the animation for this call.
278
+ * @param callback callback function after update combos done.
271
279
  * @group Data
272
280
  */
273
281
  updateComboPosition: (
@@ -279,15 +287,17 @@ export interface IGraph<
279
287
  upsertAncestors?: boolean,
280
288
  disableAnimate?: boolean,
281
289
  callback?: (model: NodeModel | EdgeModel | ComboModel) => void,
282
- stack?: boolean,
283
290
  ) => NodeModel | ComboModel | NodeModel[] | ComboModel[];
284
291
 
285
292
  /**
286
293
  * Move one or more combos a distance (dx, dy) relatively,
287
294
  * do not update other styles which leads to better performance than updating positions by updateData.
288
295
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
289
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
290
- * @param {boolean} stack whether push this operation into graph's stack, true by default
296
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
297
+ * @param dx the distance alone x-axis to move the combo.
298
+ * @param dy the distance alone y-axis to move the combo.
299
+ * @param upsertAncestors whether update the ancestors in the combo tree.
300
+ * @param callback callback function after move combo done.
291
301
  * @group Data
292
302
  */
293
303
  moveCombo: (
@@ -299,7 +309,6 @@ export interface IGraph<
299
309
  model: NodeModel | EdgeModel | ComboModel,
300
310
  canceled?: boolean,
301
311
  ) => void,
302
- stack?: boolean,
303
312
  ) => ComboModel[];
304
313
 
305
314
  // ===== view operations =====
@@ -481,7 +490,10 @@ export interface IGraph<
481
490
  * @returns
482
491
  * @group Data
483
492
  */
484
- showItem: (ids: ID | ID[], disableAnimate?: boolean) => void;
493
+ showItem: (
494
+ ids: ID | ID[],
495
+ options?: { disableAnimate?: boolean; shapeIds?: string[] },
496
+ ) => void;
485
497
  /**
486
498
  * Hide the item(s).
487
499
  * @param ids the item id(s) to be hidden
@@ -490,8 +502,12 @@ export interface IGraph<
490
502
  */
491
503
  hideItem: (
492
504
  ids: ID | ID[],
493
- disableAnimate?: boolean,
494
- keepKeyShape?: boolean,
505
+ options?: {
506
+ disableAnimate?: boolean;
507
+ keepKeyShape?: boolean;
508
+ keepRelated?: boolean;
509
+ shapeIds?: string[];
510
+ },
495
511
  ) => void;
496
512
  /**
497
513
  * Make the item(s) to the front.
@@ -499,14 +515,14 @@ export interface IGraph<
499
515
  * @returns
500
516
  * @group Item
501
517
  */
502
- frontItem: (ids: ID | ID[], stack?: boolean) => void;
518
+ frontItem: (ids: ID | ID[]) => void;
503
519
  /**
504
520
  * Make the item(s) to the back.
505
521
  * @param ids the item id(s) to back
506
522
  * @returns
507
523
  * @group Item
508
524
  */
509
- backItem: (ids: ID | ID[], stack?: boolean) => void;
525
+ backItem: (ids: ID | ID[]) => void;
510
526
  /**
511
527
  * Set state for the item(s).
512
528
  * @param ids the id(s) for the item(s) to be set
@@ -515,12 +531,7 @@ export interface IGraph<
515
531
  * @returns
516
532
  * @group Item
517
533
  */
518
- setItemState: (
519
- ids: ID | ID[],
520
- state: string,
521
- value: boolean,
522
- stack?: boolean,
523
- ) => void;
534
+ setItemState: (ids: ID | ID[], state: string, value: boolean) => void;
524
535
  /**
525
536
  * Get the state value for an item.
526
537
  * @param id the id for the item
@@ -543,7 +554,7 @@ export interface IGraph<
543
554
  * @returns
544
555
  * @group Item
545
556
  */
546
- clearItemState: (ids: ID | ID[], states?: string[], stack?: boolean) => void;
557
+ clearItemState: (ids: ID | ID[], states?: string[]) => void;
547
558
 
548
559
  /**
549
560
  * Get the rendering bbox for a node / edge / combo, or the graph (when the id is not assigned).
@@ -563,34 +574,37 @@ export interface IGraph<
563
574
  */
564
575
  getItemVisible: (id: ID) => boolean;
565
576
 
577
+ /**
578
+ * Get the visible shape ids in a node / edge / combo.
579
+ * @param id the id for the node / edge / combo
580
+ * @returns ids of the visible shapes
581
+ */
582
+ getItemVisibleShapeIds: (id: ID) => string[];
583
+
566
584
  // ===== combo operations =====
567
585
 
568
586
  /**
569
587
  * Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
570
588
  * Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
571
- * @param model combo user data
572
- * @param stack whether push this operation to stack
589
+ * @param model combo user data.
590
+ * @param childrenIds the ids of the children nodes / combos to move into the new combo.
573
591
  * @returns whether success
574
592
  * @group Combo
575
593
  */
576
- addCombo: (
577
- model: ComboUserModel,
578
- childrenIds: ID[],
579
- stack?: boolean,
580
- ) => ComboModel;
594
+ addCombo: (model: ComboUserModel, childrenIds: ID[]) => ComboModel;
581
595
  /**
582
596
  * Collapse a combo.
583
- * @param comboId combo id or item
597
+ * @param comboId combo id or ids' array.
584
598
  * @group Combo
585
599
  */
586
- collapseCombo: (comboIds: ID | ID[], stack?: boolean) => void;
600
+ collapseCombo: (comboIds: ID | ID[]) => void;
587
601
  /**
588
602
  * Expand a combo.
589
603
  * @group Combo
590
- * @param combo combo ID 或 combo 实例
604
+ * @param comboId combo id or ids' array.
591
605
  * @group Combo
592
606
  */
593
- expandCombo: (comboIds: ID | ID[], stack?: boolean) => void;
607
+ expandCombo: (comboIds: ID | ID[]) => void;
594
608
 
595
609
  // ===== layout =====
596
610
  /**
@@ -806,18 +820,16 @@ export interface IGraph<
806
820
  * Collapse sub tree(s).
807
821
  * @param ids Root id(s) of the sub trees.
808
822
  * @param disableAnimate Whether disable the animations for this operation.
809
- * @param stack Whether push this operation to stack.
810
823
  * @returns
811
824
  * @group Tree
812
825
  */
813
- collapse: (ids: ID | ID[], disableAnimate?: boolean, stack?: boolean) => void;
826
+ collapse: (ids: ID | ID[], disableAnimate?: boolean) => void;
814
827
  /**
815
828
  * Expand sub tree(s).
816
829
  * @param ids Root id(s) of the sub trees.
817
830
  * @param disableAnimate Whether disable the animations for this operation.
818
- * @param stack Whether push this operation to stack.
819
831
  * @returns
820
832
  * @group Tree
821
833
  */
822
- expand: (ids: ID | ID[], disableAnimate?: boolean, stack?: boolean) => void;
834
+ expand: (ids: ID | ID[], disableAnimate?: boolean) => void;
823
835
  }
package/src/types/hook.ts CHANGED
@@ -33,7 +33,9 @@ export interface Hooks {
33
33
  canvases: {
34
34
  background: Canvas;
35
35
  main: Canvas;
36
+ label: Canvas;
36
37
  transient: Canvas;
38
+ transientLabel: Canvas;
37
39
  };
38
40
  }>;
39
41
  // data
@@ -55,6 +57,7 @@ export interface Hooks {
55
57
  graphCore: GraphCore;
56
58
  theme: ThemeSpecification;
57
59
  transientCanvas: Canvas;
60
+ transientLabelCanvas: Canvas;
58
61
  tileOptimize?: {
59
62
  tileFirstRender?: boolean | number;
60
63
  tileFirstRenderSize?: number;
@@ -89,6 +92,8 @@ export interface Hooks {
89
92
  enableStack?: boolean;
90
93
  changes?: any;
91
94
  keepKeyShape?: boolean;
95
+ keepRelated?: boolean;
96
+ shapeIds?: string[];
92
97
  }>;
93
98
  itemzindexchange: IHook<{
94
99
  ids: ID[];
package/src/types/item.ts CHANGED
@@ -72,7 +72,7 @@ export type ClipCfg = {
72
72
  export type ShapeStyle = Partial<
73
73
  GShapeStyle & {
74
74
  animates?: IAnimates;
75
- lod?: number;
75
+ lod?: number | 'auto';
76
76
  visible?: boolean;
77
77
  } & {
78
78
  clipCfg?: ClipCfg;
@@ -180,19 +180,13 @@ export type ItemShapeStyles = {
180
180
  animates?: IAnimates;
181
181
  };
182
182
 
183
- export interface LodStrategy {
184
- levels: {
185
- zoomRange: [number, number];
186
- primary?: boolean;
187
- }[];
188
- animateCfg: AnimateCfg;
183
+ export interface LodLevel {
184
+ zoomRange: [number, number];
185
+ primary?: boolean;
189
186
  }
190
187
 
191
- export interface LodStrategyObj {
192
- levels: {
193
- [levelIdx: number]: [number, number];
194
- };
195
- animateCfg: AnimateCfg;
188
+ export interface LodLevelRanges {
189
+ [levelIdx: number]: [number, number];
196
190
  }
197
191
 
198
192
  /**
@@ -238,7 +232,7 @@ export interface IItem {
238
232
  [stateName: string]: ItemShapeStyles;
239
233
  };
240
234
  /** The zoom strategy to show and hide shapes according to their lod. */
241
- lodStrategy: LodStrategyObj;
235
+ lodLevels: LodLevelRanges;
242
236
  /** Last zoom ratio. */
243
237
  zoom: number;
244
238
  /** Cache the chaging states which are not consomed by draw */
@@ -275,7 +269,7 @@ export interface IItem {
275
269
  isReplace?: boolean,
276
270
  itemTheme?: {
277
271
  styles: NodeStyleSet | EdgeStyleSet | ComboStyleSet;
278
- lodStrategy: LodStrategyObj;
272
+ lodLevels: LodLevelRanges;
279
273
  },
280
274
  onlyMove?: boolean,
281
275
  animate?: boolean,
@@ -40,33 +40,38 @@ type Workerized = {
40
40
  iterations?: number;
41
41
  };
42
42
 
43
+ type PureLayoutOptions =
44
+ | CircularLayout
45
+ | RandomLayout
46
+ | ConcentricLayout
47
+ | GridLayout
48
+ | MDSLayout
49
+ | RadialLayout
50
+ | FruchtermanLayout
51
+ | D3ForceLayout
52
+ | ForceLayout
53
+ | ForceAtlas2
54
+ | CustomLayout;
55
+
43
56
  export type ImmediatelyInvokedLayoutOptions = {
44
57
  /**
45
58
  * like an IIFE.
46
59
  */
47
60
  execute: (graph: GraphCore, options?: any) => Promise<LayoutMapping>;
48
- } & Animatable;
61
+ } & Animatable & {
62
+ presetLayout?: Partial<PureLayoutOptions>;
63
+ };
49
64
 
50
65
  type CustomLayout = {
51
66
  type: string;
52
67
  [option: string]: any;
53
68
  };
54
69
 
55
- export type StandardLayoutOptions = (
56
- | CircularLayout
57
- | RandomLayout
58
- | ConcentricLayout
59
- | GridLayout
60
- | MDSLayout
61
- | RadialLayout
62
- | FruchtermanLayout
63
- | D3ForceLayout
64
- | ForceLayout
65
- | ForceAtlas2
66
- | CustomLayout
67
- ) &
70
+ export type StandardLayoutOptions = PureLayoutOptions &
68
71
  Animatable &
69
- Workerized;
72
+ Workerized & {
73
+ presetLayout?: Partial<PureLayoutOptions>;
74
+ };
70
75
 
71
76
  export type LayoutOptions =
72
77
  | StandardLayoutOptions
package/src/types/node.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  IBadgePosition,
10
10
  IItem,
11
11
  ItemShapeStyles,
12
- LodStrategy,
12
+ LodLevel,
13
13
  ShapeAttrEncode,
14
14
  ShapeStyle,
15
15
  ShapesEncode,
@@ -193,7 +193,7 @@ export interface NodeShapeStyles extends ItemShapeStyles {
193
193
 
194
194
  /** Data in display model. */
195
195
  export type NodeDisplayModelData = NodeModelData &
196
- NodeShapeStyles & { lodStrategy?: LodStrategy };
196
+ NodeShapeStyles & { lodLevels?: LodLevel[] };
197
197
 
198
198
  /** User input model. */
199
199
  export type NodeUserModel = GNode<NodeUserModelData>;
@@ -219,6 +219,7 @@ export interface NodeShapesEncode extends ShapesEncode {
219
219
  }
220
220
  export interface NodeEncode extends NodeShapesEncode {
221
221
  type?: string | Encode<string>;
222
+ lodLevels?: LodLevel[];
222
223
  animates?: IAnimates;
223
224
  }
224
225
 
@@ -15,6 +15,8 @@ interface EventMapType {
15
15
  export abstract class Plugin {
16
16
  public key: string;
17
17
 
18
+ static required: boolean = false;
19
+
18
20
  private events: EventMapType;
19
21
 
20
22
  public options: IPluginBaseConfig;
package/src/types/spec.ts CHANGED
@@ -43,6 +43,7 @@ export interface Specification<
43
43
  backgroundCanvas?: Canvas;
44
44
  canvas?: Canvas;
45
45
  transientCanvas?: Canvas;
46
+ transientLabelCanvas?: Canvas;
46
47
  width?: number;
47
48
  height?: number;
48
49
  renderer?:
@@ -1,7 +1,7 @@
1
1
  import { BaseThemeSolver } from '../stdlib/themeSolver/base';
2
2
  import { ComboShapeStyles } from './combo';
3
3
  import { EdgeShapeStyles } from './edge';
4
- import { LodStrategy } from './item';
4
+ import { LodLevel } from './item';
5
5
  import { NodeShapeStyles } from './node';
6
6
 
7
7
  export interface ThemeOption {}
@@ -122,13 +122,13 @@ export type ComboStyleSets =
122
122
  * dataTypeField - the field name in model.data that indicates the data type to map style set.
123
123
  * palette - color palette.
124
124
  * styles - style sets to map.
125
- * lodStrategy - level of detail strategy for global setting.
125
+ * lodLevels - level of detail strategy for global setting.
126
126
  */
127
127
  export interface NodeThemeSpecifications {
128
128
  dataTypeField?: string;
129
129
  palette?: string[] | { [dataTypeValue: string]: string };
130
130
  styles?: NodeStyleSets;
131
- lodStrategy?: LodStrategy;
131
+ lodLevels?: LodLevel[];
132
132
  }
133
133
 
134
134
  /**
@@ -136,13 +136,13 @@ export interface NodeThemeSpecifications {
136
136
  * dataTypeField - the field name in model.data that indicates the data type to map style set.
137
137
  * palette - color palette.
138
138
  * styles - style sets to map.
139
- * lodStrategy - level of detail strategy for global setting.
139
+ * lodLevels - level of detail strategy for global setting.
140
140
  */
141
141
  export interface EdgeThemeSpecifications {
142
142
  dataTypeField?: string;
143
143
  palette?: string[] | { [dataTypeValue: string]: string };
144
144
  styles?: EdgeStyleSets;
145
- lodStrategy?: LodStrategy;
145
+ lodLevels?: LodLevel[];
146
146
  }
147
147
 
148
148
  /**
@@ -150,13 +150,13 @@ export interface EdgeThemeSpecifications {
150
150
  * dataTypeField - the field name in model.data that indicates the data type to map style set.
151
151
  * palette - color palette.
152
152
  * styles - style sets to map.
153
- * lodStrategy - level of detail strategy for global setting.
153
+ * lodLevels - level of detail strategy for global setting.
154
154
  */
155
155
  export interface ComboThemeSpecifications {
156
156
  dataTypeField?: string;
157
157
  palette?: string[] | { [dataTypeValue: string]: string };
158
158
  styles?: ComboStyleSets;
159
- lodStrategy?: LodStrategy;
159
+ lodLevels?: LodLevel[];
160
160
  }
161
161
  /**
162
162
  * Theme specification with node / edge / combo palette and style mappers. And also canvas DOM CSS settings.