@antv/g6 5.0.0-beta.11 → 5.0.0-beta.13
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/api-doc/graph.d.ts +3 -3
- package/esm/api-doc/graph.js +3 -3
- package/esm/api-doc/graph.js.map +1 -1
- package/esm/constant/shape.d.ts +1 -1
- package/esm/index.d.ts +12 -62
- package/esm/index.js +4 -5
- package/esm/index.js.map +1 -1
- package/esm/item/item.js +2 -1
- package/esm/item/item.js.map +1 -1
- package/esm/runtime/controller/item.js +34 -16
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +1 -3
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.js +8 -3
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/graph.d.ts +1 -1
- package/esm/runtime/graph.js +11 -5
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/drag-canvas.js +12 -5
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/shortcuts-call.d.ts +2 -2
- package/esm/stdlib/behavior/shortcuts-call.js +12 -5
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -0
- package/esm/stdlib/behavior/zoom-canvas.js +8 -2
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/index.d.ts +6 -1
- package/esm/stdlib/index.js +8 -3
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.js +5 -1
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/esm/stdlib/item/edge/cubic.js +1 -1
- package/esm/stdlib/item/edge/cubic.js.map +1 -1
- package/esm/stdlib/item/edge/loop.js +1 -1
- package/esm/stdlib/item/edge/loop.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +1 -0
- package/esm/stdlib/item/node/base.js +5 -2
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/cube.d.ts +35 -0
- package/esm/stdlib/item/node/cube.js +54 -0
- package/esm/stdlib/item/node/cube.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +3 -0
- package/esm/stdlib/item/node/index.js +3 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/esm/stdlib/plugin/grid/index.d.ts +1 -1
- package/esm/stdlib/plugin/grid/index.js +3 -4
- package/esm/stdlib/plugin/grid/index.js.map +1 -1
- package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +2 -3
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/hull/util.d.ts +2 -2
- package/esm/stdlib/plugin/hull/util.js +6 -2
- package/esm/stdlib/plugin/hull/util.js.map +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/legend/index.d.ts +2 -2
- package/esm/stdlib/plugin/legend/index.js +3 -3
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/menu/index.d.ts +4 -4
- package/esm/stdlib/plugin/menu/index.js +3 -3
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +1 -1
- package/esm/stdlib/plugin/minimap/index.js +3 -3
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/timebar/index.js +2 -2
- package/esm/stdlib/plugin/timebar/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/esm/stdlib/plugin/toolbar/index.js +4 -4
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
- package/esm/stdlib/plugin/tooltip/index.js +3 -4
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +1 -0
- package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/esm/stdlib/plugin/watermaker/index.js +243 -0
- package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
- package/esm/types/index.d.ts +2 -1
- package/esm/types/index.js +1 -0
- package/esm/types/index.js.map +1 -1
- package/esm/types/plugin.d.ts +1 -1
- package/esm/util/bbox.js +4 -5
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/behavior.d.ts +2 -2
- package/esm/util/behavior.js +2 -2
- package/esm/util/behavior.js.map +1 -1
- package/esm/util/data.d.ts +2 -2
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.d.ts +15 -0
- package/esm/util/dom.js +29 -0
- package/esm/util/dom.js.map +1 -0
- package/esm/util/extend.d.ts +1 -1
- package/esm/util/extend.js +0 -1
- package/esm/util/extend.js.map +1 -1
- package/esm/util/index.d.ts +7 -52
- package/esm/util/index.js +7 -23
- package/esm/util/index.js.map +1 -1
- package/esm/util/layout.d.ts +1 -1
- package/esm/util/layout.js.map +1 -1
- package/esm/util/loop.d.ts +1 -1
- package/esm/util/math.d.ts +1 -1
- package/esm/util/matrix.d.ts +6 -0
- package/esm/util/matrix.js +48 -0
- package/esm/util/matrix.js.map +1 -0
- package/esm/util/path.js +1 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/point.d.ts +1 -1
- package/esm/util/polyline.d.ts +2 -1
- package/esm/util/polyline.js +2 -1
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/shape.js +12 -12
- package/esm/util/shape.js.map +1 -1
- package/esm/util/shape3d.js +15 -11
- package/esm/util/shape3d.js.map +1 -1
- package/esm/util/text.d.ts +1 -1
- package/esm/util/text.js +3 -2
- package/esm/util/text.js.map +1 -1
- package/lib/api-doc/graph.d.ts +3 -3
- package/lib/api-doc/graph.js +27 -7
- package/lib/api-doc/graph.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +12 -62
- package/lib/index.js +18 -10
- package/lib/index.js.map +1 -1
- package/lib/item/item.js +2 -1
- package/lib/item/item.js.map +1 -1
- package/lib/runtime/controller/item.js +34 -16
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +1 -3
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.js +8 -3
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/graph.d.ts +1 -1
- package/lib/runtime/graph.js +12 -5
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/drag-canvas.js +12 -5
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/shortcuts-call.d.ts +2 -2
- package/lib/stdlib/behavior/shortcuts-call.js +12 -5
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -0
- package/lib/stdlib/behavior/zoom-canvas.js +8 -2
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/index.d.ts +6 -1
- package/lib/stdlib/index.js +8 -3
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.js +5 -1
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/lib/stdlib/item/edge/cubic.js +2 -2
- package/lib/stdlib/item/edge/cubic.js.map +1 -1
- package/lib/stdlib/item/edge/loop.js +3 -3
- package/lib/stdlib/item/edge/loop.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +1 -0
- package/lib/stdlib/item/node/base.js +5 -2
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/cube.d.ts +35 -0
- package/lib/stdlib/item/node/cube.js +58 -0
- package/lib/stdlib/item/node/cube.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +3 -0
- package/lib/stdlib/item/node/index.js +3 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/lib/stdlib/plugin/grid/index.d.ts +1 -1
- package/lib/stdlib/plugin/grid/index.js +6 -7
- package/lib/stdlib/plugin/grid/index.js.map +1 -1
- package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +2 -3
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/hull/util.d.ts +2 -2
- package/lib/stdlib/plugin/hull/util.js +26 -22
- package/lib/stdlib/plugin/hull/util.js.map +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/legend/index.d.ts +2 -2
- package/lib/stdlib/plugin/legend/index.js +3 -3
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/menu/index.d.ts +4 -4
- package/lib/stdlib/plugin/menu/index.js +6 -6
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +1 -1
- package/lib/stdlib/plugin/minimap/index.js +6 -6
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/timebar/index.js +2 -2
- package/lib/stdlib/plugin/timebar/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/lib/stdlib/plugin/toolbar/index.js +5 -5
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
- package/lib/stdlib/plugin/tooltip/index.js +10 -11
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +1 -0
- package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/lib/stdlib/plugin/watermaker/index.js +247 -0
- package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +3 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/plugin.d.ts +1 -1
- package/lib/util/bbox.js +4 -5
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/behavior.d.ts +2 -2
- package/lib/util/behavior.js +2 -2
- package/lib/util/behavior.js.map +1 -1
- package/lib/util/data.d.ts +2 -2
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.d.ts +15 -0
- package/lib/util/dom.js +34 -0
- package/lib/util/dom.js.map +1 -0
- package/lib/util/extend.d.ts +1 -1
- package/lib/util/extend.js +0 -1
- package/lib/util/extend.js.map +1 -1
- package/lib/util/index.d.ts +7 -52
- package/lib/util/index.js +23 -23
- package/lib/util/index.js.map +1 -1
- package/lib/util/layout.d.ts +1 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/loop.d.ts +1 -1
- package/lib/util/math.d.ts +1 -1
- package/lib/util/matrix.d.ts +6 -0
- package/lib/util/matrix.js +52 -0
- package/lib/util/matrix.js.map +1 -0
- package/lib/util/path.js +2 -2
- package/lib/util/path.js.map +1 -1
- package/lib/util/point.d.ts +1 -1
- package/lib/util/polyline.d.ts +2 -1
- package/lib/util/polyline.js +2 -1
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/shape.js +12 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/shape3d.js +15 -11
- package/lib/util/shape3d.js.map +1 -1
- package/lib/util/text.d.ts +1 -1
- package/lib/util/text.js +3 -2
- package/lib/util/text.js.map +1 -1
- package/package.json +34 -41
- package/src/api-doc/graph.ts +4 -3
- package/src/constant/shape.ts +1 -1
- package/src/index.ts +5 -6
- package/src/item/item.ts +2 -0
- package/src/runtime/controller/item.ts +33 -14
- package/src/runtime/controller/layout.ts +1 -5
- package/src/runtime/controller/plugin.ts +14 -3
- package/src/runtime/graph.ts +12 -6
- package/src/stdlib/behavior/drag-canvas.ts +19 -7
- package/src/stdlib/behavior/shortcuts-call.ts +13 -4
- package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
- package/src/stdlib/behavior/zoom-canvas.ts +15 -2
- package/src/stdlib/index.ts +10 -1
- package/src/stdlib/item/edge/base.ts +5 -2
- package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
- package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
- package/src/stdlib/item/edge/cubic.ts +1 -1
- package/src/stdlib/item/edge/loop.ts +1 -1
- package/src/stdlib/item/node/base.ts +5 -1
- package/src/stdlib/item/node/cube.ts +102 -0
- package/src/stdlib/item/node/index.ts +3 -0
- package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
- package/src/stdlib/plugin/grid/index.ts +6 -6
- package/src/stdlib/plugin/hull/convexHull.ts +1 -1
- package/src/stdlib/plugin/hull/hullComponent.ts +2 -3
- package/src/stdlib/plugin/hull/util.ts +6 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/legend/index.ts +6 -6
- package/src/stdlib/plugin/menu/index.ts +13 -13
- package/src/stdlib/plugin/minimap/index.ts +6 -6
- package/src/stdlib/plugin/timebar/index.ts +4 -4
- package/src/stdlib/plugin/toolbar/index.ts +8 -8
- package/src/stdlib/plugin/tooltip/index.ts +10 -10
- package/src/stdlib/plugin/types.ts +1 -0
- package/src/stdlib/plugin/watermaker/index.ts +302 -0
- package/src/types/index.ts +2 -1
- package/src/types/plugin.ts +1 -1
- package/src/util/bbox.ts +4 -5
- package/src/util/behavior.ts +4 -4
- package/src/util/data.ts +2 -3
- package/src/util/dom.ts +33 -0
- package/src/util/extend.ts +2 -3
- package/src/util/index.ts +7 -24
- package/src/util/layout.ts +3 -2
- package/src/util/loop.ts +1 -1
- package/src/util/math.ts +1 -1
- package/src/util/matrix.ts +66 -0
- package/src/util/path.ts +1 -1
- package/src/util/point.ts +1 -1
- package/src/util/polyline.ts +2 -1
- package/src/util/router.ts +1 -1
- package/src/util/shape.ts +16 -12
- package/src/util/shape3d.ts +19 -10
- package/src/util/text.ts +3 -1
- package/esm/stdlib/plugin/map/index.d.ts +0 -118
- package/esm/stdlib/plugin/map/index.js +0 -683
- package/esm/stdlib/plugin/map/index.js.map +0 -1
- package/lib/stdlib/plugin/map/index.d.ts +0 -118
- package/lib/stdlib/plugin/map/index.js +0 -687
- package/lib/stdlib/plugin/map/index.js.map +0 -1
- package/src/stdlib/plugin/map/index.ts +0 -808
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { mat3 } from 'gl-matrix';
|
|
2
|
+
|
|
3
|
+
type mat3Type = [
|
|
4
|
+
number,
|
|
5
|
+
number,
|
|
6
|
+
number,
|
|
7
|
+
number,
|
|
8
|
+
number,
|
|
9
|
+
number,
|
|
10
|
+
number,
|
|
11
|
+
number,
|
|
12
|
+
number,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
function leftTranslate(out, a, v) {
|
|
16
|
+
const transMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
17
|
+
mat3.fromTranslation(transMat, v);
|
|
18
|
+
return mat3.multiply(out, transMat, a);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function leftRotate(out, a, rad) {
|
|
22
|
+
const rotateMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
23
|
+
mat3.fromRotation(rotateMat, rad);
|
|
24
|
+
return mat3.multiply(out, rotateMat, a);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function leftScale(out, a, v) {
|
|
28
|
+
const scaleMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
29
|
+
mat3.fromScaling(scaleMat, v);
|
|
30
|
+
return mat3.multiply(out, scaleMat, a);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function leftMultiply(out, a, a1) {
|
|
34
|
+
return mat3.multiply(out, a1, a);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 根据 actions 来做 transform
|
|
39
|
+
* @param m
|
|
40
|
+
* @param actions
|
|
41
|
+
*/
|
|
42
|
+
export function transform(m: number[], actions: any[][]) {
|
|
43
|
+
const matrix = m ? [].concat(m) : [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
44
|
+
|
|
45
|
+
for (let i = 0, len = actions.length; i < len; i++) {
|
|
46
|
+
const action = actions[i];
|
|
47
|
+
switch (action[0]) {
|
|
48
|
+
case 't':
|
|
49
|
+
leftTranslate(matrix, matrix, [action[1], action[2]]);
|
|
50
|
+
break;
|
|
51
|
+
case 's':
|
|
52
|
+
leftScale(matrix, matrix, [action[1], action[2]]);
|
|
53
|
+
break;
|
|
54
|
+
case 'r':
|
|
55
|
+
leftRotate(matrix, matrix, action[1]);
|
|
56
|
+
break;
|
|
57
|
+
case 'm':
|
|
58
|
+
leftMultiply(matrix, matrix, action[1]);
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return matrix;
|
|
66
|
+
}
|
package/src/util/path.ts
CHANGED
package/src/util/point.ts
CHANGED
package/src/util/polyline.ts
CHANGED
|
@@ -55,7 +55,8 @@ export const simplifyPolylinePoints = (points: PolyPoint[]): PolyPoint[] => {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Use the A* path-finding algorithm to obtain the shortest path.
|
|
58
|
+
* Use the A* path-finding algorithm to obtain the shortest path.
|
|
59
|
+
* Considering that there is no need to implement automatic obstacle avoidance, use waypoints to plan the path.
|
|
59
60
|
*/
|
|
60
61
|
export const simplePathFinder = (
|
|
61
62
|
start: PolyPoint,
|
package/src/util/router.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface RouterCfg {
|
|
|
24
24
|
/** Allowed edge directions */
|
|
25
25
|
directions?: any[];
|
|
26
26
|
/** Penalties */
|
|
27
|
-
penalties?:
|
|
27
|
+
penalties?: Record<string, any>;
|
|
28
28
|
/** Determine if use simple router for polyline when no obstacles */
|
|
29
29
|
simple?: boolean;
|
|
30
30
|
/** Function to calculate the distance between two points */
|
package/src/util/shape.ts
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
ItemShapeStyles,
|
|
25
25
|
ShapeStyle,
|
|
26
26
|
SHAPE_TYPE_3D,
|
|
27
|
-
ItemModel,
|
|
28
27
|
} from '../types/item';
|
|
29
28
|
import { NodeDisplayModel, NodeShapeMap } from '../types/node';
|
|
30
29
|
import { ComboDisplayModel, IGraph } from '../types';
|
|
@@ -212,22 +211,27 @@ export const updateShapes = (
|
|
|
212
211
|
const prevShape = prevShapeMap[id];
|
|
213
212
|
const newShape = newShapeMap[id];
|
|
214
213
|
if (newShape && !shouldUpdate(id)) return;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (prevShape !== newShape) {
|
|
214
|
+
|
|
215
|
+
if (newShape) {
|
|
216
|
+
// Remove dirty shape first.
|
|
217
|
+
if (prevShape && prevShape !== newShape) {
|
|
219
218
|
prevShape.remove();
|
|
220
219
|
}
|
|
221
|
-
if (!newShape.destroyed && newShape.style.display !== 'none') {
|
|
222
|
-
group.appendChild(newShape);
|
|
223
|
-
}
|
|
224
|
-
} else if (!prevShape && newShape) {
|
|
225
|
-
// add newShapeMap - prevShapeMap
|
|
226
220
|
finalShapeMap[id] = newShape;
|
|
227
|
-
if (
|
|
221
|
+
if (
|
|
222
|
+
// NewShape is already in the group, no need to reappend.
|
|
223
|
+
// Note: If the given child is a reference to an existing node in the document,
|
|
224
|
+
// appendChild() moves it from its current position to the new position.
|
|
225
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
|
|
226
|
+
newShape.parentElement !== group &&
|
|
227
|
+
!newShape.destroyed &&
|
|
228
|
+
newShape.style.display !== 'none'
|
|
229
|
+
) {
|
|
228
230
|
group.appendChild(newShape);
|
|
229
231
|
}
|
|
230
|
-
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (prevShape && !newShape && removeDiff) {
|
|
231
235
|
// remove prevShapeMap - newShapeMap
|
|
232
236
|
delete finalShapeMap[id];
|
|
233
237
|
prevShape.remove();
|
package/src/util/shape3d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
|
|
20
20
|
const GeometryTagMap = {
|
|
21
21
|
sphere: SphereGeometry,
|
|
22
|
-
|
|
22
|
+
cube: CubeGeometry,
|
|
23
23
|
plane: PlaneGeometry,
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -182,18 +182,27 @@ export const updateShapes3D = (
|
|
|
182
182
|
const prevShape = prevShapeMap[id];
|
|
183
183
|
const newShape = newShapeMap[id];
|
|
184
184
|
if (newShape && !shouldUpdate(id)) return;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (prevShape !== newShape) {
|
|
185
|
+
|
|
186
|
+
if (newShape) {
|
|
187
|
+
// Remove dirty shape first.
|
|
188
|
+
if (prevShape && prevShape !== newShape) {
|
|
189
189
|
prevShape.remove();
|
|
190
190
|
}
|
|
191
|
-
group.appendChild(newShape);
|
|
192
|
-
} else if (!prevShape && newShape) {
|
|
193
|
-
// add newShapeMap - prevShapeMap
|
|
194
191
|
finalShapeMap[id] = newShape;
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
if (
|
|
193
|
+
// NewShape is already in the group, no need to reappend.
|
|
194
|
+
// Note: If the given child is a reference to an existing node in the document,
|
|
195
|
+
// appendChild() moves it from its current position to the new position.
|
|
196
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
|
|
197
|
+
newShape.parentElement !== group &&
|
|
198
|
+
!newShape.destroyed &&
|
|
199
|
+
newShape.style.display !== 'none'
|
|
200
|
+
) {
|
|
201
|
+
group.appendChild(newShape);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (prevShape && !newShape && removeDiff) {
|
|
197
206
|
// remove prevShapeMap - newShapeMap
|
|
198
207
|
delete finalShapeMap[id];
|
|
199
208
|
prevShape.remove();
|
package/src/util/text.ts
CHANGED
|
@@ -13,8 +13,10 @@ export const getWordWrapWidthByBox = (
|
|
|
13
13
|
keyShapeBox: AABB,
|
|
14
14
|
maxWidth: string | number,
|
|
15
15
|
zoom = 1,
|
|
16
|
+
enableBalanceShape = false,
|
|
16
17
|
) => {
|
|
17
|
-
const
|
|
18
|
+
const balanceZoom = enableBalanceShape ? zoom : 1;
|
|
19
|
+
const keyShapeWidth = (keyShapeBox.max[0] - keyShapeBox.min[0]) * balanceZoom;
|
|
18
20
|
return getWordWrapWidthWithBase(keyShapeWidth, maxWidth);
|
|
19
21
|
};
|
|
20
22
|
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Canvas } from '@antv/g';
|
|
2
|
-
import { IGraph } from '../../../types';
|
|
3
|
-
import { ShapeStyle } from '../../../types/item';
|
|
4
|
-
import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
|
|
5
|
-
export interface MiniMapConfig extends IPluginBaseConfig {
|
|
6
|
-
/** Class name of viewport */
|
|
7
|
-
viewportClassName?: string;
|
|
8
|
-
/** Class name of minimap */
|
|
9
|
-
className?: string;
|
|
10
|
-
/** Mode of minimap */
|
|
11
|
-
mode?: 'default' | 'keyShape' | 'delegate';
|
|
12
|
-
/** Size of minimap */
|
|
13
|
-
size?: number[];
|
|
14
|
-
/** Style of delegate shape */
|
|
15
|
-
delegateStyle?: ShapeStyle;
|
|
16
|
-
/** Whether to refresh minimap */
|
|
17
|
-
refresh?: boolean;
|
|
18
|
-
/** Padding of minimap */
|
|
19
|
-
padding?: number;
|
|
20
|
-
/** Whether to hide edges on minimap to enhance performance */
|
|
21
|
-
hideEdge?: boolean;
|
|
22
|
-
/** Container for minimap */
|
|
23
|
-
container?: HTMLDivElement | null;
|
|
24
|
-
}
|
|
25
|
-
export declare class Minimap extends Base {
|
|
26
|
-
private canvas;
|
|
27
|
-
/** The viewport DOM on the minimap. */
|
|
28
|
-
private viewport;
|
|
29
|
-
/** Cache the mapping of graphics of nodes/edges/combos on main graph and minimap graph. */
|
|
30
|
-
private itemMap;
|
|
31
|
-
private container;
|
|
32
|
-
/** Ratio of (minimap graph size / main graph size). */
|
|
33
|
-
private ratio;
|
|
34
|
-
/** Distance from top of minimap graph to the top of minimap container. */
|
|
35
|
-
private dx;
|
|
36
|
-
/** Distance from left of minimap graph to the left of minimap container. */
|
|
37
|
-
private dy;
|
|
38
|
-
/** Cache the visibility while items' visibility changed. And apply them onto the minimap with debounce. */
|
|
39
|
-
private visibleCache;
|
|
40
|
-
constructor(options?: MiniMapConfig);
|
|
41
|
-
getDefaultCfgs(): MiniMapConfig;
|
|
42
|
-
getEvents(): {
|
|
43
|
-
afteritemstatechange: () => void;
|
|
44
|
-
afterlayout: () => void;
|
|
45
|
-
viewportchange: () => void;
|
|
46
|
-
afteritemchange: () => void;
|
|
47
|
-
afteritemvisibilitychange: (params: any) => void;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* If it is animating, disable refresh.
|
|
51
|
-
*/
|
|
52
|
-
protected disableRefresh(): void;
|
|
53
|
-
protected enableRefresh(): void;
|
|
54
|
-
private initViewport;
|
|
55
|
-
/**
|
|
56
|
-
* Update the viewport DOM.
|
|
57
|
-
*/
|
|
58
|
-
private updateViewport;
|
|
59
|
-
/**
|
|
60
|
-
* Clone all the graphic from main graph to the minimap graph.
|
|
61
|
-
*/
|
|
62
|
-
private updateGraphShapes;
|
|
63
|
-
/**
|
|
64
|
-
* Only draw keyShapes on the minimap.
|
|
65
|
-
*/
|
|
66
|
-
private updateKeyShapes;
|
|
67
|
-
/**
|
|
68
|
-
* Add or update keyShape of one node.
|
|
69
|
-
* @param nodeModel node data model
|
|
70
|
-
* @param group container graphics group on minimap
|
|
71
|
-
*/
|
|
72
|
-
private updateOneNodeKeyShape;
|
|
73
|
-
/**
|
|
74
|
-
* Draw the delegate rects for nodes and line edges on minimap.
|
|
75
|
-
*/
|
|
76
|
-
private updateDelegateShapes;
|
|
77
|
-
private clearDestroyedShapes;
|
|
78
|
-
/**
|
|
79
|
-
* Add or update keyShape of one edge.
|
|
80
|
-
* @param edgeModel edge data model
|
|
81
|
-
* @param group container graphics group on minimap
|
|
82
|
-
*/
|
|
83
|
-
private updateOneEdgeKeyShape;
|
|
84
|
-
/**
|
|
85
|
-
* Add or update delegate rect of one node.
|
|
86
|
-
* @param nodeModel node data model
|
|
87
|
-
* @param group container graphics group on minimap
|
|
88
|
-
*/
|
|
89
|
-
private updateOneNodeDelegateShape;
|
|
90
|
-
/**
|
|
91
|
-
* Listener for main graph updating, update the viewport DOM.
|
|
92
|
-
*/
|
|
93
|
-
private handleUpdateCanvas;
|
|
94
|
-
private handleVisibilityChange;
|
|
95
|
-
private debounceCloneVisibility;
|
|
96
|
-
init(graph: IGraph): void;
|
|
97
|
-
/**
|
|
98
|
-
* Init the DOM container for minimap.
|
|
99
|
-
*/
|
|
100
|
-
initContainer(): Promise<any>;
|
|
101
|
-
updateCanvas(): void;
|
|
102
|
-
/**
|
|
103
|
-
* Get the canvas of the minimap.
|
|
104
|
-
* @return {Canvas} G Canvas
|
|
105
|
-
*/
|
|
106
|
-
getCanvas(): Canvas;
|
|
107
|
-
/**
|
|
108
|
-
* Get the viewport DOM of the minimap.
|
|
109
|
-
* @return {HTMLElement} viewport DOM
|
|
110
|
-
*/
|
|
111
|
-
getViewport(): HTMLElement;
|
|
112
|
-
/**
|
|
113
|
-
* Get the container DOM of the minimap.
|
|
114
|
-
* @return {HTMLElement} container DOM
|
|
115
|
-
*/
|
|
116
|
-
getContainer(): HTMLElement;
|
|
117
|
-
destroy(): void;
|
|
118
|
-
}
|