@antv/g6 5.0.32 → 5.0.34

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 (197) hide show
  1. package/README.md +33 -34
  2. package/README.zh-CN.md +117 -0
  3. package/dist/g6.min.js +29 -29
  4. package/dist/lib/behaviors/collapse-expand.d.ts +6 -0
  5. package/dist/lib/behaviors/drag-element.d.ts +1 -1
  6. package/dist/lib/behaviors/optimize-viewport-transform.d.ts +1 -1
  7. package/dist/lib/elements/edges/base-edge.d.ts +5 -5
  8. package/dist/lib/elements/nodes/base-node.d.ts +2 -0
  9. package/dist/lib/elements/nodes/html.d.ts +4 -0
  10. package/dist/lib/elements/shapes/base-shape.d.ts +2 -2
  11. package/dist/lib/exports.d.ts +3 -2
  12. package/dist/lib/layouts/fishbone.d.ts +2 -1
  13. package/dist/lib/layouts/index.d.ts +2 -0
  14. package/dist/lib/layouts/snake.d.ts +80 -0
  15. package/dist/lib/layouts/types.d.ts +3 -1
  16. package/dist/lib/plugins/minimap/index.d.ts +1 -1
  17. package/dist/lib/plugins/snapline/index.d.ts +1 -1
  18. package/dist/lib/runtime/data.d.ts +1 -1
  19. package/dist/lib/runtime/element.d.ts +29 -2
  20. package/dist/lib/runtime/graph.d.ts +11 -9
  21. package/dist/lib/runtime/viewport.d.ts +22 -2
  22. package/dist/lib/spec/canvas.d.ts +26 -2
  23. package/dist/lib/spec/data.d.ts +2 -2
  24. package/dist/lib/spec/graph.d.ts +60 -12
  25. package/dist/lib/spec/viewport.d.ts +4 -0
  26. package/dist/lib/utils/cache.d.ts +5 -5
  27. package/dist/lib/utils/event/events.d.ts +4 -4
  28. package/dist/lib/utils/id.d.ts +1 -1
  29. package/dist/lib/utils/style.d.ts +5 -5
  30. package/dist/lib/utils/visibility.d.ts +1 -2
  31. package/dist/lib/version.d.ts +1 -1
  32. package/esm/behaviors/collapse-expand.d.ts +6 -0
  33. package/esm/behaviors/collapse-expand.js +4 -3
  34. package/esm/behaviors/collapse-expand.js.map +1 -1
  35. package/esm/behaviors/drag-element.d.ts +1 -1
  36. package/esm/behaviors/optimize-viewport-transform.d.ts +1 -1
  37. package/esm/behaviors/optimize-viewport-transform.js +1 -1
  38. package/esm/behaviors/optimize-viewport-transform.js.map +1 -1
  39. package/esm/elements/edges/base-edge.d.ts +5 -5
  40. package/esm/elements/nodes/base-node.d.ts +2 -0
  41. package/esm/elements/nodes/base-node.js +2 -2
  42. package/esm/elements/nodes/base-node.js.map +1 -1
  43. package/esm/elements/nodes/html.d.ts +4 -0
  44. package/esm/elements/nodes/html.js +7 -0
  45. package/esm/elements/nodes/html.js.map +1 -1
  46. package/esm/elements/shapes/base-shape.d.ts +2 -2
  47. package/esm/elements/shapes/base-shape.js +3 -3
  48. package/esm/elements/shapes/base-shape.js.map +1 -1
  49. package/esm/exports.d.ts +3 -2
  50. package/esm/exports.js +1 -1
  51. package/esm/exports.js.map +1 -1
  52. package/esm/layouts/fishbone.d.ts +2 -1
  53. package/esm/layouts/fishbone.js +1 -1
  54. package/esm/layouts/fishbone.js.map +1 -1
  55. package/esm/layouts/index.d.ts +2 -0
  56. package/esm/layouts/index.js +1 -0
  57. package/esm/layouts/index.js.map +1 -1
  58. package/esm/layouts/snake.d.ts +80 -0
  59. package/esm/layouts/snake.js +162 -0
  60. package/esm/layouts/snake.js.map +1 -0
  61. package/esm/layouts/types.d.ts +3 -1
  62. package/esm/plugins/hull/util.js +6 -1
  63. package/esm/plugins/hull/util.js.map +1 -1
  64. package/esm/plugins/minimap/index.d.ts +1 -1
  65. package/esm/plugins/snapline/index.d.ts +1 -1
  66. package/esm/preset.js +0 -2
  67. package/esm/preset.js.map +1 -1
  68. package/esm/registry/build-in.js +2 -1
  69. package/esm/registry/build-in.js.map +1 -1
  70. package/esm/runtime/data.d.ts +1 -1
  71. package/esm/runtime/data.js +8 -3
  72. package/esm/runtime/data.js.map +1 -1
  73. package/esm/runtime/element.d.ts +29 -2
  74. package/esm/runtime/element.js +34 -4
  75. package/esm/runtime/element.js.map +1 -1
  76. package/esm/runtime/graph.d.ts +11 -9
  77. package/esm/runtime/graph.js +20 -15
  78. package/esm/runtime/graph.js.map +1 -1
  79. package/esm/runtime/viewport.d.ts +22 -2
  80. package/esm/runtime/viewport.js +12 -11
  81. package/esm/runtime/viewport.js.map +1 -1
  82. package/esm/spec/canvas.d.ts +26 -2
  83. package/esm/spec/data.d.ts +2 -2
  84. package/esm/spec/graph.d.ts +60 -12
  85. package/esm/spec/viewport.d.ts +4 -0
  86. package/esm/transforms/place-radial-labels.js +6 -1
  87. package/esm/transforms/place-radial-labels.js.map +1 -1
  88. package/esm/utils/cache.d.ts +5 -5
  89. package/esm/utils/cache.js +5 -5
  90. package/esm/utils/event/events.d.ts +4 -4
  91. package/esm/utils/id.d.ts +1 -1
  92. package/esm/utils/style.d.ts +5 -5
  93. package/esm/utils/style.js +5 -5
  94. package/esm/utils/visibility.d.ts +1 -2
  95. package/esm/utils/visibility.js +8 -34
  96. package/esm/utils/visibility.js.map +1 -1
  97. package/esm/version.d.ts +1 -1
  98. package/esm/version.js +1 -1
  99. package/lib/behaviors/collapse-expand.d.ts +6 -0
  100. package/lib/behaviors/collapse-expand.js +4 -3
  101. package/lib/behaviors/collapse-expand.js.map +1 -1
  102. package/lib/behaviors/drag-element.d.ts +1 -1
  103. package/lib/behaviors/optimize-viewport-transform.d.ts +1 -1
  104. package/lib/behaviors/optimize-viewport-transform.js +1 -1
  105. package/lib/behaviors/optimize-viewport-transform.js.map +1 -1
  106. package/lib/elements/edges/base-edge.d.ts +5 -5
  107. package/lib/elements/edges/base-edge.js +17 -7
  108. package/lib/elements/edges/base-edge.js.map +1 -1
  109. package/lib/elements/nodes/base-node.d.ts +2 -0
  110. package/lib/elements/nodes/base-node.js +2 -2
  111. package/lib/elements/nodes/base-node.js.map +1 -1
  112. package/lib/elements/nodes/html.d.ts +4 -0
  113. package/lib/elements/nodes/html.js +7 -0
  114. package/lib/elements/nodes/html.js.map +1 -1
  115. package/lib/elements/shapes/base-shape.d.ts +2 -2
  116. package/lib/elements/shapes/base-shape.js +3 -3
  117. package/lib/elements/shapes/base-shape.js.map +1 -1
  118. package/lib/exports.d.ts +3 -2
  119. package/lib/exports.js +3 -2
  120. package/lib/exports.js.map +1 -1
  121. package/lib/layouts/fishbone.d.ts +2 -1
  122. package/lib/layouts/fishbone.js +2 -2
  123. package/lib/layouts/fishbone.js.map +1 -1
  124. package/lib/layouts/index.d.ts +2 -0
  125. package/lib/layouts/index.js +3 -1
  126. package/lib/layouts/index.js.map +1 -1
  127. package/lib/layouts/snake.d.ts +80 -0
  128. package/lib/layouts/snake.js +166 -0
  129. package/lib/layouts/snake.js.map +1 -0
  130. package/lib/layouts/types.d.ts +3 -1
  131. package/lib/plugins/hull/util.js +5 -0
  132. package/lib/plugins/hull/util.js.map +1 -1
  133. package/lib/plugins/minimap/index.d.ts +1 -1
  134. package/lib/plugins/snapline/index.d.ts +1 -1
  135. package/lib/preset.js +0 -2
  136. package/lib/preset.js.map +1 -1
  137. package/lib/registry/build-in.js +1 -0
  138. package/lib/registry/build-in.js.map +1 -1
  139. package/lib/runtime/data.d.ts +1 -1
  140. package/lib/runtime/data.js +7 -2
  141. package/lib/runtime/data.js.map +1 -1
  142. package/lib/runtime/element.d.ts +29 -2
  143. package/lib/runtime/element.js +34 -4
  144. package/lib/runtime/element.js.map +1 -1
  145. package/lib/runtime/graph.d.ts +11 -9
  146. package/lib/runtime/graph.js +20 -15
  147. package/lib/runtime/graph.js.map +1 -1
  148. package/lib/runtime/viewport.d.ts +22 -2
  149. package/lib/runtime/viewport.js +12 -11
  150. package/lib/runtime/viewport.js.map +1 -1
  151. package/lib/spec/canvas.d.ts +26 -2
  152. package/lib/spec/data.d.ts +2 -2
  153. package/lib/spec/graph.d.ts +60 -12
  154. package/lib/spec/viewport.d.ts +4 -0
  155. package/lib/transforms/place-radial-labels.js +6 -1
  156. package/lib/transforms/place-radial-labels.js.map +1 -1
  157. package/lib/utils/cache.d.ts +5 -5
  158. package/lib/utils/cache.js +5 -5
  159. package/lib/utils/event/events.d.ts +4 -4
  160. package/lib/utils/id.d.ts +1 -1
  161. package/lib/utils/style.d.ts +5 -5
  162. package/lib/utils/style.js +5 -5
  163. package/lib/utils/visibility.d.ts +1 -2
  164. package/lib/utils/visibility.js +8 -34
  165. package/lib/utils/visibility.js.map +1 -1
  166. package/lib/version.d.ts +1 -1
  167. package/lib/version.js +1 -1
  168. package/package.json +8 -8
  169. package/src/behaviors/collapse-expand.ts +10 -3
  170. package/src/behaviors/optimize-viewport-transform.ts +2 -2
  171. package/src/elements/edges/base-edge.ts +5 -5
  172. package/src/elements/nodes/base-node.ts +4 -2
  173. package/src/elements/nodes/html.ts +9 -0
  174. package/src/elements/shapes/base-shape.ts +3 -3
  175. package/src/exports.ts +3 -1
  176. package/src/layouts/fishbone.ts +3 -2
  177. package/src/layouts/index.ts +3 -0
  178. package/src/layouts/snake.ts +235 -0
  179. package/src/layouts/types.ts +5 -1
  180. package/src/plugins/hull/util.ts +7 -1
  181. package/src/plugins/minimap/index.ts +1 -1
  182. package/src/preset.ts +0 -3
  183. package/src/registry/build-in.ts +2 -0
  184. package/src/runtime/data.ts +11 -4
  185. package/src/runtime/element.ts +51 -4
  186. package/src/runtime/graph.ts +21 -17
  187. package/src/runtime/viewport.ts +36 -10
  188. package/src/spec/canvas.ts +26 -2
  189. package/src/spec/data.ts +2 -2
  190. package/src/spec/graph.ts +60 -12
  191. package/src/spec/viewport.ts +4 -0
  192. package/src/transforms/place-radial-labels.ts +5 -1
  193. package/src/utils/cache.ts +5 -5
  194. package/src/utils/style.ts +5 -5
  195. package/src/utils/visibility.ts +6 -35
  196. package/src/version.ts +1 -1
  197. package/README.en-US.md +0 -118
