@antv/g6 5.0.24 → 5.0.26

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 (170) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/auto-adapt-label.d.ts +99 -0
  3. package/dist/lib/behaviors/fix-element-size.d.ts +63 -19
  4. package/dist/lib/behaviors/index.d.ts +2 -0
  5. package/dist/lib/behaviors/optimize-viewport-transform.d.ts +3 -3
  6. package/dist/lib/exports.d.ts +3 -3
  7. package/dist/lib/plugins/edge-bundling/index.d.ts +97 -0
  8. package/dist/lib/plugins/index.d.ts +2 -0
  9. package/dist/lib/runtime/data.d.ts +1 -1
  10. package/dist/lib/runtime/element.d.ts +1 -1
  11. package/dist/lib/runtime/viewport.d.ts +3 -1
  12. package/dist/lib/transforms/map-node-size.d.ts +12 -21
  13. package/dist/lib/transforms/process-parallel-edges.d.ts +4 -0
  14. package/dist/lib/transforms/utils.d.ts +9 -0
  15. package/dist/lib/types/centrality.d.ts +20 -0
  16. package/dist/lib/types/index.d.ts +1 -0
  17. package/dist/lib/utils/animation.d.ts +1 -1
  18. package/dist/lib/utils/bbox.d.ts +9 -0
  19. package/dist/lib/utils/centrality.d.ts +53 -0
  20. package/dist/lib/utils/padding.d.ts +16 -0
  21. package/dist/lib/utils/transform.d.ts +0 -13
  22. package/dist/lib/version.d.ts +1 -1
  23. package/esm/behaviors/auto-adapt-label.d.ts +99 -0
  24. package/esm/behaviors/auto-adapt-label.js +167 -0
  25. package/esm/behaviors/auto-adapt-label.js.map +1 -0
  26. package/esm/behaviors/create-edge.js +5 -2
  27. package/esm/behaviors/create-edge.js.map +1 -1
  28. package/esm/behaviors/fix-element-size.d.ts +63 -19
  29. package/esm/behaviors/fix-element-size.js +142 -59
  30. package/esm/behaviors/fix-element-size.js.map +1 -1
  31. package/esm/behaviors/hover-activate.js +3 -2
  32. package/esm/behaviors/hover-activate.js.map +1 -1
  33. package/esm/behaviors/index.d.ts +2 -0
  34. package/esm/behaviors/index.js +1 -0
  35. package/esm/behaviors/index.js.map +1 -1
  36. package/esm/behaviors/optimize-viewport-transform.d.ts +3 -3
  37. package/esm/exports.d.ts +3 -3
  38. package/esm/exports.js +1 -1
  39. package/esm/exports.js.map +1 -1
  40. package/esm/plugins/edge-bundling/index.d.ts +97 -0
  41. package/esm/plugins/edge-bundling/index.js +252 -0
  42. package/esm/plugins/edge-bundling/index.js.map +1 -0
  43. package/esm/plugins/index.d.ts +2 -0
  44. package/esm/plugins/index.js +1 -0
  45. package/esm/plugins/index.js.map +1 -1
  46. package/esm/registry/build-in.js +4 -2
  47. package/esm/registry/build-in.js.map +1 -1
  48. package/esm/runtime/behavior.js +1 -1
  49. package/esm/runtime/behavior.js.map +1 -1
  50. package/esm/runtime/data.d.ts +1 -1
  51. package/esm/runtime/element.d.ts +1 -1
  52. package/esm/runtime/viewport.d.ts +3 -1
  53. package/esm/runtime/viewport.js +13 -4
  54. package/esm/runtime/viewport.js.map +1 -1
  55. package/esm/transforms/collapse-expand-combo.js +0 -1
  56. package/esm/transforms/collapse-expand-combo.js.map +1 -1
  57. package/esm/transforms/map-node-size.d.ts +12 -21
  58. package/esm/transforms/map-node-size.js +34 -178
  59. package/esm/transforms/map-node-size.js.map +1 -1
  60. package/esm/transforms/process-parallel-edges.d.ts +4 -0
  61. package/esm/transforms/process-parallel-edges.js +41 -37
  62. package/esm/transforms/process-parallel-edges.js.map +1 -1
  63. package/esm/transforms/utils.d.ts +9 -0
  64. package/esm/transforms/utils.js +11 -0
  65. package/esm/transforms/utils.js.map +1 -1
  66. package/esm/types/centrality.d.ts +20 -0
  67. package/esm/types/centrality.js +2 -0
  68. package/esm/types/centrality.js.map +1 -0
  69. package/esm/types/index.d.ts +1 -0
  70. package/esm/utils/animation.d.ts +1 -1
  71. package/esm/utils/bbox.d.ts +9 -0
  72. package/esm/utils/bbox.js +15 -0
  73. package/esm/utils/bbox.js.map +1 -1
  74. package/esm/utils/centrality.d.ts +53 -0
  75. package/esm/utils/centrality.js +177 -0
  76. package/esm/utils/centrality.js.map +1 -0
  77. package/esm/utils/padding.d.ts +16 -0
  78. package/esm/utils/padding.js +22 -0
  79. package/esm/utils/padding.js.map +1 -1
  80. package/esm/utils/transform.d.ts +0 -13
  81. package/esm/utils/transform.js +0 -23
  82. package/esm/utils/transform.js.map +1 -1
  83. package/esm/version.d.ts +1 -1
  84. package/esm/version.js +1 -1
  85. package/lib/behaviors/auto-adapt-label.d.ts +99 -0
  86. package/lib/behaviors/auto-adapt-label.js +171 -0
  87. package/lib/behaviors/auto-adapt-label.js.map +1 -0
  88. package/lib/behaviors/create-edge.js +5 -2
  89. package/lib/behaviors/create-edge.js.map +1 -1
  90. package/lib/behaviors/fix-element-size.d.ts +63 -19
  91. package/lib/behaviors/fix-element-size.js +141 -58
  92. package/lib/behaviors/fix-element-size.js.map +1 -1
  93. package/lib/behaviors/hover-activate.js +3 -2
  94. package/lib/behaviors/hover-activate.js.map +1 -1
  95. package/lib/behaviors/index.d.ts +2 -0
  96. package/lib/behaviors/index.js +3 -1
  97. package/lib/behaviors/index.js.map +1 -1
  98. package/lib/behaviors/optimize-viewport-transform.d.ts +3 -3
  99. package/lib/exports.d.ts +3 -3
  100. package/lib/exports.js +3 -2
  101. package/lib/exports.js.map +1 -1
  102. package/lib/plugins/edge-bundling/index.d.ts +97 -0
  103. package/lib/plugins/edge-bundling/index.js +256 -0
  104. package/lib/plugins/edge-bundling/index.js.map +1 -0
  105. package/lib/plugins/index.d.ts +2 -0
  106. package/lib/plugins/index.js +3 -1
  107. package/lib/plugins/index.js.map +1 -1
  108. package/lib/registry/build-in.js +2 -0
  109. package/lib/registry/build-in.js.map +1 -1
  110. package/lib/runtime/behavior.js +1 -1
  111. package/lib/runtime/behavior.js.map +1 -1
  112. package/lib/runtime/data.d.ts +1 -1
  113. package/lib/runtime/element.d.ts +1 -1
  114. package/lib/runtime/viewport.d.ts +3 -1
  115. package/lib/runtime/viewport.js +12 -3
  116. package/lib/runtime/viewport.js.map +1 -1
  117. package/lib/transforms/collapse-expand-combo.js +0 -1
  118. package/lib/transforms/collapse-expand-combo.js.map +1 -1
  119. package/lib/transforms/map-node-size.d.ts +12 -21
  120. package/lib/transforms/map-node-size.js +33 -177
  121. package/lib/transforms/map-node-size.js.map +1 -1
  122. package/lib/transforms/process-parallel-edges.d.ts +4 -0
  123. package/lib/transforms/process-parallel-edges.js +41 -37
  124. package/lib/transforms/process-parallel-edges.js.map +1 -1
  125. package/lib/transforms/utils.d.ts +9 -0
  126. package/lib/transforms/utils.js +12 -0
  127. package/lib/transforms/utils.js.map +1 -1
  128. package/lib/types/centrality.d.ts +20 -0
  129. package/lib/types/centrality.js +3 -0
  130. package/lib/types/centrality.js.map +1 -0
  131. package/lib/types/index.d.ts +1 -0
  132. package/lib/utils/animation.d.ts +1 -1
  133. package/lib/utils/bbox.d.ts +9 -0
  134. package/lib/utils/bbox.js +16 -0
  135. package/lib/utils/bbox.js.map +1 -1
  136. package/lib/utils/centrality.d.ts +53 -0
  137. package/lib/utils/centrality.js +187 -0
  138. package/lib/utils/centrality.js.map +1 -0
  139. package/lib/utils/padding.d.ts +16 -0
  140. package/lib/utils/padding.js +24 -0
  141. package/lib/utils/padding.js.map +1 -1
  142. package/lib/utils/transform.d.ts +0 -13
  143. package/lib/utils/transform.js +0 -25
  144. package/lib/utils/transform.js.map +1 -1
  145. package/lib/version.d.ts +1 -1
  146. package/lib/version.js +1 -1
  147. package/package.json +1 -1
  148. package/src/behaviors/auto-adapt-label.ts +255 -0
  149. package/src/behaviors/create-edge.ts +4 -1
  150. package/src/behaviors/fix-element-size.ts +213 -83
  151. package/src/behaviors/hover-activate.ts +5 -4
  152. package/src/behaviors/index.ts +2 -0
  153. package/src/behaviors/optimize-viewport-transform.ts +3 -3
  154. package/src/exports.ts +3 -0
  155. package/src/plugins/edge-bundling/index.ts +373 -0
  156. package/src/plugins/index.ts +2 -0
  157. package/src/registry/build-in.ts +4 -0
  158. package/src/runtime/behavior.ts +1 -0
  159. package/src/runtime/viewport.ts +14 -4
  160. package/src/transforms/collapse-expand-combo.ts +0 -1
  161. package/src/transforms/map-node-size.ts +52 -209
  162. package/src/transforms/process-parallel-edges.ts +50 -41
  163. package/src/transforms/utils.ts +12 -0
  164. package/src/types/centrality.ts +8 -0
  165. package/src/types/index.ts +1 -0
  166. package/src/utils/bbox.ts +17 -0
  167. package/src/utils/centrality.ts +209 -0
  168. package/src/utils/padding.ts +24 -0
  169. package/src/utils/transform.ts +0 -32
  170. package/src/version.ts +1 -1
