@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
package/src/util/router.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from './bbox';
|
|
13
13
|
import { getLineIntersect } from './shape';
|
|
14
14
|
import { eulerDist, manhattanDist } from './math';
|
|
15
|
+
import { getNearestPoint } from './point';
|
|
15
16
|
|
|
16
17
|
export interface RouterCfg {
|
|
17
18
|
name: 'orth' | 'er';
|
|
@@ -43,13 +44,13 @@ export interface RouterCfg {
|
|
|
43
44
|
* Whether to automatically avoid other nodes (obstacles) on the path
|
|
44
45
|
* Defaults to false.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
enableObstacleAvoidance?: boolean;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
const defaultCfg: RouterCfg = {
|
|
50
51
|
name: 'orth',
|
|
51
|
-
|
|
52
|
-
offset:
|
|
52
|
+
enableObstacleAvoidance: false,
|
|
53
|
+
offset: 2,
|
|
53
54
|
maxAllowedDirectionChange: Math.PI / 2,
|
|
54
55
|
maximumLoops: 2000,
|
|
55
56
|
gridSize: 10,
|
|
@@ -307,11 +308,11 @@ const getControlPoints = (
|
|
|
307
308
|
cameFrom,
|
|
308
309
|
scaleStartPoint,
|
|
309
310
|
endPoint,
|
|
310
|
-
|
|
311
|
+
startPoints,
|
|
311
312
|
scaleEndPoint,
|
|
312
313
|
gridSize,
|
|
313
314
|
) => {
|
|
314
|
-
const controlPoints = [
|
|
315
|
+
const controlPoints = [];
|
|
315
316
|
let pointZero = endPoint;
|
|
316
317
|
let currentId = current.id;
|
|
317
318
|
let currentX = current.x;
|
|
@@ -321,13 +322,13 @@ const getControlPoints = (
|
|
|
321
322
|
y: currentY,
|
|
322
323
|
id: currentId,
|
|
323
324
|
};
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
325
|
+
// append endPoint
|
|
326
|
+
pointZero = {
|
|
327
|
+
x: scaleEndPoint.x === endPoint.x ? endPoint.x : lastPoint.x * gridSize,
|
|
328
|
+
y: scaleEndPoint.y === endPoint.y ? endPoint.y : lastPoint.y * gridSize,
|
|
329
|
+
};
|
|
330
|
+
controlPoints.unshift(pointZero);
|
|
331
|
+
|
|
331
332
|
let currentCameFrom = cameFrom[currentId];
|
|
332
333
|
while (currentCameFrom && currentCameFrom.id !== currentId) {
|
|
333
334
|
const point = {
|
|
@@ -360,11 +361,12 @@ const getControlPoints = (
|
|
|
360
361
|
currentCameFrom = cameFrom[currentId];
|
|
361
362
|
}
|
|
362
363
|
|
|
363
|
-
//
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
// append startPoint
|
|
365
|
+
const realStartPoints = startPoints.map((point) => ({
|
|
366
|
+
x: point.x * gridSize,
|
|
367
|
+
y: point.y * gridSize,
|
|
368
|
+
}));
|
|
369
|
+
const startPoint = getNearestPoint(realStartPoints, pointZero).nearestPoint;
|
|
368
370
|
controlPoints.unshift(startPoint);
|
|
369
371
|
return controlPoints;
|
|
370
372
|
};
|
|
@@ -391,7 +393,7 @@ export const pathFinder = (
|
|
|
391
393
|
|
|
392
394
|
const cfg: RouterCfg = deepMix(defaultCfgs, routerCfg);
|
|
393
395
|
|
|
394
|
-
if (!cfg.
|
|
396
|
+
if (!cfg.enableObstacleAvoidance) {
|
|
395
397
|
return cfg.fallbackRoute(startPoint, endPoint, startNode, endNode, cfg);
|
|
396
398
|
}
|
|
397
399
|
|
|
@@ -497,7 +499,7 @@ export const pathFinder = (
|
|
|
497
499
|
cameFrom,
|
|
498
500
|
scaleStartPoint,
|
|
499
501
|
endPoint,
|
|
500
|
-
|
|
502
|
+
startPoints,
|
|
501
503
|
scaleEndPoint,
|
|
502
504
|
gridSize,
|
|
503
505
|
);
|
package/src/util/shape.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
AABB,
|
|
15
15
|
Tuple3Number,
|
|
16
16
|
} from '@antv/g';
|
|
17
|
-
import {
|
|
17
|
+
import { isArray, isNumber } from '@antv/util';
|
|
18
18
|
import { DEFAULT_LABEL_BG_PADDING } from '../constant';
|
|
19
19
|
import { Padding, Point, StandardPadding } from '../types/common';
|
|
20
20
|
import { EdgeDisplayModel, EdgeShapeMap } from '../types/edge';
|
|
@@ -33,6 +33,7 @@ import Combo from '../item/combo';
|
|
|
33
33
|
import { getShapeAnimateBeginStyles } from './animate';
|
|
34
34
|
import { isArrayOverlap } from './array';
|
|
35
35
|
import { isBetween } from './math';
|
|
36
|
+
import { cloneJSON } from './data';
|
|
36
37
|
|
|
37
38
|
export const ShapeTagMap = {
|
|
38
39
|
circle: Circle,
|
|
@@ -116,9 +117,6 @@ export const upsertShape = (
|
|
|
116
117
|
const firstRendering = !shapeMap.keyShape;
|
|
117
118
|
const { animates, disableAnimate } = model?.data || {};
|
|
118
119
|
if (!shape) {
|
|
119
|
-
// create
|
|
120
|
-
shape = createShape(type, style, id);
|
|
121
|
-
if (style.interactive === false) shape.interactive = false;
|
|
122
120
|
// find the animate styles, set them to be INIT_SHAPE_STYLES
|
|
123
121
|
if (!disableAnimate && animates) {
|
|
124
122
|
const animateFields = findAnimateFields(
|
|
@@ -126,11 +124,15 @@ export const upsertShape = (
|
|
|
126
124
|
firstRendering ? 'buildIn' : 'update',
|
|
127
125
|
id,
|
|
128
126
|
);
|
|
127
|
+
shape = createShape(type, style, id);
|
|
129
128
|
const initShapeStyles = getShapeAnimateBeginStyles(shape);
|
|
130
129
|
animateFields.forEach((key) => {
|
|
131
130
|
shape.style[key] = initShapeStyles[key];
|
|
132
131
|
});
|
|
132
|
+
} else {
|
|
133
|
+
shape = createShape(type, style, id);
|
|
133
134
|
}
|
|
135
|
+
if (style.interactive === false) shape.interactive = false;
|
|
134
136
|
} else if (shape.nodeName !== type) {
|
|
135
137
|
// remove and create for the shape changed type
|
|
136
138
|
shape.remove();
|
|
@@ -191,6 +193,7 @@ export const updateShapes = (
|
|
|
191
193
|
prevShapeMap: { [id: string]: DisplayObject },
|
|
192
194
|
newShapeMap: { [id: string]: DisplayObject },
|
|
193
195
|
group: Group,
|
|
196
|
+
labelGroup: Group,
|
|
194
197
|
removeDiff = true,
|
|
195
198
|
shouldUpdate: (id: string) => boolean = () => true,
|
|
196
199
|
): NodeShapeMap | EdgeShapeMap => {
|
|
@@ -212,16 +215,27 @@ export const updateShapes = (
|
|
|
212
215
|
prevShape.remove();
|
|
213
216
|
}
|
|
214
217
|
finalShapeMap[id] = newShape;
|
|
218
|
+
const parentGroup =
|
|
219
|
+
newShape.attributes.dataIsLabel ||
|
|
220
|
+
newShape.attributes.dataIsLabelBackground
|
|
221
|
+
? labelGroup
|
|
222
|
+
: group;
|
|
215
223
|
if (
|
|
216
224
|
// NewShape is already in the group, no need to reappend.
|
|
217
225
|
// Note: If the given child is a reference to an existing node in the document,
|
|
218
226
|
// appendChild() moves it from its current position to the new position.
|
|
219
227
|
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
|
|
220
|
-
newShape.parentElement !==
|
|
228
|
+
newShape.parentElement !== parentGroup &&
|
|
221
229
|
!newShape.destroyed &&
|
|
222
230
|
newShape.style.display !== 'none'
|
|
223
231
|
) {
|
|
224
|
-
|
|
232
|
+
parentGroup.appendChild(newShape);
|
|
233
|
+
if (newShape.style.lod === 'auto') {
|
|
234
|
+
newShape.style.visibility = 'hidden';
|
|
235
|
+
if (newShape.id === 'labelShape' && parentGroup === labelGroup) {
|
|
236
|
+
labelGroup.attributes.visibility = 'hidden';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
225
239
|
}
|
|
226
240
|
}
|
|
227
241
|
|
|
@@ -268,7 +282,7 @@ export const formatPadding = (
|
|
|
268
282
|
* @returns
|
|
269
283
|
*/
|
|
270
284
|
export const mergeStyles = (styleMaps: ItemShapeStyles[]) => {
|
|
271
|
-
let currentResult =
|
|
285
|
+
let currentResult = cloneJSON(styleMaps[0]);
|
|
272
286
|
styleMaps.forEach((styleMap, i) => {
|
|
273
287
|
if (i > 0) currentResult = merge2Styles(currentResult, styleMap);
|
|
274
288
|
});
|
|
@@ -397,11 +411,12 @@ export const isPolygonsIntersect = (
|
|
|
397
411
|
};
|
|
398
412
|
|
|
399
413
|
export const intersectBBox = (box1: Partial<AABB>, box2: Partial<AABB>) => {
|
|
400
|
-
return
|
|
401
|
-
|
|
402
|
-
box2.
|
|
403
|
-
box2.
|
|
404
|
-
box2.
|
|
414
|
+
if (!box2?.min || !box1?.min) return false;
|
|
415
|
+
return (
|
|
416
|
+
box2.min[0] <= box1.max[0] &&
|
|
417
|
+
box2.max[0] >= box1.min[0] &&
|
|
418
|
+
box2.min[1] <= box1.max[1] &&
|
|
419
|
+
box2.max[1] >= box1.min[1]
|
|
405
420
|
);
|
|
406
421
|
};
|
|
407
422
|
|
package/src/util/zoom.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LodLevel, LodLevelRanges } from '../types/item';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Format
|
|
5
|
-
* @param
|
|
4
|
+
* Format lodLevels to the pattern that ratio 1 (primary level) at level 0, and higher the ratio, higher the level.
|
|
5
|
+
* @param lodLevels
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
):
|
|
11
|
-
if (!
|
|
12
|
-
const
|
|
13
|
-
if (!levels) return;
|
|
14
|
-
const primaryLevel = levels.find((level) => level.primary);
|
|
8
|
+
export const formatLodLevels = (
|
|
9
|
+
lodLevels?: LodLevel[],
|
|
10
|
+
): LodLevelRanges | undefined => {
|
|
11
|
+
if (!lodLevels?.length) return;
|
|
12
|
+
const primaryLevel = lodLevels.find((level) => level.primary);
|
|
15
13
|
if (!primaryLevel) return;
|
|
16
|
-
const primaryIndex =
|
|
14
|
+
const primaryIndex = lodLevels.indexOf(primaryLevel);
|
|
17
15
|
const formattedLevels = {};
|
|
18
|
-
|
|
16
|
+
lodLevels.forEach((level, i) => {
|
|
19
17
|
formattedLevels[i - primaryIndex] = level.zoomRange;
|
|
20
18
|
});
|
|
21
|
-
return
|
|
22
|
-
animateCfg,
|
|
23
|
-
levels: formattedLevels,
|
|
24
|
-
};
|
|
19
|
+
return formattedLevels;
|
|
25
20
|
};
|
|
26
21
|
|
|
27
22
|
/**
|
|
@@ -30,14 +25,13 @@ export const formatLodStrategy = (
|
|
|
30
25
|
* @param zoom
|
|
31
26
|
* @returns
|
|
32
27
|
*/
|
|
33
|
-
export const getZoomLevel = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let level = 0;
|
|
38
|
-
Object.keys(levels).forEach((idx) => {
|
|
28
|
+
export const getZoomLevel = (levels: LodLevelRanges, zoom: number) => {
|
|
29
|
+
const keys = Object.keys(levels);
|
|
30
|
+
for (let i = 0; i < keys.length; i++) {
|
|
31
|
+
const idx = keys[i];
|
|
39
32
|
const zoomRange = levels[idx];
|
|
40
|
-
if (zoom >= zoomRange[0] && zoom < zoomRange[1])
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
if (zoom >= zoomRange[0] && zoom < zoomRange[1]) {
|
|
34
|
+
return Number(idx);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
43
37
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"src/","sources":["runtime/controller/extension.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAI9B,YAAY,KAAuB;QAH5B,eAAU,GAAG,EAAE,CAAC;QAIrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,cAAc;IAChB,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtensionController = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Free extensions(plugins) controller
|
|
6
|
-
*/
|
|
7
|
-
class ExtensionController {
|
|
8
|
-
constructor(graph) {
|
|
9
|
-
this.extensions = {};
|
|
10
|
-
this.graph = graph;
|
|
11
|
-
// this.tap();
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.ExtensionController = ExtensionController;
|
|
15
|
-
//# sourceMappingURL=extension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"src/","sources":["runtime/controller/extension.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,mBAAmB;IAI9B,YAAY,KAAuB;QAH5B,eAAU,GAAG,EAAE,CAAC;QAIrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,cAAc;IAChB,CAAC;CACF;AARD,kDAQC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { IGraph } from '../../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Free extensions(plugins) controller
|
|
5
|
-
*/
|
|
6
|
-
export class ExtensionController {
|
|
7
|
-
public extensions = {};
|
|
8
|
-
public graph: IGraph;
|
|
9
|
-
|
|
10
|
-
constructor(graph: IGraph<any, any>) {
|
|
11
|
-
this.graph = graph;
|
|
12
|
-
// this.tap();
|
|
13
|
-
}
|
|
14
|
-
}
|