@antv/g6 5.0.16 → 5.0.18

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 (162) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/click-select.d.ts +0 -1
  3. package/dist/lib/behaviors/optimize-viewport-transform.d.ts +0 -1
  4. package/dist/lib/constants/events/canvas.d.ts +1 -1
  5. package/dist/lib/constants/registry.d.ts +7 -1
  6. package/dist/lib/elements/edges/polyline.d.ts +1 -0
  7. package/dist/lib/elements/effect.d.ts +19 -2
  8. package/dist/lib/elements/nodes/html.d.ts +14 -0
  9. package/dist/lib/elements/shapes/base-shape.d.ts +51 -2
  10. package/dist/lib/exports.d.ts +4 -2
  11. package/dist/lib/plugins/edge-filter-lens/index.d.ts +141 -0
  12. package/dist/lib/plugins/fisheye/index.d.ts +167 -0
  13. package/dist/lib/plugins/index.d.ts +4 -0
  14. package/dist/lib/plugins/tooltip.d.ts +1 -0
  15. package/dist/lib/registry/types.d.ts +4 -0
  16. package/dist/lib/runtime/element.d.ts +3 -1
  17. package/dist/lib/runtime/plugin.d.ts +1 -1
  18. package/dist/lib/types/element.d.ts +7 -0
  19. package/dist/lib/utils/dom.d.ts +8 -5
  20. package/dist/lib/version.d.ts +1 -1
  21. package/esm/behaviors/click-select.d.ts +0 -1
  22. package/esm/behaviors/click-select.js.map +1 -1
  23. package/esm/behaviors/optimize-viewport-transform.d.ts +0 -1
  24. package/esm/behaviors/optimize-viewport-transform.js +5 -4
  25. package/esm/behaviors/optimize-viewport-transform.js.map +1 -1
  26. package/esm/constants/events/canvas.d.ts +1 -1
  27. package/esm/constants/events/canvas.js +1 -1
  28. package/esm/constants/events/canvas.js.map +1 -1
  29. package/esm/constants/registry.d.ts +7 -1
  30. package/esm/constants/registry.js +6 -0
  31. package/esm/constants/registry.js.map +1 -1
  32. package/esm/elements/edges/polyline.d.ts +1 -0
  33. package/esm/elements/edges/polyline.js +5 -1
  34. package/esm/elements/edges/polyline.js.map +1 -1
  35. package/esm/elements/effect.d.ts +19 -2
  36. package/esm/elements/effect.js +19 -2
  37. package/esm/elements/effect.js.map +1 -1
  38. package/esm/elements/nodes/html.d.ts +14 -0
  39. package/esm/elements/nodes/html.js +10 -4
  40. package/esm/elements/nodes/html.js.map +1 -1
  41. package/esm/elements/shapes/base-shape.d.ts +51 -2
  42. package/esm/elements/shapes/base-shape.js +22 -4
  43. package/esm/elements/shapes/base-shape.js.map +1 -1
  44. package/esm/exports.d.ts +4 -2
  45. package/esm/exports.js +2 -1
  46. package/esm/exports.js.map +1 -1
  47. package/esm/plugins/contextmenu/index.js +1 -1
  48. package/esm/plugins/contextmenu/index.js.map +1 -1
  49. package/esm/plugins/edge-filter-lens/index.d.ts +141 -0
  50. package/esm/plugins/edge-filter-lens/index.js +241 -0
  51. package/esm/plugins/edge-filter-lens/index.js.map +1 -0
  52. package/esm/plugins/fisheye/index.d.ts +167 -0
  53. package/esm/plugins/fisheye/index.js +288 -0
  54. package/esm/plugins/fisheye/index.js.map +1 -0
  55. package/esm/plugins/index.d.ts +4 -0
  56. package/esm/plugins/index.js +2 -0
  57. package/esm/plugins/index.js.map +1 -1
  58. package/esm/plugins/snapline/index.js +2 -2
  59. package/esm/plugins/snapline/index.js.map +1 -1
  60. package/esm/plugins/tooltip.d.ts +1 -0
  61. package/esm/plugins/tooltip.js +16 -17
  62. package/esm/plugins/tooltip.js.map +1 -1
  63. package/esm/registry/build-in.js +20 -1
  64. package/esm/registry/build-in.js.map +1 -1
  65. package/esm/registry/store.js +1 -0
  66. package/esm/registry/store.js.map +1 -1
  67. package/esm/registry/types.d.ts +4 -0
  68. package/esm/runtime/element.d.ts +3 -1
  69. package/esm/runtime/element.js +8 -2
  70. package/esm/runtime/element.js.map +1 -1
  71. package/esm/runtime/plugin.d.ts +1 -1
  72. package/esm/runtime/plugin.js +8 -1
  73. package/esm/runtime/plugin.js.map +1 -1
  74. package/esm/types/element.d.ts +7 -0
  75. package/esm/utils/dom.d.ts +8 -5
  76. package/esm/utils/dom.js +24 -15
  77. package/esm/utils/dom.js.map +1 -1
  78. package/esm/version.d.ts +1 -1
  79. package/esm/version.js +1 -1
  80. package/lib/behaviors/click-select.d.ts +0 -1
  81. package/lib/behaviors/click-select.js.map +1 -1
  82. package/lib/behaviors/optimize-viewport-transform.d.ts +0 -1
  83. package/lib/behaviors/optimize-viewport-transform.js +5 -4
  84. package/lib/behaviors/optimize-viewport-transform.js.map +1 -1
  85. package/lib/constants/events/canvas.d.ts +1 -1
  86. package/lib/constants/events/canvas.js +1 -1
  87. package/lib/constants/events/canvas.js.map +1 -1
  88. package/lib/constants/registry.d.ts +7 -1
  89. package/lib/constants/registry.js +6 -0
  90. package/lib/constants/registry.js.map +1 -1
  91. package/lib/elements/edges/polyline.d.ts +1 -0
  92. package/lib/elements/edges/polyline.js +5 -1
  93. package/lib/elements/edges/polyline.js.map +1 -1
  94. package/lib/elements/effect.d.ts +19 -2
  95. package/lib/elements/effect.js +19 -2
  96. package/lib/elements/effect.js.map +1 -1
  97. package/lib/elements/nodes/html.d.ts +14 -0
  98. package/lib/elements/nodes/html.js +10 -4
  99. package/lib/elements/nodes/html.js.map +1 -1
  100. package/lib/elements/shapes/base-shape.d.ts +51 -2
  101. package/lib/elements/shapes/base-shape.js +22 -4
  102. package/lib/elements/shapes/base-shape.js.map +1 -1
  103. package/lib/exports.d.ts +4 -2
  104. package/lib/exports.js +7 -2
  105. package/lib/exports.js.map +1 -1
  106. package/lib/plugins/contextmenu/index.js +1 -1
  107. package/lib/plugins/contextmenu/index.js.map +1 -1
  108. package/lib/plugins/edge-filter-lens/index.d.ts +141 -0
  109. package/lib/plugins/edge-filter-lens/index.js +245 -0
  110. package/lib/plugins/edge-filter-lens/index.js.map +1 -0
  111. package/lib/plugins/fisheye/index.d.ts +167 -0
  112. package/lib/plugins/fisheye/index.js +292 -0
  113. package/lib/plugins/fisheye/index.js.map +1 -0
  114. package/lib/plugins/index.d.ts +4 -0
  115. package/lib/plugins/index.js +5 -1
  116. package/lib/plugins/index.js.map +1 -1
  117. package/lib/plugins/snapline/index.js +2 -2
  118. package/lib/plugins/snapline/index.js.map +1 -1
  119. package/lib/plugins/tooltip.d.ts +1 -0
  120. package/lib/plugins/tooltip.js +16 -17
  121. package/lib/plugins/tooltip.js.map +1 -1
  122. package/lib/registry/build-in.js +19 -0
  123. package/lib/registry/build-in.js.map +1 -1
  124. package/lib/registry/store.js +1 -0
  125. package/lib/registry/store.js.map +1 -1
  126. package/lib/registry/types.d.ts +4 -0
  127. package/lib/runtime/element.d.ts +3 -1
  128. package/lib/runtime/element.js +8 -2
  129. package/lib/runtime/element.js.map +1 -1
  130. package/lib/runtime/plugin.d.ts +1 -1
  131. package/lib/runtime/plugin.js +8 -1
  132. package/lib/runtime/plugin.js.map +1 -1
  133. package/lib/types/element.d.ts +7 -0
  134. package/lib/utils/dom.d.ts +8 -5
  135. package/lib/utils/dom.js +24 -15
  136. package/lib/utils/dom.js.map +1 -1
  137. package/lib/version.d.ts +1 -1
  138. package/lib/version.js +1 -1
  139. package/package.json +1 -1
  140. package/src/behaviors/click-select.ts +0 -1
  141. package/src/behaviors/optimize-viewport-transform.ts +4 -10
  142. package/src/constants/events/canvas.ts +1 -1
  143. package/src/constants/registry.ts +6 -0
  144. package/src/elements/edges/polyline.ts +7 -1
  145. package/src/elements/effect.ts +19 -2
  146. package/src/elements/nodes/html.ts +28 -4
  147. package/src/elements/shapes/base-shape.ts +75 -5
  148. package/src/exports.ts +8 -0
  149. package/src/plugins/contextmenu/index.ts +1 -1
  150. package/src/plugins/edge-filter-lens/index.ts +404 -0
  151. package/src/plugins/fisheye/index.ts +481 -0
  152. package/src/plugins/index.ts +4 -0
  153. package/src/plugins/snapline/index.ts +2 -2
  154. package/src/plugins/tooltip.ts +18 -17
  155. package/src/registry/build-in.ts +32 -0
  156. package/src/registry/store.ts +1 -0
  157. package/src/registry/types.ts +2 -0
  158. package/src/runtime/element.ts +11 -3
  159. package/src/runtime/plugin.ts +8 -1
  160. package/src/types/element.ts +7 -0
  161. package/src/utils/dom.ts +24 -15
  162. package/src/version.ts +1 -1