@@ -0,0 +1,99 @@
1
+ import type { RuntimeContext } from '../runtime/types';
2
+ import type { ComboData, EdgeData, NodeData } from '../spec';
3
+ import type { Element, ElementDatum, IEvent, NodeCentralityOptions, Padding } from '../types';
4
+ import type { BaseBehaviorOptions } from './base-behavior';
5
+ import { BaseBehavior } from './base-behavior';
6
+ /**
7
+ * <zh/> 标签自适应显示配置项
8
+ *
9
+ * <en/> Auto Adapt Label Options
10
+ */
11
+ export interface AutoAdaptLabelOptions extends BaseBehaviorOptions {
12
+ /**
13
+ * <zh/> 是否启用
14
+ *
15
+ * <en/> Whether to enable
16
+ * @defaultValue `true`
17
+ */
18
+ enable?: boolean | ((event: IEvent) => boolean);
19
+ /**
20
+ * <zh/> 根据元素的重要性从高到低排序,重要性越高的元素其标签显示优先级越高。一般情况下 combo > node > edge
21
+ *
22
+ * <en/> Sort elements by their importance in descending order; elements with higher importance have higher label display priority; usually combo > node > edge
23
+ */
24
+ sort?: (elementA: ElementDatum, elementB: ElementDatum) => -1 | 0 | 1;
25
+ /**
26
+ * <zh/> 根据节点的重要性从高到低排序,重要性越高的节点其标签显示优先级越高。内置几种中心性算法,也可以自定义排序函数。需要注意,如果设置了 `sort`,则 `sortNode` 不会生效
27
+ *
28
+ * <en/> Sort nodes by importance in descending order; nodes with higher importance have higher label display priority. Several centrality algorithms are built in, and custom sorting functions can also be defined. It should be noted that if `sort` is set, `sortNode` will not take effect
29
+ * @defaultValue { type: 'degree' }
30
+ */
31
+ sortNode?: NodeCentralityOptions | ((nodeA: NodeData, nodeB: NodeData) => -1 | 0 | 1);
32
+ /**
33
+ * <zh/> 根据边的重要性从高到低排序,重要性越高的边其标签显示优先级越高。默认按照数据先后进行排序。需要注意,如果设置了 `sort`,则 `sortEdge` 不会生效
34
+ *
35
+ * <en/> Sort edges by importance in descending order; edges with higher importance have higher label display priority. By default, they are sorted according to the data. It should be noted that if `sort` is set, `sortEdge` will not take effect
36
+ */
37
+ sortEdge?: (edgeA: EdgeData, edgeB: EdgeData) => -1 | 0 | 1;
38
+ /**
39
+ * <zh/> 根据群组的重要性从高到低排序,重要性越高的群组其标签显示优先级越高。默认按照数据先后进行排序。需要注意,如果设置了 `sort`,则 `sortCombo` 不会生效
40
+ *
41
+ * <en/> Sort combos by importance in descending order; combos with higher importance have higher label display priority. By default, they are sorted according to the data. It should be noted that if `sort` is set, `sortCombo` will not take effect
42
+ */
43
+ sortCombo?: (comboA: ComboData, comboB: ComboData) => -1 | 0 | 1;
44
+ /**
45
+ * <zh/> 设置标签的内边距,用于判断标签是否重叠,以避免标签显示过于密集
46
+ *
47
+ * <en/> Set the padding of the label to determine whether the label overlaps to avoid the label being displayed too densely
48
+ * @defaultValue 0
49
+ */
50
+ padding?: Padding;
51
+ /**
52
+ * <zh/> 节流时间
53
+ *
54
+ * <en/> Throttle time
55
+ * @defaultValue 32
56
+ */
57
+ throttle?: number;
58
+ }
59
+ /**
60
+ * <zh/> 标签自适应显示
61
+ *
62
+ * <en/> Auto Adapt Label
63
+ * @remarks
64
+ * <zh/> 标签自适应显示是一种动态标签管理策略,旨在根据当前可视范围的空间分配、节点重要性等因素,智能调整哪些标签应显示或隐藏。通过对可视区域的实时分析,确保用户在不同的交互场景下获得最相关最清晰的信息展示,同时避免视觉过载和信息冗余。
65
+ *
66
+ * <en/ >Label Adaptive Display is a dynamic label management strategy designed to intelligently adjust which labels should be shown or hidden based on factors such as the spatial allocation of the current viewport and node importance. By analyzing the visible area in real-time, it ensures that users receive the most relevant and clear information display in various interactive scenarios, while avoiding visual overload and information redundancy.
67
+ */
68
+ export declare class AutoAdaptLabel extends BaseBehavior<AutoAdaptLabelOptions> {
69
+ static defaultOptions: Partial<AutoAdaptLabelOptions>;
70
+ constructor(context: RuntimeContext, options: AutoAdaptLabelOptions);
71
+ update(options: Partial<AutoAdaptLabelOptions>): void;
72
+ /**
73
+ * <zh/> 检查当前包围盒是否有足够的空间进行展示;如果与已经展示的包围盒有重叠,则不会展示
74
+ *
75
+ * <en/> Check whether the current bounding box has enough space to display; if it overlaps with the displayed bounding box, it will not be displayed
76
+ * @param bbox - bbox
77
+ * @param bboxes - occupied bboxes which are already shown
78
+ * @returns whether the bbox is overlapping with the bboxes or outside the viewpointBounds
79
+ */
80
+ private isOverlapping;
81
+ private occupiedBounds;
82
+ private detectLabelCollision;
83
+ private get labelElements();
84
+ private getLabelElementsInView;
85
+ private hideLabelIfExceedViewport;
86
+ private nodeCentralities;
87
+ private sortNodesByCentrality;
88
+ protected sortLabelElementsInView: (labelElements: Element[]) => Element[];
89
+ private labelElementsInView;
90
+ protected onToggleVisibility: (event: IEvent) => void;
91
+ private hiddenElements;
92
+ private hideLabel;
93
+ private showLabel;
94
+ protected onTransform: () => void;
95
+ private bindEvents;
96
+ private unbindEvents;
97
+ private validate;
98
+ destroy(): void;
99
+ }
@@ -1,21 +1,22 @@
1
1
  import type { DisplayObject } from '@antv/g';
