@antv/g6 5.0.0-beta.33 → 5.0.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/brush-select.d.ts +2 -3
- package/dist/lib/behaviors/collapse-expand.d.ts +1 -2
- package/dist/lib/behaviors/create-edge.d.ts +1 -2
- package/dist/lib/behaviors/drag-element-force.d.ts +1 -2
- package/dist/lib/behaviors/drag-element.d.ts +2 -3
- package/dist/lib/behaviors/lasso-select.d.ts +2 -3
- package/dist/lib/constants/events/animation.d.ts +1 -4
- package/dist/lib/elements/nodes/base-node.d.ts +2 -3
- package/dist/lib/elements/nodes/donut.d.ts +45 -0
- package/dist/lib/elements/nodes/html.d.ts +27 -0
- package/dist/lib/elements/nodes/index.d.ts +4 -0
- package/dist/lib/exports.d.ts +4 -3
- package/dist/lib/plugins/hull/index.d.ts +1 -2
- package/dist/lib/runtime/data.d.ts +4 -4
- package/dist/lib/runtime/element.d.ts +3 -3
- package/dist/lib/runtime/graph.d.ts +2 -3
- package/dist/lib/runtime/viewport.d.ts +1 -2
- package/dist/lib/spec/data.d.ts +74 -1
- package/dist/lib/spec/element/combo.d.ts +17 -6
- package/dist/lib/spec/element/edge.d.ts +14 -2
- package/dist/lib/spec/element/node.d.ts +19 -3
- package/dist/lib/themes/base.d.ts +1 -0
- package/dist/lib/transforms/process-parallel-edges.d.ts +1 -2
- package/dist/lib/transforms/types.d.ts +1 -1
- package/dist/lib/types/callable.d.ts +2 -2
- package/dist/lib/types/data.d.ts +1 -1
- package/dist/lib/types/id.d.ts +1 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/style.d.ts +1 -3
- package/dist/lib/utils/animation.d.ts +1 -1
- package/dist/lib/utils/behaviors/brush.d.ts +1 -2
- package/dist/lib/utils/behaviors/lasso.d.ts +1 -2
- package/dist/lib/utils/behaviors/utils.d.ts +1 -1
- package/dist/lib/utils/edge.d.ts +1 -2
- package/dist/lib/utils/id.d.ts +2 -3
- package/dist/lib/utils/palette.d.ts +1 -2
- package/dist/lib/utils/relation.d.ts +1 -2
- package/esm/behaviors/brush-select.d.ts +2 -3
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/click-element.js.map +1 -1
- package/esm/behaviors/collapse-expand.d.ts +1 -2
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.d.ts +1 -2
- package/esm/behaviors/create-edge.js.map +1 -1
- package/esm/behaviors/drag-element-force.d.ts +1 -2
- package/esm/behaviors/drag-element-force.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +2 -3
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/focus-element.js.map +1 -1
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/behaviors/lasso-select.d.ts +2 -3
- package/esm/behaviors/lasso-select.js.map +1 -1
- package/esm/constants/events/animation.d.ts +1 -4
- package/esm/constants/events/animation.js +0 -4
- package/esm/constants/events/animation.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +2 -3
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/donut.d.ts +45 -0
- package/esm/elements/nodes/donut.js +81 -0
- package/esm/elements/nodes/donut.js.map +1 -0
- package/esm/elements/nodes/html.d.ts +27 -0
- package/esm/elements/nodes/html.js +209 -0
- package/esm/elements/nodes/html.js.map +1 -0
- package/esm/elements/nodes/index.d.ts +4 -0
- package/esm/elements/nodes/index.js +2 -0
- package/esm/elements/nodes/index.js.map +1 -1
- package/esm/exports.d.ts +4 -3
- package/esm/exports.js +2 -1
- package/esm/exports.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +1 -2
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/legend.js +3 -2
- package/esm/plugins/legend.js.map +1 -1
- package/esm/registry/build-in.js +5 -3
- package/esm/registry/build-in.js.map +1 -1
- package/esm/runtime/canvas.js +5 -2
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +4 -4
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +3 -3
- package/esm/runtime/element.js +59 -42
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +2 -3
- package/esm/runtime/graph.js +11 -9
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +2 -2
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/viewport.d.ts +1 -2
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/spec/data.d.ts +74 -1
- package/esm/spec/element/combo.d.ts +17 -6
- package/esm/spec/element/edge.d.ts +14 -2
- package/esm/spec/element/node.d.ts +19 -3
- package/esm/themes/base.d.ts +1 -0
- package/esm/themes/base.js +2 -0
- package/esm/themes/base.js.map +1 -1
- package/esm/transforms/process-parallel-edges.d.ts +1 -2
- package/esm/transforms/process-parallel-edges.js +2 -4
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/transforms/types.d.ts +1 -1
- package/esm/transforms/update-related-edge.js.map +1 -1
- package/esm/types/callable.d.ts +2 -2
- package/esm/types/data.d.ts +1 -1
- package/esm/types/id.d.ts +1 -0
- package/esm/types/id.js +2 -0
- package/esm/types/id.js.map +1 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/style.d.ts +1 -3
- package/esm/utils/animation.d.ts +1 -1
- package/esm/utils/animation.js +1 -1
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/behaviors/brush.d.ts +1 -2
- package/esm/utils/behaviors/brush.js.map +1 -1
- package/esm/utils/behaviors/lasso.d.ts +1 -2
- package/esm/utils/behaviors/lasso.js.map +1 -1
- package/esm/utils/behaviors/utils.d.ts +1 -1
- package/esm/utils/change.js.map +1 -1
- package/esm/utils/edge.d.ts +1 -2
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/id.d.ts +2 -3
- package/esm/utils/id.js.map +1 -1
- package/esm/utils/palette.d.ts +1 -2
- package/esm/utils/palette.js.map +1 -1
- package/esm/utils/relation.d.ts +1 -2
- package/esm/utils/relation.js.map +1 -1
- package/esm/utils/style.js +3 -3
- package/esm/utils/style.js.map +1 -1
- package/lib/behaviors/brush-select.d.ts +2 -3
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/click-element.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +1 -2
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.d.ts +1 -2
- package/lib/behaviors/create-edge.js.map +1 -1
- package/lib/behaviors/drag-element-force.d.ts +1 -2
- package/lib/behaviors/drag-element-force.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +2 -3
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/focus-element.js.map +1 -1
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/behaviors/lasso-select.d.ts +2 -3
- package/lib/behaviors/lasso-select.js.map +1 -1
- package/lib/constants/events/animation.d.ts +1 -4
- package/lib/constants/events/animation.js +0 -4
- package/lib/constants/events/animation.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +2 -3
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/donut.d.ts +45 -0
- package/lib/elements/nodes/donut.js +85 -0
- package/lib/elements/nodes/donut.js.map +1 -0
- package/lib/elements/nodes/html.d.ts +27 -0
- package/lib/elements/nodes/html.js +213 -0
- package/lib/elements/nodes/html.js.map +1 -0
- package/lib/elements/nodes/index.d.ts +4 -0
- package/lib/elements/nodes/index.js +5 -1
- package/lib/elements/nodes/index.js.map +1 -1
- package/lib/exports.d.ts +4 -3
- package/lib/exports.js +5 -1
- package/lib/exports.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +1 -2
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/legend.js +3 -2
- package/lib/plugins/legend.js.map +1 -1
- package/lib/registry/build-in.js +4 -2
- package/lib/registry/build-in.js.map +1 -1
- package/lib/runtime/canvas.js +5 -2
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +4 -4
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +3 -3
- package/lib/runtime/element.js +58 -41
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +2 -3
- package/lib/runtime/graph.js +10 -8
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +2 -2
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/viewport.d.ts +1 -2
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/spec/data.d.ts +74 -1
- package/lib/spec/element/combo.d.ts +17 -6
- package/lib/spec/element/edge.d.ts +14 -2
- package/lib/spec/element/node.d.ts +19 -3
- package/lib/themes/base.d.ts +1 -0
- package/lib/themes/base.js +2 -0
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/process-parallel-edges.d.ts +1 -2
- package/lib/transforms/process-parallel-edges.js +2 -4
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/transforms/types.d.ts +1 -1
- package/lib/transforms/update-related-edge.js.map +1 -1
- package/lib/types/callable.d.ts +2 -2
- package/lib/types/data.d.ts +1 -1
- package/lib/types/id.d.ts +1 -0
- package/lib/{spec/element/base.js → types/id.js} +1 -1
- package/lib/types/id.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/style.d.ts +1 -3
- package/lib/utils/animation.d.ts +1 -1
- package/lib/utils/animation.js +1 -1
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/behaviors/brush.d.ts +1 -2
- package/lib/utils/behaviors/brush.js.map +1 -1
- package/lib/utils/behaviors/lasso.d.ts +1 -2
- package/lib/utils/behaviors/lasso.js.map +1 -1
- package/lib/utils/behaviors/utils.d.ts +1 -1
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/edge.d.ts +1 -2
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/id.d.ts +2 -3
- package/lib/utils/id.js.map +1 -1
- package/lib/utils/palette.d.ts +1 -2
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/relation.d.ts +1 -2
- package/lib/utils/relation.js.map +1 -1
- package/lib/utils/style.js +3 -3
- package/lib/utils/style.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviors/brush-select.ts +1 -2
- package/src/behaviors/click-element.ts +1 -2
- package/src/behaviors/collapse-expand.ts +1 -2
- package/src/behaviors/create-edge.ts +1 -2
- package/src/behaviors/drag-element-force.ts +1 -2
- package/src/behaviors/drag-element.ts +1 -2
- package/src/behaviors/focus-element.ts +1 -2
- package/src/behaviors/hover-element.ts +1 -2
- package/src/behaviors/lasso-select.ts +1 -2
- package/src/constants/events/animation.ts +0 -4
- package/src/elements/nodes/base-node.ts +3 -3
- package/src/elements/nodes/donut.ts +137 -0
- package/src/elements/nodes/html.ts +230 -0
- package/src/elements/nodes/index.ts +4 -0
- package/src/exports.ts +20 -1
- package/src/plugins/hull/index.ts +1 -2
- package/src/plugins/legend.ts +4 -4
- package/src/registry/build-in.ts +6 -2
- package/src/runtime/canvas.ts +5 -2
- package/src/runtime/data.ts +2 -1
- package/src/runtime/element.ts +62 -36
- package/src/runtime/graph.ts +13 -10
- package/src/runtime/layout.ts +4 -4
- package/src/runtime/viewport.ts +1 -2
- package/src/spec/data.ts +74 -1
- package/src/spec/element/combo.ts +17 -6
- package/src/spec/element/edge.ts +14 -2
- package/src/spec/element/node.ts +19 -3
- package/src/themes/base.ts +3 -0
- package/src/transforms/arrange-draw-order.ts +1 -1
- package/src/transforms/process-parallel-edges.ts +4 -6
- package/src/transforms/types.ts +1 -1
- package/src/transforms/update-related-edge.ts +1 -2
- package/src/types/callable.ts +2 -2
- package/src/types/data.ts +1 -1
- package/src/types/id.ts +1 -0
- package/src/types/index.ts +1 -0
- package/src/types/style.ts +1 -3
- package/src/utils/animation.ts +2 -2
- package/src/utils/behaviors/brush.ts +1 -2
- package/src/utils/behaviors/lasso.ts +1 -2
- package/src/utils/behaviors/utils.ts +1 -1
- package/src/utils/change.ts +1 -2
- package/src/utils/edge.ts +1 -1
- package/src/utils/id.ts +1 -2
- package/src/utils/palette.ts +1 -1
- package/src/utils/relation.ts +1 -2
- package/src/utils/style.ts +3 -3
- package/dist/lib/runtime/index.d.ts +0 -6
- package/dist/lib/spec/element/base.d.ts +0 -6
- package/esm/runtime/index.d.ts +0 -6
- package/esm/runtime/index.js +0 -7
- package/esm/runtime/index.js.map +0 -1
- package/esm/spec/element/base.d.ts +0 -6
- package/esm/spec/element/base.js +0 -2
- package/esm/spec/element/base.js.map +0 -1
- package/lib/runtime/index.d.ts +0 -6
- package/lib/runtime/index.js +0 -8
- package/lib/runtime/index.js.map +0 -1
- package/lib/spec/element/base.d.ts +0 -6
- package/lib/spec/element/base.js.map +0 -1
- package/src/runtime/index.ts +0 -7
- package/src/spec/element/base.ts +0 -6
package/src/runtime/graph.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
2
|
import type { AABB, BaseStyleProps } from '@antv/g';
|
|
3
|
-
import
|
|
4
|
-
import { debounce, isEqual, isFunction, isNumber, isObject, isString, omit } from '@antv/util';
|
|
3
|
+
import { debounce, isArray, isEqual, isFunction, isNumber, isObject, isString, omit } from '@antv/util';
|
|
5
4
|
import { COMBO_KEY, GraphEvent } from '../constants';
|
|
6
5
|
import type { Plugin } from '../plugins/types';
|
|
7
6
|
import { getExtension } from '../registry';
|
|
@@ -30,6 +29,7 @@ import type {
|
|
|
30
29
|
ElementDatum,
|
|
31
30
|
ElementType,
|
|
32
31
|
FitViewOptions,
|
|
32
|
+
ID,
|
|
33
33
|
IEvent,
|
|
34
34
|
NodeLikeData,
|
|
35
35
|
PartialEdgeData,
|
|
@@ -65,8 +65,6 @@ export class Graph extends EventEmitter {
|
|
|
65
65
|
|
|
66
66
|
static defaultOptions: G6Spec = {
|
|
67
67
|
autoResize: false,
|
|
68
|
-
width: 800,
|
|
69
|
-
height: 600,
|
|
70
68
|
theme: 'light',
|
|
71
69
|
rotation: 0,
|
|
72
70
|
zoom: 1,
|
|
@@ -146,7 +144,7 @@ export class Graph extends EventEmitter {
|
|
|
146
144
|
|
|
147
145
|
if (zoomRange) this.options.zoomRange = zoomRange;
|
|
148
146
|
if (isNumber(zoom)) this.options.zoom = zoom;
|
|
149
|
-
if (isNumber(padding)) this.options.padding = padding;
|
|
147
|
+
if (isNumber(padding) || isArray(padding)) this.options.padding = padding;
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
public setBackground(background: G6Spec['background']): void {
|
|
@@ -486,13 +484,14 @@ export class Graph extends EventEmitter {
|
|
|
486
484
|
await container.init();
|
|
487
485
|
} else {
|
|
488
486
|
const $container = isString(container) ? document.getElementById(container!) : container;
|
|
487
|
+
const containerSize = sizeOf($container!);
|
|
489
488
|
|
|
490
489
|
this.emit(GraphEvent.BEFORE_CANVAS_INIT, { container: $container, width, height });
|
|
491
490
|
|
|
492
491
|
const canvas = new Canvas({
|
|
493
492
|
container: $container!,
|
|
494
|
-
width,
|
|
495
|
-
height,
|
|
493
|
+
width: width ?? containerSize[0],
|
|
494
|
+
height: height ?? containerSize[1],
|
|
496
495
|
renderer,
|
|
497
496
|
});
|
|
498
497
|
|
|
@@ -502,7 +501,7 @@ export class Graph extends EventEmitter {
|
|
|
502
501
|
}
|
|
503
502
|
}
|
|
504
503
|
|
|
505
|
-
private
|
|
504
|
+
private initRuntime() {
|
|
506
505
|
this.context.options = this.options;
|
|
507
506
|
if (!this.context.batch) this.context.batch = new BatchController(this.context);
|
|
508
507
|
if (!this.context.plugin) this.context.plugin = new PluginController(this.context);
|
|
@@ -514,10 +513,14 @@ export class Graph extends EventEmitter {
|
|
|
514
513
|
}
|
|
515
514
|
|
|
516
515
|
private async prepare(): Promise<void> {
|
|
516
|
+
// 等待同步任务执行完成,避免 render 后立即调用 destroy 导致的问题
|
|
517
|
+
// Wait for synchronous tasks to complete, to avoid problems caused by calling destroy immediately after render
|
|
518
|
+
await Promise.resolve();
|
|
519
|
+
|
|
517
520
|
if (this.destroyed) throw new Error('Graph has been destroyed');
|
|
518
521
|
|
|
519
522
|
await this.initCanvas();
|
|
520
|
-
this.
|
|
523
|
+
this.initRuntime();
|
|
521
524
|
}
|
|
522
525
|
|
|
523
526
|
/**
|
|
@@ -530,8 +533,8 @@ export class Graph extends EventEmitter {
|
|
|
530
533
|
* <en/> This process will execute data update, element rendering, and layout execution
|
|
531
534
|
*/
|
|
532
535
|
public async render(): Promise<void> {
|
|
533
|
-
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_RENDER));
|
|
534
536
|
await this.prepare();
|
|
537
|
+
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_RENDER));
|
|
535
538
|
await Promise.all([this.context.element?.draw(), this.context.layout?.layout()]);
|
|
536
539
|
await this.autoFit();
|
|
537
540
|
emit(this, new GraphLifeCycleEvent(GraphEvent.AFTER_RENDER));
|
package/src/runtime/layout.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { COMBO_KEY, GraphEvent, TREE_KEY } from '../constants';
|
|
|
8
8
|
import { getExtension } from '../registry';
|
|
9
9
|
import type { EdgeData, NodeData } from '../spec';
|
|
10
10
|
import type { STDLayoutOptions } from '../spec/layout';
|
|
11
|
-
import type { Combo, Node, PartialGraphData, TreeData } from '../types';
|
|
11
|
+
import type { Combo, ID, Node, PartialGraphData, TreeData } from '../types';
|
|
12
12
|
import { getAnimation } from '../utils/animation';
|
|
13
13
|
import { isVisible } from '../utils/element';
|
|
14
14
|
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
@@ -292,7 +292,7 @@ export class LayoutController {
|
|
|
292
292
|
const nodeSize: number | ((node: LayoutGraphlibNode) => number) =
|
|
293
293
|
(options?.nodeSize as number) ??
|
|
294
294
|
((node) => {
|
|
295
|
-
const nodeElement = element?.getElement<Node | Combo>(node.id);
|
|
295
|
+
const nodeElement = element?.getElement<Node | Combo>(node.id as string);
|
|
296
296
|
const { size } = nodeElement?.attributes || {};
|
|
297
297
|
return Math.max(...parseSize(size));
|
|
298
298
|
});
|
|
@@ -327,7 +327,7 @@ export class LayoutController {
|
|
|
327
327
|
const { nodes, edges } = layoutData;
|
|
328
328
|
const dataToUpdate: Required<PartialGraphData> = { nodes: [], edges: [], combos: [] };
|
|
329
329
|
nodes.forEach(({ id, data: { x, y, z = 0 } }) => {
|
|
330
|
-
dataToUpdate.nodes.push({ id, style: { x, y, z } });
|
|
330
|
+
dataToUpdate.nodes.push({ id: id as ID, style: { x, y, z } });
|
|
331
331
|
});
|
|
332
332
|
|
|
333
333
|
edges.forEach(({ id, data: { points = [], controlPoints = points.slice(1, points.length - 1) } }) => {
|
|
@@ -338,7 +338,7 @@ export class LayoutController {
|
|
|
338
338
|
if (controlPoints?.length) {
|
|
339
339
|
// points 的第一个点是起点,最后一个点是终点,中间的点是控制点
|
|
340
340
|
// The first point of points is the starting point, and the last point is the end point, and the middle point is the control point
|
|
341
|
-
dataToUpdate.edges.push({ id, style: { controlPoints: controlPoints.map(parsePoint) } });
|
|
341
|
+
dataToUpdate.edges.push({ id: id as ID, style: { controlPoints: controlPoints.map(parsePoint) } });
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
|
package/src/runtime/viewport.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AABB } from '@antv/g';
|
|
2
|
-
import type { ID } from '@antv/graphlib';
|
|
3
2
|
import { clamp, isNumber, pick } from '@antv/util';
|
|
4
3
|
import { AnimationType, GraphEvent } from '../constants';
|
|
5
|
-
import type { FitViewOptions, Point, TransformOptions, Vector2, ViewportAnimationEffectTiming } from '../types';
|
|
4
|
+
import type { FitViewOptions, ID, Point, TransformOptions, Vector2, ViewportAnimationEffectTiming } from '../types';
|
|
6
5
|
import { getAnimation } from '../utils/animation';
|
|
7
6
|
import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
|
|
8
7
|
import { AnimateEvent, ViewportEvent, emit } from '../utils/event';
|
package/src/spec/data.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ID } from '
|
|
1
|
+
import type { ID } from '../types';
|
|
2
2
|
import type { ComboStyle } from './element/combo';
|
|
3
3
|
import type { EdgeStyle } from './element/edge';
|
|
4
4
|
import type { NodeStyle } from './element/node';
|
|
@@ -25,24 +25,97 @@ export interface GraphData {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface NodeData {
|
|
28
|
+
/**
|
|
29
|
+
* <zh/> 节点 ID
|
|
30
|
+
*
|
|
31
|
+
* <en/> Node ID
|
|
32
|
+
*/
|
|
28
33
|
id: ID;
|
|
34
|
+
/**
|
|
35
|
+
* <zh/> 节点类型
|
|
36
|
+
*
|
|
37
|
+
* <en/> Node type
|
|
38
|
+
*/
|
|
39
|
+
type?: string;
|
|
40
|
+
/**
|
|
41
|
+
* <zh/> 节点数据
|
|
42
|
+
*
|
|
43
|
+
* <en/> Node data
|
|
44
|
+
*/
|
|
29
45
|
data?: Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* <zh/> 节点样式
|
|
48
|
+
*
|
|
49
|
+
* <en/> Node style
|
|
50
|
+
*/
|
|
30
51
|
style?: NodeStyle;
|
|
31
52
|
[key: string]: unknown;
|
|
32
53
|
}
|
|
33
54
|
|
|
34
55
|
export interface ComboData {
|
|
56
|
+
/**
|
|
57
|
+
* <zh/> Combo ID
|
|
58
|
+
*
|
|
59
|
+
* <en/> Combo ID
|
|
60
|
+
*/
|
|
35
61
|
id: ID;
|
|
62
|
+
/**
|
|
63
|
+
* <zh/> Combo 类型
|
|
64
|
+
*
|
|
65
|
+
* <en/> Combo type
|
|
66
|
+
*/
|
|
67
|
+
type?: string;
|
|
68
|
+
/**
|
|
69
|
+
* <zh/> Combo 数据
|
|
70
|
+
*
|
|
71
|
+
* <en/> Combo data
|
|
72
|
+
*/
|
|
36
73
|
data?: Record<string, unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* <zh/> Combo 样式
|
|
76
|
+
*
|
|
77
|
+
* <en/> Combo style
|
|
78
|
+
*/
|
|
37
79
|
style?: ComboStyle;
|
|
38
80
|
[key: string]: unknown;
|
|
39
81
|
}
|
|
40
82
|
|
|
41
83
|
export interface EdgeData {
|
|
84
|
+
/**
|
|
85
|
+
* <zh/> 边 ID
|
|
86
|
+
*
|
|
87
|
+
* <en/> Edge ID
|
|
88
|
+
*/
|
|
42
89
|
id?: ID;
|
|
90
|
+
/**
|
|
91
|
+
* <zh/> 边源节点 ID
|
|
92
|
+
*
|
|
93
|
+
* <en/> Source node ID
|
|
94
|
+
*/
|
|
43
95
|
source: ID;
|
|
96
|
+
/**
|
|
97
|
+
* <zh/> 边目标节点 ID
|
|
98
|
+
*
|
|
99
|
+
* <en/> Target node ID
|
|
100
|
+
*/
|
|
44
101
|
target: ID;
|
|
102
|
+
/**
|
|
103
|
+
* <zh/> 边类型
|
|
104
|
+
*
|
|
105
|
+
* <en/> Edge type
|
|
106
|
+
*/
|
|
107
|
+
type?: string;
|
|
108
|
+
/**
|
|
109
|
+
* <zh/> 边数据
|
|
110
|
+
*
|
|
111
|
+
* <en/> Edge data
|
|
112
|
+
*/
|
|
45
113
|
data?: Record<string, unknown>;
|
|
114
|
+
/**
|
|
115
|
+
* <zh/> 边样式
|
|
116
|
+
*
|
|
117
|
+
* <en/> Edge style
|
|
118
|
+
*/
|
|
46
119
|
style?: EdgeStyle;
|
|
47
120
|
[key: string]: unknown;
|
|
48
121
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { ID } from '@antv/graphlib';
|
|
2
1
|
import type { BaseComboStyleProps } from '../../elements/combos';
|
|
2
|
+
import type { ID, State } from '../../types';
|
|
3
3
|
import type { CallableObject } from '../../types/callable';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComboData } from '../data';
|
|
5
5
|
import type { AnimationOptions } from './animation';
|
|
6
|
-
import type { BaseElementStyle } from './base';
|
|
7
6
|
import type { PaletteOptions } from './palette';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -12,18 +11,24 @@ import type { PaletteOptions } from './palette';
|
|
|
12
11
|
* <en/> Combo spec
|
|
13
12
|
*/
|
|
14
13
|
export interface ComboOptions {
|
|
14
|
+
/**
|
|
15
|
+
* <zh/> Combo 类型
|
|
16
|
+
*
|
|
17
|
+
* <en/> Combo type
|
|
18
|
+
*/
|
|
19
|
+
type?: string | ((datum: ComboData) => string);
|
|
15
20
|
/**
|
|
16
21
|
* <zh/> Combo 样式
|
|
17
22
|
*
|
|
18
23
|
* <en/> Combo style
|
|
19
24
|
*/
|
|
20
|
-
style?: CallableObject<ComboStyle,
|
|
25
|
+
style?: CallableObject<ComboStyle, ComboData>;
|
|
21
26
|
/**
|
|
22
27
|
* <zh/> Combo 状态样式
|
|
23
28
|
*
|
|
24
29
|
* <en/> Combo state style
|
|
25
30
|
*/
|
|
26
|
-
state?: Record<string, CallableObject<ComboStyle,
|
|
31
|
+
state?: Record<string, CallableObject<ComboStyle, ComboData>>;
|
|
27
32
|
/**
|
|
28
33
|
* <zh/> Combo 动画
|
|
29
34
|
*
|
|
@@ -45,7 +50,13 @@ export interface StaticComboOptions {
|
|
|
45
50
|
palette?: PaletteOptions;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
export interface ComboStyle extends
|
|
53
|
+
export interface ComboStyle extends Partial<BaseComboStyleProps> {
|
|
54
|
+
/**
|
|
55
|
+
* <zh/> 初始状态
|
|
56
|
+
*
|
|
57
|
+
* <en/> Initial state
|
|
58
|
+
*/
|
|
59
|
+
states?: State[];
|
|
49
60
|
children?: ID[];
|
|
50
61
|
[key: string]: any;
|
|
51
62
|
}
|
package/src/spec/element/edge.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseEdgeStyleProps } from '../../elements/edges';
|
|
2
|
+
import { State } from '../../types';
|
|
2
3
|
import type { CallableObject } from '../../types/callable';
|
|
3
4
|
import type { EdgeData } from '../data';
|
|
4
5
|
import type { AnimationOptions } from './animation';
|
|
5
|
-
import type { BaseElementStyle } from './base';
|
|
6
6
|
import type { PaletteOptions } from './palette';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -11,6 +11,12 @@ import type { PaletteOptions } from './palette';
|
|
|
11
11
|
* <en/> Edge spec
|
|
12
12
|
*/
|
|
13
13
|
export interface EdgeOptions {
|
|
14
|
+
/**
|
|
15
|
+
* <zh/> 边类型
|
|
16
|
+
*
|
|
17
|
+
* <en/> Edge type
|
|
18
|
+
*/
|
|
19
|
+
type?: string | ((datum: EdgeData) => string);
|
|
14
20
|
/**
|
|
15
21
|
* <zh/> 边样式
|
|
16
22
|
*
|
|
@@ -44,6 +50,12 @@ export interface StaticEdgeOptions {
|
|
|
44
50
|
palette?: PaletteOptions;
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
export interface EdgeStyle extends
|
|
53
|
+
export interface EdgeStyle extends Partial<BaseEdgeStyleProps> {
|
|
54
|
+
/**
|
|
55
|
+
* <zh/> 初始状态
|
|
56
|
+
*
|
|
57
|
+
* <en/> Initial state
|
|
58
|
+
*/
|
|
59
|
+
states?: State[];
|
|
48
60
|
[key: string]: any;
|
|
49
61
|
}
|
package/src/spec/element/node.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { ID } from '@antv/graphlib';
|
|
2
1
|
import type { BaseNodeStyleProps } from '../../elements/nodes';
|
|
2
|
+
import type { ID, State } from '../../types';
|
|
3
3
|
import type { CallableObject } from '../../types/callable';
|
|
4
4
|
import type { NodeData } from '../data';
|
|
5
5
|
import type { AnimationOptions } from './animation';
|
|
6
|
-
import type { BaseElementStyle } from './base';
|
|
7
6
|
import type { PaletteOptions } from './palette';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -12,6 +11,12 @@ import type { PaletteOptions } from './palette';
|
|
|
12
11
|
* <en/> Node spec
|
|
13
12
|
*/
|
|
14
13
|
export interface NodeOptions {
|
|
14
|
+
/**
|
|
15
|
+
* <zh/> 节点类型
|
|
16
|
+
*
|
|
17
|
+
* <en/> Node type
|
|
18
|
+
*/
|
|
19
|
+
type?: string | ((datum: NodeData) => string);
|
|
15
20
|
/**
|
|
16
21
|
* <zh/> 节点样式
|
|
17
22
|
*
|
|
@@ -45,7 +50,18 @@ export interface StaticNodeOptions {
|
|
|
45
50
|
palette?: PaletteOptions;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
export interface NodeStyle extends
|
|
53
|
+
export interface NodeStyle extends Partial<BaseNodeStyleProps> {
|
|
54
|
+
/**
|
|
55
|
+
* <zh/> 初始状态
|
|
56
|
+
*
|
|
57
|
+
* <en/> Initial state
|
|
58
|
+
*/
|
|
59
|
+
states?: State[];
|
|
60
|
+
/**
|
|
61
|
+
* <zh/> 子节点 ID (树图专用)
|
|
62
|
+
*
|
|
63
|
+
* <en/> Child node ID (for tree graph)
|
|
64
|
+
*/
|
|
49
65
|
children?: ID[];
|
|
50
66
|
[key: string]: any;
|
|
51
67
|
}
|
package/src/themes/base.ts
CHANGED
|
@@ -34,6 +34,7 @@ type ThemeTokens = {
|
|
|
34
34
|
nodeStroke: string;
|
|
35
35
|
nodeBadgePalette?: string[];
|
|
36
36
|
nodePaletteOptions?: PaletteOptions;
|
|
37
|
+
donutPaletteOptions?: PaletteOptions;
|
|
37
38
|
edgeColor: string;
|
|
38
39
|
edgeColorDisabled: string;
|
|
39
40
|
edgePaletteOptions?: PaletteOptions;
|
|
@@ -120,6 +121,7 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
120
121
|
strokeOpacity: 0.85,
|
|
121
122
|
},
|
|
122
123
|
inactive: {
|
|
124
|
+
donutOpacity: 0.25,
|
|
123
125
|
iconOpacity: 0.25,
|
|
124
126
|
labelOpacity: 0.25,
|
|
125
127
|
opacity: 0.25,
|
|
@@ -127,6 +129,7 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
127
129
|
disabled: {
|
|
128
130
|
color: nodeColorDisabled,
|
|
129
131
|
labelOpacity: 0.25,
|
|
132
|
+
donutOpacity: 0.25,
|
|
130
133
|
},
|
|
131
134
|
},
|
|
132
135
|
animation: {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { PathStyleProps } from '@antv/g';
|
|
2
|
-
import type { ID } from '@antv/graphlib';
|
|
3
2
|
import { deepMix, isBoolean, isEmpty } from '@antv/util';
|
|
4
3
|
import type { RuntimeContext } from '../runtime/types';
|
|
5
4
|
import type { EdgeData } from '../spec';
|
|
6
|
-
import type { ElementDatum, ElementType, LoopPlacement, NodeLikeData } from '../types';
|
|
5
|
+
import type { ElementDatum, ElementType, ID, LoopPlacement, NodeLikeData } from '../types';
|
|
7
6
|
import { groupByChangeType, reduceDataChanges } from '../utils/change';
|
|
8
7
|
import { idOf } from '../utils/id';
|
|
9
8
|
import type { BaseTransformOptions } from './base-transform';
|
|
@@ -153,9 +152,7 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
|
|
|
153
152
|
arcEdges.forEach((edge, i, edgeArr) => {
|
|
154
153
|
const computeStyle = () => {
|
|
155
154
|
const length = edgeArr.length;
|
|
156
|
-
const style: EdgeData['style'] = {
|
|
157
|
-
type: CUBIC_EDGE_TYPE,
|
|
158
|
-
};
|
|
155
|
+
const style: EdgeData['style'] = {};
|
|
159
156
|
if (edge.source === edge.target) {
|
|
160
157
|
const len = CUBIC_LOOP_PLACEMENTS.length;
|
|
161
158
|
style.loopPlacement = CUBIC_LOOP_PLACEMENTS[i % len];
|
|
@@ -172,7 +169,8 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
|
|
|
172
169
|
return style;
|
|
173
170
|
};
|
|
174
171
|
|
|
175
|
-
const mergedEdgeData = deepMix(edge, { style: computeStyle() });
|
|
172
|
+
const mergedEdgeData = deepMix(edge, { type: CUBIC_EDGE_TYPE, style: computeStyle() });
|
|
173
|
+
|
|
176
174
|
const element = this.context.element?.getElement(idOf(edge));
|
|
177
175
|
if (element) reassignTo('update', 'edge', mergedEdgeData);
|
|
178
176
|
else reassignTo('add', 'edge', mergedEdgeData);
|
package/src/transforms/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ID } from '@antv/graphlib';
|
|
2
1
|
import type { ComboData, EdgeData, NodeData } from '../spec';
|
|
2
|
+
import type { ID } from '../types';
|
|
3
3
|
import type { BaseTransform, BaseTransformOptions } from './base-transform';
|
|
4
4
|
|
|
5
5
|
export type BuiltInTransformOptions = BaseTransformOptions;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ID } from '
|
|
2
|
-
import type { NodeLikeData } from '../types';
|
|
1
|
+
import type { ID, NodeLikeData } from '../types';
|
|
3
2
|
import { idOf } from '../utils/id';
|
|
4
3
|
import { BaseTransform } from './base-transform';
|
|
5
4
|
import type { DrawData } from './types';
|
package/src/types/callable.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type CallableValue<Returns, Param = Returns> = Returns | ((args: Param) =
|
|
|
27
27
|
* }
|
|
28
28
|
*/
|
|
29
29
|
export type CallableObject<Obj extends Record<string, unknown>, T> =
|
|
30
|
-
| ((datum: T
|
|
30
|
+
| ((datum: T) => Obj)
|
|
31
31
|
| {
|
|
32
|
-
[K in keyof Obj]: Obj[K] | ((datum: T
|
|
32
|
+
[K in keyof Obj]: Obj[K] | ((datum: T) => NonNullable<Obj[K]>);
|
|
33
33
|
};
|
package/src/types/data.ts
CHANGED
package/src/types/id.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ID = string;
|
package/src/types/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type * from './element';
|
|
|
9
9
|
export type * from './enum';
|
|
10
10
|
export type * from './event';
|
|
11
11
|
export type * from './graphlib';
|
|
12
|
+
export type * from './id';
|
|
12
13
|
export type * from './node';
|
|
13
14
|
export type * from './padding';
|
|
14
15
|
export type * from './placement';
|
package/src/types/style.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ElementDatum } from './data';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* <zh/> 样式计算迭代上下文
|
|
@@ -7,6 +7,4 @@ import type { ElementData, ElementDatum } from './data';
|
|
|
7
7
|
*/
|
|
8
8
|
export type StyleIterationContext = {
|
|
9
9
|
datum: ElementDatum;
|
|
10
|
-
index: number;
|
|
11
|
-
elementData: ElementData;
|
|
12
10
|
};
|
package/src/utils/animation.ts
CHANGED
|
@@ -182,7 +182,7 @@ type Callbacks = {
|
|
|
182
182
|
* @param callbacks - <zh/> 回调函数 | <en/> callback function
|
|
183
183
|
* @returns <zh/> 动画对象 | <en/> animation object
|
|
184
184
|
*/
|
|
185
|
-
export function withAnimationCallbacks(animation: IAnimation | null, callbacks: Callbacks) {
|
|
185
|
+
export function withAnimationCallbacks(animation: IAnimation | null | undefined, callbacks: Callbacks) {
|
|
186
186
|
callbacks.before?.();
|
|
187
187
|
if (animation) {
|
|
188
188
|
callbacks.beforeAnimate?.(animation);
|
|
@@ -193,7 +193,7 @@ export function withAnimationCallbacks(animation: IAnimation | null, callbacks:
|
|
|
193
193
|
} else {
|
|
194
194
|
callbacks.after?.();
|
|
195
195
|
}
|
|
196
|
-
return animation;
|
|
196
|
+
return animation || null;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { isPointInPolygon } from '../point';
|
|
2
2
|
|
|
3
|
-
import type { ID } from '@antv/graphlib';
|
|
4
3
|
import type { Graph } from '../../runtime/graph';
|
|
5
|
-
import type { Point, Points } from '../../types';
|
|
4
|
+
import type { ID, Point, Points } from '../../types';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* <zh/> 元素中心是否在 rect 中
|
|
@@ -2,9 +2,8 @@ import { AABB } from '@antv/g';
|
|
|
2
2
|
import { getLinesIntersection } from '../line';
|
|
3
3
|
import { isPointInPolygon } from '../point';
|
|
4
4
|
|
|
5
|
-
import type { ID } from '@antv/graphlib';
|
|
6
5
|
import type { Graph } from '../../runtime/graph';
|
|
7
|
-
import type { Points } from '../../types';
|
|
6
|
+
import type { ID, Points } from '../../types';
|
|
8
7
|
import type { LineSegment } from '../line';
|
|
9
8
|
|
|
10
9
|
/**
|
package/src/utils/change.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ID } from '@antv/graphlib';
|
|
2
1
|
import { groupBy } from '@antv/util';
|
|
3
2
|
import { ChangeType } from '../constants';
|
|
4
|
-
import type { DataAdded, DataChange, DataChanges, DataRemoved, DataUpdated } from '../types';
|
|
3
|
+
import type { DataAdded, DataChange, DataChanges, DataRemoved, DataUpdated, ID } from '../types';
|
|
5
4
|
import { idOf } from './id';
|
|
6
5
|
|
|
7
6
|
/**
|
package/src/utils/edge.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AABB } from '@antv/g';
|
|
2
|
-
import type { ID } from '@antv/graphlib';
|
|
3
2
|
import type { PathArray } from '@antv/util';
|
|
4
3
|
import { isEqual, isNumber } from '@antv/util';
|
|
5
4
|
import type { EdgeData } from '../spec';
|
|
@@ -7,6 +6,7 @@ import type {
|
|
|
7
6
|
EdgeKey,
|
|
8
7
|
EdgeLabelPlacement,
|
|
9
8
|
EdgeLabelStyleProps,
|
|
9
|
+
ID,
|
|
10
10
|
LoopPlacement,
|
|
11
11
|
Node,
|
|
12
12
|
Point,
|
package/src/utils/id.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ID } from '@antv/graphlib';
|
|
2
1
|
import { isNumber, isString } from '@antv/util';
|
|
3
2
|
import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
|
|
4
|
-
import type { DataID } from '../types';
|
|
3
|
+
import type { DataID, ID } from '../types';
|
|
5
4
|
import { isEdgeData } from './is';
|
|
6
5
|
|
|
7
6
|
/**
|
package/src/utils/palette.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ID } from '@antv/graphlib';
|
|
2
1
|
import { groupBy, isFunction, isNumber, isString } from '@antv/util';
|
|
3
2
|
import type { CategoricalPalette } from '../palettes/types';
|
|
4
3
|
import { getExtension } from '../registry';
|
|
5
4
|
import type { PaletteOptions, STDPaletteOptions } from '../spec/element/palette';
|
|
5
|
+
import type { ID } from '../types';
|
|
6
6
|
import type { ElementData, ElementDatum } from '../types/data';
|
|
7
7
|
import { idOf } from './id';
|
|
8
8
|
|
package/src/utils/relation.ts
CHANGED
package/src/utils/style.ts
CHANGED
|
@@ -14,13 +14,13 @@ export function computeElementCallbackStyle(
|
|
|
14
14
|
callableStyle: CallableObject<Record<string, unknown>, ElementDatum>,
|
|
15
15
|
context: StyleIterationContext,
|
|
16
16
|
) {
|
|
17
|
-
const { datum
|
|
17
|
+
const { datum } = context;
|
|
18
18
|
|
|
19
|
-
if (isFunction(callableStyle)) return callableStyle(datum
|
|
19
|
+
if (isFunction(callableStyle)) return callableStyle(datum);
|
|
20
20
|
|
|
21
21
|
return Object.fromEntries(
|
|
22
22
|
Object.entries(callableStyle).map(([key, style]) => {
|
|
23
|
-
if (isFunction(style)) return [key, style(datum
|
|
23
|
+
if (isFunction(style)) return [key, style(datum)];
|
|
24
24
|
return [key, style];
|
|
25
25
|
}),
|
|
26
26
|
);
|
package/esm/runtime/index.d.ts
DELETED
package/esm/runtime/index.js
DELETED
package/esm/runtime/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["runtime/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|