@antv/g6 5.0.0-beta.38 → 5.0.0-beta.39
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.
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/{click-element.d.ts → click-select.d.ts} +27 -11
- package/{lib/behaviors/hover-element.d.ts → dist/lib/behaviors/hover-activate.d.ts} +5 -5
- package/dist/lib/behaviors/index.d.ts +4 -4
- package/dist/lib/exports.d.ts +3 -3
- package/dist/lib/layouts/index.d.ts +1 -1
- package/dist/lib/layouts/types.d.ts +2 -2
- package/dist/lib/runtime/data.d.ts +9 -0
- package/dist/lib/runtime/element.d.ts +1 -1
- package/dist/lib/types/node.d.ts +12 -0
- package/dist/lib/utils/prefix.d.ts +1 -1
- package/dist/lib/utils/style.d.ts +10 -0
- package/{lib/behaviors/click-element.d.ts → esm/behaviors/click-select.d.ts} +27 -11
- package/esm/behaviors/{click-element.js → click-select.js} +40 -24
- package/esm/behaviors/click-select.js.map +1 -0
- package/{dist/lib/behaviors/hover-element.d.ts → esm/behaviors/hover-activate.d.ts} +5 -5
- package/esm/behaviors/{hover-element.js → hover-activate.js} +7 -7
- package/esm/behaviors/hover-activate.js.map +1 -0
- package/esm/behaviors/index.d.ts +4 -4
- package/esm/behaviors/index.js +2 -2
- package/esm/behaviors/index.js.map +1 -1
- package/esm/elements/combos/base-combo.js +3 -2
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/edges/base-edge.js +5 -4
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/edges/cubic-horizontal.js +2 -2
- package/esm/elements/edges/cubic-horizontal.js.map +1 -1
- package/esm/elements/edges/cubic-vertical.js +2 -2
- package/esm/elements/edges/cubic-vertical.js.map +1 -1
- package/esm/elements/edges/cubic.js +2 -2
- package/esm/elements/edges/cubic.js.map +1 -1
- package/esm/elements/edges/line.js +2 -2
- package/esm/elements/edges/line.js.map +1 -1
- package/esm/elements/edges/polyline.js +2 -2
- package/esm/elements/edges/polyline.js.map +1 -1
- package/esm/elements/edges/quadratic.js +2 -2
- package/esm/elements/edges/quadratic.js.map +1 -1
- package/esm/elements/nodes/base-node.js +8 -8
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/circle.js +2 -2
- package/esm/elements/nodes/circle.js.map +1 -1
- package/esm/elements/nodes/donut.js +3 -2
- package/esm/elements/nodes/donut.js.map +1 -1
- package/esm/elements/nodes/ellipse.js +2 -2
- package/esm/elements/nodes/ellipse.js.map +1 -1
- package/esm/elements/nodes/image.js +2 -2
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/elements/nodes/rect.js +2 -2
- package/esm/elements/nodes/rect.js.map +1 -1
- package/esm/elements/nodes/triangle.js +3 -2
- package/esm/elements/nodes/triangle.js.map +1 -1
- package/esm/elements/shapes/badge.js +2 -2
- package/esm/elements/shapes/badge.js.map +1 -1
- package/esm/elements/shapes/contour.js +2 -2
- package/esm/elements/shapes/contour.js.map +1 -1
- package/esm/elements/shapes/label.js +2 -2
- package/esm/elements/shapes/label.js.map +1 -1
- package/esm/exports.d.ts +3 -3
- package/esm/exports.js +2 -2
- package/esm/exports.js.map +1 -1
- package/esm/layouts/index.d.ts +1 -1
- package/esm/layouts/index.js +1 -1
- package/esm/layouts/index.js.map +1 -1
- package/esm/layouts/types.d.ts +2 -2
- package/esm/plugins/background/index.js +1 -2
- package/esm/plugins/background/index.js.map +1 -1
- package/esm/registry/build-in.js +5 -6
- package/esm/registry/build-in.js.map +1 -1
- package/esm/runtime/data.d.ts +9 -0
- package/esm/runtime/data.js +19 -7
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +1 -1
- package/esm/runtime/element.js +23 -16
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.js +1 -0
- package/esm/runtime/graph.js.map +1 -1
- package/esm/types/node.d.ts +12 -0
- package/esm/utils/id.js +2 -4
- package/esm/utils/id.js.map +1 -1
- package/esm/utils/palette.js +17 -9
- package/esm/utils/palette.js.map +1 -1
- package/esm/utils/prefix.d.ts +1 -1
- package/esm/utils/prefix.js +7 -6
- package/esm/utils/prefix.js.map +1 -1
- package/esm/utils/shape.js +1 -1
- package/esm/utils/shape.js.map +1 -1
- package/esm/utils/size.js +2 -3
- package/esm/utils/size.js.map +1 -1
- package/esm/utils/style.d.ts +10 -0
- package/esm/utils/style.js +15 -0
- package/esm/utils/style.js.map +1 -1
- package/{esm/behaviors/click-element.d.ts → lib/behaviors/click-select.d.ts} +27 -11
- package/lib/behaviors/{click-element.js → click-select.js} +42 -26
- package/lib/behaviors/click-select.js.map +1 -0
- package/{esm/behaviors/hover-element.d.ts → lib/behaviors/hover-activate.d.ts} +5 -5
- package/lib/behaviors/{hover-element.js → hover-activate.js} +9 -9
- package/lib/behaviors/hover-activate.js.map +1 -0
- package/lib/behaviors/index.d.ts +4 -4
- package/lib/behaviors/index.js +5 -5
- package/lib/behaviors/index.js.map +1 -1
- package/lib/elements/combos/base-combo.js +2 -1
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/edges/base-edge.js +4 -3
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/edges/cubic-horizontal.js +2 -2
- package/lib/elements/edges/cubic-horizontal.js.map +1 -1
- package/lib/elements/edges/cubic-vertical.js +2 -2
- package/lib/elements/edges/cubic-vertical.js.map +1 -1
- package/lib/elements/edges/cubic.js +2 -2
- package/lib/elements/edges/cubic.js.map +1 -1
- package/lib/elements/edges/line.js +2 -2
- package/lib/elements/edges/line.js.map +1 -1
- package/lib/elements/edges/polyline.js +2 -2
- package/lib/elements/edges/polyline.js.map +1 -1
- package/lib/elements/edges/quadratic.js +2 -2
- package/lib/elements/edges/quadratic.js.map +1 -1
- package/lib/elements/nodes/base-node.js +8 -8
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/circle.js +2 -2
- package/lib/elements/nodes/circle.js.map +1 -1
- package/lib/elements/nodes/donut.js +2 -1
- package/lib/elements/nodes/donut.js.map +1 -1
- package/lib/elements/nodes/ellipse.js +2 -2
- package/lib/elements/nodes/ellipse.js.map +1 -1
- package/lib/elements/nodes/image.js +2 -2
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/elements/nodes/rect.js +2 -2
- package/lib/elements/nodes/rect.js.map +1 -1
- package/lib/elements/nodes/triangle.js +2 -1
- package/lib/elements/nodes/triangle.js.map +1 -1
- package/lib/elements/shapes/badge.js +2 -2
- package/lib/elements/shapes/badge.js.map +1 -1
- package/lib/elements/shapes/contour.js +2 -2
- package/lib/elements/shapes/contour.js.map +1 -1
- package/lib/elements/shapes/label.js +2 -2
- package/lib/elements/shapes/label.js.map +1 -1
- package/lib/exports.d.ts +3 -3
- package/lib/exports.js +4 -5
- package/lib/exports.js.map +1 -1
- package/lib/layouts/index.d.ts +1 -1
- package/lib/layouts/index.js +1 -2
- package/lib/layouts/index.js.map +1 -1
- package/lib/layouts/types.d.ts +2 -2
- package/lib/plugins/background/index.js +1 -2
- package/lib/plugins/background/index.js.map +1 -1
- package/lib/registry/build-in.js +3 -4
- package/lib/registry/build-in.js.map +1 -1
- package/lib/runtime/data.d.ts +9 -0
- package/lib/runtime/data.js +19 -7
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +1 -1
- package/lib/runtime/element.js +22 -15
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.js +1 -0
- package/lib/runtime/graph.js.map +1 -1
- package/lib/types/node.d.ts +12 -0
- package/lib/utils/id.js +2 -4
- package/lib/utils/id.js.map +1 -1
- package/lib/utils/palette.js +16 -8
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/prefix.d.ts +1 -1
- package/lib/utils/prefix.js +6 -5
- package/lib/utils/prefix.js.map +1 -1
- package/lib/utils/shape.js +1 -1
- package/lib/utils/shape.js.map +1 -1
- package/lib/utils/size.js +2 -3
- package/lib/utils/size.js.map +1 -1
- package/lib/utils/style.d.ts +10 -0
- package/lib/utils/style.js +17 -1
- package/lib/utils/style.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviors/{click-element.ts → click-select.ts} +72 -31
- package/src/behaviors/{hover-element.ts → hover-activate.ts} +10 -10
- package/src/behaviors/index.ts +4 -4
- package/src/elements/combos/base-combo.ts +3 -2
- package/src/elements/edges/base-edge.ts +5 -4
- package/src/elements/edges/cubic-horizontal.ts +2 -2
- package/src/elements/edges/cubic-vertical.ts +2 -2
- package/src/elements/edges/cubic.ts +2 -2
- package/src/elements/edges/line.ts +2 -2
- package/src/elements/edges/polyline.ts +2 -2
- package/src/elements/edges/quadratic.ts +2 -2
- package/src/elements/nodes/base-node.ts +8 -8
- package/src/elements/nodes/circle.ts +2 -2
- package/src/elements/nodes/donut.ts +3 -2
- package/src/elements/nodes/ellipse.ts +2 -2
- package/src/elements/nodes/image.ts +2 -2
- package/src/elements/nodes/rect.ts +2 -2
- package/src/elements/nodes/triangle.ts +3 -2
- package/src/elements/shapes/badge.ts +2 -2
- package/src/elements/shapes/contour.ts +2 -2
- package/src/elements/shapes/label.ts +2 -2
- package/src/exports.ts +4 -5
- package/src/layouts/index.ts +0 -1
- package/src/layouts/types.ts +2 -2
- package/src/plugins/background/index.ts +1 -2
- package/src/registry/build-in.ts +5 -7
- package/src/runtime/data.ts +20 -5
- package/src/runtime/element.ts +18 -13
- package/src/runtime/graph.ts +1 -0
- package/src/types/node.ts +12 -0
- package/src/utils/id.ts +2 -4
- package/src/utils/palette.ts +17 -9
- package/src/utils/prefix.ts +8 -7
- package/src/utils/shape.ts +1 -1
- package/src/utils/size.ts +1 -2
- package/src/utils/style.ts +17 -0
- package/esm/behaviors/click-element.js.map +0 -1
- package/esm/behaviors/hover-element.js.map +0 -1
- package/lib/behaviors/click-element.js.map +0 -1
- package/lib/behaviors/hover-element.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
2
|
import type { PathArray } from '@antv/util';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import type { Point } from '../../types';
|
|
5
4
|
import { getCubicPath, getCurveControlPoint, parseCurveOffset, parseCurvePosition } from '../../utils/edge';
|
|
5
|
+
import { mergeOptions } from '../../utils/style';
|
|
6
6
|
import type { BaseEdgeStyleProps } from './base-edge';
|
|
7
7
|
import { BaseEdge } from './base-edge';
|
|
8
8
|
|
|
@@ -48,7 +48,7 @@ export class Cubic extends BaseEdge {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
constructor(options: DisplayObjectConfig<CubicStyleProps>) {
|
|
51
|
-
super(
|
|
51
|
+
super(mergeOptions({ style: Cubic.defaultStyleProps }, options));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
2
|
import type { PathArray } from '@antv/util';
|
|
3
|
-
import {
|
|
3
|
+
import { mergeOptions } from '../../utils/style';
|
|
4
4
|
import type { BaseEdgeStyleProps } from './base-edge';
|
|
5
5
|
import { BaseEdge } from './base-edge';
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ export class Line extends BaseEdge {
|
|
|
24
24
|
static defaultStyleProps: Partial<LineStyleProps> = {};
|
|
25
25
|
|
|
26
26
|
constructor(options: DisplayObjectConfig<LineStyleProps>) {
|
|
27
|
-
super(
|
|
27
|
+
super(mergeOptions({ style: Line.defaultStyleProps }, options));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
protected getKeyPath(attributes: ParsedLineStyleProps): PathArray {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
2
|
import type { PathArray } from '@antv/util';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import type { LoopStyleProps, Padding, Point, Port } from '../../types';
|
|
5
4
|
import { getBBoxHeight, getBBoxWidth, getNodeBBox } from '../../utils/bbox';
|
|
6
5
|
import { getPolylineLoopPath, getPolylinePath } from '../../utils/edge';
|
|
7
6
|
import { findPorts, getConnectionPoint, getPortPosition } from '../../utils/element';
|
|
8
7
|
import { subStyleProps } from '../../utils/prefix';
|
|
9
8
|
import { orth } from '../../utils/router/orth';
|
|
9
|
+
import { mergeOptions } from '../../utils/style';
|
|
10
10
|
import type { BaseEdgeStyleProps } from './base-edge';
|
|
11
11
|
import { BaseEdge } from './base-edge';
|
|
12
12
|
|
|
@@ -70,7 +70,7 @@ export class Polyline extends BaseEdge {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
constructor(options: DisplayObjectConfig<PolylineStyleProps>) {
|
|
73
|
-
super(
|
|
73
|
+
super(mergeOptions({ style: Polyline.defaultStyleProps }, options));
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
protected getKeyPath(attributes: ParsedPolylineStyleProps): PathArray {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
2
|
import type { PathArray } from '@antv/util';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import type { Point } from '../../types';
|
|
5
4
|
import { getCurveControlPoint, getQuadraticPath } from '../../utils/edge';
|
|
5
|
+
import { mergeOptions } from '../../utils/style';
|
|
6
6
|
import type { BaseEdgeStyleProps } from './base-edge';
|
|
7
7
|
import { BaseEdge } from './base-edge';
|
|
8
8
|
|
|
@@ -48,7 +48,7 @@ export class Quadratic extends BaseEdge {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
constructor(options: DisplayObjectConfig<QuadraticStyleProps>) {
|
|
51
|
-
super(
|
|
51
|
+
super(mergeOptions({ style: Quadratic.defaultStyleProps }, options));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
protected getKeyPath(attributes: ParsedQuadraticStyleProps): PathArray {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { BaseStyleProps, DisplayObject, DisplayObjectConfig, Group } from '@antv/g';
|
|
2
2
|
import { Circle as GCircle } from '@antv/g';
|
|
3
|
-
import { deepMix, isEmpty } from '@antv/util';
|
|
4
3
|
import type { CategoricalPalette } from '../../palettes/types';
|
|
5
4
|
import type { NodeData } from '../../spec';
|
|
6
5
|
import type {
|
|
@@ -22,6 +21,7 @@ import { getRectIntersectPoint } from '../../utils/point';
|
|
|
22
21
|
import { getXYByPlacement } from '../../utils/position';
|
|
23
22
|
import { omitStyleProps, subObject, subStyleProps } from '../../utils/prefix';
|
|
24
23
|
import { parseSize } from '../../utils/size';
|
|
24
|
+
import { mergeOptions } from '../../utils/style';
|
|
25
25
|
import { getWordWrapWidthByBox } from '../../utils/text';
|
|
26
26
|
import { replaceTranslateInTransform } from '../../utils/transform';
|
|
27
27
|
import { BaseElement } from '../base-element';
|
|
@@ -218,7 +218,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
constructor(options: DisplayObjectConfig<S>) {
|
|
221
|
-
super(
|
|
221
|
+
super(mergeOptions({ style: BaseNode.defaultStyleProps }, options));
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
protected getSize(attributes = this.attributes) {
|
|
@@ -233,9 +233,9 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps {
|
|
236
|
-
if (attributes.label === false ||
|
|
236
|
+
if (attributes.label === false || !attributes.labelText) return false;
|
|
237
237
|
|
|
238
|
-
const { placement, maxWidth, ...labelStyle } = subStyleProps<Required<NodeLabelStyleProps>>(
|
|
238
|
+
const { placement, maxWidth, offsetX, offsetY, ...labelStyle } = subStyleProps<Required<NodeLabelStyleProps>>(
|
|
239
239
|
this.getGraphicStyle(attributes),
|
|
240
240
|
'label',
|
|
241
241
|
);
|
|
@@ -243,7 +243,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
243
243
|
const keyBounds = keyShape.getLocalBounds();
|
|
244
244
|
|
|
245
245
|
return Object.assign(
|
|
246
|
-
getTextStyleByPlacement(keyBounds, placement),
|
|
246
|
+
getTextStyleByPlacement(keyBounds, placement, offsetX, offsetY),
|
|
247
247
|
{ wordWrapWidth: getWordWrapWidthByBox(keyBounds, maxWidth) },
|
|
248
248
|
labelStyle,
|
|
249
249
|
);
|
|
@@ -259,7 +259,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
protected getIconStyle(attributes: Required<S>): false | IconStyleProps {
|
|
262
|
-
if (attributes.icon === false ||
|
|
262
|
+
if (attributes.icon === false || (!attributes.iconText && !attributes.iconSrc)) return false;
|
|
263
263
|
|
|
264
264
|
const iconStyle = subStyleProps(this.getGraphicStyle(attributes), 'icon');
|
|
265
265
|
const keyShape = this.getKey();
|
|
@@ -275,7 +275,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
275
275
|
Object.keys(badges).forEach((key) => {
|
|
276
276
|
badgesShapeStyle[key] = false;
|
|
277
277
|
});
|
|
278
|
-
if (attributes.badge === false ||
|
|
278
|
+
if (attributes.badge === false || !attributes.badges?.length) return badgesShapeStyle;
|
|
279
279
|
|
|
280
280
|
const { badges: badgeOptions = [], badgePalette, opacity = 1, ...restAttributes } = attributes;
|
|
281
281
|
const colors = getPaletteColors(badgePalette);
|
|
@@ -308,7 +308,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
308
308
|
portsShapeStyle[key] = false;
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
-
if (attributes.port === false ||
|
|
311
|
+
if (attributes.port === false || !attributes.ports?.length) return portsShapeStyle;
|
|
312
312
|
|
|
313
313
|
const portStyle = subStyleProps<PortStyleProps>(this.getGraphicStyle(attributes), 'port');
|
|
314
314
|
const { ports: portOptions = [] } = attributes;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, CircleStyleProps as GCircleStyleProps, Group } from '@antv/g';
|
|
2
2
|
import { Circle as GCircle } from '@antv/g';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import { ICON_SIZE_RATIO } from '../../constants/element';
|
|
5
4
|
import type { Point } from '../../types';
|
|
6
5
|
import { getEllipseIntersectPoint } from '../../utils/point';
|
|
6
|
+
import { mergeOptions } from '../../utils/style';
|
|
7
7
|
import type { IconStyleProps } from '../shapes';
|
|
8
8
|
import type { BaseNodeStyleProps } from './base-node';
|
|
9
9
|
import { BaseNode } from './base-node';
|
|
@@ -26,7 +26,7 @@ export class Circle extends BaseNode {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
constructor(options: DisplayObjectConfig<CircleStyleProps>) {
|
|
29
|
-
super(
|
|
29
|
+
super(mergeOptions({ style: Circle.defaultStyleProps }, options));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
protected drawKeyShape(attributes: Required<CircleStyleProps>, container: Group) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Path } from '@antv/g';
|
|
2
|
-
import {
|
|
2
|
+
import { isNumber, isString } from '@antv/util';
|
|
3
3
|
import { getPaletteColors } from '../../utils/palette';
|
|
4
4
|
import { subStyleProps } from '../../utils/prefix';
|
|
5
5
|
import { parseSize } from '../../utils/size';
|
|
@@ -8,6 +8,7 @@ import { Circle } from './circle';
|
|
|
8
8
|
import type { BaseStyleProps, DisplayObjectConfig, Group } from '@antv/g';
|
|
9
9
|
import type { CategoricalPalette } from '../../palettes/types';
|
|
10
10
|
import type { DonutRound, Prefix } from '../../types';
|
|
11
|
+
import { mergeOptions } from '../../utils/style';
|
|
11
12
|
import type { CircleStyleProps } from './circle';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -51,7 +52,7 @@ export class Donut extends Circle {
|
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
constructor(options: DisplayObjectConfig<DonutStyleProps>) {
|
|
54
|
-
super(
|
|
55
|
+
super(mergeOptions({ style: Donut.defaultStyleProps }, options));
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
private parseOuterR() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, EllipseStyleProps as GEllipseStyleProps, Group } from '@antv/g';
|
|
2
2
|
import { Ellipse as GEllipse } from '@antv/g';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import { ICON_SIZE_RATIO } from '../../constants/element';
|
|
5
4
|
import type { Point } from '../../types';
|
|
6
5
|
import { getEllipseIntersectPoint } from '../../utils/point';
|
|
6
|
+
import { mergeOptions } from '../../utils/style';
|
|
7
7
|
import type { IconStyleProps } from '../shapes';
|
|
8
8
|
import type { BaseNodeStyleProps } from './base-node';
|
|
9
9
|
import { BaseNode } from './base-node';
|
|
@@ -26,7 +26,7 @@ export class Ellipse extends BaseNode {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
constructor(options: DisplayObjectConfig<EllipseStyleProps>) {
|
|
29
|
-
super(
|
|
29
|
+
super(mergeOptions({ style: Ellipse.defaultStyleProps }, options));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
protected drawKeyShape(attributes: Required<EllipseStyleProps>, container: Group) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, RectStyleProps as GRectStyleProps, Group } from '@antv/g';
|
|
2
2
|
import { Image as GImage, ImageStyleProps as GImageStyleProps, Rect as GRect } from '@antv/g';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import { ICON_SIZE_RATIO } from '../../constants/element';
|
|
5
4
|
import { subStyleProps } from '../../utils/prefix';
|
|
5
|
+
import { mergeOptions } from '../../utils/style';
|
|
6
6
|
import { add } from '../../utils/vector';
|
|
7
7
|
import type { IconStyleProps } from '../shapes';
|
|
8
8
|
import type { BaseNodeStyleProps } from './base-node';
|
|
@@ -39,7 +39,7 @@ export class Image extends BaseNode<ImageStyleProps> {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
constructor(options: DisplayObjectConfig<ImageStyleProps>) {
|
|
42
|
-
super(
|
|
42
|
+
super(mergeOptions({ style: Image.defaultStyleProps }, options));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
protected getKeyStyle(attributes: Required<ImageStyleProps>): GImageStyleProps {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, RectStyleProps as GRectStyleProps, Group } from '@antv/g';
|
|
2
2
|
import { Rect as GRect } from '@antv/g';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import { ICON_SIZE_RATIO } from '../../constants/element';
|
|
4
|
+
import { mergeOptions } from '../../utils/style';
|
|
5
5
|
import type { IconStyleProps } from '../shapes';
|
|
6
6
|
import type { BaseNodeStyleProps } from './base-node';
|
|
7
7
|
import { BaseNode } from './base-node';
|
|
@@ -25,7 +25,7 @@ export class Rect extends BaseNode<RectStyleProps> {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
constructor(options: DisplayObjectConfig<RectStyleProps>) {
|
|
28
|
-
super(
|
|
28
|
+
super(mergeOptions({ style: Rect.defaultStyleProps }, options));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
protected getKeyStyle(attributes: ParsedRectStyleProps): GRectStyleProps {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
|
-
import {
|
|
2
|
+
import { isEmpty } from '@antv/util';
|
|
3
3
|
import { ICON_SIZE_RATIO } from '../../constants/element';
|
|
4
4
|
import type { NodePortStyleProps, Point, TriangleDirection, TrianglePortPlacement } from '../../types';
|
|
5
5
|
import { getIncircleRadius, getTriangleCenter } from '../../utils/bbox';
|
|
6
6
|
import { getPortXYByPlacement, getTrianglePoints, getTrianglePorts } from '../../utils/element';
|
|
7
7
|
import { subStyleProps } from '../../utils/prefix';
|
|
8
|
+
import { mergeOptions } from '../../utils/style';
|
|
8
9
|
import type { PolygonStyleProps } from '../shapes';
|
|
9
10
|
import { IconStyleProps } from '../shapes';
|
|
10
11
|
import { Polygon } from '../shapes/polygon';
|
|
@@ -36,7 +37,7 @@ export class Triangle extends Polygon<TriangleStyleProps> {
|
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
constructor(options: DisplayObjectConfig<TriangleStyleProps>) {
|
|
39
|
-
super(
|
|
40
|
+
super(mergeOptions({ style: Triangle.defaultStyleProps }, options));
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
protected getPoints(attributes: Required<TriangleStyleProps>): Point[] {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, Group } from '@antv/g';
|
|
2
|
-
import {
|
|
2
|
+
import { mergeOptions } from '../../utils/style';
|
|
3
3
|
import { BaseShape } from './base-shape';
|
|
4
4
|
import type { LabelStyleProps } from './label';
|
|
5
5
|
import { Label } from './label';
|
|
@@ -18,7 +18,7 @@ export class Badge extends BaseShape<BadgeStyleProps> {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
constructor(options: BadgeOptions) {
|
|
21
|
-
super(
|
|
21
|
+
super(mergeOptions({ style: Badge.defaultStyleProps }, options));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
protected getBadgeStyle(attributes: ParsedBadgeStyleProps) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, Group, PathStyleProps } from '@antv/g';
|
|
2
2
|
import { Path } from '@antv/g';
|
|
3
|
-
import { deepMix } from '@antv/util';
|
|
4
3
|
import type { CardinalPlacement, Prefix } from '../../types';
|
|
5
4
|
import { getPolygonTextStyleByPlacement } from '../../utils/polygon';
|
|
6
5
|
import { subStyleProps } from '../../utils/prefix';
|
|
6
|
+
import { mergeOptions } from '../../utils/style';
|
|
7
7
|
import { getWordWrapWidthByBox } from '../../utils/text';
|
|
8
8
|
import type { LabelStyleProps } from '../shapes';
|
|
9
9
|
import { BaseShape } from './base-shape';
|
|
@@ -76,7 +76,7 @@ export class Contour extends BaseShape<ContourStyleProps> {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
constructor(options: ContourOptions) {
|
|
79
|
-
super(
|
|
79
|
+
super(mergeOptions({ style: Contour.defaultStyleProps }, options));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
protected getLabelStyle(attributes: ParsedContourStyleProps): LabelStyleProps | false {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DisplayObjectConfig, Group, Rect, RectStyleProps, Text, TextStyleProps } from '@antv/g';
|
|
2
|
-
import { deepMix } from '@antv/util';
|
|
3
2
|
import type { Padding } from '../../types/padding';
|
|
4
3
|
import type { Prefix } from '../../types/prefix';
|
|
5
4
|
import { parsePadding } from '../../utils/padding';
|
|
6
5
|
import { omitStyleProps, startsWith, subStyleProps } from '../../utils/prefix';
|
|
6
|
+
import { mergeOptions } from '../../utils/style';
|
|
7
7
|
import { BaseShape } from './base-shape';
|
|
8
8
|
|
|
9
9
|
export interface LabelStyleProps extends TextStyleProps, Prefix<'background', RectStyleProps> {
|
|
@@ -39,7 +39,7 @@ export class Label extends BaseShape<LabelStyleProps> {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
constructor(options: LabelOptions) {
|
|
42
|
-
super(
|
|
42
|
+
super(mergeOptions({ style: Label.defaultStyleProps }, options));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
protected isTextStyle(key: string) {
|
package/src/exports.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export {
|
|
2
2
|
BaseBehavior,
|
|
3
3
|
BrushSelect,
|
|
4
|
-
|
|
4
|
+
ClickSelect,
|
|
5
5
|
CollapseExpand,
|
|
6
6
|
CreateEdge,
|
|
7
7
|
DragCanvas,
|
|
8
8
|
DragElement,
|
|
9
9
|
DragElementForce,
|
|
10
10
|
FocusElement,
|
|
11
|
-
|
|
11
|
+
HoverActivate,
|
|
12
12
|
LassoSelect,
|
|
13
13
|
ScrollCanvas,
|
|
14
14
|
ZoomCanvas,
|
|
@@ -46,7 +46,6 @@ export {
|
|
|
46
46
|
CircularLayout,
|
|
47
47
|
ComboCombinedLayout,
|
|
48
48
|
ConcentricLayout,
|
|
49
|
-
D3Force3DLayout,
|
|
50
49
|
D3ForceLayout,
|
|
51
50
|
DagreLayout,
|
|
52
51
|
ForceAtlas2Layout,
|
|
@@ -107,14 +106,14 @@ export type { AnimationContext, AnimationEffectTiming, AnimationExecutor, Animat
|
|
|
107
106
|
export type {
|
|
108
107
|
BaseBehaviorOptions,
|
|
109
108
|
BrushSelectOptions,
|
|
110
|
-
|
|
109
|
+
ClickSelectOptions,
|
|
111
110
|
CollapseExpandOptions,
|
|
112
111
|
CreateEdgeOptions,
|
|
113
112
|
DragCanvasOptions,
|
|
114
113
|
DragElementForceOptions,
|
|
115
114
|
DragElementOptions,
|
|
116
115
|
FocusElementOptions,
|
|
117
|
-
|
|
116
|
+
HoverActivateOptions,
|
|
118
117
|
LassoSelectOptions,
|
|
119
118
|
ScrollCanvasOptions,
|
|
120
119
|
ZoomCanvasOptions,
|
package/src/layouts/index.ts
CHANGED
package/src/layouts/types.ts
CHANGED
|
@@ -79,11 +79,11 @@ interface FruchtermanLayout extends BaseLayoutOptions, FruchtermanLayoutOptions
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
interface D3ForceLayout extends BaseLayoutOptions, D3ForceLayoutOptions {
|
|
82
|
-
type: '
|
|
82
|
+
type: 'd3-force';
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
interface D3Force3DLayout extends BaseLayoutOptions, D3Force3DLayoutOptions {
|
|
86
|
-
type: '
|
|
86
|
+
type: 'd3-force3d';
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
interface ForceLayout extends BaseLayoutOptions, ForceLayoutOptions {
|
|
@@ -24,7 +24,6 @@ export class Background extends BasePlugin<BackgroundOptions> {
|
|
|
24
24
|
static defaultOptions: Partial<BackgroundOptions> = {
|
|
25
25
|
transition: 'background 0.5s',
|
|
26
26
|
backgroundSize: 'cover',
|
|
27
|
-
opacity: '0.35',
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
private $element: HTMLElement = createPluginContainer('background');
|
|
@@ -33,7 +32,7 @@ export class Background extends BasePlugin<BackgroundOptions> {
|
|
|
33
32
|
super(context, Object.assign({}, Background.defaultOptions, options));
|
|
34
33
|
|
|
35
34
|
const $container = this.context.canvas.getContainer();
|
|
36
|
-
$container!.
|
|
35
|
+
$container!.prepend(this.$element);
|
|
37
36
|
|
|
38
37
|
this.update(options);
|
|
39
38
|
}
|
package/src/registry/build-in.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ComboCollapse, ComboExpand, Fade, NodeCollapse, NodeExpand, PathIn, PathOut, Translate } from '../animations';
|
|
2
2
|
import {
|
|
3
3
|
BrushSelect,
|
|
4
|
-
|
|
4
|
+
ClickSelect,
|
|
5
5
|
CollapseExpand,
|
|
6
6
|
CreateEdge,
|
|
7
7
|
DragCanvas,
|
|
8
8
|
DragElement,
|
|
9
9
|
DragElementForce,
|
|
10
10
|
FocusElement,
|
|
11
|
-
|
|
11
|
+
HoverActivate,
|
|
12
12
|
LassoSelect,
|
|
13
13
|
ScrollCanvas,
|
|
14
14
|
ZoomCanvas,
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
CircularLayout,
|
|
39
39
|
ComboCombinedLayout,
|
|
40
40
|
ConcentricLayout,
|
|
41
|
-
D3Force3DLayout,
|
|
42
41
|
D3ForceLayout,
|
|
43
42
|
DagreLayout,
|
|
44
43
|
ForceAtlas2Layout,
|
|
@@ -100,8 +99,8 @@ export const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
100
99
|
'drag-element-force': DragElementForce,
|
|
101
100
|
'scroll-canvas': ScrollCanvas,
|
|
102
101
|
'collapse-expand': CollapseExpand,
|
|
103
|
-
'click-
|
|
104
|
-
'hover-
|
|
102
|
+
'click-select': ClickSelect,
|
|
103
|
+
'hover-activate': HoverActivate,
|
|
105
104
|
'focus-element': FocusElement,
|
|
106
105
|
'create-edge': CreateEdge,
|
|
107
106
|
'brush-select': BrushSelect,
|
|
@@ -126,8 +125,7 @@ export const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
126
125
|
'force-atlas2': ForceAtlas2Layout,
|
|
127
126
|
circular: CircularLayout,
|
|
128
127
|
concentric: ConcentricLayout,
|
|
129
|
-
|
|
130
|
-
'd3-force-3d': D3Force3DLayout,
|
|
128
|
+
'd3-force': D3ForceLayout,
|
|
131
129
|
dagre: DagreLayout,
|
|
132
130
|
dendrogram,
|
|
133
131
|
force: ForceLayout,
|
package/src/runtime/data.ts
CHANGED
|
@@ -143,6 +143,10 @@ export class DataController {
|
|
|
143
143
|
}, [] as NodeData[]);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
public getEdgeDatum(id: ID) {
|
|
147
|
+
return toG6Data(this.model.getEdge(id));
|
|
148
|
+
}
|
|
149
|
+
|
|
146
150
|
public getEdgeData(ids?: ID[]) {
|
|
147
151
|
return this.model.getAllEdges().reduce((acc, edge) => {
|
|
148
152
|
const data = toG6Data(edge);
|
|
@@ -224,9 +228,20 @@ export class DataController {
|
|
|
224
228
|
*/
|
|
225
229
|
public getElementDataById(id: ID): ElementDatum {
|
|
226
230
|
const type = this.getElementType(id);
|
|
227
|
-
if (type === '
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
if (type === 'edge') return this.getEdgeDatum(id);
|
|
232
|
+
return this.getNodeLikeDatum(id);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* <zh/> 获取节点的数据
|
|
237
|
+
*
|
|
238
|
+
* <en/> Get node data
|
|
239
|
+
* @param id - <zh/> 节点 ID | <en/> node ID
|
|
240
|
+
* @returns <zh/> 节点数据 | <en/> node data
|
|
241
|
+
*/
|
|
242
|
+
public getNodeLikeDatum(id: ID) {
|
|
243
|
+
const data = this.model.getNode(id);
|
|
244
|
+
return toG6Data(data);
|
|
230
245
|
}
|
|
231
246
|
|
|
232
247
|
/**
|
|
@@ -496,7 +511,7 @@ export class DataController {
|
|
|
496
511
|
*/
|
|
497
512
|
public setParent(id: ID, parent: ID | undefined, hierarchyKey: HierarchyKey, update: boolean = true) {
|
|
498
513
|
if (id === parent) return;
|
|
499
|
-
const originalParentId = parentIdOf(this.
|
|
514
|
+
const originalParentId = parentIdOf(this.getNodeLikeDatum(id));
|
|
500
515
|
|
|
501
516
|
// Sync data
|
|
502
517
|
if (originalParentId !== parent && hierarchyKey === COMBO_KEY) {
|
|
@@ -681,7 +696,7 @@ export class DataController {
|
|
|
681
696
|
*/
|
|
682
697
|
protected removeNodeLikeHierarchy(id: ID) {
|
|
683
698
|
if (this.model.hasTreeStructure(COMBO_KEY)) {
|
|
684
|
-
const grandParent = parentIdOf(this.
|
|
699
|
+
const grandParent = parentIdOf(this.getNodeLikeDatum(id));
|
|
685
700
|
|
|
686
701
|
// 从父节点的 children 列表中移除
|
|
687
702
|
// remove from its parent's children list
|
package/src/runtime/element.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable jsdoc/require-param */
|
|
3
3
|
import type { BaseStyleProps } from '@antv/g';
|
|
4
4
|
import { Group } from '@antv/g';
|
|
5
|
-
import { groupBy
|
|
5
|
+
import { groupBy } from '@antv/util';
|
|
6
6
|
import { AnimationType, COMBO_KEY, ChangeType, GraphEvent } from '../constants';
|
|
7
7
|
import { ELEMENT_TYPES } from '../constants/element';
|
|
8
8
|
import { getExtension } from '../registry';
|
|
@@ -80,9 +80,11 @@ export class ElementController {
|
|
|
80
80
|
const userDefinedType = options[elementType]?.type || datum.type;
|
|
81
81
|
|
|
82
82
|
if (!userDefinedType) {
|
|
83
|
-
|
|
83
|
+
if (elementType === 'edge') return 'line';
|
|
84
|
+
// node / combo
|
|
85
|
+
else return 'circle';
|
|
84
86
|
}
|
|
85
|
-
if (
|
|
87
|
+
if (typeof userDefinedType === 'string') return userDefinedType;
|
|
86
88
|
return userDefinedType(datum as any);
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -112,7 +114,7 @@ export class ElementController {
|
|
|
112
114
|
parsePalette(this.getTheme(elementType)?.palette),
|
|
113
115
|
parsePalette(options[elementType]?.palette),
|
|
114
116
|
);
|
|
115
|
-
if (
|
|
117
|
+
if (palette?.field) {
|
|
116
118
|
Object.assign(this.paletteStyle, assignColorByPalette(elementData, palette));
|
|
117
119
|
}
|
|
118
120
|
});
|
|
@@ -141,11 +143,13 @@ export class ElementController {
|
|
|
141
143
|
|
|
142
144
|
private computeElementsDefaultStyle(ids?: ID[]) {
|
|
143
145
|
this.forEachElementData((elementType, elementData) => {
|
|
144
|
-
elementData
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
const length = elementData.length;
|
|
147
|
+
for (let i = 0; i < length; i++) {
|
|
148
|
+
const datum = elementData[i];
|
|
149
|
+
if (ids === undefined || ids.includes(idOf(datum))) {
|
|
147
150
|
this.computeElementDefaultStyle(elementType, { datum });
|
|
148
|
-
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
149
153
|
});
|
|
150
154
|
}
|
|
151
155
|
|
|
@@ -195,12 +199,14 @@ export class ElementController {
|
|
|
195
199
|
*/
|
|
196
200
|
private computeElementsStatesStyle(ids?: ID[]) {
|
|
197
201
|
this.forEachElementData((elementType, elementData) => {
|
|
198
|
-
elementData
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
const length = elementData.length;
|
|
203
|
+
for (let i = 0; i < length; i++) {
|
|
204
|
+
const datum = elementData[i];
|
|
205
|
+
if (ids === undefined || ids.includes(idOf(datum))) {
|
|
201
206
|
const states = this.getElementState(idOf(datum));
|
|
202
207
|
this.computeElementStatesStyle(elementType, states, { datum });
|
|
203
|
-
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
204
210
|
});
|
|
205
211
|
}
|
|
206
212
|
|
|
@@ -449,7 +455,6 @@ export class ElementController {
|
|
|
449
455
|
if (exactStage === 'show') updateStyle(element, { visibility: 'visible' });
|
|
450
456
|
}
|
|
451
457
|
},
|
|
452
|
-
afterAnimate: () => {},
|
|
453
458
|
after: () => {
|
|
454
459
|
if (stage === 'collapse') updateStyle(element, style);
|
|
455
460
|
if (exactStage === 'hide') updateStyle(element, { visibility: getCachedStyle(element, 'visibility') });
|
package/src/runtime/graph.ts
CHANGED
package/src/types/node.ts
CHANGED
|
@@ -44,6 +44,18 @@ export interface NodeLabelStyleProps extends LabelStyleProps {
|
|
|
44
44
|
* @defaultValue '200%'
|
|
45
45
|
*/
|
|
46
46
|
maxWidth?: string | number;
|
|
47
|
+
/**
|
|
48
|
+
* <zh/> 标签在 x 轴方向上的偏移量
|
|
49
|
+
*
|
|
50
|
+
* <en/> The offset of the label in the x-axis direction
|
|
51
|
+
*/
|
|
52
|
+
offsetX?: number;
|
|
53
|
+
/**
|
|
54
|
+
* <zh/> 标签在 y 轴方向上的偏移量
|
|
55
|
+
*
|
|
56
|
+
* <en/> The offset of the label in the y-axis direction
|
|
57
|
+
*/
|
|
58
|
+
offsetY?: number;
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
/**
|
package/src/utils/id.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { isNumber, isString } from '@antv/util';
|
|
2
1
|
import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
|
|
3
2
|
import type { DataID, ID } from '../types';
|
|
4
|
-
import { isEdgeData } from './is';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* <zh/> 获取节点/边/Combo 的 ID
|
|
@@ -11,8 +9,8 @@ import { isEdgeData } from './is';
|
|
|
11
9
|
* @returns <zh/> 节点/边/Combo 的 ID | <en/> ID of node/edge/combo
|
|
12
10
|
*/
|
|
13
11
|
export function idOf(data: Partial<NodeData | EdgeData | ComboData>): ID {
|
|
14
|
-
if (
|
|
15
|
-
if (
|
|
12
|
+
if (data.id !== undefined) return data.id;
|
|
13
|
+
if (data.source !== undefined && data.target !== undefined) return `${data.source}-${data.target}`;
|
|
16
14
|
|
|
17
15
|
throw new Error('The data does not have available id.');
|
|
18
16
|
}
|