@antv/g6 5.0.0-beta.2 → 5.0.0-beta.4

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 (82) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/constant/shape.d.ts +2 -0
  3. package/esm/index.d.ts +2 -1
  4. package/esm/index.js +1 -1
  5. package/esm/item/node.js +8 -3
  6. package/esm/item/node.js.map +1 -1
  7. package/esm/stdlib/behavior/index.d.ts +1 -0
  8. package/esm/stdlib/behavior/index.js +1 -0
  9. package/esm/stdlib/behavior/index.js.map +1 -1
  10. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  11. package/esm/stdlib/behavior/shortcuts-call.js +80 -0
  12. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  13. package/esm/stdlib/index.d.ts +1 -0
  14. package/esm/stdlib/index.js +3 -2
  15. package/esm/stdlib/index.js.map +1 -1
  16. package/esm/stdlib/item/node/base.js +7 -14
  17. package/esm/stdlib/item/node/base.js.map +1 -1
  18. package/esm/stdlib/item/node/diamond.js +1 -1
  19. package/esm/stdlib/item/node/ellipse.js +2 -2
  20. package/esm/stdlib/item/node/hexagon.js +6 -2
  21. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  22. package/esm/stdlib/item/node/image.d.ts +40 -0
  23. package/esm/stdlib/item/node/image.js +110 -0
  24. package/esm/stdlib/item/node/image.js.map +1 -0
  25. package/esm/stdlib/item/node/index.d.ts +1 -0
  26. package/esm/stdlib/item/node/index.js +1 -0
  27. package/esm/stdlib/item/node/index.js.map +1 -1
  28. package/esm/stdlib/theme/dark.js +42 -2
  29. package/esm/stdlib/theme/dark.js.map +1 -1
  30. package/esm/stdlib/theme/light.js +4 -4
  31. package/esm/types/event.d.ts +1 -0
  32. package/esm/types/item.d.ts +6 -0
  33. package/esm/types/item.js.map +1 -1
  34. package/lib/constant/shape.d.ts +2 -0
  35. package/lib/index.d.ts +2 -1
  36. package/lib/index.js +1 -1
  37. package/lib/item/node.js +8 -3
  38. package/lib/item/node.js.map +1 -1
  39. package/lib/stdlib/behavior/index.d.ts +1 -0
  40. package/lib/stdlib/behavior/index.js +1 -0
  41. package/lib/stdlib/behavior/index.js.map +1 -1
  42. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  43. package/lib/stdlib/behavior/shortcuts-call.js +84 -0
  44. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  45. package/lib/stdlib/index.d.ts +1 -0
  46. package/lib/stdlib/index.js +3 -2
  47. package/lib/stdlib/index.js.map +1 -1
  48. package/lib/stdlib/item/node/base.js +7 -14
  49. package/lib/stdlib/item/node/base.js.map +1 -1
  50. package/lib/stdlib/item/node/diamond.js +1 -1
  51. package/lib/stdlib/item/node/ellipse.js +2 -2
  52. package/lib/stdlib/item/node/hexagon.js +6 -2
  53. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  54. package/lib/stdlib/item/node/image.d.ts +40 -0
  55. package/lib/stdlib/item/node/image.js +114 -0
  56. package/lib/stdlib/item/node/image.js.map +1 -0
  57. package/lib/stdlib/item/node/index.d.ts +1 -0
  58. package/lib/stdlib/item/node/index.js +1 -0
  59. package/lib/stdlib/item/node/index.js.map +1 -1
  60. package/lib/stdlib/theme/dark.js +42 -2
  61. package/lib/stdlib/theme/dark.js.map +1 -1
  62. package/lib/stdlib/theme/light.js +4 -4
  63. package/lib/types/event.d.ts +1 -0
  64. package/lib/types/item.d.ts +6 -0
  65. package/lib/types/item.js.map +1 -1
  66. package/package.json +2 -4
  67. package/src/constant/shape.ts +1 -1
  68. package/src/index.ts +1 -1
  69. package/src/item/node.ts +8 -3
  70. package/src/stdlib/behavior/index.ts +1 -0
  71. package/src/stdlib/behavior/shortcuts-call.ts +120 -0
  72. package/src/stdlib/index.ts +3 -0
  73. package/src/stdlib/item/node/base.ts +9 -15
  74. package/src/stdlib/item/node/diamond.ts +1 -1
  75. package/src/stdlib/item/node/ellipse.ts +2 -2
  76. package/src/stdlib/item/node/hexagon.ts +6 -2
  77. package/src/stdlib/item/node/image.ts +190 -0
  78. package/src/stdlib/item/node/index.ts +1 -0
  79. package/src/stdlib/theme/dark.ts +66 -2
  80. package/src/stdlib/theme/light.ts +4 -4
  81. package/src/types/event.ts +1 -0
  82. package/src/types/item.ts +10 -0