@@ -42,6 +42,12 @@ export interface CollapseExpandOptions extends BaseBehaviorOptions {
42
42
  * <en/> Callback when expand is completed
43
43
  */
44
44
  onExpand?: (id: ID) => void;
45
+ /**
46
+ * <zh/> 是否对准目标元素,避免视图偏移
47
+ *
48
+ * <en/> Whether to focus on the target element to avoid view offset
49
+ */
50
+ align?: boolean;
45
51
  }
46
52
  /**
47
53
  * <zh/> 展开/收起元素交互
@@ -145,7 +145,7 @@ export declare class DragElement extends BaseBehavior<DragElementOptions> {
145
145
  * @returns delta
146
146
  * @internal
147
147
  */
148
- protected getDelta(event: IElementDragEvent): [number, number] | Float32Array | [number, number, number];
148
+ protected getDelta(event: IElementDragEvent): import("../types").Vector2 | import("../types").Vector3;
149
149
  /**
150
150
  * <zh/> 拖拽开始时的回调
151
151
  *
@@ -20,7 +20,7 @@ export interface OptimizeViewportTransformOptions extends BaseBehaviorOptions {
20
20
  /**
21
21
  * <zh/> 指定始终显示的图形元素。应用此交互后,在画布操作过程中,只有通过该属性指定的图形元素会保持可见,其余图形元素将被隐藏,从而提升渲染性能。默认情况下,节点始终可见,而其他图形元素在操作画布过程中会自动隐藏
22
22
  *
23
- * <en/> Specify the graphic elements that are always visible. After applying this interaction, only the graphic elements specified by this property will remain visible during the canvas operation, and the rest of the graphic elements will be hidden to improve rendering performance. By default, nodes are always visible, while other graphic elements are automatically hidden during canvas operations
23
+ * <en/> Specify the shapes that are always visible. After applying this interaction, only the shapes specified by this property will remain visible during the canvas operation, and the rest of the shapes will be hidden to improve rendering performance. By default, nodes are always visible, while other shapes are automatically hidden during canvas operations
24
24
  */