2
2
  import type { RuntimeContext } from '../runtime/types';
3
+ import type { ComboData, EdgeData, NodeData } from '../spec';
3
4
  import type { IViewportEvent, State } from '../types';
4
5
  import type { BaseBehaviorOptions } from './base-behavior';
5
6
  import { BaseBehavior } from './base-behavior';
6
7
  export type FixShapeConfig = {
7
8
  /**
8
- * <zh/> 指定要固定大小的元素属性对应的图形。如果不指定,则固定整个元素
9
+ * <zh/> 指定要固定大小的图形,可以是图形的类名字,或者是一个函数,该函数接收构成元素的所有图形并返回目标图形
9
10
  *
10
- * <en/> Specify the shape corresponding to properties to be fixed in size. If not specified, fix the entire element
11
+ * <en/> Specify the shape to be fixed in size. This can be a class name string of the shape, or a function that takes all shapes composing the element and returns the target shape
11
12
  */
12
- shape: (shapes: DisplayObject[]) => DisplayObject;
13
+ shape: string | ((shapes: DisplayObject[]) => DisplayObject);
13
14
  /**
14
- * <zh/> 指定要固定大小的属性
15
+ * <zh/> 指定要固定大小的图形属性字段。如果未指定,则默认固定整个图形的大小
15
16
  *
16
- * <en/> Specify properties to be fixed
17
+ * <en/> Specify the fields of the shape to be fixed in size. If not specified, the entire shape's size will be fixed by default
17
18
  */
18
- fields: string[];
19
+ fields?: string[];
19
20
  };
