@antv/g6 5.0.0-beta.25 → 5.0.0-beta.27
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/esm/constant/shape.d.ts +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +6 -4
- package/esm/item/combo.js +10 -3
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +12 -4
- package/esm/item/edge.js +100 -17
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +18 -8
- package/esm/item/item.js +121 -62
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +10 -4
- package/esm/item/node.js +92 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +5 -1
- package/esm/runtime/controller/data.js +38 -1
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/index.d.ts +1 -1
- package/esm/runtime/controller/index.js +1 -1
- package/esm/runtime/controller/index.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +22 -11
- package/esm/runtime/controller/item.js +241 -96
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +3 -0
- package/esm/runtime/controller/layout.js +178 -98
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +3 -0
- package/esm/runtime/controller/plugin.js +66 -24
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/viewport.js +9 -2
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.d.ts +57 -26
- package/esm/runtime/graph.js +263 -139
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +9 -3
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +6 -3
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.js +8 -8
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +4 -0
- package/esm/stdlib/behavior/drag-node.js +121 -27
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.js +3 -3
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +3 -3
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/validateData.js +2 -2
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +2 -0
- package/esm/stdlib/index.js +3 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +2 -11
- package/esm/stdlib/item/edge/base.js +12 -105
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +2 -20
- package/esm/stdlib/item/node/base.js +10 -150
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/esm/stdlib/plugin/fisheye/index.js +3 -2
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/index.d.ts +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
- package/esm/stdlib/plugin/lodController/index.js +556 -0
- package/esm/stdlib/plugin/lodController/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.js +2 -1
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.js +12 -14
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/esm/stdlib/plugin/toolbar/index.js +27 -29
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/theme/dark.js +32 -35
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +27 -30
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/spec.js +2 -2
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/types/animate.d.ts +1 -1
- package/esm/types/combo.d.ts +2 -2
- package/esm/types/edge.d.ts +2 -2
- package/esm/types/graph.d.ts +62 -43
- package/esm/types/hook.d.ts +5 -0
- package/esm/types/item.d.ts +9 -15
- package/esm/types/layout.d.ts +7 -2
- package/esm/types/layout.js.map +1 -1
- package/esm/types/node.d.ts +3 -2
- package/esm/types/plugin.d.ts +1 -0
- package/esm/types/plugin.js +1 -0
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +1 -0
- package/esm/types/theme.d.ts +7 -7
- package/esm/util/animate.d.ts +7 -2
- package/esm/util/animate.js +40 -23
- package/esm/util/animate.js.map +1 -1
- package/esm/util/bbox.d.ts +7 -1
- package/esm/util/bbox.js +16 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/data.d.ts +7 -1
- package/esm/util/data.js +17 -5
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.js +5 -5
- package/esm/util/dom.js.map +1 -1
- package/esm/util/item.d.ts +1 -1
- package/esm/util/item.js +8 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/mapper.js +1 -1
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/path.d.ts +6 -1
- package/esm/util/path.js +72 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/polyline.d.ts +10 -0
- package/esm/util/polyline.js +22 -17
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/router.js +19 -18
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +1 -1
- package/esm/util/shape.js +28 -13
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +5 -8
- package/esm/util/zoom.js +15 -20
- package/esm/util/zoom.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +6 -4
- package/lib/item/combo.js +10 -3
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +12 -4
- package/lib/item/edge.js +99 -16
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +18 -8
- package/lib/item/item.js +119 -60
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +10 -4
- package/lib/item/node.js +92 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +5 -1
- package/lib/runtime/controller/data.js +38 -1
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/index.d.ts +1 -1
- package/lib/runtime/controller/index.js +1 -1
- package/lib/runtime/controller/index.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +22 -11
- package/lib/runtime/controller/item.js +238 -93
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +3 -0
- package/lib/runtime/controller/layout.js +178 -98
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +3 -0
- package/lib/runtime/controller/plugin.js +66 -24
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/viewport.js +9 -2
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.d.ts +57 -26
- package/lib/runtime/graph.js +263 -139
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +9 -3
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +6 -3
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.js +8 -8
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +4 -0
- package/lib/stdlib/behavior/drag-node.js +121 -27
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.js +3 -3
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +3 -3
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/validateData.js +2 -2
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +2 -0
- package/lib/stdlib/index.js +3 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +2 -11
- package/lib/stdlib/item/edge/base.js +12 -105
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +2 -20
- package/lib/stdlib/item/node/base.js +10 -150
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/lib/stdlib/plugin/fisheye/index.js +2 -1
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/index.d.ts +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
- package/lib/stdlib/plugin/lodController/index.js +560 -0
- package/lib/stdlib/plugin/lodController/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.js +2 -1
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.js +12 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/lib/stdlib/plugin/toolbar/index.js +27 -29
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/theme/dark.js +32 -35
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +27 -30
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/spec.js +2 -2
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/types/animate.d.ts +1 -1
- package/lib/types/combo.d.ts +2 -2
- package/lib/types/edge.d.ts +2 -2
- package/lib/types/graph.d.ts +62 -43
- package/lib/types/hook.d.ts +5 -0
- package/lib/types/item.d.ts +9 -15
- package/lib/types/layout.d.ts +7 -2
- package/lib/types/layout.js.map +1 -1
- package/lib/types/node.d.ts +3 -2
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/plugin.js +1 -0
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +1 -0
- package/lib/types/theme.d.ts +7 -7
- package/lib/util/animate.d.ts +7 -2
- package/lib/util/animate.js +40 -23
- package/lib/util/animate.js.map +1 -1
- package/lib/util/bbox.d.ts +7 -1
- package/lib/util/bbox.js +18 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/data.d.ts +7 -1
- package/lib/util/data.js +19 -6
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.js +5 -5
- package/lib/util/dom.js.map +1 -1
- package/lib/util/item.d.ts +1 -1
- package/lib/util/item.js +8 -8
- package/lib/util/item.js.map +1 -1
- package/lib/util/mapper.js +1 -1
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/path.d.ts +6 -1
- package/lib/util/path.js +72 -1
- package/lib/util/path.js.map +1 -1
- package/lib/util/polyline.d.ts +10 -0
- package/lib/util/polyline.js +25 -18
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/router.js +19 -18
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +1 -1
- package/lib/util/shape.js +27 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +5 -8
- package/lib/util/zoom.js +17 -22
- package/lib/util/zoom.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +13 -5
- package/src/item/edge.ts +126 -17
- package/src/item/item.ts +140 -57
- package/src/item/node.ts +109 -12
- package/src/runtime/controller/data.ts +64 -3
- package/src/runtime/controller/index.ts +1 -1
- package/src/runtime/controller/item.ts +321 -135
- package/src/runtime/controller/layout.ts +254 -113
- package/src/runtime/controller/plugin.ts +86 -33
- package/src/runtime/controller/viewport.ts +8 -2
- package/src/runtime/graph.ts +383 -158
- package/src/stdlib/behavior/click-select.ts +8 -3
- package/src/stdlib/behavior/drag-canvas.ts +6 -3
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +165 -50
- package/src/stdlib/behavior/scroll-canvas.ts +3 -3
- package/src/stdlib/behavior/zoom-canvas.ts +3 -3
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/validateData.ts +2 -2
- package/src/stdlib/index.ts +3 -0
- package/src/stdlib/item/edge/base.ts +15 -139
- package/src/stdlib/item/node/base.ts +20 -215
- package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
- package/src/stdlib/plugin/fisheye/index.ts +3 -2
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/lodController/index.ts +602 -0
- package/src/stdlib/plugin/menu/index.ts +1 -1
- package/src/stdlib/plugin/minimap/index.ts +12 -14
- package/src/stdlib/plugin/toolbar/index.ts +29 -31
- package/src/stdlib/theme/dark.ts +32 -34
- package/src/stdlib/theme/light.ts +27 -29
- package/src/stdlib/themeSolver/spec.ts +2 -2
- package/src/types/animate.ts +1 -1
- package/src/types/combo.ts +2 -2
- package/src/types/edge.ts +2 -2
- package/src/types/graph.ts +65 -53
- package/src/types/hook.ts +5 -0
- package/src/types/item.ts +8 -14
- package/src/types/layout.ts +20 -15
- package/src/types/node.ts +3 -2
- package/src/types/plugin.ts +2 -0
- package/src/types/spec.ts +1 -0
- package/src/types/theme.ts +7 -7
- package/src/util/animate.ts +104 -75
- package/src/util/bbox.ts +26 -1
- package/src/util/data.ts +15 -6
- package/src/util/dom.ts +6 -6
- package/src/util/item.ts +15 -1
- package/src/util/mapper.ts +1 -1
- package/src/util/path.ts +72 -2
- package/src/util/polyline.ts +30 -23
- package/src/util/router.ts +21 -19
- package/src/util/shape.ts +27 -12
- package/src/util/zoom.ts +19 -25
- package/esm/runtime/controller/extension.d.ts +0 -9
- package/esm/runtime/controller/extension.js +0 -11
- package/esm/runtime/controller/extension.js.map +0 -1
- package/lib/runtime/controller/extension.d.ts +0 -9
- package/lib/runtime/controller/extension.js +0 -15
- package/lib/runtime/controller/extension.js.map +0 -1
- package/src/runtime/controller/extension.ts +0 -14
|
@@ -19,13 +19,12 @@ import {
|
|
|
19
19
|
SHAPE_TYPE,
|
|
20
20
|
ShapeStyle,
|
|
21
21
|
State,
|
|
22
|
-
|
|
22
|
+
LodLevelRanges,
|
|
23
23
|
} from '../../../types/item';
|
|
24
24
|
import { formatPadding, mergeStyles, upsertShape } from '../../../util/shape';
|
|
25
25
|
import { DEFAULT_ANIMATE_CFG, fadeIn, fadeOut } from '../../../util/animate';
|
|
26
26
|
import { getWordWrapWidthByEnds } from '../../../util/text';
|
|
27
27
|
import { AnimateCfg } from '../../../types/animate';
|
|
28
|
-
import { getZoomLevel } from '../../../util/zoom';
|
|
29
28
|
import { DEFAULT_ARROW_CONFIG, getArrowPath } from '../../../util/arrow';
|
|
30
29
|
import Node from '../../../item/node';
|
|
31
30
|
|
|
@@ -37,7 +36,7 @@ export abstract class BaseEdge {
|
|
|
37
36
|
sourcePoint: Point;
|
|
38
37
|
targetPoint: Point;
|
|
39
38
|
nodeMap: Map<ID, Node>;
|
|
40
|
-
|
|
39
|
+
lodLevels?: LodLevelRanges;
|
|
41
40
|
labelPosition: {
|
|
42
41
|
x: number;
|
|
43
42
|
y: number;
|
|
@@ -50,45 +49,20 @@ export abstract class BaseEdge {
|
|
|
50
49
|
};
|
|
51
50
|
// cache the zoom level infomations
|
|
52
51
|
private zoomCache: {
|
|
53
|
-
// the id of shapes which are hidden by zoom changing.
|
|
54
|
-
hiddenShape: { [shapeId: string]: boolean };
|
|
55
|
-
// the ratio to scale the size of shapes whose visual size should be kept, e.g. label and badges.
|
|
56
|
-
balanceRatio: number;
|
|
57
52
|
// last responsed zoom ratio.
|
|
58
53
|
zoom: number;
|
|
59
|
-
// last responsed zoom level where the zoom ratio at. Zoom ratio 1 at level 0.
|
|
60
|
-
zoomLevel: number;
|
|
61
|
-
// shape ids in different zoom levels.
|
|
62
|
-
levelShapes: {
|
|
63
|
-
[level: string]: string[];
|
|
64
|
-
};
|
|
65
54
|
// wordWrapWidth of labelShape according to the maxWidth
|
|
66
55
|
wordWrapWidth: number;
|
|
67
|
-
// animate configurations for zoom level changing
|
|
68
|
-
animateConfig: AnimateCfg;
|
|
69
|
-
// the tag of first rendering
|
|
70
|
-
firstRender: boolean;
|
|
71
56
|
} = {
|
|
72
|
-
hiddenShape: {},
|
|
73
|
-
balanceRatio: 1,
|
|
74
57
|
zoom: 1,
|
|
75
|
-
zoomLevel: 0,
|
|
76
|
-
levelShapes: {},
|
|
77
58
|
wordWrapWidth: 50,
|
|
78
|
-
animateConfig: DEFAULT_ANIMATE_CFG.zoom,
|
|
79
|
-
firstRender: true,
|
|
80
59
|
};
|
|
81
60
|
constructor(props) {
|
|
82
|
-
const { themeStyles,
|
|
61
|
+
const { themeStyles, lodLevels, zoom } = props;
|
|
83
62
|
if (themeStyles) this.themeStyles = themeStyles;
|
|
84
|
-
this.
|
|
63
|
+
this.lodLevels = lodLevels;
|
|
85
64
|
this.transformCache = {};
|
|
86
65
|
this.zoomCache.zoom = zoom;
|
|
87
|
-
this.zoomCache.balanceRatio = 1 / zoom;
|
|
88
|
-
this.zoomCache.animateConfig = {
|
|
89
|
-
...DEFAULT_ANIMATE_CFG.zoom,
|
|
90
|
-
...lodStrategy?.animateCfg,
|
|
91
|
-
};
|
|
92
66
|
}
|
|
93
67
|
|
|
94
68
|
/**
|
|
@@ -108,9 +82,9 @@ export abstract class BaseEdge {
|
|
|
108
82
|
const { data } = model;
|
|
109
83
|
const dataStyles = {} as EdgeShapeStyles;
|
|
110
84
|
Object.keys(data).forEach((fieldName) => {
|
|
111
|
-
if (RESERVED_SHAPE_IDS.includes(fieldName))
|
|
85
|
+
if (RESERVED_SHAPE_IDS.includes(fieldName)) {
|
|
112
86
|
dataStyles[fieldName] = data[fieldName] as ShapeStyle;
|
|
113
|
-
else if (fieldName === OTHER_SHAPES_FIELD_NAME) {
|
|
87
|
+
} else if (fieldName === OTHER_SHAPES_FIELD_NAME) {
|
|
114
88
|
Object.keys(data[fieldName]).forEach(
|
|
115
89
|
(otherShapeId) =>
|
|
116
90
|
(dataStyles[otherShapeId] = data[fieldName][otherShapeId]),
|
|
@@ -146,15 +120,6 @@ export abstract class BaseEdge {
|
|
|
146
120
|
});
|
|
147
121
|
|
|
148
122
|
const { zoom } = this.zoomCache;
|
|
149
|
-
const levelShapes = {};
|
|
150
|
-
Object.keys(shapeMap).forEach((shapeId) => {
|
|
151
|
-
const { lod } = shapeMap[shapeId].attributes;
|
|
152
|
-
if (lod !== undefined) {
|
|
153
|
-
levelShapes[lod] = levelShapes[lod] || [];
|
|
154
|
-
levelShapes[lod].push(shapeId);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
this.zoomCache.levelShapes = levelShapes;
|
|
158
123
|
|
|
159
124
|
const { maxWidth = '60%' } = this.mergedStyles.labelShape || {};
|
|
160
125
|
this.zoomCache.wordWrapWidth = getWordWrapWidthByEnds(
|
|
@@ -164,7 +129,6 @@ export abstract class BaseEdge {
|
|
|
164
129
|
);
|
|
165
130
|
|
|
166
131
|
this.zoomCache.zoom = 1;
|
|
167
|
-
this.zoomCache.zoomLevel = 0;
|
|
168
132
|
if (zoom !== 1) this.onZoom(shapeMap, zoom);
|
|
169
133
|
}
|
|
170
134
|
|
|
@@ -311,7 +275,7 @@ export abstract class BaseEdge {
|
|
|
311
275
|
positionStyle = {
|
|
312
276
|
x: projection.x + offsetY * Math.cos(Math.PI - angle),
|
|
313
277
|
y: projection.y + offsetY * Math.sin(Math.PI - angle),
|
|
314
|
-
transform: `rotate(${(angle / Math.PI) * 180})`,
|
|
278
|
+
transform: `rotate(${(angle / Math.PI) * 180}deg)`,
|
|
315
279
|
};
|
|
316
280
|
}
|
|
317
281
|
this.labelPosition = {
|
|
@@ -356,21 +320,20 @@ export abstract class BaseEdge {
|
|
|
356
320
|
const { labelBackgroundShape, labelShape: labelShapeStyle } =
|
|
357
321
|
this.mergedStyles;
|
|
358
322
|
|
|
359
|
-
const
|
|
323
|
+
const textGeoBBox = labelShape.getGeometryBounds();
|
|
360
324
|
const { x, y, transform, isRevert } = this.labelPosition;
|
|
361
325
|
const { padding, ...backgroundStyle } = labelBackgroundShape;
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
const textHeight = textBBox.max[1] - textBBox.min[1];
|
|
326
|
+
const textWidth = textGeoBBox.max[0] - textGeoBBox.min[0];
|
|
327
|
+
const textHeight = textGeoBBox.max[1] - textGeoBBox.min[1];
|
|
365
328
|
const bgStyle = {
|
|
366
329
|
fill: '#fff',
|
|
367
330
|
...backgroundStyle,
|
|
368
|
-
x:
|
|
369
|
-
y:
|
|
331
|
+
x: textGeoBBox.min[0] - padding[3] + labelShape.style.x,
|
|
332
|
+
y: textGeoBBox.min[1] - padding[0] + labelShape.style.y,
|
|
370
333
|
width: textWidth + padding[1] + padding[3],
|
|
371
|
-
height: textHeight +
|
|
372
|
-
transform: transform,
|
|
334
|
+
height: textHeight + padding[0] + padding[2],
|
|
373
335
|
};
|
|
336
|
+
if (transform) bgStyle.transform = transform;
|
|
374
337
|
if (labelShapeStyle.position === 'start') {
|
|
375
338
|
if (isRevert) {
|
|
376
339
|
bgStyle.transformOrigin = `${bgStyle.width - padding[1]} ${
|
|
@@ -532,8 +495,6 @@ export abstract class BaseEdge {
|
|
|
532
495
|
|
|
533
496
|
/**
|
|
534
497
|
* The listener for graph zooming.
|
|
535
|
-
* 1. show / hide some shapes while zoom level changed;
|
|
536
|
-
* 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
|
|
537
498
|
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
538
499
|
* @param zoom The zoom level of the graph.
|
|
539
500
|
*/
|
|
@@ -541,92 +502,7 @@ export abstract class BaseEdge {
|
|
|
541
502
|
shapeMap: EdgeShapeMap,
|
|
542
503
|
zoom: number,
|
|
543
504
|
cacheHiddenShape = {},
|
|
544
|
-
) => {
|
|
545
|
-
// balance the size for label, badges
|
|
546
|
-
this.balanceShapeSize(shapeMap, zoom);
|
|
547
|
-
|
|
548
|
-
// zoomLevel changed
|
|
549
|
-
if (!this.lodStrategy) return;
|
|
550
|
-
const { levels } = this.lodStrategy;
|
|
551
|
-
const {
|
|
552
|
-
levelShapes,
|
|
553
|
-
hiddenShape,
|
|
554
|
-
animateConfig,
|
|
555
|
-
firstRender = true,
|
|
556
|
-
zoomLevel: previousLevel,
|
|
557
|
-
} = this.zoomCache;
|
|
558
|
-
|
|
559
|
-
// last zoom ratio responsed by zoom changing, which might not equal to zoom.previous in props since the function is debounced.
|
|
560
|
-
const currentLevel = getZoomLevel(levels, zoom);
|
|
561
|
-
const levelNums = Object.keys(levelShapes).map(Number);
|
|
562
|
-
const maxLevel = Math.max(...levelNums);
|
|
563
|
-
const minLevel = Math.min(...levelNums);
|
|
564
|
-
if (currentLevel < previousLevel) {
|
|
565
|
-
// zoomLevel changed, from higher to lower, hide something
|
|
566
|
-
if (firstRender) {
|
|
567
|
-
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
568
|
-
levelShapes[String(i)]?.forEach((id) => {
|
|
569
|
-
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
570
|
-
shapeMap[id]?.hide();
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
} else {
|
|
574
|
-
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
575
|
-
levelShapes[String(i)]?.forEach((id) =>
|
|
576
|
-
fadeOut(id, shapeMap[id], hiddenShape, animateConfig),
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
} else if (currentLevel > previousLevel) {
|
|
581
|
-
// zoomLevel changed, from lower to higher, show something
|
|
582
|
-
for (let i = currentLevel; i >= minLevel; i--) {
|
|
583
|
-
levelShapes[String(i)]?.forEach((id) => {
|
|
584
|
-
if (hiddenShape[id]) return;
|
|
585
|
-
fadeIn(
|
|
586
|
-
id,
|
|
587
|
-
shapeMap[id],
|
|
588
|
-
this.mergedStyles[id] ||
|
|
589
|
-
this.mergedStyles[id.replace('Background', '')],
|
|
590
|
-
hiddenShape,
|
|
591
|
-
animateConfig,
|
|
592
|
-
);
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
this.zoomCache.zoom = zoom;
|
|
598
|
-
this.zoomCache.zoomLevel = currentLevel;
|
|
599
|
-
this.zoomCache.firstRender = false;
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Update the shapes' sizes e.g. labelShape, labelBackgroundShape, to keep the visual size while zooming.
|
|
604
|
-
* @param shapeMap
|
|
605
|
-
* @param zoom
|
|
606
|
-
* @returns
|
|
607
|
-
*/
|
|
608
|
-
private balanceShapeSize(shapeMap, zoom) {
|
|
609
|
-
const { labelShape, labelBackgroundShape } = shapeMap;
|
|
610
|
-
const balanceRatio = 1 / zoom || 1;
|
|
611
|
-
this.zoomCache.balanceRatio = balanceRatio;
|
|
612
|
-
const { labelShape: labelStyle = {} } = this.mergedStyles;
|
|
613
|
-
const { position = 'bottom' } = labelStyle;
|
|
614
|
-
if (!labelShape) return;
|
|
615
|
-
|
|
616
|
-
if (position === 'bottom') labelShape.style.transformOrigin = '0';
|
|
617
|
-
else labelShape.style.transformOrigin = '';
|
|
618
|
-
|
|
619
|
-
const oriTransform = this.transformCache.labelShapeTransform;
|
|
620
|
-
labelShape.style.transform = `${oriTransform} scale(${balanceRatio}, ${balanceRatio})`;
|
|
621
|
-
|
|
622
|
-
const wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
|
|
623
|
-
labelShape.style.wordWrapWidth = wordWrapWidth;
|
|
624
|
-
|
|
625
|
-
if (!labelBackgroundShape) return;
|
|
626
|
-
|
|
627
|
-
const oriBgTransform = this.transformCache.labelBackgroundShapeTransform;
|
|
628
|
-
labelBackgroundShape.style.transform = `${oriBgTransform} scale(${balanceRatio}, ${balanceRatio})`;
|
|
629
|
-
}
|
|
505
|
+
) => {};
|
|
630
506
|
|
|
631
507
|
/**
|
|
632
508
|
* Update the source point { x, y } for the edge. Called in item's draw func.
|
|
@@ -2,13 +2,12 @@ import { AABB, DisplayObject } from '@antv/g';
|
|
|
2
2
|
import { OTHER_SHAPES_FIELD_NAME, RESERVED_SHAPE_IDS } from '../../../constant';
|
|
3
3
|
import { NodeDisplayModel } from '../../../types';
|
|
4
4
|
import {
|
|
5
|
-
BadgePosition,
|
|
6
5
|
GShapeStyle,
|
|
7
6
|
SHAPE_TYPE,
|
|
8
7
|
SHAPE_TYPE_3D,
|
|
9
8
|
ShapeStyle,
|
|
10
9
|
State,
|
|
11
|
-
|
|
10
|
+
LodLevelRanges,
|
|
12
11
|
} from '../../../types/item';
|
|
13
12
|
import {
|
|
14
13
|
NodeModelData,
|
|
@@ -30,16 +29,13 @@ import {
|
|
|
30
29
|
} from '../../../util/shape';
|
|
31
30
|
import { getWordWrapWidthByBox } from '../../../util/text';
|
|
32
31
|
import { convertToNumber } from '../../../util/type';
|
|
33
|
-
import { DEFAULT_ANIMATE_CFG, fadeIn, fadeOut } from '../../../util/animate';
|
|
34
|
-
import { getZoomLevel } from '../../../util/zoom';
|
|
35
|
-
import { AnimateCfg } from '../../../types/animate';
|
|
36
32
|
|
|
37
33
|
export abstract class BaseNode {
|
|
38
34
|
type: string;
|
|
39
35
|
defaultStyles: NodeShapeStyles | ComboShapeStyles;
|
|
40
36
|
themeStyles: NodeShapeStyles | ComboShapeStyles;
|
|
41
37
|
mergedStyles: NodeShapeStyles | ComboShapeStyles;
|
|
42
|
-
|
|
38
|
+
lodLevels?: LodLevelRanges;
|
|
43
39
|
enableBalanceShape?: boolean;
|
|
44
40
|
//vertex coordinate
|
|
45
41
|
|
|
@@ -50,46 +46,21 @@ export abstract class BaseNode {
|
|
|
50
46
|
|
|
51
47
|
// cache the zoom level infomations
|
|
52
48
|
protected zoomCache: {
|
|
53
|
-
// the id of shapes which are hidden by zoom changing.
|
|
54
|
-
hiddenShape: { [shapeId: string]: boolean };
|
|
55
|
-
// the ratio to scale the shapes (e.g. labelShape, labelBackgroundShape) to keep to visual size while zooming.
|
|
56
|
-
balanceRatio: number;
|
|
57
49
|
// last responsed zoom ratio.
|
|
58
50
|
zoom: number;
|
|
59
|
-
// last responsed zoom level where the zoom ratio at. Zoom ratio 1 at level 0.
|
|
60
|
-
zoomLevel: number;
|
|
61
|
-
// shape ids in different zoom levels.
|
|
62
|
-
levelShapes: {
|
|
63
|
-
[level: string]: string[];
|
|
64
|
-
};
|
|
65
51
|
// wordWrapWidth of labelShape according to the maxWidth
|
|
66
52
|
wordWrapWidth: number;
|
|
67
|
-
// animate configurations for zoom level changing
|
|
68
|
-
animateConfig: AnimateCfg;
|
|
69
|
-
// the tag of first rendering
|
|
70
|
-
firstRender: boolean;
|
|
71
53
|
} = {
|
|
72
|
-
hiddenShape: {},
|
|
73
54
|
zoom: 1,
|
|
74
|
-
zoomLevel: 0,
|
|
75
|
-
balanceRatio: 1,
|
|
76
|
-
levelShapes: {},
|
|
77
55
|
wordWrapWidth: 32,
|
|
78
|
-
animateConfig: DEFAULT_ANIMATE_CFG.zoom,
|
|
79
|
-
firstRender: true,
|
|
80
56
|
};
|
|
81
57
|
|
|
82
58
|
constructor(props) {
|
|
83
|
-
const { themeStyles,
|
|
59
|
+
const { themeStyles, lodLevels, enableBalanceShape, zoom } = props;
|
|
84
60
|
if (themeStyles) this.themeStyles = themeStyles;
|
|
85
|
-
this.
|
|
61
|
+
this.lodLevels = lodLevels;
|
|
86
62
|
this.enableBalanceShape = enableBalanceShape;
|
|
87
63
|
this.zoomCache.zoom = zoom;
|
|
88
|
-
this.zoomCache.balanceRatio = 1 / zoom;
|
|
89
|
-
this.zoomCache.animateConfig = {
|
|
90
|
-
...DEFAULT_ANIMATE_CFG.zoom,
|
|
91
|
-
...lodStrategy?.animateCfg,
|
|
92
|
-
};
|
|
93
64
|
}
|
|
94
65
|
|
|
95
66
|
/**
|
|
@@ -120,6 +91,7 @@ export abstract class BaseNode {
|
|
|
120
91
|
}
|
|
121
92
|
const { position } = data[fieldName][key];
|
|
122
93
|
dataStyles[`${position}BadgeShape`] = {
|
|
94
|
+
...this.themeStyles[fieldName],
|
|
123
95
|
...data[fieldName][key],
|
|
124
96
|
tag: 'badgeShape',
|
|
125
97
|
};
|
|
@@ -127,6 +99,7 @@ export abstract class BaseNode {
|
|
|
127
99
|
} else if (fieldName === 'anchorShapes') {
|
|
128
100
|
Object.keys(data[fieldName]).forEach((idx) => {
|
|
129
101
|
dataStyles[`anchorShape${idx}`] = {
|
|
102
|
+
...this.themeStyles[fieldName],
|
|
130
103
|
...data[fieldName][idx],
|
|
131
104
|
tag: 'anchorShape',
|
|
132
105
|
};
|
|
@@ -157,16 +130,6 @@ export abstract class BaseNode {
|
|
|
157
130
|
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
158
131
|
*/
|
|
159
132
|
public updateCache(shapeMap) {
|
|
160
|
-
const levelShapes = {};
|
|
161
|
-
Object.keys(shapeMap).forEach((shapeId) => {
|
|
162
|
-
const { lod } = shapeMap[shapeId].attributes;
|
|
163
|
-
if (lod !== undefined) {
|
|
164
|
-
levelShapes[lod] = levelShapes[lod] || [];
|
|
165
|
-
levelShapes[lod].push(shapeId);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
this.zoomCache.levelShapes = levelShapes;
|
|
169
|
-
|
|
170
133
|
if (shapeMap.labelShape) {
|
|
171
134
|
const { maxWidth = '200%' } = this.mergedStyles.labelShape || {};
|
|
172
135
|
this.zoomCache.wordWrapWidth = getWordWrapWidthByBox(
|
|
@@ -399,7 +362,6 @@ export abstract class BaseNode {
|
|
|
399
362
|
shapeMap,
|
|
400
363
|
model,
|
|
401
364
|
);
|
|
402
|
-
this.balanceShapeSize(shapeMap, this.zoomCache.zoom);
|
|
403
365
|
|
|
404
366
|
return bgShape;
|
|
405
367
|
}
|
|
@@ -478,21 +440,24 @@ export abstract class BaseNode {
|
|
|
478
440
|
if (haloShapeStyle.visible === false) return;
|
|
479
441
|
const { nodeName, attributes } = keyShape;
|
|
480
442
|
const { x, y, fill } = attributes;
|
|
481
|
-
|
|
443
|
+
const s = {
|
|
444
|
+
...attributes,
|
|
445
|
+
...keyShapeStyle,
|
|
446
|
+
x,
|
|
447
|
+
y,
|
|
448
|
+
stroke: fill,
|
|
449
|
+
...haloShapeStyle,
|
|
450
|
+
batchKey: 'halo',
|
|
451
|
+
};
|
|
452
|
+
delete s.fillOpacity;
|
|
453
|
+
const shape = this.upsertShape(
|
|
482
454
|
nodeName as SHAPE_TYPE,
|
|
483
455
|
'haloShape',
|
|
484
|
-
|
|
485
|
-
...attributes,
|
|
486
|
-
...keyShapeStyle,
|
|
487
|
-
x,
|
|
488
|
-
y,
|
|
489
|
-
stroke: fill,
|
|
490
|
-
...haloShapeStyle,
|
|
491
|
-
batchKey: 'halo',
|
|
492
|
-
},
|
|
456
|
+
s,
|
|
493
457
|
shapeMap,
|
|
494
458
|
model,
|
|
495
459
|
);
|
|
460
|
+
return shape;
|
|
496
461
|
}
|
|
497
462
|
|
|
498
463
|
/**
|
|
@@ -785,167 +750,7 @@ export abstract class BaseNode {
|
|
|
785
750
|
shapeMap: NodeShapeMap | ComboShapeMap,
|
|
786
751
|
zoom: number,
|
|
787
752
|
cacheHiddenShape = {},
|
|
788
|
-
) => {
|
|
789
|
-
// zoomLevel changed
|
|
790
|
-
if (this.lodStrategy) {
|
|
791
|
-
const { levels } = this.lodStrategy;
|
|
792
|
-
// last zoom ratio responsed by zoom changing, which might not equal to zoom.previous in props since the function is debounced.
|
|
793
|
-
const {
|
|
794
|
-
levelShapes,
|
|
795
|
-
hiddenShape,
|
|
796
|
-
animateConfig,
|
|
797
|
-
firstRender = true,
|
|
798
|
-
zoomLevel: previousLevel,
|
|
799
|
-
} = this.zoomCache;
|
|
800
|
-
const currentLevel = getZoomLevel(levels, zoom);
|
|
801
|
-
const levelNums = Object.keys(levelShapes).map(Number);
|
|
802
|
-
const maxLevel = Math.max(...levelNums);
|
|
803
|
-
const minLevel = Math.min(...levelNums);
|
|
804
|
-
if (currentLevel < previousLevel) {
|
|
805
|
-
if (firstRender) {
|
|
806
|
-
// zoomLevel changed, from higher to lower, hide something
|
|
807
|
-
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
808
|
-
levelShapes[String(i)]?.forEach((id) => {
|
|
809
|
-
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
810
|
-
shapeMap[id].hide();
|
|
811
|
-
hiddenShape[id] = true;
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
} else {
|
|
815
|
-
// zoomLevel changed, from higher to lower, hide something
|
|
816
|
-
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
817
|
-
levelShapes[String(i)]?.forEach((id) =>
|
|
818
|
-
fadeOut(id, shapeMap[id], hiddenShape, animateConfig),
|
|
819
|
-
);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
} else if (currentLevel > previousLevel) {
|
|
823
|
-
// zoomLevel changed, from lower to higher, show something
|
|
824
|
-
for (let i = currentLevel; i >= minLevel; i--) {
|
|
825
|
-
levelShapes[String(i)]?.forEach((id) => {
|
|
826
|
-
fadeIn(
|
|
827
|
-
id,
|
|
828
|
-
shapeMap[id],
|
|
829
|
-
this.mergedStyles[id] ||
|
|
830
|
-
this.mergedStyles[id.replace('Background', '')],
|
|
831
|
-
hiddenShape,
|
|
832
|
-
animateConfig,
|
|
833
|
-
);
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
this.zoomCache.zoomLevel = currentLevel;
|
|
838
|
-
}
|
|
839
|
-
this.balanceShapeSize(shapeMap, zoom);
|
|
840
|
-
this.zoomCache.zoom = zoom;
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* Update the shapes' sizes e.g. labelShape, labelBackgroundShape, to keep the visual size while zooming.
|
|
845
|
-
* @param shapeMap
|
|
846
|
-
* @param zoom
|
|
847
|
-
* @returns
|
|
848
|
-
*/
|
|
849
|
-
private balanceShapeSize(
|
|
850
|
-
shapeMap: NodeShapeMap | ComboShapeMap,
|
|
851
|
-
zoom: number,
|
|
852
|
-
) {
|
|
853
|
-
if (!this.enableBalanceShape) return;
|
|
854
|
-
// balance the size for label, badges
|
|
855
|
-
const { keyShape, labelShape, labelBackgroundShape } = shapeMap;
|
|
856
|
-
const balanceRatio = 1 / zoom || 1;
|
|
857
|
-
this.zoomCache.balanceRatio = balanceRatio;
|
|
858
|
-
if (!labelShape || !labelShape.isVisible()) return;
|
|
859
|
-
const { position = 'bottom' } = this.mergedStyles.labelShape;
|
|
860
|
-
|
|
861
|
-
const keyShapeLocal = keyShape.getLocalBounds();
|
|
862
|
-
if (zoom < 1) {
|
|
863
|
-
// if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
|
|
864
|
-
if (position === 'bottom') labelShape.style.transformOrigin = '0';
|
|
865
|
-
else labelShape.style.transformOrigin = '';
|
|
866
|
-
} else {
|
|
867
|
-
switch (position) {
|
|
868
|
-
case 'bottom':
|
|
869
|
-
labelShape.style.transformOrigin = `0 ${
|
|
870
|
-
keyShapeLocal.max[1] - labelShape.attributes.y
|
|
871
|
-
}`;
|
|
872
|
-
break;
|
|
873
|
-
case 'right':
|
|
874
|
-
labelShape.style.transformOrigin = `${
|
|
875
|
-
keyShapeLocal.max[0] - labelShape.attributes.x
|
|
876
|
-
} 0`;
|
|
877
|
-
break;
|
|
878
|
-
case 'top':
|
|
879
|
-
labelShape.style.transformOrigin = `0 ${
|
|
880
|
-
keyShapeLocal.min[1] - labelShape.attributes.y
|
|
881
|
-
}`;
|
|
882
|
-
break;
|
|
883
|
-
case 'left':
|
|
884
|
-
labelShape.style.transformOrigin = `${
|
|
885
|
-
keyShapeLocal.min[0] - labelShape.attributes.x
|
|
886
|
-
} 0`;
|
|
887
|
-
break;
|
|
888
|
-
default:
|
|
889
|
-
// center
|
|
890
|
-
labelShape.style.transformOrigin = ``;
|
|
891
|
-
break;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
const oriTransform = (labelShape.style.transform || '').replace(
|
|
895
|
-
this.scaleTransformCache,
|
|
896
|
-
'',
|
|
897
|
-
);
|
|
898
|
-
const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
|
|
899
|
-
labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
|
|
900
|
-
this.scaleTransformCache = scaleTransform;
|
|
901
|
-
labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
|
|
902
|
-
|
|
903
|
-
if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
|
|
904
|
-
|
|
905
|
-
const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
|
|
906
|
-
.mergedStyles.labelBackgroundShape.padding as number[];
|
|
907
|
-
const sidePadding = paddingRight + paddingLeft;
|
|
908
|
-
const { width, height, x, y } = labelBackgroundShape.attributes;
|
|
909
|
-
|
|
910
|
-
switch (position) {
|
|
911
|
-
case 'top':
|
|
912
|
-
// if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
|
|
913
|
-
labelBackgroundShape.style.transformOrigin = `${
|
|
914
|
-
paddingLeft + (width - sidePadding) / 2
|
|
915
|
-
} ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
|
|
916
|
-
break;
|
|
917
|
-
case 'left':
|
|
918
|
-
labelBackgroundShape.style.transformOrigin = `${
|
|
919
|
-
zoom < 1 ? width - paddingRight : keyShapeLocal.min[0] - x
|
|
920
|
-
} ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
|
|
921
|
-
break;
|
|
922
|
-
case 'right':
|
|
923
|
-
labelBackgroundShape.style.transformOrigin = `${
|
|
924
|
-
zoom < 1 ? paddingLeft : keyShapeLocal.max[0] - x
|
|
925
|
-
} ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
|
|
926
|
-
break;
|
|
927
|
-
case 'bottom':
|
|
928
|
-
labelBackgroundShape.style.transformOrigin = `${
|
|
929
|
-
paddingLeft + (width - sidePadding) / 2
|
|
930
|
-
} ${
|
|
931
|
-
zoom < 1
|
|
932
|
-
? paddingTop + (height - paddingTop - paddingBottom) / 2
|
|
933
|
-
: keyShapeLocal.max[1] - y
|
|
934
|
-
}`;
|
|
935
|
-
break;
|
|
936
|
-
default:
|
|
937
|
-
// center
|
|
938
|
-
labelBackgroundShape.style.transformOrigin = `${
|
|
939
|
-
paddingLeft + (width - sidePadding) / 2
|
|
940
|
-
} ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
const labelBBox = labelShape.getGeometryBounds();
|
|
944
|
-
const labelWidth = labelBBox.max[0] - labelBBox.min[0];
|
|
945
|
-
const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
|
|
946
|
-
|
|
947
|
-
labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
|
|
948
|
-
}
|
|
753
|
+
) => {};
|
|
949
754
|
|
|
950
755
|
/**
|
|
951
756
|
* Create (if does not exit in shapeMap) or update the shape according to the configurations.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import { clone } from '@antv/util';
|
|
3
2
|
import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
|
|
4
3
|
import { IGraph } from '../../../types';
|
|
5
4
|
import { IG6GraphEvent } from '../../../types/event';
|
|
6
5
|
import { ShapeStyle } from '../../../types/item';
|
|
7
6
|
import { distance } from '../../../util/point';
|
|
7
|
+
import { cloneJSON } from '../../../util/data';
|
|
8
8
|
|
|
9
9
|
const DELTA = 0.01;
|
|
10
10
|
interface EdgeFilterLensConfig extends IPluginBaseConfig {
|
|
@@ -47,7 +47,7 @@ export class EdgeFilterLens extends Base {
|
|
|
47
47
|
showType: 'both',
|
|
48
48
|
trigger: 'mousemove',
|
|
49
49
|
r: 60,
|
|
50
|
-
delegateStyle:
|
|
50
|
+
delegateStyle: cloneJSON(lensDelegateStyle),
|
|
51
51
|
showLabel: 'edge',
|
|
52
52
|
scaleRBy: 'wheel',
|
|
53
53
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import {
|
|
2
|
+
import { throttle, uniqueId } from '@antv/util';
|
|
3
3
|
import { IGraph } from '../../../types';
|
|
4
4
|
import { Point } from '../../../types/common';
|
|
5
5
|
import { IG6GraphEvent } from '../../../types/event';
|
|
6
6
|
import { ShapeStyle } from '../../../types/item';
|
|
7
7
|
import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
|
|
8
|
+
import { cloneJSON } from '../../../util/data';
|
|
8
9
|
|
|
9
10
|
const DELTA = 0.05;
|
|
10
11
|
/**
|
|
@@ -92,7 +93,7 @@ export class Fisheye extends Base {
|
|
|
92
93
|
trigger: 'mousemove',
|
|
93
94
|
d: 1.5,
|
|
94
95
|
r: 300,
|
|
95
|
-
delegateStyle:
|
|
96
|
+
delegateStyle: cloneJSON(lensDelegateStyle),
|
|
96
97
|
showLabel: true,
|
|
97
98
|
maxD: 5,
|
|
98
99
|
minD: 0,
|
|
@@ -23,8 +23,8 @@ export class VisibilityUpdatedCommand implements Command {
|
|
|
23
23
|
graph.pauseStack();
|
|
24
24
|
each(values, (value) =>
|
|
25
25
|
value.visible
|
|
26
|
-
? graph.showItem(value.ids, this.disableAnimate)
|
|
27
|
-
: graph.hideItem(value.ids, this.disableAnimate),
|
|
26
|
+
? graph.showItem(value.ids, { disableAnimate: this.disableAnimate })
|
|
27
|
+
: graph.hideItem(value.ids, { disableAnimate: this.disableAnimate }),
|
|
28
28
|
);
|
|
29
29
|
graph.resumeStack();
|
|
30
30
|
}
|