25
25
  shapes?: {
26
26
  node?: string[];
@@ -95,33 +95,33 @@ export interface BaseEdgeStyleProps extends BaseShapeStyleProps, Prefix<'label',
95
95
  /**
96
96
  * <zh/> 在 “起点” 处添加一个标记图形,其中 “起始点” 为边与起始节点的交点
97
97
  *
98
- * <en/> Add a marker graphic at the "start point", where the "start point" is the intersection of the edge and the source node
98
+ * <en/> Add a marker at the "start point", where the "start point" is the intersection of the edge and the source node
99
99
  */
100
100
  markerStart?: DisplayObject | null;
101
101
  /**
102
102
  * <zh/> 调整 “起点” 处标记图形的位置,正偏移量向内,负偏移量向外
103
103
  *
104
- * <en/> Adjust the position of the marker graphic at the "start point", positive offset inward, negative offset outward
104
+ * <en/> Adjust the position of the marker at the "start point", positive offset inward, negative offset outward
105
105
  * @defaultValue 0
106
106
  */
107
107
  markerStartOffset?: number;
108
108
  /**
109
109
  * <zh/> 在 “终点” 处添加一个标记图形,其中 “终点” 为边与终止节点的交点
110
110
  *
111
- * <en/> Add a marker graphic at the "end point", where the "end point" is the intersection of the edge and the target node
111
+ * <en/> Add a marker at the "end point", where the "end point" is the intersection of the edge and the target node
112
112
  */
113
113
  markerEnd?: DisplayObject | null;
114
114
  /**
115
115
  * <zh/> 调整 “终点” 处标记图形的位置,正偏移量向内,负偏移量向外
116
116
  *
117
- * <en/> Adjust the position of the marker graphic at the "end point", positive offset inward, negative offset outward
117
+ * <en/> Adjust the position of the marker at the "end point", positive offset inward, negative offset outward
118
118
  * @defaultValue 0
119
119
  */
120
120
  markerEndOffset?: number;
121
121
  /**
122
122
  * <zh/> 在路径除了 “起点” 和 “终点” 之外的每一个顶点上放置标记图形。在内部实现中,由于我们会把路径中部分命令转换成 C 命令,因此这些顶点实际是三阶贝塞尔曲线的控制点
123
123
  *
124
- * <en/> Place a marker graphic on each vertex of the path except for the "start point" and "end point". In the internal implementation, because we will convert some commands in the path to C commands, these controlPoints are actually the control points of the cubic Bezier curve
124
+ * <en/> Place a marker on each vertex of the path except for the "start point" and "end point". In the internal implementation, because we will convert some commands in the path to C commands, these controlPoints are actually the control points of the cubic Bezier curve
125
125
  */
126
126
  markerMid?: DisplayObject | null;
127
127
  /**
@@ -52,6 +52,7 @@ export interface BaseNodeStyleProps extends BaseShapeStyleProps, Prefix<'label',
52
52
  * <zh/> 仅在树图中生效
53
53
  *
54
54
  * <en/> Only valid in the tree graph
55
+ * @ignore
55
56
  */
56
57
  childrenNode?: ID[];
57
58
  /**
@@ -62,6 +63,7 @@ export interface BaseNodeStyleProps extends BaseShapeStyleProps, Prefix<'label',
62
63
  * <zh/> 仅在树图中生效。如果当前节点为收起状态,children 可能为空,通过 childrenData 能够获取完整的子元素数据
63
64
  *
64
65
  * <en/> Only valid in the tree graph. If the current node is collapsed, children may be empty, and the complete child element data can be obtained through childrenData
66
+ * @ignore
65
67
  */
66
68
  childrenData?: NodeData[];
67
69
  /**
@@ -41,6 +41,10 @@ export declare class HTML extends BaseNode<HTMLStyleProps> {
41
41
  private get eventService();
42
42
  private get events();
43
43
  protected getDomElement(): HTMLElement;
44
+ /**
45
+ * @override
46
+ */
47
+ render(attributes?: Required<HTMLStyleProps>, container?: Group): void;
44
48
  protected getKeyStyle(attributes: Required<HTMLStyleProps>): GHTMLStyleProps;
45
49
  protected drawKeyShape(attributes: Required<HTMLStyleProps>, container: Group): GHTML | undefined;
46
50
  connectedCallback(): void;
@@ -66,8 +66,8 @@ export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps>
66
66
  /**
67
67
  * <zh/> 从给定的属性对象中提取图形样式属性。删除特定的属性,如位置、变换和类名
68
68
  *
69
- * <en/> Extracts the graphic style properties from a given attribute object.
70
- * Removes specific properties like position, transformation, and class name.
69
+ * <en/> Extracts the shape styles from a given attribute object.
70
+ * Removes specific styles like position, transformation, and class name.
71
71
  * @param style - <zh/> 属性对象 | <en/> attribute object
72
72
  * @returns <zh/> 仅包含样式属性的对象 | <en/> An object containing only the style properties.
73
73
  */
@@ -5,7 +5,7 @@ export { BaseEdge, Cubic, CubicHorizontal, CubicRadial, CubicVertical, Line, Pol
5
5
  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
- export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, compactBox as CompactBoxLayout, ConcentricLayout, D3ForceLayout, DagreLayout, dendrogram as DendrogramLayout, FishboneLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, indented as IndentedLayout, MDSLayout, mindmap as MindmapLayout, RadialLayout, RandomLayout, } from './layouts';
8
+ export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, compactBox as CompactBoxLayout, ConcentricLayout, D3ForceLayout, DagreLayout, dendrogram as DendrogramLayout, FishboneLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, indented as IndentedLayout, MDSLayout, mindmap as MindmapLayout, RadialLayout, RandomLayout, SnakeLayout, } from './layouts';
9
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';
@@ -33,11 +33,12 @@ export type { BaseNodeStyleProps, CircleStyleProps, DiamondStyleProps, DonutStyl
33
33
  export type { BadgeStyleProps, BaseShapeStyleProps, IconStyleProps, LabelStyleProps, PolygonStyleProps, } from './elements/shapes';
34
34
  export type { UpsertHooks } from './elements/shapes/base-shape';
35
35
  export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shapes/contour';
36
- export type { FishboneLayoutOptions } from './layouts';
36
+ export type { FishboneLayoutOptions, SnakeLayoutOptions } from './layouts';
37
37
  export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
38
38
  export type { CategoricalPalette } from './palettes/types';
39
39
  export type { BackgroundOptions, BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, EdgeBundlingOptions, EdgeFilterLensOptions, FisheyeOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, SnaplineOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
40
40
  export type { CanvasConfig, DataURLOptions } from './runtime/canvas';
41
+ export type { CollapseExpandNodeOptions } from './runtime/element';
41
42
  export type { RuntimeContext } from './runtime/types';
42
43
  export type { BehaviorOptions, CanvasOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, GraphData, GraphOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions, ViewportOptions, } from './spec';
43
44
  export type { CustomBehaviorOption } from './spec/behavior';
@@ -1,7 +1,8 @@
1
+ import type { BaseLayoutOptions } from '../layouts/types';
1
2
  import type { GraphData, NodeData } from '../spec';
2
3
  import type { Size } from '../types';
3
4
  import { BaseLayout } from './base-layout';
4
- export interface FishboneLayoutOptions {
5
+ export interface FishboneLayoutOptions extends BaseLayoutOptions {
5
6
  /**
6
7
  * <zh/> 节点大小
7
8
  *
@@ -2,4 +2,6 @@ export { compactBox, dendrogram, indented, mindmap } from '@antv/hierarchy';
2
2
  export { AntVDagreLayout, CircularLayout, ComboCombinedLayout, ConcentricLayout, D3ForceLayout, DagreLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, MDSLayout, RadialLayout, RandomLayout, } from '@antv/layout';
3
3
  export { BaseLayout } from './base-layout';
4
4
  export { FishboneLayout } from './fishbone';
5
+ export { SnakeLayout } from './snake';
5
6
  export type { FishboneLayoutOptions } from './fishbone';
7
+ export type { SnakeLayoutOptions } from './snake';
@@ -0,0 +1,80 @@
1
+ import type { GraphData, NodeData } from '../spec';
2
+ import type { Padding, Size } from '../types';
3
+ import { BaseLayout } from './base-layout';
4
+ import type { BaseLayoutOptions } from './types';
5
+ export interface SnakeLayoutOptions extends BaseLayoutOptions {
6
+ /**
7
+ * <zh/> 节点尺寸
8
+ *
9
+ * <en/> Node size
10
+ */
11
+ nodeSize?: Size | ((node: NodeData) => Size);
12
+ /**
13
+ * <zh/> 内边距,即布局区域与画布边界的距离
14
+ *
15
+ * <en/> Padding, the distance between the layout area and the canvas boundary
16
+ * @defaultValue 0
17
+ */
18
+ padding?: Padding;
19
+ /**
20
+ * <zh/> 节点排序方法。默认按照在图中的路径顺序进行展示
21
+ *
22
+ * <en/> Node sorting method
23
+ */
24
+ sortBy?: (nodeA: NodeData, nodeB: NodeData) => -1 | 0 | 1;
25
+ /**
26
+ * <zh/> 节点列数
27
+ *
28
+ * <en/> Number of node columns
29
+ * @defaultValue 5
30
+ */
31
+ cols?: number;
32
+ /**
33
+ * <zh/> 节点行之间的间隙大小。默认将根据画布高度和节点总行数自动计算
34
+ *
35
+ * <en/> The size of the gap between a node's rows
36
+ */
37
+ rowGap?: number;
38
+ /**
39
+ * <zh/> 节点列之间的间隙大小。默认将根据画布宽度和节点总列数自动计算
40
+ *
41
+ * <en/> The size of the gap between a node's columns
42
+ */
43
+ colGap?: number;
44
+ /**
45
+ * <zh/> 节点排布方向是否顺时针
46
+ *
47
+ * <en/> Whether the node arrangement direction is clockwise
48
+ * @defaultValue true
49
+ * @remarks
50
+ * <zh/> 在顺时针排布时,节点从左上角开始,第一行从左到右排列,第二行从右到左排列,依次类推,形成 S 型路径。在逆时针排布时,节点从右上角开始,第一行从右到左排列,第二行从左到右排列,依次类推,形成反向 S 型路径。
51
+ *
52
+ * <en/> When arranged clockwise, the nodes start from the upper left corner, the first row is arranged from left to right, the second row is arranged from right to left, and so on, forming an S-shaped path. When arranged counterclockwise, the nodes start from the upper right corner, the first row is arranged from right to left, the second row is arranged from left to right, and so on, forming a reverse S-shaped path.
53
+ */
54
+ clockwise?: boolean;
55
+ }
56
+ /**
57
+ * <zh/> 蛇形布局
58
+ *
59
+ * <en/> Snake layout
60
+ * @remarks
61
+ * <zh/> 蛇形布局(Snake Layout)是一种特殊的图形布局方式,能够在较小的空间内更有效地展示长链结构。需要注意的是,其图数据需要确保节点按照从源节点到汇节点的顺序进行线性排列,形成一条明确的路径。
62
+ *
63
+ * <zh/> 节点按 S 字型排列,第一个节点位于第一行的起始位置,接下来的节点在第一行向右排列,直到行末尾。到达行末尾后,下一行的节点从右向左反向排列。这个过程重复进行,直到所有节点排列完毕。
64
+ *
65
+ * <en/> The Snake layout is a special way of graph layout that can more effectively display long chain structures in a smaller space. Note that the graph data needs to ensure that the nodes are linearly arranged in the order from the source node to the sink node to form a clear path.
66
+ *
67
+ * <en/> The nodes are arranged in an S-shaped pattern, with the first node at the beginning of the first row, and the following nodes arranged to the right until the end of the row. After reaching the end of the row, the nodes in the next row are arranged in reverse from right to left. This process is repeated until all nodes are arranged.
68
+ */
69
+ export declare class SnakeLayout extends BaseLayout {
70
+ id: string;
71
+ static defaultOptions: Partial<SnakeLayoutOptions>;
72
+ private formatSize;
73
+ /**
74
+ * Validates the graph data to ensure it meets the requirements for linear arrangement.
75
+ * @param data - Graph data
76
+ * @returns false if the graph is not connected, has more than one source or sink node, or contains cycles.
77
+ */
78
+ private validate;
79
+ execute(model: GraphData, options?: SnakeLayoutOptions): Promise<GraphData>;
80
+ }
@@ -1,7 +1,9 @@
1
1
  import type { AntVDagreLayoutOptions, LayoutWithIterations as AntVIterativeLayout, Layout as AntVNonIterativeLayout, CircularLayoutOptions, ConcentricLayoutOptions, D3Force3DLayoutOptions, D3ForceLayoutOptions, DagreLayoutOptions, ForceAtlas2LayoutOptions, ForceLayoutOptions, FruchtermanLayoutOptions, GridLayoutOptions, MDSLayoutOptions, RadialLayoutOptions, RandomLayoutOptions } from '@antv/layout';
2
2
  import type { NodeData } from '../spec/data';
3
3
  import type { BaseLayout } from './base-layout';
4
- export type BuiltInLayoutOptions = AntVDagreLayout | CircularLayout | ConcentricLayout | D3ForceLayout | D3Force3DLayout | DagreLayout | ForceAtlas2 | ForceLayout | FruchtermanLayout | GridLayout | MDSLayout | RadialLayout | RandomLayout;
4
+ import type { FishboneLayoutOptions } from './fishbone';
5
+ import type { SnakeLayoutOptions } from './snake';
6
+ export type BuiltInLayoutOptions = AntVDagreLayout | CircularLayout | ConcentricLayout | D3ForceLayout | D3Force3DLayout | DagreLayout | ForceAtlas2 | ForceLayout | FruchtermanLayout | GridLayout | MDSLayout | RadialLayout | RandomLayout | SnakeLayoutOptions | FishboneLayoutOptions;
5
7
  export interface BaseLayoutOptions extends AnimationOptions, WebWorkerLayoutOptions, Record<string, any> {
6
8
  /**
7
9
  * <zh/> 布局类型
@@ -50,7 +50,7 @@ export interface MinimapOptions extends BasePluginOptions {
50
50
  * - 也可以传入一个函数,接收元素的 id 和类型,返回一个图形
51
51
  *
52
52
  * <en/>
53
- * - 'key' uses the key shape of the element as the thumbnail graphic
53
+ * - 'key' uses the key shape of the element as the thumbnail shape
54
54
  * - You can also pass in a function that receives the id and type of the element and returns a shape
55
55
  */
56
56
  shape?: 'key' | ((id: string, elementType: ElementType) => DisplayObject);
@@ -92,7 +92,7 @@ export declare class Snapline extends BasePlugin<SnaplineOptions> {
92
92
  * @returns delta
93
93
  * @internal
94
94
  */
95
- protected getDelta(event: IDragEvent<Node>): [number, number] | Float32Array | [number, number, number];
95
+ protected getDelta(event: IDragEvent<Node>): import("../../types").Vector2 | import("../../types").Vector3;
96
96
  private enableSnap;
97
97
  private calcSnaplineMetadata;
98
98
  protected onDragStart: () => void;
@@ -175,7 +175,7 @@ export declare class DataController {
175
175
  * @param hierarchyKey - <zh/> 层次结构类型 | <en/> hierarchy type
176
176
  * @param update - <zh/> 添加新/旧父节点数据更新记录 | <en/> add new/old parent node data update record
177
177
  */
178
- setParent(id: ID, parent: ID | undefined, hierarchyKey: HierarchyKey, update?: boolean): void;
178
+ setParent(id: ID, parent: ID | undefined | null, hierarchyKey: HierarchyKey, update?: boolean): void;
179
179
  /**
180
180
  * <zh/> 刷新 combo 数据
181
181
  *
@@ -79,6 +79,14 @@ export declare class ElementController {
79
79
  private destroyElement;
80
80
  private destroyElements;
81
81
  private clearElement;
82
+ /**
83
+ * <zh/> 将布局结果对齐到元素,避免视图偏移。会修改布局结果
84
+ *
85
+ * <en/> Align the layout result to the element to avoid view offset. Will modify the layout result
86
+ * @param layoutResult - <zh/> 布局结果 | <en/> layout result
87
+ * @param id - <zh/> 元素 ID | <en/> element ID
88
+ */
89
+ private alignLayoutResultToElement;
82
90
  /**
83
91
  * <zh/> 收起节点
84
92
  *
@@ -86,7 +94,7 @@ export declare class ElementController {
86
94
  * @param id - <zh/> 元素 ID | <en/> element ID
87
95
  * @param animation - <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true
88
96
  */
89
- collapseNode(id: ID, animation: boolean): Promise<void>;
97
+ collapseNode(id: ID, options: CollapseExpandNodeOptions): Promise<void>;
90
98
  /**
91
99
  * <zh/> 展开节点
92
100
  *
@@ -94,7 +102,7 @@ export declare class ElementController {
94
102
  * @param id - <zh/> 元素 ID | <en/> element ID
95
103
  * @param animation - <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true
96
104
  */
97
- expandNode(id: ID, animation: boolean): Promise<void>;
105
+ expandNode(id: ID, options: CollapseExpandNodeOptions): Promise<void>;
98
106
  collapseCombo(id: ID, animation: boolean): Promise<void>;
99
107
  expandCombo(id: ID, animation: boolean): Promise<void>;
100
108
  destroy(): void;
@@ -113,3 +121,22 @@ export interface DrawContext {
113
121
  /** <zh/> 展开阶段的目标元素 id | <en/> ID of the target element in the expand stage */
114
122
  target?: ID;
115
123
  }
124
+ /**
125
+ * <zh/> 展开/收起节点选项
126
+ *
127
+ * <en/> Expand / collapse node options
128
+ */
129
+ export interface CollapseExpandNodeOptions {
130
+ /**
131
+ * <zh/> 是否使用动画
132
+ *
133
+ * <en/> Whether to use animation
134
+ */
135
+ animation?: boolean;
136
+ /**
137
+ * <zh/> 保证展开/收起的节点位置不变
138
+ *
139
+ * <en/> Ensure that the position of the expanded/collapsed node remains unchanged
140
+ */
141
+ align?: boolean;
142
+ }
@@ -8,6 +8,7 @@ import type { UpdateTransformOption } from '../spec/transform';
8
8
  import type { DataID, EdgeDirection, ElementDatum, ElementType, FitViewOptions, HierarchyKey, ID, IEvent, NodeLikeData, PartialEdgeData, PartialGraphData, PartialNodeLikeData, Point, State, ViewportAnimationEffectTiming } from '../types';
9
9
  import type { DataURLOptions } from './canvas';
10
10
  import { Canvas } from './canvas';
11
+ import type { CollapseExpandNodeOptions } from './element';
11
12
  export declare class Graph extends EventEmitter {
12
13
  private options;
13
14
  /**
@@ -249,7 +250,7 @@ export declare class Graph extends EventEmitter {
249
250
  * <zh/> 获取插件实例
250
251
  *
251
252
  * <en/> Get plugin instance
252
- * @param key - <zh/> 插件 key | <en/> plugin key
253
+ * @param key - <zh/> 插件 key(在配置 plugin 时需要手动传入指定) | <en/> plugin key(need to be specified manually when configuring plugin)
253
254
  * @returns <zh/> 插件实例 | <en/> plugin instance
254
255
  * @remarks
255
256
  * <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
@@ -1147,23 +1148,24 @@ export declare class Graph extends EventEmitter {
1147
1148
  getElementRenderBounds(id: ID): AABB;
1148
1149
  private isCollapsingExpanding;
1149
1150
  /**
1150
- * <zh/> 收起组合
1151
+ * <zh/> 收起元素
1151
1152
  *
1152
- * <en/> Collapse Combo
1153
+ * <en/> Collapse element
1153
1154
  * @param id - <zh/> 元素 ID | <en/> element ID
1154
- * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1155
+ * @param options - <zh/> 是否启用动画或者配置收起节点的配置项 | <en/> whether to enable animation or the options of collapsing node
1155
1156
  * @apiCategory element
1156
1157
  */
1157
- collapseElement(id: ID, animation?: boolean): Promise<void>;
1158
+ collapseElement(id: ID, options?: boolean | CollapseExpandNodeOptions): Promise<void>;
1158
1159
  /**
1159
- * <zh/> 展开组合
1160
+ * <zh/> 展开元素
1160
1161
  *
1161
- * <en/> Expand Combo
1162
+ * <en/> Expand Element
1162
1163
  * @param id - <zh/> 元素 ID | <en/> element ID
1163
- * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1164
+ * @param animation - <zh/> 是否启用动画或者配置收起节点的配置项 | <en/> whether to enable animation or the options of collapsing node
1165
+ * @param options
1164
1166
  * @apiCategory element
1165
1167
  */
1166
- expandElement(id: ID, animation?: boolean): Promise<void>;
1168
+ expandElement(id: ID, options?: boolean | CollapseExpandNodeOptions): Promise<void>;
1167
1169
  private setElementCollapsibility;
1168
1170
  /**
1169
1171
  * <zh/> 导出画布内容为 DataURL
@@ -42,8 +42,8 @@ export declare class ViewportController {
42
42
  private transformResolver?;
43
43
  transform(options: TransformOptions, animation?: ViewportAnimationEffectTiming): Promise<void>;
44
44
  fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void>;
45
- fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void>;
46
- focusElements(ids: ID[], animation?: ViewportAnimationEffectTiming): Promise<void>;
45
+ fitCenter(options: FocusOptions): Promise<void>;
46
+ focusElements(ids: ID[], options?: FocusOptions): Promise<void>;
47
47
  private focus;
48
48
  /**
49
49
  * <zh/> 获取画布元素在视口中的包围盒
@@ -65,3 +65,23 @@ export declare class ViewportController {
65
65
  isInViewport(target: Point | AABB, complete?: boolean, tolerance?: number): boolean;
66
66
  cancelAnimation(): void;
67
67
  }
68
+ export interface FocusOptions {
69
+ /**
70
+ * <zh/> 动画配置
71
+ *
72
+ * <en/> Animation configuration
73
+ */
74
+ animation?: ViewportAnimationEffectTiming;
75
+ /**
76
+ * <zh/> 使用子图形计算包围盒
77
+ *
78
+ * <en/> Calculate the bounding box by using sub-shapes
79
+ */
80
+ shapes?: string;
81
+ /**
82
+ * <zh/> 对齐位置,默认为画布中心
83
+ *
84
+ * <en/> Alignment position, default is the center of the canvas
85
+ */
86
+ position?: Point;
87
+ }
@@ -17,18 +17,30 @@ export interface CanvasOptions {
17
17
  * <zh/> 画布宽度
18
18
  *
19
19
  * <en/> canvas width
20
+ * @remarks
21
+ * <zh/> 如果未设置,则会自动获取容器宽度
22
+ *
23
+ * <en/> If not set, the container width will be automatically obtained
20
24
  */
21
25
  width?: number;
22
26
  /**
23
27
  * <zh/> 画布高度
24
28
  *
25
29
  * <en/> canvas height
30
+ * @remarks
31
+ * <zh/> 如果未设置,则会自动获取容器高度
32
+ *
33
+ * <en/> If not set, the container height will be automatically obtained
26
34
  */
27
35
  height?: number;
28
36
  /**
29
- * <zh/> 获取渲染器
37
+ * <zh/> 手动置顶渲染器
38
+ *
39
+ * <en/> manually set renderer
40
+ * @remarks
41
+ * <zh/> G6 采用了分层渲染的方式,分为 background、main、label、transient 四层,用户可以通过该配置项分别设置每层画布的渲染器
30
42
  *
31
- * <en/> get renderer
43
+ * <en/> G6 adopts a layered rendering method, divided into four layers: background, main, label, transient. Users can set the renderer of each layer canvas separately through this configuration item
32
44
  */
33
45
  renderer?: (layer: 'background' | 'main' | 'label' | 'transient') => IRenderer;
34
46
  /**
@@ -36,18 +48,30 @@ export interface CanvasOptions {
36
48
  *
37
49
  * <en/> whether to auto resize canvas
38
50
  * @defaultValue false
51
+ * @remarks
52
+ * <zh/> 基于 window.onresize 事件自动调整画布大小
53
+ *
54
+ * <en/> Automatically adjust the canvas size based on the window.onresize event
39
55
  */
40
56
  autoResize?: boolean;
41
57
  /**
42
58
  * <zh/> 画布背景色
43
59
  *
44
60
  * <en/> canvas background color
61
+ * @remarks
62
+ * <zh/> 该颜色作为导出图片时的背景色
63
+ *
64
+ * <en/> This color is used as the background color when exporting images
45
65
  */
46
66
  background?: string;
47
67
  /**
48
68
  * <zh/> 设备像素比
49
69
  *
50
70
  * <en/> device pixel ratio
71
+ * @remarks
72
+ * <zh/> 用于高清屏的设备像素比,默认为 [window.devicePixelRatio](https://developer.mozilla.org/zh-CN/docs/Web/API/Window/devicePixelRatio)
73
+ *
74
+ * <en/> Device pixel ratio for high-definition screens, default is [window.devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio)
51
75
  */
52
76
  devicePixelRatio?: number;
53
77
  /**
@@ -91,7 +91,7 @@ export interface NodeData {
91
91
  *
92
92
  * <en/> ID of the combo to which the node belongs
93
93
  */
94
- combo?: ID;
94
+ combo?: ID | null;
95
95
  /**
96
96
  * <zh/> 子节点 ID
97
97
  *
@@ -159,7 +159,7 @@ export interface ComboData {
159
159
  *
160
160
  * <en/> ID of the combo to which the combo belongs
161
161
  */
162
- combo?: ID;
162
+ combo?: ID | null;
163
163
  [key: string]: unknown;
164
164
  }
165
165
  /**
@@ -38,30 +38,50 @@ export interface GraphOptions extends CanvasOptions, ViewportOptions {
38
38
  * <zh/> 数据
39
39
  *
40
40
  * <en/> Data
41
+ * @remarks
42
+ * <zh/> 详见 [Data](/api/data/graph-data)
43
+ *
44
+ * <en/> See [Data](/en/api/data/graph-data)
41
45
  */
42
46
  data?: GraphData;
43
47
  /**
44
- * <zh/> 布局
48
+ * <zh/> 布局配置项
49
+ *
50
+ * <en/> Layout options
51
+ * @remarks
52
+ * <zh/> 详见 [Layout](/api/layouts/antv-dagre-layout)
45
53
  *
46
- * <en/> Layout
54
+ * <en/> See [Layout](/en/api/layouts/antv-dagre-layout)
47
55
  */
48
56
  layout?: LayoutOptions;
49
57
  /**
50
- * <zh/> 节点
58
+ * <zh/> 节点配置项
59
+ *
60
+ * <en/> Node options
61
+ * @remarks
62
+ * <zh/> 详见 [Node](/api/elements/nodes/base-node)
51
63
  *
52
- * <en/> Node
64
+ * <en/> See [Node](/en/api/elements/nodes/base-node)
53
65
  */
54
66
  node?: NodeOptions;
55
67
  /**
56
- * <zh/> 边
68
+ * <zh/> 边配置项
57
69
  *
58
- * <en/> Edge
70
+ * <en/> Edge options
71
+ * @remarks
72
+ * <zh/> 详见 [Edge](/api/elements/edges/base-edge)
73
+ *
74
+ * <en/> See [Edge](/en/api/elements/edges/base-edge)
59
75
  */
60
76
  edge?: EdgeOptions;
61
77
  /**
62
- * <zh/> Combo
78
+ * <zh/> 组合配置项
63
79
  *
64
- * <en/> Combo
80
+ * <en/> Combo options
81
+ * @remarks
82
+ * <zh/> 详见 [Combo](/api/elements/combos/base-combo)
83
+ *
84
+ * <en/> See [Combo](/en/api/elements/combos/base-combo)
65
85
  */
66
86
  combo?: ComboOptions;
67
87
  /**
@@ -71,15 +91,43 @@ export interface GraphOptions extends CanvasOptions, ViewportOptions {
71
91
  */
72
92
  theme?: ThemeOptions;
73
93
  /**
74
- * <zh/> 交互
94
+ * <zh/> 启用交互
95
+ *
96
+ * <en/> Enable interactions
97
+ * @remarks
98
+ * <zh/>
99
+ * - 概念:[核心概念 - 交互](/manual/core-concept/behavior)
100
+ *
101
+ * - 内置交互: [交互](/api/behaviors/auto-adapt-label)
102
+ *
103
+ * - 自定义交互: [自定义扩展 - 自定义交互](/manual/advanced/custom-behavior)
75
104
  *
76
- * <en/> Behaviors
105
+ * <en/>
106
+ * - Concept: [Concepts - Behavior](/en/manual/core-concept/behavior)
107
+ *
108
+ * - Built-in behaviors: [Behavior](/en/api/behaviors/auto-adapt-label)
109
+ *
110
+ * - Custom behaviors: [Custom Extension - Custom Behavior](/en/manual/advanced/custom-behavior)
77
111
  */
78
112
  behaviors?: BehaviorOptions;
79
113
  /**
80
- * <zh/> 画布插件
114
+ * <zh/> 启用插件
115
+ *
116
+ * <en/> Enable plugins
117
+ * @remarks
118
+ * <zh/>
119
+ * - 概念:[核心概念 - 插件](/manual/core-concept/plugin)
120
+ *
121
+ * - 内置插件: [插件](/en/api/plugins/background)
122
+ *
123
+ * - 自定义插件: [自定义扩展 - 自定义插件](/manual/advanced/custom-plugin)
124
+ *
125
+ * <en/>
126
+ * - Concept: [Concepts - Plugin](/en/manual/core-concept/plugin)
127
+ *
128
+ * - Built-in plugins: [Plugin](/en/api/plugins/background)
81
129
  *
82
- * <en/> Canvas plugins
130
+ * - Custom plugins: [Custom Extension - Custom Plugin](/en/manual/advanced/custom-plugin)
83
131
  */
84
132
  plugins?: PluginOptions;
85
133
  /**
@@ -23,6 +23,10 @@ export interface ViewportOptions {
23
23
  * <zh/> 是否自动适应
24
24
  *
25
25
  * <en/> whether to auto fit
26
+ * @remarks
27
+ * <zh/> 每次执行 `render` 时,都会根据 `autoFit` 进行自适应
28
+ *
29
+ * <en/> Every time `render` is executed, it will be adapted according to `autoFit`
26
30
  */
27
31
  autoFit?: {
28
32
  type: 'view';