@antv/g6 5.0.0-beta.34 → 5.0.0-beta.35
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/animations/types.d.ts +3 -4
- package/dist/lib/behaviors/base-behavior.d.ts +2 -1
- package/dist/lib/behaviors/brush-select.d.ts +31 -13
- package/dist/lib/behaviors/click-element.d.ts +28 -5
- package/dist/lib/behaviors/collapse-expand.d.ts +2 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +7 -0
- package/dist/lib/behaviors/drag-element.d.ts +2 -2
- package/dist/lib/behaviors/index.d.ts +2 -0
- package/dist/lib/behaviors/lasso-select.d.ts +2 -1
- package/dist/lib/behaviors/scroll-canvas.d.ts +64 -0
- package/dist/lib/behaviors/types.d.ts +2 -1
- package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/dist/lib/constants/events/graph.d.ts +5 -1
- package/dist/lib/elements/combos/base-combo.d.ts +1 -1
- package/dist/lib/elements/edges/base-edge.d.ts +0 -5
- package/dist/lib/elements/nodes/base-node.d.ts +1 -7
- package/dist/lib/elements/shapes/badge.d.ts +1 -1
- package/dist/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
- package/dist/lib/elements/shapes/index.d.ts +2 -0
- package/dist/lib/exports.d.ts +12 -20
- package/dist/lib/plugins/bubble-sets.d.ts +45 -0
- package/dist/lib/plugins/camera-setting.d.ts +4 -2
- package/dist/lib/plugins/contextmenu.d.ts +1 -0
- package/dist/lib/plugins/grid-line.d.ts +51 -8
- package/dist/lib/plugins/hull/index.d.ts +43 -11
- package/dist/lib/plugins/index.d.ts +4 -0
- package/dist/lib/plugins/timebar.d.ts +225 -0
- package/dist/lib/plugins/tooltip.d.ts +2 -2
- package/dist/lib/registry/index.d.ts +1 -1
- package/dist/lib/runtime/data.d.ts +9 -3
- package/dist/lib/runtime/element.d.ts +3 -7
- package/dist/lib/runtime/graph.d.ts +530 -42
- package/dist/lib/runtime/types.d.ts +3 -3
- package/dist/lib/runtime/viewport.d.ts +2 -2
- package/dist/lib/spec/canvas.d.ts +6 -2
- package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +12 -4
- package/dist/lib/spec/index.d.ts +1 -1
- package/dist/lib/spec/theme.d.ts +1 -4
- package/dist/lib/spec/viewport.d.ts +1 -1
- package/dist/lib/themes/types.d.ts +0 -1
- package/dist/lib/transforms/process-parallel-edges.d.ts +1 -1
- package/dist/lib/types/data.d.ts +2 -2
- package/dist/lib/types/viewport.d.ts +4 -4
- package/dist/lib/utils/animation.d.ts +5 -5
- package/dist/lib/utils/data.d.ts +2 -2
- package/dist/lib/utils/element.d.ts +1 -1
- package/dist/lib/utils/event/events.d.ts +1 -1
- package/dist/lib/utils/event/index.d.ts +1 -1
- package/dist/lib/utils/palette.d.ts +1 -1
- package/dist/lib/utils/relation.d.ts +2 -2
- package/dist/lib/utils/visibility.d.ts +1 -1
- package/esm/animations/types.d.ts +3 -4
- package/esm/behaviors/base-behavior.d.ts +2 -1
- package/esm/behaviors/brush-select.d.ts +31 -13
- package/esm/behaviors/brush-select.js +7 -2
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/click-element.d.ts +28 -5
- package/esm/behaviors/click-element.js +11 -0
- package/esm/behaviors/click-element.js.map +1 -1
- package/esm/behaviors/collapse-expand.d.ts +2 -0
- package/esm/behaviors/collapse-expand.js +2 -2
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +7 -0
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +2 -2
- package/esm/behaviors/index.d.ts +2 -0
- package/esm/behaviors/index.js +1 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/lasso-select.d.ts +2 -1
- package/esm/behaviors/lasso-select.js +1 -1
- package/esm/behaviors/lasso-select.js.map +1 -1
- package/esm/behaviors/scroll-canvas.d.ts +64 -0
- package/esm/behaviors/scroll-canvas.js +80 -0
- package/esm/behaviors/scroll-canvas.js.map +1 -0
- package/esm/behaviors/types.d.ts +2 -1
- package/esm/behaviors/zoom-canvas.d.ts +1 -1
- package/esm/constants/events/graph.d.ts +5 -1
- package/esm/constants/events/graph.js +4 -0
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/elements/combos/base-combo.d.ts +1 -1
- package/esm/elements/edges/base-edge.d.ts +0 -5
- package/esm/elements/edges/base-edge.js +1 -2
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +1 -7
- package/esm/elements/nodes/base-node.js +2 -2
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/shapes/badge.d.ts +1 -1
- package/{lib/plugins/hull/shape.d.ts → esm/elements/shapes/contour.d.ts} +17 -17
- package/esm/{plugins/hull/shape.js → elements/shapes/contour.js} +12 -11
- package/esm/elements/shapes/contour.js.map +1 -0
- package/esm/elements/shapes/index.d.ts +2 -0
- package/esm/elements/shapes/index.js +1 -0
- package/esm/elements/shapes/index.js.map +1 -1
- package/esm/exports.d.ts +12 -20
- package/esm/exports.js +6 -17
- package/esm/exports.js.map +1 -1
- package/esm/plugins/bubble-sets.d.ts +45 -0
- package/esm/plugins/bubble-sets.js +212 -0
- package/esm/plugins/bubble-sets.js.map +1 -0
- package/esm/plugins/camera-setting.d.ts +4 -2
- package/esm/plugins/camera-setting.js.map +1 -1
- package/esm/plugins/contextmenu.d.ts +1 -0
- package/esm/plugins/contextmenu.js +1 -0
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +51 -8
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/history/utils.js +6 -2
- package/esm/plugins/history/utils.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +43 -11
- package/esm/plugins/hull/index.js +46 -16
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/index.d.ts +4 -0
- package/esm/plugins/index.js +2 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.js +2 -1
- package/esm/plugins/legend.js.map +1 -1
- package/esm/plugins/timebar.d.ts +225 -0
- package/esm/plugins/timebar.js +253 -0
- package/esm/plugins/timebar.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +2 -2
- package/esm/registry/build-in.js +10 -7
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/index.d.ts +1 -1
- package/esm/registry/index.js +1 -1
- package/esm/runtime/canvas.js +2 -2
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +9 -3
- package/esm/runtime/data.js +20 -3
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +3 -7
- package/esm/runtime/element.js +6 -4
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +530 -42
- package/esm/runtime/graph.js +409 -33
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/types.d.ts +3 -3
- package/esm/runtime/viewport.d.ts +2 -2
- package/esm/runtime/viewport.js +2 -2
- package/esm/spec/canvas.d.ts +6 -2
- package/{dist/lib/spec/spec.d.ts → esm/spec/graph.d.ts} +12 -4
- package/esm/spec/graph.js +2 -0
- package/esm/spec/graph.js.map +1 -0
- package/esm/spec/index.d.ts +1 -1
- package/esm/spec/theme.d.ts +1 -4
- package/esm/spec/viewport.d.ts +1 -1
- package/esm/themes/base.js +9 -9
- package/esm/themes/base.js.map +1 -1
- package/esm/themes/types.d.ts +0 -1
- package/esm/transforms/process-parallel-edges.d.ts +1 -1
- package/esm/types/data.d.ts +2 -2
- package/esm/types/viewport.d.ts +4 -4
- package/esm/utils/animation.d.ts +5 -5
- package/esm/utils/animation.js +2 -2
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/change.js +8 -1
- package/esm/utils/change.js.map +1 -1
- package/esm/utils/data.d.ts +2 -2
- package/esm/utils/data.js +2 -2
- package/esm/utils/element.d.ts +1 -1
- package/esm/utils/element.js +2 -2
- package/esm/utils/event/events.d.ts +1 -1
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/event/index.d.ts +1 -1
- package/esm/utils/event/index.js +1 -1
- package/esm/utils/palette.d.ts +1 -1
- package/esm/utils/palette.js +1 -1
- package/esm/utils/relation.d.ts +2 -2
- package/esm/utils/relation.js +2 -2
- package/esm/utils/visibility.d.ts +1 -1
- package/esm/utils/visibility.js +1 -1
- package/lib/animations/types.d.ts +3 -4
- package/lib/behaviors/base-behavior.d.ts +2 -1
- package/lib/behaviors/brush-select.d.ts +31 -13
- package/lib/behaviors/brush-select.js +7 -2
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/click-element.d.ts +28 -5
- package/lib/behaviors/click-element.js +11 -0
- package/lib/behaviors/click-element.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +2 -0
- package/lib/behaviors/collapse-expand.js +2 -2
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +7 -0
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +2 -2
- package/lib/behaviors/index.d.ts +2 -0
- package/lib/behaviors/index.js +3 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/lasso-select.d.ts +2 -1
- package/lib/behaviors/lasso-select.js +1 -1
- package/lib/behaviors/lasso-select.js.map +1 -1
- package/lib/behaviors/scroll-canvas.d.ts +64 -0
- package/lib/behaviors/scroll-canvas.js +84 -0
- package/lib/behaviors/scroll-canvas.js.map +1 -0
- package/lib/behaviors/types.d.ts +2 -1
- package/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/lib/constants/events/graph.d.ts +5 -1
- package/lib/constants/events/graph.js +4 -0
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/elements/combos/base-combo.d.ts +1 -1
- package/lib/elements/edges/base-edge.d.ts +0 -5
- package/lib/elements/edges/base-edge.js +1 -2
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +1 -7
- package/lib/elements/nodes/base-node.js +2 -2
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/shapes/badge.d.ts +1 -1
- package/{esm/plugins/hull/shape.d.ts → lib/elements/shapes/contour.d.ts} +17 -17
- package/lib/{plugins/hull/shape.js → elements/shapes/contour.js} +15 -14
- package/lib/elements/shapes/contour.js.map +1 -0
- package/lib/elements/shapes/index.d.ts +2 -0
- package/lib/elements/shapes/index.js +3 -1
- package/lib/elements/shapes/index.js.map +1 -1
- package/lib/exports.d.ts +12 -20
- package/lib/exports.js +46 -17
- package/lib/exports.js.map +1 -1
- package/lib/plugins/bubble-sets.d.ts +45 -0
- package/lib/plugins/bubble-sets.js +216 -0
- package/lib/plugins/bubble-sets.js.map +1 -0
- package/lib/plugins/camera-setting.d.ts +4 -2
- package/lib/plugins/camera-setting.js.map +1 -1
- package/lib/plugins/contextmenu.d.ts +1 -0
- package/lib/plugins/contextmenu.js +1 -0
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +51 -8
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/history/utils.js +6 -2
- package/lib/plugins/history/utils.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +43 -11
- package/lib/plugins/hull/index.js +46 -16
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/index.d.ts +4 -0
- package/lib/plugins/index.js +5 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.js +2 -1
- package/lib/plugins/legend.js.map +1 -1
- package/lib/plugins/timebar.d.ts +225 -0
- package/lib/plugins/timebar.js +257 -0
- package/lib/plugins/timebar.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +2 -2
- package/lib/registry/build-in.js +8 -5
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/index.d.ts +1 -1
- package/lib/registry/index.js +1 -1
- package/lib/runtime/canvas.js +2 -2
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +9 -3
- package/lib/runtime/data.js +20 -3
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +3 -7
- package/lib/runtime/element.js +6 -4
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +530 -42
- package/lib/runtime/graph.js +409 -33
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/types.d.ts +3 -3
- package/lib/runtime/viewport.d.ts +2 -2
- package/lib/runtime/viewport.js +2 -2
- package/lib/spec/canvas.d.ts +6 -2
- package/{esm/spec/spec.d.ts → lib/spec/graph.d.ts} +12 -4
- package/lib/spec/{spec.js → graph.js} +1 -1
- package/lib/spec/graph.js.map +1 -0
- package/lib/spec/index.d.ts +1 -1
- package/lib/spec/theme.d.ts +1 -4
- package/lib/spec/viewport.d.ts +1 -1
- package/lib/themes/base.js +9 -9
- package/lib/themes/base.js.map +1 -1
- package/lib/themes/types.d.ts +0 -1
- package/lib/transforms/process-parallel-edges.d.ts +1 -1
- package/lib/types/data.d.ts +2 -2
- package/lib/types/viewport.d.ts +4 -4
- package/lib/utils/animation.d.ts +5 -5
- package/lib/utils/animation.js +2 -2
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/change.js +8 -1
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/data.d.ts +2 -2
- package/lib/utils/data.js +2 -2
- package/lib/utils/element.d.ts +1 -1
- package/lib/utils/element.js +2 -2
- package/lib/utils/event/events.d.ts +1 -1
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/event/index.d.ts +1 -1
- package/lib/utils/event/index.js +1 -1
- package/lib/utils/palette.d.ts +1 -1
- package/lib/utils/palette.js +1 -1
- package/lib/utils/relation.d.ts +2 -2
- package/lib/utils/relation.js +2 -2
- package/lib/utils/visibility.d.ts +1 -1
- package/lib/utils/visibility.js +1 -1
- package/package.json +2 -1
- package/src/animations/types.ts +3 -4
- package/src/behaviors/base-behavior.ts +1 -1
- package/src/behaviors/brush-select.ts +33 -14
- package/src/behaviors/click-element.ts +28 -5
- package/src/behaviors/collapse-expand.ts +4 -2
- package/src/behaviors/drag-canvas.ts +7 -0
- package/src/behaviors/drag-element.ts +2 -2
- package/src/behaviors/index.ts +2 -0
- package/src/behaviors/lasso-select.ts +2 -2
- package/src/behaviors/scroll-canvas.ts +143 -0
- package/src/behaviors/types.ts +2 -1
- package/src/behaviors/zoom-canvas.ts +1 -1
- package/src/constants/events/graph.ts +4 -0
- package/src/elements/combos/base-combo.ts +1 -1
- package/src/elements/edges/base-edge.ts +1 -7
- package/src/elements/nodes/base-node.ts +3 -12
- package/src/{plugins/hull/shape.ts → elements/shapes/contour.ts} +27 -34
- package/src/elements/shapes/index.ts +2 -0
- package/src/exports.ts +104 -24
- package/src/plugins/bubble-sets.ts +268 -0
- package/src/plugins/camera-setting.ts +4 -2
- package/src/plugins/contextmenu.ts +1 -0
- package/src/plugins/grid-line.ts +51 -8
- package/src/plugins/history/utils.ts +6 -2
- package/src/plugins/hull/index.ts +57 -20
- package/src/plugins/index.ts +4 -0
- package/src/plugins/legend.ts +3 -1
- package/src/plugins/timebar.ts +450 -0
- package/src/plugins/tooltip.ts +2 -2
- package/src/registry/build-in.ts +21 -6
- package/src/registry/index.ts +1 -1
- package/src/runtime/canvas.ts +2 -2
- package/src/runtime/data.ts +21 -3
- package/src/runtime/element.ts +5 -4
- package/src/runtime/graph.ts +543 -48
- package/src/runtime/types.ts +3 -3
- package/src/runtime/viewport.ts +2 -2
- package/src/spec/canvas.ts +6 -2
- package/src/spec/{spec.ts → graph.ts} +12 -4
- package/src/spec/index.ts +1 -1
- package/src/spec/theme.ts +1 -5
- package/src/spec/viewport.ts +1 -1
- package/src/themes/base.ts +9 -9
- package/src/themes/types.ts +0 -2
- package/src/transforms/process-parallel-edges.ts +1 -1
- package/src/types/data.ts +2 -2
- package/src/types/viewport.ts +4 -4
- package/src/utils/animation.ts +4 -4
- package/src/utils/change.ts +6 -1
- package/src/utils/data.ts +2 -2
- package/src/utils/element.ts +2 -2
- package/src/utils/event/events.ts +3 -1
- package/src/utils/event/index.ts +1 -1
- package/src/utils/palette.ts +1 -1
- package/src/utils/relation.ts +2 -2
- package/src/utils/visibility.ts +1 -1
- package/esm/plugins/hull/shape.js.map +0 -1
- package/esm/spec/spec.js +0 -2
- package/esm/spec/spec.js.map +0 -1
- package/lib/plugins/hull/shape.js.map +0 -1
- package/lib/spec/spec.js.map +0 -1
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { Timebar as TimebarComponent } from '@antv/component';
|
|
2
|
+
import { Canvas } from '@antv/g';
|
|
3
|
+
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
4
|
+
import { isArray, isDate, isNumber } from '@antv/util';
|
|
5
|
+
import { idOf } from '../utils/id';
|
|
6
|
+
import { BasePlugin } from './base-plugin';
|
|
7
|
+
|
|
8
|
+
import type { TimebarStyleProps as TimebarComponentStyleProps } from '@antv/component';
|
|
9
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
10
|
+
import type { GraphData } from '../spec';
|
|
11
|
+
import type { ElementDatum, ElementType, ID } from '../types';
|
|
12
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
13
|
+
|
|
14
|
+
const prospectiveTimeKeys = ['timestamp', 'time', 'date', 'datetime'];
|
|
15
|
+
|
|
16
|
+
const PADDING = 10;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* <zh/> Timebar 时间条的配置项。
|
|
20
|
+
* <en/> The configuration item of the Timebar.
|
|
21
|
+
*/
|
|
22
|
+
export interface TimebarOptions extends BasePluginOptions {
|
|
23
|
+
/**
|
|
24
|
+
* <zh/> 给工具栏的 DOM 追加的类名,便于自定义样式
|
|
25
|
+
*
|
|
26
|
+
* <en/> The class name appended to the menu DOM for custom styles
|
|
27
|
+
* @defaultValue 'g6-timebar'
|
|
28
|
+
*/
|
|
29
|
+
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* <zh/> X 位置
|
|
32
|
+
*
|
|
33
|
+
* <en/> X position
|
|
34
|
+
* @remarks
|
|
35
|
+
* <zh/> 设置后 `position` 会失效
|
|
36
|
+
*
|
|
37
|
+
* <en/> Setting will invalidate `position`
|
|
38
|
+
*/
|
|
39
|
+
x?: number;
|
|
40
|
+
/**
|
|
41
|
+
* <zh/> Y 位置
|
|
42
|
+
*
|
|
43
|
+
* <en/> Y position
|
|
44
|
+
* <zh/> 设置后 `position` 会失效
|
|
45
|
+
*
|
|
46
|
+
* <en/> Setting will invalidate `position`
|
|
47
|
+
*/
|
|
48
|
+
y?: number;
|
|
49
|
+
/**
|
|
50
|
+
* <zh/> 时间条宽度
|
|
51
|
+
*
|
|
52
|
+
* <en/> Timebar width
|
|
53
|
+
* @defaultValue 450
|
|
54
|
+
*/
|
|
55
|
+
width?: number;
|
|
56
|
+
/**
|
|
57
|
+
* <zh/> 时间条高度
|
|
58
|
+
*
|
|
59
|
+
* <en/> Timebar height
|
|
60
|
+
* @defaultValue 60
|
|
61
|
+
*/
|
|
62
|
+
height?: number;
|
|
63
|
+
/**
|
|
64
|
+
* <zh/> Timebar 的位置, 当前可配置 'bottom' | 'top'
|
|
65
|
+
*
|
|
66
|
+
* <en/> Timebar location, currently configurable 'bottom' | 'top'
|
|
67
|
+
* @defaultValue 'bottom'
|
|
68
|
+
*/
|
|
69
|
+
position?: 'bottom' | 'top';
|
|
70
|
+
/**
|
|
71
|
+
* <zh/> 获取元素时间
|
|
72
|
+
*
|
|
73
|
+
* <en/> Get element time
|
|
74
|
+
*/
|
|
75
|
+
getTime?: (datum: ElementDatum) => number;
|
|
76
|
+
/**
|
|
77
|
+
* <zh/> 时间数据
|
|
78
|
+
*
|
|
79
|
+
* <en/> Time data
|
|
80
|
+
* @remarks
|
|
81
|
+
* <zh/> timebarType 为 'chart' 时,需要额外传入 value 字段作为图表数据
|
|
82
|
+
*
|
|
83
|
+
* <en/> When timebarType is 'chart', you need to pass in the value field as chart data
|
|
84
|
+
*/
|
|
85
|
+
data: number[] | { time: number; value: number }[];
|
|
86
|
+
/**
|
|
87
|
+
* <zh/> Timebar 展示类型
|
|
88
|
+
* - time: 显示为时间轴
|
|
89
|
+
* - chart: 显示为趋势图
|
|
90
|
+
*
|
|
91
|
+
* <en/> Timebar Displays the type
|
|
92
|
+
* - time: Display as a timeline
|
|
93
|
+
* - chart: Display as a trend chart
|
|
94
|
+
* @defaultValue 'time'
|
|
95
|
+
*/
|
|
96
|
+
timebarType?: 'time' | 'chart';
|
|
97
|
+
/**
|
|
98
|
+
* <zh/> 筛选类型
|
|
99
|
+
*
|
|
100
|
+
* <en/> Filter element types
|
|
101
|
+
*/
|
|
102
|
+
elementTypes?: ElementType[];
|
|
103
|
+
/**
|
|
104
|
+
* <zh/> 筛选模式
|
|
105
|
+
* - modify: 通过修改图数据进行筛选
|
|
106
|
+
* - visibility: 通过修改元素可见性进行筛选
|
|
107
|
+
*
|
|
108
|
+
* <en/> Filter mode
|
|
109
|
+
* - modify: Filter by modifying the graph data.
|
|
110
|
+
* - visibility: Filter by modifying element visibility
|
|
111
|
+
* @defaultValue 'modify'
|
|
112
|
+
*/
|
|
113
|
+
mode?: 'modify' | 'visibility';
|
|
114
|
+
/**
|
|
115
|
+
* <zh/> 当前时间值
|
|
116
|
+
*
|
|
117
|
+
* <en/> Current time value
|
|
118
|
+
*/
|
|
119
|
+
values?: number | [number, number] | Date | [Date, Date];
|
|
120
|
+
/**
|
|
121
|
+
* <zh/> 图表模式下自定义时间格式化
|
|
122
|
+
*
|
|
123
|
+
* <en/> Custom time formatting in chart mode
|
|
124
|
+
*/
|
|
125
|
+
labelFormatter?: (time: number | Date) => string;
|
|
126
|
+
/**
|
|
127
|
+
* <zh/> 是否循环播放
|
|
128
|
+
*
|
|
129
|
+
* <en/> Whether to loop
|
|
130
|
+
*/
|
|
131
|
+
loop?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* <zh/> 时间区间变化时执行的回调
|
|
134
|
+
*
|
|
135
|
+
* <en/> Callback executed when the time interval changes
|
|
136
|
+
*/
|
|
137
|
+
onChange?: (values: number | [number, number]) => void;
|
|
138
|
+
/**
|
|
139
|
+
* <zh/> 重置时执行的回调
|
|
140
|
+
*
|
|
141
|
+
* <en/> Callback executed when reset
|
|
142
|
+
*/
|
|
143
|
+
onReset?: () => void;
|
|
144
|
+
/**
|
|
145
|
+
* <zh/> 播放速度变化时执行的回调
|
|
146
|
+
*
|
|
147
|
+
* <en/> Callback executed when the playback speed changes
|
|
148
|
+
*/
|
|
149
|
+
onSpeedChange?: (speed: number) => void;
|
|
150
|
+
/**
|
|
151
|
+
* <zh/> 开始播放时执行的回调
|
|
152
|
+
*
|
|
153
|
+
* <en/> Callback executed when playback starts
|
|
154
|
+
*/
|
|
155
|
+
onPlay?: () => void;
|
|
156
|
+
/**
|
|
157
|
+
* <zh/> 暂停时执行的回调
|
|
158
|
+
*
|
|
159
|
+
* <en/> Callback executed when paused
|
|
160
|
+
*/
|
|
161
|
+
onPause?: () => void;
|
|
162
|
+
/**
|
|
163
|
+
* <zh/> 后退时执行的回调
|
|
164
|
+
*
|
|
165
|
+
* <en/> Callback executed when backward
|
|
166
|
+
*/
|
|
167
|
+
onBackward?: () => void;
|
|
168
|
+
/**
|
|
169
|
+
* <zh/> 前进时执行的回调
|
|
170
|
+
*
|
|
171
|
+
* <en/> Callback executed when forward
|
|
172
|
+
*/
|
|
173
|
+
onForward?: () => void;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* <zh/> 时间组件
|
|
178
|
+
*
|
|
179
|
+
* <en/> Timebar
|
|
180
|
+
*/
|
|
181
|
+
export class Timebar extends BasePlugin<TimebarOptions> {
|
|
182
|
+
static defaultOptions: Partial<TimebarOptions> = {
|
|
183
|
+
position: 'bottom',
|
|
184
|
+
enable: true,
|
|
185
|
+
timebarType: 'time',
|
|
186
|
+
className: 'g6-timebar',
|
|
187
|
+
width: 450,
|
|
188
|
+
height: 60,
|
|
189
|
+
zIndex: 3,
|
|
190
|
+
elementTypes: ['node'],
|
|
191
|
+
mode: 'modify',
|
|
192
|
+
getTime: (datum) => inferTime(datum, prospectiveTimeKeys, undefined),
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
private timebar?: TimebarComponent;
|
|
196
|
+
|
|
197
|
+
private canvas?: Canvas;
|
|
198
|
+
|
|
199
|
+
private wrapper?: HTMLElement;
|
|
200
|
+
|
|
201
|
+
private originalData?: GraphData;
|
|
202
|
+
|
|
203
|
+
constructor(context: RuntimeContext, options: TimebarOptions) {
|
|
204
|
+
super(context, Object.assign({}, Timebar.defaultOptions, options));
|
|
205
|
+
this.backup();
|
|
206
|
+
this.upsertTimebar();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* <zh/> 播放
|
|
211
|
+
*
|
|
212
|
+
* <en/> Play
|
|
213
|
+
*/
|
|
214
|
+
public play() {
|
|
215
|
+
this.timebar?.play();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* <zh/> 暂停
|
|
220
|
+
*
|
|
221
|
+
* <en/> Pause
|
|
222
|
+
*/
|
|
223
|
+
public pause() {
|
|
224
|
+
this.timebar?.pause();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* <zh/> 前进
|
|
229
|
+
*
|
|
230
|
+
* <en/> Forward
|
|
231
|
+
*/
|
|
232
|
+
public forward() {
|
|
233
|
+
this.timebar?.forward();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* <zh/> 后退
|
|
238
|
+
*
|
|
239
|
+
* <en/> Backward
|
|
240
|
+
*/
|
|
241
|
+
public backward() {
|
|
242
|
+
this.timebar?.backward();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* <zh/> 重置
|
|
247
|
+
*
|
|
248
|
+
* <en/> Reset
|
|
249
|
+
*/
|
|
250
|
+
public reset() {
|
|
251
|
+
this.timebar?.reset();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public update(options: Partial<TimebarOptions>) {
|
|
255
|
+
super.update(options);
|
|
256
|
+
this.backup();
|
|
257
|
+
|
|
258
|
+
Object.keys(options).forEach((key) => {
|
|
259
|
+
switch (key) {
|
|
260
|
+
case 'position':
|
|
261
|
+
this.upsertWrapper();
|
|
262
|
+
break;
|
|
263
|
+
default:
|
|
264
|
+
this.upsertTimebar();
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* <zh/> 备份数据
|
|
272
|
+
*
|
|
273
|
+
* <en/> Backup data
|
|
274
|
+
*/
|
|
275
|
+
private backup() {
|
|
276
|
+
this.originalData = shallowCopy(this.context.graph.getData());
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private upsertTimebar() {
|
|
280
|
+
const { canvas } = this.context;
|
|
281
|
+
const { onChange, timebarType, data, x, y, width, height, mode, ...restOptions } = this.options;
|
|
282
|
+
|
|
283
|
+
const canvasSize = canvas.getSize();
|
|
284
|
+
|
|
285
|
+
this.upsertCanvas().ready.then(() => {
|
|
286
|
+
const style: TimebarComponentStyleProps = {
|
|
287
|
+
x: canvasSize[0] / 2 - width / 2,
|
|
288
|
+
y: PADDING,
|
|
289
|
+
onChange: (value) => {
|
|
290
|
+
const range = (isArray(value) ? value : [value, value]).map((time) =>
|
|
291
|
+
isDate(time) ? time.getTime() : time,
|
|
292
|
+
) as [number, number];
|
|
293
|
+
|
|
294
|
+
if (this.options.mode === 'modify') this.filterElements(range);
|
|
295
|
+
else this.hiddenElements(range);
|
|
296
|
+
|
|
297
|
+
onChange?.(range);
|
|
298
|
+
},
|
|
299
|
+
...restOptions,
|
|
300
|
+
data: data.map((datum) => (isNumber(datum) ? { time: datum, value: 0 } : datum)),
|
|
301
|
+
width,
|
|
302
|
+
height,
|
|
303
|
+
type: timebarType,
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
if (!this.timebar) {
|
|
307
|
+
this.timebar = new TimebarComponent({ style });
|
|
308
|
+
this.canvas?.appendChild(this.timebar);
|
|
309
|
+
} else {
|
|
310
|
+
this.timebar.update(style);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private upsertWrapper() {
|
|
316
|
+
if (!this.wrapper) {
|
|
317
|
+
const wrapper = document.createElement('div');
|
|
318
|
+
wrapper.style.position = 'absolute';
|
|
319
|
+
this.wrapper = wrapper;
|
|
320
|
+
}
|
|
321
|
+
const { x, y, className, position } = this.options;
|
|
322
|
+
if (className) this.wrapper.className = className;
|
|
323
|
+
|
|
324
|
+
if (isNumber(x) || isNumber(y)) {
|
|
325
|
+
Object.assign(this.wrapper.style, {
|
|
326
|
+
left: `${x ?? 0}px`,
|
|
327
|
+
top: `${y ?? 0}px`,
|
|
328
|
+
});
|
|
329
|
+
} else {
|
|
330
|
+
Object.assign(this.wrapper.style, {
|
|
331
|
+
[position === 'top' ? 'bottom' : 'top']: 'unset',
|
|
332
|
+
[position === 'top' ? 'top' : 'bottom']: '0px',
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
this.context.canvas.getContainer()?.appendChild(this.wrapper);
|
|
337
|
+
|
|
338
|
+
return this.wrapper;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private upsertCanvas() {
|
|
342
|
+
const wrapper = this.upsertWrapper();
|
|
343
|
+
if (this.canvas) return this.canvas;
|
|
344
|
+
|
|
345
|
+
const { height } = this.options;
|
|
346
|
+
const [width] = this.context.canvas.getSize();
|
|
347
|
+
|
|
348
|
+
this.canvas = new Canvas({
|
|
349
|
+
container: wrapper,
|
|
350
|
+
width,
|
|
351
|
+
height: height + PADDING,
|
|
352
|
+
renderer: this.context.options.renderer?.('main') || new CanvasRenderer(),
|
|
353
|
+
supportsMutipleCanvasesInOneContainer: true,
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
return this.canvas;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private async filterElements(range: number | [number, number]) {
|
|
360
|
+
if (!this.originalData) return;
|
|
361
|
+
const { elementTypes, getTime } = this.options;
|
|
362
|
+
const { graph, element } = this.context;
|
|
363
|
+
|
|
364
|
+
const newData = shallowCopy(this.originalData);
|
|
365
|
+
|
|
366
|
+
elementTypes.forEach((type) => {
|
|
367
|
+
const key = `${type}s` as const;
|
|
368
|
+
newData[key] = (this.originalData![key] || []).filter((datum) => {
|
|
369
|
+
const time = getTime(datum);
|
|
370
|
+
if (match(time, range)) return true;
|
|
371
|
+
return false;
|
|
372
|
+
}) as any;
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const nodeLikeIds = [...newData.nodes, ...newData.combos].map((datum) => idOf(datum));
|
|
376
|
+
newData.edges = newData.edges!.filter((edge) => {
|
|
377
|
+
const source = edge.source;
|
|
378
|
+
const target = edge.target;
|
|
379
|
+
return nodeLikeIds.includes(source) && nodeLikeIds.includes(target);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
graph.setData(newData);
|
|
383
|
+
await element!.draw({ animation: false, silence: true });
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private hiddenElements(range: number | [number, number]) {
|
|
387
|
+
const { graph } = this.context;
|
|
388
|
+
const { elementTypes, getTime } = this.options;
|
|
389
|
+
const hideElementId: ID[] = [];
|
|
390
|
+
const showElementId: ID[] = [];
|
|
391
|
+
|
|
392
|
+
elementTypes.forEach((elementType) => {
|
|
393
|
+
const key = `${elementType}s` as const;
|
|
394
|
+
const elementData = this.originalData?.[key] || [];
|
|
395
|
+
|
|
396
|
+
elementData.forEach((elementDatum) => {
|
|
397
|
+
const id = idOf(elementDatum);
|
|
398
|
+
const time = getTime(elementDatum);
|
|
399
|
+
if (match(time, range)) showElementId.push(id);
|
|
400
|
+
else hideElementId.push(id);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
graph.hideElement(hideElementId, false);
|
|
405
|
+
graph.showElement(showElementId, false);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* <zh/> 销毁时间条
|
|
410
|
+
*
|
|
411
|
+
* <en/> Destroy the timebar
|
|
412
|
+
*/
|
|
413
|
+
public destroy(): void {
|
|
414
|
+
const { graph } = this.context;
|
|
415
|
+
this.originalData && graph.setData({ ...this.originalData });
|
|
416
|
+
this.timebar?.destroy();
|
|
417
|
+
this.canvas?.destroy();
|
|
418
|
+
this.wrapper?.remove();
|
|
419
|
+
this.originalData = undefined;
|
|
420
|
+
this.wrapper = undefined;
|
|
421
|
+
this.timebar = undefined;
|
|
422
|
+
this.canvas = undefined;
|
|
423
|
+
|
|
424
|
+
super.destroy();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const shallowCopy = (data: GraphData) => {
|
|
429
|
+
const { nodes = [], edges = [], combos = [] } = data;
|
|
430
|
+
return {
|
|
431
|
+
nodes: [...nodes],
|
|
432
|
+
edges: [...edges],
|
|
433
|
+
combos: [...combos],
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
const match = (time: number, range: number | [number, number]) => {
|
|
438
|
+
if (isNumber(range)) return time === range;
|
|
439
|
+
const [start, end] = range;
|
|
440
|
+
return time >= start && time <= end;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const inferTime = (datum: ElementDatum, optionsKeys: string[], defaultValue?: any): number => {
|
|
444
|
+
for (let i = 0; i < optionsKeys.length; i++) {
|
|
445
|
+
const key = optionsKeys[i];
|
|
446
|
+
const val = datum.data?.[key];
|
|
447
|
+
if (val) return val as number;
|
|
448
|
+
}
|
|
449
|
+
return defaultValue;
|
|
450
|
+
};
|
package/src/plugins/tooltip.ts
CHANGED
|
@@ -12,9 +12,9 @@ export interface TooltipOptions
|
|
|
12
12
|
/** <zh/> 触发方式 | <en/> Event type that triggers display of tooltip */
|
|
13
13
|
trigger?: 'hover' | 'click';
|
|
14
14
|
/** <zh/> 自定义内容 | <en/> Function for getting tooltip content */
|
|
15
|
-
getContent?: (
|
|
15
|
+
getContent?: (event: IElementEvent, items: ElementDatum[]) => HTMLElement | string;
|
|
16
16
|
/** <zh/> 是否启用 | <en/> Is enable */
|
|
17
|
-
enable?: boolean | ((
|
|
17
|
+
enable?: boolean | ((event: IElementEvent) => boolean);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class Tooltip extends BasePlugin<TooltipOptions> {
|
package/src/registry/build-in.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
FocusElement,
|
|
11
11
|
HoverElement,
|
|
12
12
|
LassoSelect,
|
|
13
|
+
ScrollCanvas,
|
|
13
14
|
ZoomCanvas,
|
|
14
15
|
} from '../behaviors';
|
|
15
16
|
import {
|
|
@@ -53,7 +54,18 @@ import {
|
|
|
53
54
|
mindmap,
|
|
54
55
|
} from '../layouts';
|
|
55
56
|
import { blues, greens, oranges, spectral, tableau } from '../palettes';
|
|
56
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
BubbleSets,
|
|
59
|
+
Contextmenu,
|
|
60
|
+
GridLine,
|
|
61
|
+
History,
|
|
62
|
+
Hull,
|
|
63
|
+
Legend,
|
|
64
|
+
Timebar,
|
|
65
|
+
Toolbar,
|
|
66
|
+
Tooltip,
|
|
67
|
+
Watermark,
|
|
68
|
+
} from '../plugins';
|
|
57
69
|
import { dark, light } from '../themes';
|
|
58
70
|
import { ArrangeDrawOrder, CollapseExpandCombo, ProcessParallelEdges, UpdateRelatedEdge } from '../transforms';
|
|
59
71
|
import type { ExtensionRegistry } from './types';
|
|
@@ -73,6 +85,7 @@ export const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
73
85
|
'drag-canvas': DragCanvas,
|
|
74
86
|
'drag-element': DragElement,
|
|
75
87
|
'drag-element-force': DragElementForce,
|
|
88
|
+
'scroll-canvas': ScrollCanvas,
|
|
76
89
|
'collapse-expand': CollapseExpand,
|
|
77
90
|
'click-element': ClickElement,
|
|
78
91
|
'hover-element': HoverElement,
|
|
@@ -137,14 +150,16 @@ export const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
137
150
|
light,
|
|
138
151
|
},
|
|
139
152
|
plugin: {
|
|
140
|
-
|
|
153
|
+
'bubble-sets': BubbleSets,
|
|
141
154
|
'grid-line': GridLine,
|
|
142
|
-
watermark: Watermark,
|
|
143
|
-
tooltip: Tooltip,
|
|
144
155
|
contextmenu: Contextmenu,
|
|
145
|
-
toolbar: Toolbar,
|
|
146
|
-
legend: Legend,
|
|
147
156
|
history: History,
|
|
157
|
+
timebar: Timebar,
|
|
158
|
+
hull: Hull,
|
|
159
|
+
legend: Legend,
|
|
160
|
+
toolbar: Toolbar,
|
|
161
|
+
tooltip: Tooltip,
|
|
162
|
+
watermark: Watermark,
|
|
148
163
|
},
|
|
149
164
|
transform: {
|
|
150
165
|
'update-related-edges': UpdateRelatedEdge,
|
package/src/registry/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ const EXTENSION_REGISTRY: ExtensionRegistry = {
|
|
|
37
37
|
* <zh/> 要注册的扩展类,在使用时创建实例
|
|
38
38
|
*
|
|
39
39
|
* <en/> The extension class to be registered. An instance will be created upon use
|
|
40
|
-
* @
|
|
40
|
+
* @remarks
|
|
41
41
|
* <zh/> 内置扩展在项目导入时会自动注册。对于非内置扩展,可以通过 `register` 方法手动注册。扩展只需要注册一次,即可在项目的任何位置使用。
|
|
42
42
|
*
|
|
43
43
|
* <en/> Built-in extensions are automatically registered when the project is imported. For non-built-in extensions, you can manually register them using the `register` method. Extensions only need to be registered once and can be used anywhere in the project.
|
package/src/runtime/canvas.ts
CHANGED
|
@@ -187,7 +187,7 @@ export class Canvas {
|
|
|
187
187
|
Object.values(this.canvas)
|
|
188
188
|
.map((canvas) => canvas.document.documentElement)
|
|
189
189
|
.filter((el) => el.childNodes.length > 0)
|
|
190
|
-
.map((el) => el.
|
|
190
|
+
.map((el) => el.getBounds()),
|
|
191
191
|
);
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -319,7 +319,7 @@ export class Canvas {
|
|
|
319
319
|
*
|
|
320
320
|
* <en/> G Canvas destroy does not handle animation objects, causing memory leaks
|
|
321
321
|
* @param canvas GCanvas
|
|
322
|
-
* @
|
|
322
|
+
* @remarks
|
|
323
323
|
* <zh/> 这些操作都应该在 G 中完成,这里只是一个临时的解决方案
|
|
324
324
|
* 此操作大概能在测试环节降低 10~20% 的内存占用(从 2800MB 降低到 2200MB)
|
|
325
325
|
*
|
package/src/runtime/data.ts
CHANGED
|
@@ -36,7 +36,7 @@ export class DataController {
|
|
|
36
36
|
* <zh/> 最近一次删除的 combo 的 id
|
|
37
37
|
*
|
|
38
38
|
* <en/> The ids of the last deleted combos
|
|
39
|
-
* @
|
|
39
|
+
* @remarks
|
|
40
40
|
* <zh/> 当删除 combo 后,会将其 id 从 comboIds 中移除,此时根据 Graphlib 的 changes 事件获取到的 NodeRemoved 无法区分是 combo 还是 node。
|
|
41
41
|
* 因此需要记录最近一次删除的 combo 的 id,并用于 isCombo 的判断
|
|
42
42
|
*
|
|
@@ -109,7 +109,7 @@ export class DataController {
|
|
|
109
109
|
*
|
|
110
110
|
* <en/> Perform operations without leaving records
|
|
111
111
|
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
112
|
-
* @
|
|
112
|
+
* @remarks
|
|
113
113
|
* <zh/> 通常用于运行时调整元素并同步数据,避免触发数据变更导致重绘
|
|
114
114
|
*
|
|
115
115
|
* <en/> Usually used to adjust elements at runtime and synchronize data to avoid triggering data changes and causing redraws
|
|
@@ -417,6 +417,24 @@ export class DataController {
|
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
/**
|
|
421
|
+
* <zh/> 将所有数据提交到变更记录中以进行重绘
|
|
422
|
+
*
|
|
423
|
+
* <en/> Submit all data to the change record for redrawing
|
|
424
|
+
*/
|
|
425
|
+
public refreshData() {
|
|
426
|
+
const { nodes, edges, combos } = this.getData();
|
|
427
|
+
nodes.forEach((node) => {
|
|
428
|
+
this.pushChange({ value: node, original: node, type: ChangeType.NodeUpdated });
|
|
429
|
+
});
|
|
430
|
+
edges.forEach((edge) => {
|
|
431
|
+
this.pushChange({ value: edge, original: edge, type: ChangeType.EdgeUpdated });
|
|
432
|
+
});
|
|
433
|
+
combos.forEach((combo) => {
|
|
434
|
+
this.pushChange({ value: combo, original: combo, type: ChangeType.ComboUpdated });
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
420
438
|
public syncNodeDatum(datum: PartialNodeLikeData<NodeData>) {
|
|
421
439
|
const { model } = this;
|
|
422
440
|
|
|
@@ -502,7 +520,7 @@ export class DataController {
|
|
|
502
520
|
*
|
|
503
521
|
* <en/> Refresh combo data
|
|
504
522
|
* @param id - <zh/> combo ID | <en/> combo ID
|
|
505
|
-
* @
|
|
523
|
+
* @remarks
|
|
506
524
|
* <zh/> 不会更改数据,但会触发数据变更事件
|
|
507
525
|
*
|
|
508
526
|
* <en/> Will not change the data, but will trigger data change events
|
package/src/runtime/element.ts
CHANGED
|
@@ -123,11 +123,12 @@ export class ElementController {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
public getPaletteStyle(id: ID) {
|
|
126
|
+
public getPaletteStyle(elementType: ElementType, id: ID): BaseStyleProps {
|
|
127
127
|
const color = this.paletteStyle[id];
|
|
128
128
|
if (!color) return {};
|
|
129
129
|
|
|
130
|
-
return { color };
|
|
130
|
+
if (elementType === 'edge') return { stroke: color };
|
|
131
|
+
return { fill: color };
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
private defaultStyle: Record<ID, Record<string, unknown>> = {};
|
|
@@ -285,7 +286,7 @@ export class ElementController {
|
|
|
285
286
|
* <en/> Get edge end context
|
|
286
287
|
* @param id - <zh/> 边 id | <en/> edge id
|
|
287
288
|
* @returns <zh/> 边端点连接上下文 | <en/> edge end context
|
|
288
|
-
* @
|
|
289
|
+
* @remarks
|
|
289
290
|
* <zh/> 只提供了最基本的节点示例和连接点位置信息,更多的上下文信息需要在边元素中计算
|
|
290
291
|
*
|
|
291
292
|
* <en/> Only the most basic node instances and connection point position information are provided, and more context information needs to be calculated in the edge element
|
|
@@ -302,7 +303,7 @@ export class ElementController {
|
|
|
302
303
|
const id = idOf(datum);
|
|
303
304
|
// 优先级(从低到高) Priority (from low to high):
|
|
304
305
|
const themeStyle = this.getThemeStyle(elementType);
|
|
305
|
-
const paletteStyle = this.getPaletteStyle(id);
|
|
306
|
+
const paletteStyle = this.getPaletteStyle(elementType, id);
|
|
306
307
|
const dataStyle = datum.style || {};
|
|
307
308
|
const defaultStyle = this.getDefaultStyle(id);
|
|
308
309
|
const themeStateStyle = this.getThemeStateStyle(elementType, this.getElementState(id));
|