@@ -1 +1 @@
1
- {"version":3,"file":"item.js","sourceRoot":"src/","sources":["types/item.ts"],"names":[],"mappings":";;;AAqIA,IAAY,aAaX;AAbD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;IACf,4CAA2B,CAAA;IAC3B,4CAA2B,CAAA;IAC3B,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,8BAAa,CAAA;IACb,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,4BAAW,CAAA;IACX,sCAAqB,CAAA;AACvB,CAAC,EAbW,aAAa,6BAAb,aAAa,QAaxB"}
1
+ {"version":3,"file":"item.js","sourceRoot":"src/","sources":["types/item.ts"],"names":[],"mappings":";;;AA+IA,IAAY,aAaX;AAbD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;IACf,4CAA2B,CAAA;IAC3B,4CAA2B,CAAA;IAC3B,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,8BAAa,CAAA;IACb,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,4BAAW,CAAA;IACX,sCAAqB,CAAA;AACvB,CAAC,EAbW,aAAa,6BAAb,aAAa,QAaxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g6",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.4",
4
4
  "description": "A Graph Visualization Framework in JavaScript",
5
5
  "keywords": [
6
6
  "antv",
@@ -69,18 +69,16 @@
69
69
  "@antv/g-plugin-control": "^1.7.43",
70
70
  "@antv/g-plugin-dragndrop": "^1.8.1",
71
71
  "@antv/g-svg": "^1.8.36",
72
- "@antv/g-webgl": "^1.9.18",
72
+ "@antv/g-webgl": "^1.9.19",
73
73
  "@antv/graphlib": "^2.0.2",
74
74
  "@antv/gui": "0.5.1-alpha.1",
75
75
  "@antv/hierarchy": "latest",
76
76
  "@antv/layout": "^1.2.9",
77
- "@antv/hierarchy": "latest",
78
77
  "@antv/layout-gpu": "^1.1.5",
79
78
  "@antv/layout-wasm": "1.3.1",
80
79
  "@antv/matrix-util": "^3.0.4",
81
80
  "@antv/util": "~2.0.5",
82
81
  "@antv/path-util": "3.0.1",
83
- "@antv/util": "^3.3.1",
84
82
  "color": "^4.2.3",
85
83
  "insert-css": "^2.0.0",
86
84
  "stats-js": "^1.0.1",
@@ -1,5 +1,5 @@
1
- import { ShapeStyle } from '../types/item';
2
1
  import type { StandardPadding } from 'types/common';
2
+ import { ShapeStyle } from '../types/item';
3
3
 
4
4
  export const RESERVED_SHAPE_IDS = [
5
5
  'keyShape',
package/src/index.ts CHANGED
@@ -14,7 +14,7 @@ runtime.enableCSSParsing = false;
14
14
  * Extend the graph class with std lib
15
15
  */
16
16
 
17
- const version = '5.0.0-beta.2';
17
+ const version = '5.0.0-beta.4';
18
18
 
19
19
  const Graph = extend(EmptyGraph, stdLib);
20
20
 
package/src/item/node.ts CHANGED
@@ -192,7 +192,11 @@ export default class Node extends Item {
192
192
  return;
193
193
  }
194
194
  }
195
- group.setLocalPosition([position.x, position.y, position.z]);
195
+ group.setLocalPosition([
196
+ position.x as number,
197
+ position.y as number,
198
+ position.z,
199
+ ]);
196
200
  onfinish(displayModel.id, !animate);
197
201
  }
198
202
 
@@ -297,12 +301,13 @@ export default class Node extends Item {
297
301
  intersectPoint = innerPoint;
298
302
  break;
299
303
  default: {
304
+ // boundsCache can be removed here since `getBounds` has already done.
300
305
  intersectPoint = getRectIntersectByPoint(
301
306
  {
302
307
  x: keyShapeRenderBBox.min[0],
303
308
  y: keyShapeRenderBBox.min[1],
304
- width: keyShapeRenderBBox.max[0] - keyShapeRenderBBox.min[0],
305
- height: keyShapeRenderBBox.max[1] - keyShapeRenderBBox.min[1],
309
+ width: keyShapeWidth,
310
+ height: keyShapeHeight,
306
311
  },
307
312
  point,
308
313
  );
@@ -13,3 +13,4 @@ export * from './orbit-canvas-3d';
13
13
  export * from './rotate-canvas-3d';
14
14
  export * from './track-canvas-3d';
15
15
  export * from './zoom-canvas-3d';
16
+ export * from './shortcuts-call';
@@ -0,0 +1,120 @@
1
+ import type { IG6GraphEvent } from '../../types';
2
+ import { Behavior } from '../../types/behavior';
3
+
4
+ const DEFAULT_TRIGGER = 'ctrl';
5
+ const ALLOW_TRIGGERS = ['shift', 'ctrl', 'alt', 'control'] as const;
6
+ const DEFAULT_COMBINED_KEY = '1';
7
+ type Trigger = (typeof ALLOW_TRIGGERS)[number];
8
+
9
+ interface ShortcutsCallOptions {
10
+ /**
11
+ * The main key to pressed to apply shortcuts call
12
+ * Defaults to `"ctrl"`.
13
+ */
14
+ trigger?: Trigger;
15
+ /**
16
+ * The combined key to pressed with trigger to apply shortcuts call.
17
+ * Defaults to `"1"`.
18
+ */
19
+ combinedKey?: string;
20
+ /**
21
+ *
22
+ * The function to be called.
23
+ * Defaults to `"fitView"`.
24
+ *
25
+ */
26
+ functionName?: string;
27
+ /**
28
+ * The function params.
29
+ */
30
+ functionParams?: any[];
31
+ }
32
+
33
+ const DEFAULT_OPTIONS: ShortcutsCallOptions = {
34
+ trigger: DEFAULT_TRIGGER,
35
+ combinedKey: DEFAULT_COMBINED_KEY,
36
+ functionName: 'fitView',
37
+ functionParams: [],
38
+ };
39
+
40
+ export class ShortcutsCall extends Behavior {
41
+ triggerKeydown = false;
42
+
43
+ constructor(options: Partial<ShortcutsCallOptions>) {
44
+ super(Object.assign({}, DEFAULT_OPTIONS, options));
45
+ // Validate options
46
+ if (options.trigger && !ALLOW_TRIGGERS.includes(options.trigger)) {
47
+ console.warn(
48
+ `G6: Invalid trigger option "${options.trigger}" for shortcuts-call behavior!`,
49
+ );
50
+ this.options.trigger = DEFAULT_OPTIONS.trigger;
51
+ }
52
+ if (options.combinedKey === this.options.trigger) {
53
+ this.options.combinedKey = undefined;
54
+ }
55
+ }
56
+
57
+ getEvents = () => {
58
+ return {
59
+ keyup: this.onKeyUp,
60
+ keydown: this.onKeyDown,
61
+ };
62
+ };
63
+
64
+ public onKeyDown(e: IG6GraphEvent) {
65
+ const code = e.key;
66
+ if (!code) return;
67
+
68
+ const { graph } = this;
69
+ const { trigger, combinedKey, functionName, functionParams } = this.options;
70
+
71
+ const triggerLowerCase = trigger.toLowerCase();
72
+ const codeLowerCase = code.toLowerCase();
73
+ // While holding down the Control key, allow users to set the trigger as "ctrl".
74
+ if (!this.triggerKeydown) {
75
+ if (
76
+ codeLowerCase === triggerLowerCase ||
77
+ (codeLowerCase === 'control' && triggerLowerCase === 'ctrl') ||
78
+ (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
79
+ ) {
80
+ this.triggerKeydown = true;
81
+ } else {
82
+ this.triggerKeydown = false;
83
+ }
84
+ }
85
+
86
+ if (!graph[functionName]) {
87
+ console.warn(
88
+ `G6: Invalid functionName option: "${functionName}" for shortcuts-call behavior!`,
89
+ );
90
+ return {};
91
+ }
92
+ if (!this.triggerKeydown) return;
93
+
94
+ if (!combinedKey) {
95
+ if (functionParams && functionParams.length) {
96
+ graph[functionName](...functionParams);
97
+ } else {
98
+ graph[functionName]();
99
+ }
100
+ return;
101
+ }
102
+
103
+ const combinedKeyLowerCase = combinedKey.toLowerCase();
104
+ if (
105
+ codeLowerCase === combinedKeyLowerCase ||
106
+ (codeLowerCase === 'control' && combinedKeyLowerCase === 'ctrl') ||
107
+ (codeLowerCase === 'ctrl' && combinedKeyLowerCase === 'control')
108
+ ) {
109
+ if (functionParams && functionParams.length) {
110
+ graph[functionName](...functionParams);
111
+ } else {
112
+ graph[functionName]();
113
+ }
114
+ }
115
+ }
116
+
117
+ public onKeyUp() {
118
+ this.triggerKeydown = false;
119
+ }
120
+ }
@@ -31,6 +31,7 @@ const {
31
31
  TriangleNode,
32
32
  EllipseNode,
33
33
  ModelRectNode,
34
+ ImageNode,
34
35
  } = Nodes;
35
36
 
36
37
  const {
@@ -60,6 +61,7 @@ const {
60
61
  DragNode,
61
62
  DragCombo,
62
63
  ClickSelect,
64
+ ShortcutsCall,
63
65
  } = Behaviors;
64
66
  const {
65
67
  History,
@@ -128,6 +130,7 @@ const stdLib = {
128
130
  nodes: {
129
131
  'circle-node': CircleNode,
130
132
  'rect-node': RectNode,
133
+ 'image-node': ImageNode,
131
134
  },
132
135
  edges: {
133
136
  'line-edge': LineEdge,
@@ -186,10 +186,10 @@ export abstract class BaseNode {
186
186
  });
187
187
  this.zoomCache.levelShapes = levelShapes;
188
188
 
189
- if (shapeMap.labelShape && this.boundsCache.keyShapeLocal) {
189
+ if (shapeMap.labelShape) {
190
190
  const { maxWidth = '200%' } = this.mergedStyles.labelShape || {};
191
191
  this.zoomCache.wordWrapWidth = getWordWrapWidthByBox(
192
- this.boundsCache.keyShapeLocal,
192
+ shapeMap.keyShape.getLocalBounds(),
193
193
  maxWidth,
194
194
  1,
195
195
  );
@@ -286,12 +286,10 @@ export abstract class BaseNode {
286
286
  const { labelShape: shapeStyle } = this.mergedStyles;
287
287
  if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
288
288
  const { keyShape } = shapeMap;
289
- this.boundsCache.keyShapeLocal =
290
- this.boundsCache.keyShapeLocal || keyShape.getLocalBounds();
291
289
  const keyShapeBox = getShapeLocalBoundsByStyle(
292
290
  keyShape,
293
291
  this.mergedStyles.keyShape,
294
- this.boundsCache.keyShapeLocal,
292
+ keyShape.getLocalBounds(),
295
293
  );
296
294
  const {
297
295
  position,
@@ -577,12 +575,12 @@ export abstract class BaseNode {
577
575
  position: string | [number, number],
578
576
  anchorPositionMap: IAnchorPositionMap,
579
577
  ): [number, number] {
580
- const keyShapeBBox = this.boundsCache.keyShapeLocal;
578
+ const keyShapeBBox = this.boundsCache.keyShapeLocal!;
581
579
  const keyShapeWidth = keyShapeBBox.max[0] - keyShapeBBox.min[0];
582
580
  const keyShapeHeight = keyShapeBBox.max[1] - keyShapeBBox.min[1];
583
581
  const defaultPosition: [number, number] = [
584
- keyShapeBBox.max[0],
585
- keyShapeBBox.min[1],
582
+ keyShapeBBox.max[0] - keyShapeBBox.center[0],
583
+ keyShapeBBox.min[1] - keyShapeBBox.center[1],
586
584
  ]; //topRight
587
585
  if (position instanceof Array) {
588
586
  return [
@@ -645,12 +643,10 @@ export abstract class BaseNode {
645
643
  (style) => style.tag === 'badgeShape',
646
644
  );
647
645
  if (!individualConfigs.length) return {};
648
- this.boundsCache.keyShapeLocal =
649
- this.boundsCache.keyShapeLocal || shapeMap.keyShape.getLocalBounds();
650
646
  const keyShapeBBox = getShapeLocalBoundsByStyle(
651
647
  shapeMap.keyShape,
652
648
  keyShapeStyle,
653
- this.boundsCache.keyShapeLocal,
649
+ shapeMap.keyShape.getLocalBounds(),
654
650
  );
655
651
  const keyShapeSize = Math.min(
656
652
  keyShapeBBox.max[0] - keyShapeBBox.min[0],
@@ -759,8 +755,6 @@ export abstract class BaseNode {
759
755
  (text as string).length <= 1
760
756
  ? bgHeight
761
757
  : Math.max(bgHeight, bbox.max[0] - bbox.min[0]) + 8;
762
- let bgX = isLeft ? pos.x - bgWidth : pos.x;
763
- if (isCenter) bgX = pos.x - bgWidth / 2;
764
758
  shapes[bgShapeId] = this.upsertShape(
765
759
  'rect',
766
760
  bgShapeId,
@@ -771,8 +765,8 @@ export abstract class BaseNode {
771
765
  width: bgWidth,
772
766
  radius: bgHeight / 2,
773
767
  zIndex,
774
- x: bgX,
775
- y: pos.y,
768
+ x: bbox.center[0] - bgWidth / 2,
769
+ y: bbox.center[1] - bgHeight / 2,
776
770
  ...otherStyles,
777
771
  } as GShapeStyle,
778
772
  shapeMap,
@@ -12,7 +12,7 @@ type PathArray = any; //TODO: cannot import type PathArray
12
12
  export class DiamondNode extends BaseNode {
13
13
  override defaultStyles = {
14
14
  keyShape: {
15
- size: [50, 30],
15
+ size: [32, 32],
16
16
  x: 0,
17
17
  y: 0,
18
18
  },
@@ -11,8 +11,8 @@ import { BaseNode } from './base';
11
11
  export class EllipseNode extends BaseNode {
12
12
  override defaultStyles = {
13
13
  keyShape: {
14
- rx: 30,
15
- ry: 20,
14
+ rx: 16,
15
+ ry: 12,
16
16
  x: 0,
17
17
  y: 0,
18
18
  },
@@ -17,10 +17,10 @@ const offsetAngleMap = {
17
17
  export class HexagonNode extends BaseNode {
18
18
  override defaultStyles = {
19
19
  keyShape: {
20
- r: 20,
20
+ r: 16,
21
21
  x: 0,
22
22
  y: 0,
23
- direction: 'horizontal',
23
+ direction: 'vertical',
24
24
  },
25
25
  };
26
26
  mergedStyles: NodeShapeStyles;
@@ -167,6 +167,10 @@ export class HexagonNode extends BaseNode {
167
167
  const vy = r * Math.sin(angle);
168
168
  anchorPositionMap[anchorPositionDirection[i]] = [vx, vy];
169
169
  }
170
+ if (!anchorPositionMap.hasOwnProperty('default')) {
171
+ anchorPositionMap['default'] =
172
+ anchorPositionMap[anchorPositionDirection[0]];
173
+ }
170
174
  return anchorPositionMap;
171
175
  }
172
176
  }
@@ -0,0 +1,190 @@
1
+ import { DisplayObject } from '@antv/g';
2
+ import { ComboDisplayModel, NodeDisplayModel } from '../../../types';
3
+ import { State } from '../../../types/item';
4
+ import {
5
+ NodeModelData,
6
+ NodeShapeMap,
7
+ NodeShapeStyles,
8
+ } from '../../../types/node';
9
+ import { convertToNumber } from '../../../util/type';
10
+ import { BaseNode } from './base';
11
+ import { ComboModelData, ComboShapeMap } from '../../../types/combo';
12
+ import { ShapeTagMap } from '../../../util/shape';
13
+
14
+ export class ImageNode extends BaseNode {
15
+ override defaultStyles = {
16
+ keyShape: {
17
+ x: 0,
18
+ y: 0,
19
+ width: 32,
20
+ height: 32,
21
+ },
22
+ };
23
+ mergedStyles: NodeShapeStyles;
24
+ constructor(props) {
25
+ super(props);
26
+ // suggest to merge default styles like this to avoid style value missing
27
+ // this.defaultStyles = mergeStyles([this.baseDefaultStyles, this.defaultStyles]);
28
+ }
29
+
30
+ public override drawKeyShape(
31
+ model: NodeDisplayModel,
32
+ shapeMap: NodeShapeMap,
33
+ diffData?: { previous: NodeModelData; current: NodeModelData },
34
+ diffState?: { previous: State[]; current: State[] },
35
+ ): DisplayObject {
36
+ const clipCfg = this.mergedStyles.keyShape?.clipCfg;
37
+ let clipPath: DisplayObject | undefined;
38
+ if (clipCfg) {
39
+ const { type, ...rest } = clipCfg;
40
+ clipPath = new ShapeTagMap[type]();
41
+ clipPath.attr(rest);
42
+ }
43
+
44
+ const shape = this.upsertShape(
45
+ 'image',
46
+ 'keyShape',
47
+ {
48
+ ...this.mergedStyles.keyShape,
49
+ x: this.mergedStyles.keyShape!.x,
50
+ y: this.mergedStyles.keyShape!.y,
51
+ anchor: '0.5 0.5',
52
+ },
53
+ shapeMap,
54
+ model,
55
+ );
56
+
57
+ if (clipPath) {
58
+ shape.appendChild(clipPath);
59
+ shape.attr('clipPath', clipPath);
60
+ }
61
+
62
+ return shape;
63
+ }
64
+
65
+ public override calculateAnchorPosition(keyShapeStyle) {
66
+ const x = convertToNumber(keyShapeStyle.x);
67
+ const y = convertToNumber(keyShapeStyle.y);
68
+ const height = keyShapeStyle.height;
69
+ const width = keyShapeStyle.width;
70
+ const anchorPositionMap = {};
71
+ anchorPositionMap['top'] = [x, y - height / 2];
72
+ anchorPositionMap['left'] = [x - width / 2, y];
73
+ anchorPositionMap['right'] = anchorPositionMap['default'] = [
74
+ x + width / 2,
75
+ y,
76
+ ];
77
+ anchorPositionMap['bottom'] = [x, y + height / 2];
78
+ return anchorPositionMap;
79
+ }
80
+
81
+ public draw(
82
+ model: NodeDisplayModel,
83
+ shapeMap: NodeShapeMap,
84
+ diffData?: { previous: NodeModelData; current: NodeModelData },
85
+ diffState?: { previous: State[]; current: State[] },
86
+ ): NodeShapeMap {
87
+ const { data = {} } = model;
88
+ let shapes: NodeShapeMap = { keyShape: undefined };
89
+
90
+ // keyShape
91
+ shapes.keyShape = this.drawKeyShape(model, shapeMap, diffData);
92
+
93
+ // labelShape
94
+ if (data.labelShape) {
95
+ shapes.labelShape = this.drawLabelShape(model, shapeMap, diffData);
96
+ }
97
+
98
+ // haloShape
99
+ if (data.haloShape && this.drawHaloShape) {
100
+ shapes.haloShape = this.drawHaloShape(model, shapeMap, diffData);
101
+ }
102
+
103
+ // labelBackgroundShape
104
+ if (data.labelBackgroundShape) {
105
+ shapes.labelBackgroundShape = this.drawLabelBackgroundShape(
106
+ model,
107
+ shapeMap,
108
+ diffData,
109
+ );
110
+ }
111
+
112
+ // anchor shapes
113
+ if (data.anchorShapes) {
114
+ const anchorShapes = this.drawAnchorShapes(
115
+ model,
116
+ shapeMap,
117
+ diffData,
118
+ diffState,
119
+ );
120
+ shapes = {
121
+ ...shapes,
122
+ ...anchorShapes,
123
+ };
124
+ }
125
+
126
+ // iconShape
127
+ if (data.iconShape) {
128
+ shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
129
+ }
130
+
131
+ // badgeShape
132
+ if (data.badgeShapes) {
133
+ const badgeShapes = this.drawBadgeShapes(
134
+ model,
135
+ shapeMap,
136
+ diffData,
137
+ diffState,
138
+ );
139
+ shapes = {
140
+ ...shapes,
141
+ ...badgeShapes,
142
+ };
143
+ }
144
+
145
+ // otherShapes
146
+ if (data.otherShapes && this.drawOtherShapes) {
147
+ shapes = {
148
+ ...shapes,
149
+ ...this.drawOtherShapes(model, shapeMap, diffData),
150
+ };
151
+ }
152
+ return shapes;
153
+ }
154
+
155
+ public drawHaloShape(
156
+ model: NodeDisplayModel | ComboDisplayModel,
157
+ shapeMap: NodeShapeMap | ComboShapeMap,
158
+ diffData?: {
159
+ previous: NodeModelData | ComboModelData;
160
+ current: NodeModelData | ComboModelData;
161
+ },
162
+ diffState?: { previous: State[]; current: State[] },
163
+ ): DisplayObject {
164
+ const { keyShape } = shapeMap;
165
+ const { haloShape: haloShapeStyle, keyShape: keyShapeStyle } =
166
+ this.mergedStyles;
167
+ if (haloShapeStyle?.visible === false) return;
168
+
169
+ const clipShape = haloShapeStyle?.clipCfg?.type || 'rect';
170
+ const { attributes } = keyShape;
171
+ const { x, y, fill } = attributes;
172
+
173
+ return this.upsertShape(
174
+ clipShape,
175
+ 'haloShape',
176
+ {
177
+ ...attributes,
178
+ ...keyShapeStyle,
179
+ x,
180
+ y,
181
+ stroke: fill,
182
+ ...haloShapeStyle,
183
+ fill: 'transparent',
184
+ batchKey: 'halo',
185
+ },
186
+ shapeMap,
187
+ model,
188
+ );
189
+ }
190
+ }
@@ -8,3 +8,4 @@ export * from './ellipse';
8
8
  export * from './donut';
9
9
  export * from './diamond';
10
10
  export * from './modelRect';
11
+ export * from './image';
@@ -7,6 +7,7 @@ const textColor = 'rgba(255,255,255,0.85)';
7
7
  const nodeColor = 'rgb(34,126,255)';
8
8
  const edgeColor = 'rgb(153, 173, 209)';
9
9
  const comboFill = 'rgb(253, 253, 253)';
10
+ const comboStroke = 'rgba(153,173,209,1)';
10
11
  const disabledFill = '#D0E4FF';
11
12
 
12
13
  const edgeMainStroke = '#637088';
@@ -105,7 +106,7 @@ export const DarkTheme = {
105
106
  },
106
107
  haloShape: {
107
108
  opacity: 0.45,
108
- lineWidth: 20,
109
+ lineWidth: 12,
109
110
  zIndex: -1,
110
111
  pointerEvents: 'none',
111
112
  visible: true,
@@ -118,7 +119,7 @@ export const DarkTheme = {
118
119
  },
119
120
  haloShape: {
120
121
  opacity: 0.25,
121
- lineWidth: 20,
122
+ lineWidth: 12,
122
123
  zIndex: -1,
123
124
  pointerEvents: 'none',
124
125
  visible: true,
@@ -301,6 +302,23 @@ export const DarkTheme = {
301
302
  height: 10,
302
303
  padding: [25, 20, 15, 20],
303
304
  },
305
+ labelShape: {
306
+ ...DEFAULT_TEXT_STYLE,
307
+ fill: textColor,
308
+ opacity: 0.85,
309
+ position: 'bottom',
310
+ zIndex: 2,
311
+ lod: 0,
312
+ maxLines: 1,
313
+ },
314
+ labelBackgroundShape: {
315
+ padding: [2, 4, 2, 4],
316
+ lineWidth: 0,
317
+ fill: '#000',
318
+ opacity: 0.75,
319
+ zIndex: 1,
320
+ lod: 0,
321
+ },
304
322
  },
305
323
  selected: {
306
324
  keyShape: {
@@ -311,12 +329,30 @@ export const DarkTheme = {
311
329
  labelShape: {
312
330
  fontWeight: 700,
313
331
  },
332
+ haloShape: {
333
+ opacity: 0.25,
334
+ lineWidth: 12,
335
+ pointerEvents: 'none',
336
+ zIndex: -1,
337
+ visible: true,
338
+ stroke: comboStroke,
339
+ droppable: false,
340
+ },
314
341
  },
315
342
  active: {
316
343
  keyShape: {
317
344
  stroke: nodeStroke,
318
345
  lineWidth: 1,
319
346
  },
347
+ haloShape: {
348
+ opacity: 0.25,
349
+ lineWidth: 12,
350
+ pointerEvents: 'none',
351
+ zIndex: -1,
352
+ visible: true,
353
+ stroke: comboStroke,
354
+ droppable: false,
355
+ },
320
356
  },
321
357
  highlight: {
322
358
  keyShape: {
@@ -334,6 +370,9 @@ export const DarkTheme = {
334
370
  fill: comboFill,
335
371
  lineWidth: 1,
336
372
  },
373
+ labelShape: {
374
+ opacity: 0.65,
375
+ },
337
376
  },
338
377
  disable: {
339
378
  keyShape: {
@@ -344,6 +383,31 @@ export const DarkTheme = {
344
383
  fill: disabledFill,
345
384
  opacity: 0.25,
346
385
  },
386
+ labelShape: {
387
+ opacity: 0.25,
388
+ },
389
+ },
390
+ collapsed: {
391
+ keyShape: {
392
+ ...DEFAULT_SHAPE_STYLE,
393
+ fill: comboFill,
394
+ lineWidth: 1,
395
+ stroke: comboStroke,
396
+ // the collapsed size
397
+ r: 16,
398
+ width: 48,
399
+ height: 24,
400
+ padding: [25, 20, 15, 20],
401
+ },
402
+ iconShape: {
403
+ ...DEFAULT_TEXT_STYLE,
404
+ fill: comboStroke,
405
+ fontSize: 12,
406
+ zIndex: 1,
407
+ lod: -1,
408
+ contentType: 'childCount',
409
+ visible: true,
410
+ },
347
411
  },
348
412
  },
349
413
  ],