@@ -63,7 +63,6 @@ export interface ClickSelectOptions extends BaseBehaviorOptions {
63
63
  * <zh/> 当有元素被选中时,除了选中元素及其受影响的邻居元素外,其他所有元素应用的状态。
64
64
  *
65
65
  * <en/> The state to be applied to all unselected elements when some elements are selected, excluding the selected element and its affected neighbors
66
- * @defaultValue undefined
67
66
  */
68
67
  unselectedState?: State;
69
68
  /**
@@ -43,7 +43,6 @@ export declare class OptimizeViewportTransform extends BaseBehavior<OptimizeView
43
43
  static defaultOptions: Partial<OptimizeViewportTransformOptions>;
44
44
  private isVisible;
45
45
  constructor(context: RuntimeContext, options: OptimizeViewportTransformOptions);
46
- private filterShapes;
47
46
  private setElementsVisibility;
48
47
  private hideShapes;
49
48
  private showShapes;
@@ -21,7 +21,7 @@ export declare enum CanvasEvent {
21
21
  *
22
22
  * <en/> Triggered when the pointer enters
23
23
  */
24
- POINTER_OVER = "canvas:canvas:pointerover",
24
+ POINTER_OVER = "canvas:pointerover",
25
25
  /**
26
26
  * <zh/> 指针移出时触发
27
27
  *
@@ -58,5 +58,11 @@ export declare enum ExtensionCategory {
58
58
  *
59
59
  * <en/> Data transform
60
60
  */
61
- TRANSFORM = "transform"
61
+ TRANSFORM = "transform",
62
+ /**
63
+ * <zh/> 图形
64
+ *
65
+ * <en/> Shape
66
+ */
67
+ SHAPE = "shape"
62
68
  }