20
21
  /**
21
22
  * <zh/> 固定元素大小交互配置项
@@ -27,32 +28,57 @@ export interface FixElementSizeOptions extends BaseBehaviorOptions {
27
28
  * <zh/> 是否启用固定元素大小交互。默认在缩小画布时启用
28
29
  *
29
30
  * <en/> Whether to enable the fix element size behavior. Enabled by default when zooming out
30
- * @defaultValue `(event) => Boolean(event.data.scale < 1)`
31
+ * @remarks
32
+ * <zh/> 默认在缩小画布时启用,设置 `enable: (event) => event.data.scale < 1`;如果希望在放大画布时启用,设置 `enable: (event) => event.data.scale > 1`;如果希望在放大缩小画布时都启用,设置 `enable: true`
33
+ *
34
+ * <en/> Enabled by default when zooming out, set `enable: (event) => event.data.scale < 1`; If you want to enable it when zooming in, set `enable: (event) => event.data.scale > 1`; If you want to enable it when zooming in and out, set `enable: true`
35
+ * @defaultValue (event) => Boolean(event.data.scale < 1)
31
36
  */
32
37
  enable?: boolean | ((event: IViewportEvent) => boolean);
33
38
  /**
34
39
  * <zh/> 指定要固定大小的元素状态
35
40
  *
36
41
  * <en/> Specify the state of elements to be fixed in size
42
+ * @defaultValue `'selected'`
37
43
  */
38
44
  state?: State;
45
+ /**
46
+ * <zh/> 节点过滤器,用于过滤哪些节点在缩放过程中保持固定大小
47
+ *
48
+ * <en/> Node filter for filtering which nodes remain fixed in size during zooming
49
+ * @defaultValue () => true
50
+ */
51
+ nodeFilter?: (datum: NodeData) => boolean;
52
+ /**
53
+ * <zh/> 边过滤器,用于过滤哪些边在缩放过程中保持固定大小
54
+ *
55
+ * <en/> Edge filter for filtering which edges remain fixed in size during zooming
56
+ * @defaultValue () => true
57
+ */
58
+ edgeFilter?: (datum: EdgeData) => boolean;
59
+ /**
60
+ * <zh/> Combo 过滤器,用于过滤哪些 Combo 在缩放过程中保持固定大小
61
+ *
62
+ * <en/> Combo filter for filtering which combos remain fixed in size during zooming
63
+ * @defaultValue () => true
64
+ */
65
+ comboFilter?: (datum: ComboData) => boolean;
39
66
  /**
40
67
  * <zh/> 节点配置项,用于定义哪些属性在视觉上保持固定大小。若未指定(即为 undefined),则整个节点将被固定
41
68
  *
42
69
  * <en/> Node configuration for defining which node attributes should remain fixed in size visually. If not specified (i.e., undefined), the entire node will be fixed in size.
43
70
  * @example
44
- * <zh/> 例如,在缩放过程中固定节点的 lineWidth 属性,可以配置如下:
71
+ * <zh/> 如果在缩放过程中希望固定节点主图形的 lineWidth,可以这样配置:
72
+ *
73
+ * <en/> If you want to fix the lineWidth of the key shape of the node during zooming, you can configure it like this:
74
+ * ```ts
75
+ * { node: [{ shape: 'key', fields: ['lineWidth'] }] }
76
+ *```
77
+ * <zh/> 如果在缩放过程中想保持元素标签大小不变,可以这样配置:
45
78
  *
46
- * <en/> For example, to fix `lineWidth` attribute of a node during zooming, you can configure it as follows:
79
+ * <en/> If you want to keep the label size of the element unchanged during zooming, you can configure it like this:
47
80
  * ```ts
48
- * {
49
- * node: [
50
- * {
51
- * shape: (shapes: DisplayObject[]) => shapes.find((shape) => shape.className === 'key'),
52
- * fields: ['lineWidth'],
53
- * },
54
- * ],
55
- * }
81
+ * { shape: 'label' }
56
82
  * ```
57
83
  */
58
84
  node?: FixShapeConfig | FixShapeConfig[];
@@ -60,6 +86,7 @@ export interface FixElementSizeOptions extends BaseBehaviorOptions {
60
86
  * <zh/> 边配置项,用于定义哪些属性在视觉上保持固定大小。默认固定 lineWidth、labelFontSize 属性
61
87
  *
62
88
  * <en/> Edge configuration for defining which edge attributes should remain fixed in size visually. By default, the lineWidth and labelFontSize attributes are fixed
89
+ * @defaultValue [{ shape: 'key', fields: ['lineWidth'] }, { shape: 'halo', fields: ['lineWidth'] }, { shape: 'label' }]
63
90
  */
64
91
  edge?: FixShapeConfig | FixShapeConfig[];
65
92
  /**
@@ -68,18 +95,35 @@ export interface FixElementSizeOptions extends BaseBehaviorOptions {
68
95
  * <en/> Combo configuration for defining which combo attributes should remain fixed in size visually. By default, the entire combo will be fixed
69
96
  */
70
97
  combo?: FixShapeConfig | FixShapeConfig[];
98
+ /**
99
+ * <zh/> 元素重绘时是否还原样式
100
+ *
101
+ * <en/> Whether to reset styles when elements are redrawn
102
+ * @defaultValue false
103
+ */
104
+ reset?: boolean;
71
105
  }