@@ -39,6 +39,7 @@ type ParsedPolylineStyleProps = Required<PolylineStyleProps>;
39
39
  export declare class Polyline extends BaseEdge {
40
40
  static defaultStyleProps: Partial<PolylineStyleProps>;
41
41
  constructor(options: DisplayObjectConfig<PolylineStyleProps>);
42
+ protected getControlPoints(attributes: ParsedPolylineStyleProps): Point[];
42
43
  protected getPoints(attributes: ParsedPolylineStyleProps): Point[];
43
44
  protected getKeyPath(attributes: ParsedPolylineStyleProps): PathArray;
44
45
  protected getLoopPath(attributes: ParsedPolylineStyleProps): PathArray;
@@ -1,8 +1,8 @@
1
1
  import type { Element } from '../types';
2
2
  /**
3
- * <zh/> 基于样式属性是否变化控制函数是否执行
3
+ * <zh/> 优化方法执行次数,仅在样式属性发生变化时执行函数
4
4
  *
5
- * <en/> Control whether the function is executed based on whether the style attribute changes
5
+ * <en/> Optimize the number of method executions, and only execute the function when the style attributes change
6
6
  * @param styler - <zh/> 获取样式属性函数 | <en/> Get style attribute function
7
7
  * @returns <zh/> 装饰器 | <en/> Decorator
8
8
  * @remarks
@@ -13,5 +13,22 @@ import type { Element } from '../types';
13
13
  * <en/> Only when getStyle is specified, the function will be called with the current attributes and the new attributes respectively. If they are the same, the function will not be executed.
14
14
  *
15
15
  * If shapeKey is specified, the attributes of the shape will be directly obtained as the original style attributes, which is usually used when the bounding box of the element is used in the getStyle function.
16
+ * @example
17
+ * <zh/> 仅当 value 发生变化时执行函数
18
+ *
19
+ * <en/> Execute the function only when value changes
20
+ *
21
+ * ```typescript
22
+ * class CustomNode extends BaseNode {
23
+ *
24
+ * @effect((self, attributes) => {
25
+ * const { value } = attributes;
26
+ * return { value }
27
+ * })
28
+ * drawCustomShape(attributes, container) {
29
+ * this.upsert('custom', 'circle', { ...attributes }, container);
30
+ * }
31
+ * }
32
+ * ```
16
33
  */
17
34
  export declare function effect(styler: (self: any, attributes: Record<string, unknown>) => Record<string, unknown>): (target: Element, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -13,6 +13,20 @@ export interface HTMLStyleProps extends BaseNodeStyleProps {
13
13
  * <en/> HTML content, can be a string or `HTMLElement`
14
14
  */
15
15
  innerHTML: string | HTMLElement;
16
+ /**
17
+ * <zh/> 横行偏移量。HTML 容器默认以左上角为原点,通过 dx 来进行横向偏移
18
+ *
19
+ * <en/> Horizontal offset. The HTML container defaults to the upper left corner as the origin, and the horizontal offset is performed through dx
20
+ * @defaultValue 0
21
+ */
22
+ dx?: number;
23
+ /**
24
+ * <zh/> 纵向偏移量。HTML 容器默认以左上角为原点,通过 dy 来进行纵向偏移
25
+ *
26
+ * <en/> Vertical offset. The HTML container defaults to the upper left corner as the origin, and the vertical offset is performed through dy
27
+ * @defaultValue 0
28
+ */
29
+ dy?: number;
16
30
  }
17
31
  /**
18
32
  * <zh/> HTML 节点
@@ -26,11 +26,12 @@ export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps>
26
26
  * @param Ctor - <zh> 图形类型 | <en> shape type
27
27
  * @param style - <zh> 图形样式 | <en> shape style
28
28
  * @param container - <zh> 容器 | <en> container
29
+ * @param hooks - <zh> 钩子函数 | <en> hooks
29
30
  * @returns <zh> 图形实例 | <en> shape instance
30
31
  */
31
- protected upsert<T extends DisplayObject>(className: string, Ctor: {
32
+ protected upsert<T extends DisplayObject>(className: string, Ctor: string | {
32
33
  new (...args: any[]): T;
33
- }, style: T['attributes'] | false, container: DisplayObject): T | undefined;
34
+ }, style: T['attributes'] | false, container: DisplayObject, hooks?: UpsertHooks): T | undefined;
34
35
  /**
35
36
  * <zh/> 使用 transform 更新图形位置
36
37
  *
@@ -67,3 +68,51 @@ export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps>
67
68
  private setVisibility;
68
69
  destroy(): void;
69
70
  }
71
+ /**
72
+ * <zh/> 图形 upsert 方法生命周期钩子
73
+ *
74
+ * <en/> Shape upsert method lifecycle hooks
75
+ */
76
+ export interface UpsertHooks {
77
+ /**
78
+ * <zh/> 图形创建前
79
+ *
80
+ * <en/> Before creating the shape
81
+ */
82
+ beforeCreate?: () => void;
83
+ /**
84
+ * <zh/> 图形创建后
85
+ *
86
+ * <en/> After creating the shape
87
+ * @param instance - <zh/> 图形实例 | <en/> shape instance
88
+ */
89
+ afterCreate?: (instance: DisplayObject) => void;
90
+ /**
91
+ * <zh/> 图形更新前
92
+ *
93
+ * <en/> Before updating the shape
94
+ * @param instance - <zh/> 图形实例 | <en/> shape instance
95
+ */
96
+ beforeUpdate?: (instance: DisplayObject) => void;
97
+ /**
98
+ * <zh/> 图形更新后
99
+ *
100
+ * <en/> After updating the shape
101
+ * @param instance - <zh/> 图形实例 | <en/> shape instance
102
+ */
103
+ afterUpdate?: (instance: DisplayObject) => void;
104
+ /**
105
+ * <zh/> 图形销毁前
106
+ *
107
+ * <en/> Before destroying the shape
108
+ * @param instance - <zh/> 图形实例 | <en/> shape instance
109
+ */
110
+ beforeDestroy?: (instance: DisplayObject) => void;
111
+ /**
112
+ * <zh/> 图形销毁后
113
+ *
114
+ * <en/> After destroying the shape
115
+ * @param instance - <zh/> 图形实例 | <en/> shape instance
116
+ */
117
+ afterDestroy?: (instance: DisplayObject) => void;
118
+ }
@@ -2,10 +2,11 @@ export { BaseBehavior, BrushSelect, ClickSelect, CollapseExpand, CreateEdge, Dra
2
2
  export { CanvasEvent, ComboEvent, CommonEvent, ContainerEvent, EdgeEvent, ExtensionCategory, GraphEvent, HistoryEvent, NodeEvent, } from './constants';
3
3
  export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
4
4
  export { BaseEdge, Cubic, CubicHorizontal, CubicVertical, Line, Polyline, Quadratic } from './elements/edges';
5
+ export { effect } from './elements/effect';
5
6
  export { BaseNode, Circle, Diamond, Donut, Ellipse, HTML, Hexagon, Image, Rect, Star, Triangle, } from './elements/nodes';
6
7
  export { Badge, BaseShape, Icon, Label } from './elements/shapes';
7
8
  export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, ConcentricLayout, D3ForceLayout, DagreLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, MDSLayout, RadialLayout, RandomLayout, compactBox, dendrogram, indented, mindmap, } from './layouts';
8
- export { BasePlugin, BubbleSets, CameraSetting, Contextmenu, Fullscreen, GridLine, History, Hull, Legend, Minimap, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
9
+ export { BasePlugin, BubbleSets, CameraSetting, Contextmenu, EdgeFilterLens, Fisheye, Fullscreen, GridLine, History, Hull, Legend, Minimap, Snapline, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
9
10
  export { getExtension, getExtensions } from './registry/get';
10
11
  export { register } from './registry/register';
11
12
  export { Graph } from './runtime/graph';
@@ -28,10 +29,11 @@ export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps }
28
29
  export type { BaseEdgeStyleProps, CubicHorizontalStyleProps, CubicStyleProps, CubicVerticalStyleProps, LineStyleProps, PolylineStyleProps, QuadraticStyleProps, } from './elements/edges';
29
30
  export type { BaseNodeStyleProps, CircleStyleProps, DiamondStyleProps, DonutStyleProps, EllipseStyleProps, HTMLStyleProps, HexagonStyleProps, ImageStyleProps, RectStyleProps, StarStyleProps, TriangleStyleProps, } from './elements/nodes';
30
31
  export type { BadgeStyleProps, BaseShapeStyleProps, IconStyleProps, LabelStyleProps, PolygonStyleProps, } from './elements/shapes';
32
+ export type { UpsertHooks } from './elements/shapes/base-shape';
31
33
  export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shapes/contour';
32
34
  export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
33
35
  export type { CategoricalPalette } from './palettes/types';
34
- export type { BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
36
+ export type { BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, EdgeFilterLensOptions, FisheyeOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, SnaplineOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
35
37
  export type { DataURLOptions } from './runtime/canvas';
36
38
  export type { RuntimeContext } from './runtime/types';
37
39
  export type { BehaviorOptions, CanvasOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, GraphData, GraphOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions, ViewportOptions, } from './spec';
@@ -0,0 +1,141 @@
1
+ import type { BaseStyleProps } from '@antv/g';
2
+ import type { RuntimeContext } from '../../runtime/types';
3
+ import type { EdgeData, NodeData } from '../../spec';
4
+ import type { EdgeStyle } from '../../spec/element/edge';
5
+ import type { NodeStyle } from '../../spec/element/node';
6
+ import type { ElementType, ID, IPointerEvent } from '../../types';
7
+ import type { BasePluginOptions } from '../base-plugin';
8
+ import { BasePlugin } from '../base-plugin';
9
+ /**
10
+ * <zh/> 边过滤镜插件配置项
11
+ *
12
+ * <en/> Edge filter lens plugin options
13
+ */
14
+ export interface EdgeFilterLensOptions extends BasePluginOptions {
15
+ /**
16
+ * <zh/> 移动透镜的方式
17
+ * - `'pointermove'`:始终跟随鼠标移动
18
+ * - `'click'`:鼠标点击时透镜移动
19
+ * - `'drag'`:拖拽透镜
20
+ *
21
+ * <en/> The way to move the lens
22
+ * - `'pointermove'`: always follow the mouse movement
23
+ * - `'click'`: move the lens when the mouse clicks
24
+ * - `'drag'`: drag the lens
25
+ * @defaultValue 'pointermove'
26
+ */
27
+ trigger?: 'pointermove' | 'click' | 'drag';
28
+ /**
29
+ * <zh/> 透镜的半径
30
+ *
31
+ * <en/> The radius of the lens
32
+ * @defaultValue 60
33
+ */
34
+ r?: number;
35
+ /**
36
+ * <zh/> 透镜的最大半径。只有在 `scaleRBy` 为 `wheel` 时生效
37
+ *
38
+ * <en/> The maximum radius of the lens. Only valid when `scaleRBy` is `wheel`
39
+ * @defaultValue canvas 宽高最小值的一半
40
+ */
41
+ maxR?: number;
42
+ /**
43
+ * <zh/> 透镜的最小半径。只有在 `scaleRBy` 为 `wheel` 时生效
44
+ *
45
+ * <en/> The minimum radius of the lens. Only valid when `scaleRBy` is `wheel`
46
+ * @defaultValue 0
47
+ */
48
+ minR?: number;
49
+ /**
50
+ * <zh/> 缩放透镜半径的方式
51
+ * - `'wheel'`:通过滚轮缩放透镜的半径
52
+ *
53
+ * <en/> The way to scale the radius of the lens
54
+ * - `'wheel'`: scale the radius of the lens by the wheel
55
+ * @defaultValue `'wheel'`
56
+ */
57
+ scaleRBy?: 'wheel';
58
+ /**
59
+ * <zh/> 边显示的条件
60
+ * - `'both'`:只有起始节点和目标节点都在透镜中时,边才会显示
61
+ * - `'source'`:只有起始节点在透镜中时,边才会显示
62
+ * - `'target'`:只有目标节点在透镜中时,边才会显示
63
+ * - `'either'`:只要起始节点或目标节点有一个在透镜中时,边就会显示
64
+ *
65
+ * <en/> The condition for displaying the edge
66
+ * - `'both'`: The edge is displayed only when both the source node and the target node are in the lens
67
+ * - `'source'`: The edge is displayed only when the source node is in the lens
68
+ * - `'target'`: The edge is displayed only when the target node is in the lens
69
+ * - `'either'`: The edge is displayed when either the source node or the target node is in the lens
70
+ * @defaultValue 'both'
71
+ */
72
+ nodeType?: 'both' | 'source' | 'target' | 'either';
73
+ /**
74
+ * <zh/> 过滤出始终不在透镜中显示的元素
75
+ *
76
+ * <en/> Filter elements that are never displayed in the lens
77
+ * @param id - <zh/> 元素的 id | <en/> The id of the element
78
+ * @param elementType - <zh/> 元素的类型 | <en/> The type of the element
79
+ * @returns <zh/> 是否显示 | <en/> Whether to display
80
+ */
81
+ filter?: (id: ID, elementType: ElementType) => boolean;
82
+ /**
83
+ * <zh/> 透镜的样式
84
+ *
85
+ * <en/> The style of the lens
86
+ */
87
+ style?: BaseStyleProps;
88
+ /**
89
+ * <zh/> 在透镜中节点的样式
90
+ *
91
+ * <en/> The style of the nodes displayed in the lens
92
+ */
93
+ nodeStyle?: NodeStyle | ((datum: NodeData) => NodeStyle);
94
+ /**
95
+ * <zh/> 在透镜中边的样式
96
+ *
97
+ * <en/> The style of the edges displayed in the lens
98
+ */
99
+ edgeStyle?: EdgeStyle | ((datum: EdgeData) => EdgeStyle);
100
+ /**
101
+ * <zh/> 是否阻止默认事件
102
+ *
103
+ * <en/> Whether to prevent the default event
104
+ * @defaultValue true
105
+ */
106
+ preventDefault?: boolean;
107
+ }
108
+ /**
109
+ * <zh/> 边过滤镜插件
110
+ *
111
+ * <en/> Edge filter lens plugin
112
+ * @remarks
113
+ * <zh/> 边过滤镜可以将关注的边保留在过滤镜范围内,其他边将在该范围内不显示。
114
+ *
115
+ * <en/> EdgeFilterLens can keep the focused edges within the lens range, while other edges will not be displayed within that range.
116
+ */
117
+ export declare class EdgeFilterLens extends BasePlugin<EdgeFilterLensOptions> {
118
+ static defaultOptions: Partial<EdgeFilterLensOptions>;
119
+ constructor(context: RuntimeContext, options: EdgeFilterLensOptions);
120
+ private lens;
121
+ private shapes;
122
+ private r;
123
+ private get canvas();
124
+ private get isLensOn();
125
+ protected onEdgeFilter: (event: IPointerEvent) => void;
126
+ private renderLens;
127
+ private getFilterData;
128
+ private getFocusElements;
129
+ private renderFocusElements;
130
+ private getElementStyle;
131
+ private scaleRByWheel;
132
+ get graphDom(): import("@antv/g").CanvasLike | null;
133
+ private isLensDragging;
134
+ private onDragStart;
135
+ private onDrag;
136
+ private onDragEnd;
137
+ private bindEvents;
138
+ private unbindEvents;
139
+ update(options: Partial<EdgeFilterLensOptions>): void;
140
+ destroy(): void;
141
+ }
@@ -0,0 +1,167 @@
1
+ import type { CircleStyleProps } from '../../elements';
2
+ import type { RuntimeContext } from '../../runtime/types';
3
+ import type { NodeData } from '../../spec';
4
+ import type { NodeStyle } from '../../spec/element/node';
5
+ import type { IPointerEvent, Point } from '../../types';
6
+ import type { BasePluginOptions } from '../base-plugin';
7
+ import { BasePlugin } from '../base-plugin';
8
+ /**
9
+ * <zh/> 鱼眼放大镜插件配置项
10
+ *
11
+ * <en/> Fisheye Plugin Options
12
+ */
13
+ export interface FisheyeOptions extends BasePluginOptions {
14
+ /**
15
+ * <zh/> 移动鱼眼放大镜的方式
16
+ * - `'pointermove'`:始终跟随鼠标移动
17
+ * - `'click'`:鼠标点击时移动
18
+ * - `'drag'`:拖拽移动
19
+ *
20
+ * <en/> The way to move the fisheye lens
21
+ * - `'pointermove'`: always follow the mouse movement
22
+ * - `'click'`: move when the mouse is clicked
23
+ * - `'drag'`: move by dragging
24
+ * @defaultValue `'pointermove'`
25
+ */
26
+ trigger?: 'pointermove' | 'drag' | 'click';
27
+ /**
28
+ * <zh/> 鱼眼放大镜半径
29
+ *
30
+ * <en/> The radius of the fisheye lens
31
+ * @remarks
32
+ * <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*unAvQqAb_NMAAAAAAAAAAAAADmJ7AQ/original" width="200" />
33
+ * @defaultValue 120
34
+ */
35
+ r?: number;
36
+ /**
37
+ * <zh/> 鱼眼放大镜可调整的最大半径,配合 `scaleRBy` 使用
38
+ *
39
+ * <en/> The maximum radius that the fisheye lens can be adjusted, used with `scaleRBy`
40
+ * @defaultValue 画布宽高的最小值的一半
41
+ */
42
+ maxR?: number;
43
+ /**
44
+ * <zh/> 鱼眼放大镜可调整的最小半径,配合 `scaleRBy` 使用
45
+ *
46
+ * <en/> The minimum radius that the fisheye lens can be adjusted, used with `scaleRBy`
47
+ * @defaultValue 0
48
+ */
49
+ minR?: number;
50
+ /**
51
+ * <zh/> 调整鱼眼放大镜范围半径的方式
52
+ * - `'wheel'`:滚轮调整
53
+ * - `'drag'`:拖拽调整
54
+ *
55
+ * <en/> The way to adjust the range radius of the fisheye lens
56
+ * - `'wheel'`: adjust by wheel
57
+ * - `'drag'`: adjust by drag
58
+ * @remarks
59
+ * <zh/> 如果 `trigger`、`scaleRBy` 和 `scaleDBy` 同时设置为 `'drag'`,优先级顺序为 `trigger` > `scaleRBy` > `scaleDBy`,只会为优先级最高的配置项绑定拖拽事件。同理,如果 `scaleRBy` 和 `scaleDBy` 同时设置为 `'wheel'`,只会为 `scaleRBy` 绑定滚轮事件
60
+ *
61
+ * <en/> If `trigger`, `scaleRBy`, and `scaleDBy` are set to `'drag'` at the same time, the priority order is `trigger` > `scaleRBy` > `scaleDBy`, and only the configuration item with the highest priority will be bound to the drag event. Similarly, if `scaleRBy` and `scaleDBy` are set to `'wheel'` at the same time, only `scaleRBy` will be bound to the wheel event
62
+ */
63
+ scaleRBy?: 'wheel' | 'drag';
64
+ /**
65
+ * <zh/> 畸变因子
66
+ *
67
+ * <en/> Distortion factor
68
+ * @remarks
69
+ * <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*4ITFR7GOl8UAAAAAAAAAAAAADmJ7AQ/original" width="200" />
70
+ * @defaultValue 1.5
71
+ */
72
+ d?: number;
73
+ /**
74
+ * <zh/> 鱼眼放大镜可调整的最大畸变因子,配合 `scaleDBy` 使用
75
+ *
76
+ * <en/> The maximum distortion factor that the fisheye lens can be adjusted, used with `scaleDBy`
77
+ * @defaultValue 5
78
+ */
79
+ maxD?: number;
80
+ /**
81
+ * <zh/> 鱼眼放大镜可调整的最小畸变因子,配合 `scaleDBy` 使用
82
+ *
83
+ * <en/> The minimum distortion factor that the fisheye lens can be adjusted, used with `scaleDBy`
84
+ * @defaultValue 0
85
+ */
86
+ minD?: number;
87
+ /**
88
+ * <zh/> 调整鱼眼放大镜畸变因子的方式
89
+ * - `'wheel'`:滚轮调整
90
+ * - `'drag'`:拖拽调整
91
+ *
92
+ * <en/> The way to adjust the distortion factor of the fisheye lens
93
+ * - `'wheel'`: adjust by wheel
94
+ * - `'drag'`: adjust by drag
95
+ */
96
+ scaleDBy?: 'wheel' | 'drag';
97
+ /**
98
+ * <zh/> 是否在鱼眼放大镜中显示畸变因子数值
99
+ *
100
+ * <en/> Whether to display the value of the distortion factor in the fisheye lens
101
+ * @defaultValue true
102
+ */
103
+ showDPercent?: boolean;
104
+ /**
105
+ * <zh/> 鱼眼放大镜样式
106
+ *
107
+ * <en/> Fisheye Lens Style
108
+ */
109
+ style?: Partial<CircleStyleProps>;
110
+ /**
111
+ * <zh/> 在鱼眼放大镜中的节点样式
112
+ *
113
+ * <en/> Node style in the fisheye lens
114
+ */
115
+ nodeStyle?: NodeStyle | ((datum: NodeData) => NodeStyle);
116
+ /**
117
+ * <zh/> 是否阻止默认事件
118
+ *
119
+ * <en/> Whether to prevent the default event
120
+ * @defaultValue true
121
+ */
122
+ preventDefault?: boolean;
123
+ }
124
+ /**
125
+ * <zh/> 鱼眼放大镜
126
+ *
127
+ * <en/> Fisheye Distortion
128
+ * @remarks
129
+ * <zh/> Fisheye 鱼眼放大镜是为 focus+context 的探索场景设计的,它能够保证在放大关注区域的同时,保证上下文以及上下文与关注中心的关系不丢失。
130
+ *
131
+ * <en/> Fisheye is designed for focus+context exploration, it keeps the context and the relationships between context and the focus while magnifying the focus area.
132
+ */
133
+ export declare class Fisheye extends BasePlugin<FisheyeOptions> {
134
+ static defaultOptions: Partial<FisheyeOptions>;
135
+ constructor(context: RuntimeContext, options: FisheyeOptions);
136
+ private lens;
137
+ private r;
138
+ private d;
139
+ private get canvas();
140
+ private get isLensOn();
141
+ protected onCreateFisheye: (event: IPointerEvent) => void;
142
+ protected onMagnify: (origin: Point) => void;
143
+ private renderLens;
144
+ private getDPercent;
145
+ private prevMagnifiedStyleMap;
146
+ private prevOriginStyleMap;
147
+ private renderFocusElements;
148
+ private getNodeStyle;
149
+ private updateStyle;
150
+ private isWheelValid;
151
+ private scaleR;
152
+ private scaleD;
153
+ private scaleRByWheel;
154
+ private scaleDByWheel;
155
+ private isDragValid;
156
+ private isLensDragging;
157
+ private onDragStart;
158
+ private onDrag;
159
+ private onDragEnd;
160
+ private scaleRByDrag;
161
+ private scaleDByDrag;
162
+ get graphDom(): import("@antv/g").CanvasLike | null;
163
+ private bindEvents;
164
+ private unbindEvents;
165
+ update(options: Partial<FisheyeOptions>): void;
166
+ destroy(): void;
167
+ }
@@ -3,6 +3,8 @@ 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 { EdgeFilterLens } from './edge-filter-lens';
7
+ export { Fisheye } from './fisheye';
6
8
  export { Fullscreen } from './fullscreen';
7
9
  export { GridLine } from './grid-line';
8
10
  export { History } from './history';
@@ -19,6 +21,8 @@ export type { BasePluginOptions } from './base-plugin';
19
21
  export type { BubbleSetsOptions } from './bubble-sets';
20
22
  export type { CameraSettingOptions } from './camera-setting';
21
23
  export type { ContextmenuOptions } from './contextmenu';
24
+ export type { EdgeFilterLensOptions } from './edge-filter-lens';
25
+ export type { FisheyeOptions } from './fisheye';
22
26
  export type { FullscreenOptions } from './fullscreen';
23
27
  export type { GridLineOptions } from './grid-line';
24
28
  export type { HistoryOptions } from './history';
@@ -106,6 +106,7 @@ export declare class Tooltip extends BasePlugin<TooltipOptions> {
106
106
  * @param event - <zh/> 目标元素,不传则为外部调用 | <en/> Target element, not passed in as external call
107
107
  */
108
108
  hide: (event?: IElementEvent) => void;
109
+ private get tooltipStyleProps();
109
110
  private initTooltip;
110
111
  /**
111
112
  * <zh/> 销毁tooltip
@@ -1,3 +1,4 @@
1
+ import type { DisplayObject } from '@antv/g';
1
2
  import type { STDAnimation } from '../animations/types';
2
3
  import type { Behavior } from '../behaviors/types';
3
4
  import type { Layout } from '../layouts/types';
@@ -36,4 +37,7 @@ export interface ExtensionRegistry {
36
37
  transform: Record<string, {
37
38
  new (...args: any[]): Transform;
38
39
  }>;
40
+ shape: Record<string, {
41
+ new (...args: any[]): DisplayObject;
42
+ }>;
39
43
  }
@@ -51,7 +51,7 @@ export declare class ElementController {
51
51
  getStateStyle(id: ID): Record<string, unknown>;
52
52
  private computeStyle;
53
53
  getElement<T extends Element>(id: ID): T | undefined;
54
- getElementZIndex(id: ID): any;
54
+ getElementZIndex(id: ID): number;
55
55
  getNodes(): Node[];
56
56
  getEdges(): Edge[];
57
57
  getCombos(): Combo[];
@@ -118,4 +118,6 @@ export interface DrawContext {
118
118
  collapseExpandTarget?: ID;
119
119
  /** <zh/> 绘制类型 | <en/> Draw type */
120
120
  type?: 'render' | 'draw';
121
+ /** <zh/> 展开阶段的目标元素 id | <en/> ID of the target element in the expand stage */
122
+ target?: ID;
121
123
  }
@@ -6,5 +6,5 @@ export declare class PluginController extends ExtensionController<BasePlugin<Cus
6
6
  category: "plugin";
7
7
  constructor(context: RuntimeContext);
8
8
  setPlugins(plugins: PluginOptions): void;
9
- getPluginInstance(key: string): BasePlugin<CustomPluginOption>;
9
+ getPluginInstance(key: string): BasePlugin<CustomPluginOption> | undefined;
10
10
  }
@@ -70,6 +70,13 @@ export interface BaseElementStyleProps extends BaseShapeStyleProps {
70
70
  * <en/> Element methods
71
71
  */
72
72
  export interface ElementMethods {
73
+ /**
74
+ * <zh/> 更新元素属性
75
+ *
76
+ * <en/> Update element attributes
77
+ * @param attr - <zh/> 属性 | <en/> Attributes
78
+ */
79
+ update(attr: any): void;
73
80
  /**
74
81
  * <zh/> 获取当前元素内的子图形
75
82
  *
@@ -5,12 +5,15 @@
5
5
  */
6
6
  export declare function sizeOf(container: HTMLElement): [number, number];
7
7
  /**
8
- * Create a plugin DOM element.
9
- * @param type - plugin type
10
- * @param cover - cover the container
11
- * @returns plugin DOM element
8
+ * <zh/> 创建插件容器
9
+ *
10
+ * <en/> Create a plugin container
11
+ * @param type - <zh/> 插件类型 | <en/> plugin type
12
+ * @param cover - <zh/> 容器是否覆盖整个画布 | <en/> Whether the container covers the entire canvas
13
+ * @param style - <zh/> 额外样式 | <en/> Additional style
14
+ * @returns <zh/> 插件容器 | <en/> plugin container
12
15
  */
13
- export declare function createPluginContainer(type: string, cover?: boolean): HTMLDivElement;
16
+ export declare function createPluginContainer(type: string, cover?: boolean, style?: Partial<CSSStyleDeclaration>): HTMLElement;
14
17
  /**
15
18
  * Create a DOM element, if exists, remove it and create a new one.
16
19
  * @param id - id
@@ -1 +1 @@
1
- export declare const version = "5.0.16";
1
+ export declare const version = "5.0.18";
@@ -63,7 +63,6 @@ export interface ClickSelectOptions extends BaseBehaviorOptions {
63
63
  * <zh/> 当有元素被选中时,除了选中元素及其受影响的邻居元素外,其他所有元素应用的状态。
64
64
  *
65
65
  * <en/> The state to be applied to all unselected elements when some elements are selected, excluding the selected element and its affected neighbors
66
- * @defaultValue undefined
67
66
  */
68
67
  unselectedState?: State;
69
68
  /**