72
106
  /**
73
107
  * <zh/> 缩放画布过程中固定元素大小
74
108
  *
75
109
  * <en/> Fix element size while zooming
76
110
  */
77
- export declare class FixElementSize extends BaseBehavior {
111
+ export declare class FixElementSize extends BaseBehavior<FixElementSizeOptions> {
78
112
  static defaultOptions: Partial<FixElementSizeOptions>;
79
- private elementCache;
80
113
  constructor(context: RuntimeContext, options: FixElementSizeOptions);
81
114
  private isZoomEvent;
115
+ private relatedEdgeToUpdate;
116
+ private zoom;
82
117
  private fixElementSize;
118
+ private cachedStyles;
119
+ private getOriginalFieldValue;
120
+ private scaleEntireElement;
121
+ private scaleSpecificShapes;
122
+ private skipIfExceedViewport;
123
+ private fixNodeLike;
124
+ private fixEdge;
125
+ private updateRelatedEdges;
126
+ private restoreCachedStyles;
83
127
  private resetTransform;
84
128
  private bindEvents;
85
129
  private unbindEvents;
@@ -1,3 +1,4 @@
1
+ export { AutoAdaptLabel } from './auto-adapt-label';
1
2
  export { BaseBehavior } from './base-behavior';
2
3
  export { BrushSelect } from './brush-select';
3
4
  export { ClickSelect } from './click-select';
@@ -13,6 +14,7 @@ export { LassoSelect } from './lasso-select';
13
14
  export { OptimizeViewportTransform } from './optimize-viewport-transform';
14
15
  export { ScrollCanvas } from './scroll-canvas';
15
16
  export { ZoomCanvas } from './zoom-canvas';
17
+ export type { AutoAdaptLabelOptions } from './auto-adapt-label';
16
18
  export type { BaseBehaviorOptions } from './base-behavior';
17
19
  export type { BrushSelectOptions } from './brush-select';
18
20
  export type { ClickSelectOptions } from './click-select';
@@ -16,10 +16,10 @@ export interface OptimizeViewportTransformOptions extends BaseBehaviorOptions {
16
16
  */
17
17
  enable?: boolean | ((event: IViewportEvent) => boolean);
18
18
  /**
19
- * <zh/> 始终保留的图形类名。操作画布过程中会隐藏元素reservedShapes(除了指定类名的图形),以提高性能
19
+ * <zh/> 在画布操作过程中,元素会被隐藏以提高性能。通过设置 `shapes` 配置项,可以保留指定类名的子图形不被隐藏,从而保留整个元素的部分可见性
20
20
  *
21
- * <en/> Persistently reserved shape classnames. Elements are hidden during canvas manipulation (except for shapes with specified classnames) to enhance performance.
22
- * @defaultValue `{ node: ['key'] }`
21
+ * <en/> During canvas operations, elements are hidden to improve performance. By configuring the `shapes` option, specific sub-elements with designated class names can be retained, thereby maintaining partial visibility of the entire element.
22
+ * @defaultValue { node: ['key'] }
23
23
  */
24
24
  shapes?: {
25
25
  node?: string[];
@@ -6,7 +6,7 @@ export { effect } from './elements/effect';
6
6
  export { BaseNode, Circle, Diamond, Donut, Ellipse, HTML, Hexagon, Image, Rect, Star, Triangle, } from './elements/nodes';
7
7
  export { Badge, BaseShape, Icon, Label } from './elements/shapes';
8
8
  export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, compactBox as CompactBoxLayout, ConcentricLayout, D3ForceLayout, DagreLayout, dendrogram as DendrogramLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, indented as IndentedLayout, MDSLayout, mindmap as MindmapLayout, RadialLayout, RandomLayout, } from './layouts';
9
- export { Background, BasePlugin, BubbleSets, CameraSetting, Contextmenu, EdgeFilterLens, Fisheye, Fullscreen, GridLine, History, Hull, Legend, Minimap, Snapline, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
9
+ export { Background, BasePlugin, BubbleSets, CameraSetting, Contextmenu, EdgeBundling, EdgeFilterLens, Fisheye, Fullscreen, GridLine, History, Hull, Legend, Minimap, Snapline, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
10
10
  export { getExtension, getExtensions } from './registry/get';
11
11
  export { register } from './registry/register';
12
12
  export { Graph } from './runtime/graph';
@@ -34,7 +34,7 @@ export type { UpsertHooks } from './elements/shapes/base-shape';
34
34
  export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shapes/contour';
35
35
  export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
36
36
  export type { CategoricalPalette } from './palettes/types';
37
- export type { BackgroundOptions, BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, EdgeFilterLensOptions, FisheyeOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, SnaplineOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
37
+ export type { BackgroundOptions, BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, EdgeBundlingOptions, EdgeFilterLensOptions, FisheyeOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, SnaplineOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
38
38
  export type { DataURLOptions } from './runtime/canvas';
39
39
  export type { RuntimeContext } from './runtime/types';
40
40
  export type { BehaviorOptions, CanvasOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, GraphData, GraphOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions, ViewportOptions, } from './spec';
@@ -44,6 +44,6 @@ export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spe
44
44
  export type { CustomPluginOption } from './spec/plugin';
45
45
  export type { BaseTransformOptions, MapNodeSizeOptions, PlaceRadialLabelsOptions, ProcessParallelEdgesOptions, } from './transforms';
46
46
  export type { DrawData } from './transforms/types';
47
- export type { BaseElementStyleProps, CardinalPlacement, CollapsedMarkerStyleProps, Combo, CornerPlacement, DirectionalPlacement, Edge, EdgeArrowStyleProps, EdgeDirection, EdgeLabelStyleProps, Element, ElementDatum, ElementHooks, ElementMethods, ElementType, FitViewOptions, HierarchyKey, IAnimateEvent, ID, IDragEvent, IElementDragEvent, IElementEvent, IElementLifeCycleEvent, IEvent, IGraphLifeCycleEvent, IKeyboardEvent, IPointerEvent, IViewportEvent, IWheelEvent, LoopPlacement, LoopStyleProps, Node, NodeBadgeStyleProps, NodeLabelStyleProps, NodeLikeData, NodePortStyleProps, Padding, Placement, Point, PortStyleProps, Prefix, PrefixKey, RelativePlacement, Size, State, TransformOptions, TreeData, TriangleDirection, Vector2, Vector3, ViewportAnimationEffectTiming, } from './types';
47
+ export type { BaseElementStyleProps, CardinalPlacement, CollapsedMarkerStyleProps, Combo, CornerPlacement, DirectionalPlacement, Edge, EdgeArrowStyleProps, EdgeDirection, EdgeLabelStyleProps, Element, ElementDatum, ElementHooks, ElementMethods, ElementType, FitViewOptions, HierarchyKey, IAnimateEvent, ID, IDragEvent, IElementDragEvent, IElementEvent, IElementLifeCycleEvent, IEvent, IGraphLifeCycleEvent, IKeyboardEvent, IPointerEvent, IViewportEvent, IWheelEvent, LoopPlacement, LoopStyleProps, Node, NodeBadgeStyleProps, NodeCentralityOptions, NodeLabelStyleProps, NodeLikeData, NodePortStyleProps, Padding, Placement, Point, PortStyleProps, Prefix, PrefixKey, RelativePlacement, Size, State, TransformOptions, TreeData, TriangleDirection, Vector2, Vector3, ViewportAnimationEffectTiming, } from './types';
48
48
  export type { Command, CommandData } from './types/history';
49
49
  export type { ShortcutKey } from './utils/shortcut';
@@ -0,0 +1,97 @@
1
+ import type { RuntimeContext } from '../../runtime/types';
2
+ import type { BasePluginOptions } from '../base-plugin';
3
+ import { BasePlugin } from '../base-plugin';
4
+ /**
5
+ * <zh/> 边绑定插件的配置项
6
+ *
7
+ * <en/> Edge bundling options
8
+ */
9
+ export interface EdgeBundlingOptions extends BasePluginOptions {
10
+ /**
11
+ * <zh/> 边的强度
12
+ *
13
+ * <en/> The strength of the edge
14
+ * @defaultValue 0.1
15
+ */
16
+ K?: number;
17
+ /**
18
+ * <zh/> 初始步长。在后续的周期中,步长将双倍递增
19
+ *
20
+ * <en/> An initial step size. In subsequent cycles, the step size will double incrementally
21
+ * @defaultValue 0.1
22
+ */
23
+ lambda?: number;
24
+ /**
25
+ * <zh/> 模拟周期数
26
+ *
27
+ * <en/> The number of simulation cycles
28
+ * @defaultValue 6
29
+ */
30
+ cycles?: number;
31
+ /**
32
+ * <zh/> 初始切割点数。在后续的周期中,切割点数将根据 `divRate` 逐步递增
33
+ *
34
+ * <en/> An initial number of subdivision points for each edge. In subsequent cycles, the number of subdivision points will increase gradually according to `divRate`
35
+ * @defaultValue 1
36
+ */
37
+ divisions?: number;
38
+ /**
39
+ * <zh/> 切割点数增长率
40
+ *
41
+ * <en/> The rate at which the number of subdivision points increases
42
+ * @defaultValue 2
43
+ */
44
+ divRate?: number;
45
+ /**
46
+ * <zh/> 指定在第一个周期中执行的迭代次数。在后续的周期中,迭代次数将根据 `iterRate` 逐步递减
47
+ *
48
+ * <en/> The number of iteration steps during the first cycle. In subsequent cycles, the number of iterations will decrease gradually according to `iterRate`
49
+ * @defaultValue 90
50
+ */
51
+ iterations?: number;
52
+ /**
53
+ * <zh/> 迭代次数递减率
54
+ *
55
+ * <en/> The rate at which the number of iterations decreases
56
+ * @defaultValue 2 / 3
57
+ */
58
+ iterRate?: number;
59
+ /**
60
+ * <zh/> 边兼容性阈值,决定了哪些边应该被绑定在一起
61
+ *
62
+ * <en/> Edge compatibility threshold, which determines which edges should be bundled together
63
+ * @defaultValue 0.6
64
+ */
65
+ bundleThreshold?: number;
66
+ }
67
+ /**
68
+ * <zh/> 边绑定
69
+ *
70
+ * <en/> Edge bundling
71
+ * @remarks
72
+ * <zh/> 边绑定(Edge Bundling)是一种图可视化技术,用于减少复杂网络图中的视觉混乱,并揭示图中的高级别模式和结构。其思想是将相邻的边捆绑在一起。
73
+ *
74
+ * <zh/> G6 中提供的边绑定插件是基于 FEDB(Force-Directed Edge Bundling for Graph Visualization)一文的实现:将边建模为可以相互吸引的柔性弹簧,通过自组织的方式进行捆绑。
75
+ *
76
+ * <en/> Edge bundling is a graph visualization technique used to reduce visual clutter in complex network graphs and reveal high-level patterns and structures in the graph. The idea is to bundle adjacent edges together.
77
+ *
78
+ * <en/> The edge bundling plugin provided in G6 is based on the implementation of the paper FEDB (Force-Directed Edge Bundling for Graph Visualization): modeling edges as flexible springs that can attract each other and bundling them in a self-organizing way.
79
+ */
80
+ export declare class EdgeBundling extends BasePlugin<EdgeBundlingOptions> {
81
+ static defaultOptions: Partial<EdgeBundlingOptions>;
82
+ constructor(context: RuntimeContext, options?: EdgeBundlingOptions);
83
+ private edgeBundles;
84
+ private edgePoints;
85
+ private get nodeMap();
86
+ private divideEdges;
87
+ private getVectorPosition;
88
+ private measureEdgeCompatibility;
89
+ private getEdgeBundles;
90
+ private getSpringForce;
91
+ private getElectrostaticForce;
92
+ private getEdgeForces;
93
+ protected onBundle: () => void;
94
+ private bindEvents;
95
+ private unbindEvents;
96
+ destroy(): void;
97
+ }
@@ -3,6 +3,7 @@ export { BasePlugin } from './base-plugin';
3
3
  export { BubbleSets } from './bubble-sets';
4
4
  export { CameraSetting } from './camera-setting';
5
5
  export { Contextmenu } from './contextmenu';
6
+ export { EdgeBundling } from './edge-bundling';
6
7
  export { EdgeFilterLens } from './edge-filter-lens';
7
8
  export { Fisheye } from './fisheye';
8
9
  export { Fullscreen } from './fullscreen';
@@ -21,6 +22,7 @@ export type { BasePluginOptions } from './base-plugin';
21
22
  export type { BubbleSetsOptions } from './bubble-sets';
22
23
  export type { CameraSettingOptions } from './camera-setting';
23
24
  export type { ContextmenuOptions } from './contextmenu';
25
+ export type { EdgeBundlingOptions } from './edge-bundling';
24
26
  export type { EdgeFilterLensOptions } from './edge-filter-lens';
25
27
  export type { FisheyeOptions } from './fisheye';
26
28
  export type { FullscreenOptions } from './fullscreen';
@@ -105,7 +105,7 @@ export declare class DataController {
105
105
  * @returns <zh/> 节点和 combo 的数据 | <en/> node and combo data
106
106
  */
107
107
  getNodeLikeData(ids?: ID[]): NodeLikeData[];
108
- getElementDataByState(elementType: ElementType, state: string): (NodeData | ComboData | EdgeData)[];
108
+ getElementDataByState(elementType: ElementType, state: string): (NodeData | EdgeData | ComboData)[];
109
109
  getElementState(id: ID): State[];
110
110
  hasNode(id: ID): boolean;
111
111
  hasEdge(id: ID): boolean;
@@ -13,7 +13,7 @@ export declare class ElementController {
13
13
  private forEachElementData;
14
14
  getElementType(elementType: ElementType, datum: ElementDatum): string;
15
15
  private getTheme;
16
- getThemeStyle(elementType: ElementType): import("../spec/element/node").NodeStyle | import("../spec/element/combo").ComboStyle | import("../spec/element/edge").EdgeStyle;
16
+ getThemeStyle(elementType: ElementType): import("../spec/element/node").NodeStyle | import("../spec/element/edge").EdgeStyle | import("../spec/element/combo").ComboStyle;
17
17
  getThemeStateStyle(elementType: ElementType, states: State[]): any;
18
18
  private paletteStyle;
19
19
  private computePaletteStyle;
@@ -58,8 +58,10 @@ export declare class ViewportController {
58
58
  *
59
59
  * <en/> Determine whether the point or bounding box is in the viewport
60
60
  * @param target - <zh/> 点或包围盒 | <en/> Point or bounding box
61
+ * @param complete - <zh/> 是否完全在视口中 | <en/> Whether it is completely in the viewport
62
+ * @param tolerance - <zh/> 视口外的容差 | <en/> Tolerance outside the viewport
61
63
  * @returns - <zh/> 是否在视口中 | <en/> Whether it is in the viewport
62
64
  */
63
- isInViewport(target: Point | AABB): boolean;
65
+ isInViewport(target: Point | AABB, complete?: boolean, tolerance?: number): boolean;
64
66
  cancelAnimation(): void;
65
67
  }
@@ -1,6 +1,6 @@
1
1
  import type { RuntimeContext } from '../runtime/types';
2
2
  import type { GraphData } from '../spec';
3
- import type { EdgeDirection, ID, Size } from '../types';
3
+ import type { ID, NodeCentralityOptions, Size } from '../types';
4
4
  import type { BaseTransformOptions } from './base-transform';
5
5
  import { BaseTransform } from './base-transform';
6
6
  import type { DrawData } from './types';
@@ -23,25 +23,7 @@ export interface MapNodeSizeOptions extends BaseTransformOptions {
23
23
  * - Custom centrality calculation method: `(graphData: GraphData) => Map<ID, number>`, where `graphData` is the graph data, and `Map<ID, number>` is the mapping from node ID to centrality value
24
24
  * @defaultValue { type: 'eigenvector' }
25
25
  */
26
- centrality?: {
27
- type: 'degree';
28
- direction?: EdgeDirection;
29
- } | {
30
- type: 'betweenness';
31
- directed?: boolean;
32
- weightPropertyName?: string;
33
- } | {
34
- type: 'closeness';
35
- directed?: boolean;
36
- weightPropertyName?: string;
37
- } | {
38
- type: 'eigenvector';
39
- directed?: boolean;
40
- } | {
41
- type: 'pagerank';
42
- epsilon?: number;
43
- linkProb?: number;
44
- } | ((graphData: GraphData) => Map<ID, number>);
26
+ centrality?: NodeCentralityOptions | ((graphData: GraphData) => Map<ID, number>);
45
27
  /**
46
28
  * <zh/> 节点最大尺寸
47
29
  *
@@ -73,9 +55,16 @@ export interface MapNodeSizeOptions extends BaseTransformOptions {
73
55
  * @defaultValue 'log'
74
56
  */
75
57
  scale?: 'linear' | 'log' | 'pow' | 'sqrt' | ((value: number, domain: [number, number], range: [number, number]) => number);
58
+ /**
59
+ * <zh/> 是否同步调整标签大小
60
+ *
61
+ * <en/> Whether to map label size synchronously
62
+ * @defaultValue false
63
+ */
64
+ mapLabelSize?: boolean | [number, number];
76
65
  }
77
66
  /**
78
- * <zh/> 根据节点中心性调整节点的大小
67
+ * <zh/> 根据节点重要性调整节点的大小
79
68
  *
80
69
  * <en/> Map node size based on node importance
81
70
  * @remarks
@@ -87,6 +76,8 @@ export declare class MapNodeSize extends BaseTransform<MapNodeSizeOptions> {
87
76
  static defaultOptions: Partial<MapNodeSizeOptions>;
88
77
  constructor(context: RuntimeContext, options: MapNodeSizeOptions);
89
78
  beforeDraw(input: DrawData): DrawData;
79
+ private assignLabelStyle;
80
+ private getLabelSizeByNodeSize;
90
81
  private getCentralities;
91
82
  private assignSizeByCentrality;
92
83
  }
@@ -40,6 +40,10 @@ export interface ProcessParallelEdgesOptions extends BaseTransformOptions {
40
40
  * <zh/> 处理平行边,即多条边共享同一源节点和目标节点
41
41
  *
42
42
  * <en/> Process parallel edges which share the same source and target nodes
43
+ * @remarks
44
+ * <zh/> 平行边(Parallel Edges)是指在图结构中,两个节点之间存在多条边。这些边共享相同的源节点和目标节点,但可能代表不同的关系或属性。为了避免边的重叠和混淆,提供了两种处理平行边的方式:(1) 捆绑模式(bundle):将平行边捆绑在一起,通过改变曲率与其他边分开;(2) 合并模式(merge):将平行边合并为一条聚合。
45
+ *
46
+ * <en/> Parallel Edges refer to multiple edges existing between two nodes in a graph structure. These edges share the same source and target nodes but may represent different relationships or attributes. To avoid edge overlap and confusion, two methods are provided for handling parallel edges: (1) Bundle Mode: Bundles parallel edges together and separates them from other edges by altering their curvature; (2) Merge Mode: Merges parallel edges into a single aggregated edge.
43
47
  */
44
48
  export declare class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOptions> {
45
49
  static defaultOptions: Partial<ProcessParallelEdgesOptions>;
@@ -11,3 +11,12 @@ import type { DrawData } from './types';
11
11
  * @param overwrite - <zh/>是否覆盖现有数据 | <en/>whether to overwrite existing data
12
12
  */
13
13
  export declare function reassignTo(input: DrawData, type: 'add' | 'update' | 'remove', elementType: ElementType, datum: ElementDatum, overwrite?: boolean): void;
14
+ /**
15
+ * <zh/> 判断样式是否与原始样式一致
16
+ *
17
+ * <en/> Determine whether the style is consistent with the original style
18
+ * @param style - <zh/> 样式 | <en/> style
19
+ * @param originalStyle - <zh/> 原始样式 | <en/> original style
20
+ * @returns <zh/> 是否一致 | <en/> Whether it is consistent
21
+ */
22
+ export declare function isStyleEqual(style: Record<string, unknown>, originalStyle: Record<string, unknown>): boolean;
@@ -0,0 +1,20 @@
1
+ import type { EdgeDirection } from './edge';
2
+ export type NodeCentralityOptions = {
3
+ type: 'degree';
4
+ direction?: EdgeDirection;
5
+ } | {
6
+ type: 'betweenness';
7
+ directed?: boolean;
8
+ weightPropertyName?: string;
9
+ } | {
10
+ type: 'closeness';
11
+ directed?: boolean;
12
+ weightPropertyName?: string;
13
+ } | {
14
+ type: 'eigenvector';
15
+ directed?: boolean;
16
+ } | {
17
+ type: 'pagerank';
18
+ epsilon?: number;
19
+ linkProb?: number;
20
+ };
@@ -1,6 +1,7 @@
1
1
  export type * from './anchor';
2
2
  export type * from './animation';
3
3
  export type * from './canvas';
4
+ export type * from './centrality';
4
5
  export type * from './change';
5
6
  export type * from './combo';
6
7
  export type * from './data';
@@ -24,7 +24,7 @@ export declare function preprocessKeyframes(keyframes: Keyframe[]): Keyframe[];
24
24
  *
25
25
  * <en/> During the animation, some attributes do not explicitly specify the attribute value, but in fact there is an attribute value in G, so use this method to get the actual default value
26
26
  */
27
- export declare function inferDefaultValue(name: string): false | 0 | 1 | "visible" | never[] | undefined;
27
+ export declare function inferDefaultValue(name: string): false | "visible" | 0 | 1 | never[] | undefined;
28
28
  /**
29
29
  * <zh/> 获取动画配置
30
30
  *
@@ -56,6 +56,15 @@ export declare function getExpandedBBox(bbox: AABB, padding: Padding): AABB;
56
56
  * @returns <zh/> 整体包围盒 | <en/> Overall bounding box
57
57
  */
58
58
  export declare function getCombinedBBox(bboxes: AABB[]): AABB;
59
+ /**
60
+ * <zh/> 判断 bbox1 是否完全包含在 bbox2 内
61
+ *
62
+ * <en/> Determine whether bbox1 is completely contained in bbox2
63
+ * @param bbox1 - <zh/> 目标包围盒 | <en/> Target bounding box
64
+ * @param bbox2 - <zh/> 参考包围盒 | <en/> Reference bounding box
65
+ * @returns <zh/> 如果 bbox1 完全包含在 bbox2 内返回 true,否则返回 false | <en/> Returns true if bbox1 is completely contained in bbox2, false otherwise
66
+ */
67
+ export declare function isBBoxInside(bbox1: AABB, bbox2: AABB): boolean;
59
68
  /**
60
69
  * <zh/> 判断点是否在给定的包围盒内
61
70
  *