@antv/g6 5.0.0-beta.1 → 5.0.0-beta.10
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 +4 -1
- package/esm/constant/shape.js.map +1 -1
- package/esm/index.d.ts +22 -7
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +16 -9
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +20 -3
- package/esm/item/edge.js +99 -43
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +21 -11
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +2 -1
- package/esm/item/node.js +33 -16
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +7 -10
- package/esm/runtime/controller/data.js +125 -281
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +267 -151
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/graph.d.ts +103 -23
- package/esm/runtime/graph.js +460 -88
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.d.ts +9 -9
- package/esm/stdlib/behavior/activate-relations.js +8 -8
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.js +1 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +1 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +207 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/drag-canvas.js +59 -28
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +43 -32
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +76 -63
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +3 -0
- package/esm/stdlib/behavior/index.js +3 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +1 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/esm/stdlib/behavior/shortcuts-call.js +80 -0
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/zoom-canvas.js +55 -24
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/transformV4Data.d.ts +2 -2
- package/esm/stdlib/data/transformV4Data.js +2 -2
- package/esm/stdlib/data/transformV4Data.js.map +1 -1
- package/esm/stdlib/data/validateData.d.ts +2 -2
- package/esm/stdlib/data/validateData.js +9 -9
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +16 -6
- package/esm/stdlib/index.js +20 -10
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +10 -1
- package/esm/stdlib/item/edge/base.js +20 -13
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/line.js +5 -2
- package/esm/stdlib/item/edge/line.js.map +1 -1
- package/esm/stdlib/item/edge/polyline.d.ts +3 -2
- package/esm/stdlib/item/edge/polyline.js +3 -3
- package/esm/stdlib/item/edge/polyline.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +1 -1
- package/esm/stdlib/item/node/base.js +18 -26
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +1 -0
- package/esm/stdlib/item/node/base3d.js +1 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/diamond.js +1 -1
- package/esm/stdlib/item/node/ellipse.js +2 -2
- package/esm/stdlib/item/node/hexagon.js +12 -5
- package/esm/stdlib/item/node/hexagon.js.map +1 -1
- package/esm/stdlib/item/node/image.d.ts +40 -0
- package/esm/stdlib/item/node/image.js +110 -0
- package/esm/stdlib/item/node/image.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/history/combo-command.js +2 -2
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
- package/esm/stdlib/plugin/history/index.d.ts +10 -10
- package/esm/stdlib/plugin/history/index.js +14 -14
- package/esm/stdlib/plugin/history/index.js.map +1 -1
- package/esm/stdlib/plugin/history/item-data-command.js +25 -16
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.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/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +2 -0
- package/esm/stdlib/plugin/index.js +2 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/legend/index.js +1 -1
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/map/index.d.ts +118 -0
- package/esm/stdlib/plugin/map/index.js +683 -0
- package/esm/stdlib/plugin/map/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
- package/esm/stdlib/plugin/minimap/index.js +116 -9
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
- package/esm/stdlib/plugin/snapline/index.js +1063 -0
- package/esm/stdlib/plugin/snapline/index.js.map +1 -0
- package/esm/stdlib/plugin/timebar/index.d.ts +98 -0
- package/esm/stdlib/plugin/timebar/index.js +303 -0
- package/esm/stdlib/plugin/timebar/index.js.map +1 -0
- package/esm/stdlib/plugin/toolbar/index.js +1 -1
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +2 -0
- package/esm/stdlib/theme/dark.js +42 -2
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +4 -4
- package/esm/types/common.d.ts +1 -0
- package/esm/types/event.d.ts +1 -0
- package/esm/types/graph.d.ts +48 -22
- package/esm/types/hook.d.ts +22 -2
- package/esm/types/item.d.ts +6 -0
- package/esm/types/item.js.map +1 -1
- package/esm/types/spec.d.ts +19 -3
- package/esm/types/view.d.ts +5 -0
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +29 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/canvas.d.ts +2 -2
- package/esm/util/canvas.js +5 -11
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/event.d.ts +3 -1
- package/esm/util/event.js +8 -1
- package/esm/util/event.js.map +1 -1
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/layout.d.ts +11 -0
- package/esm/util/layout.js +45 -0
- package/esm/util/layout.js.map +1 -1
- package/esm/util/point.js +9 -2
- package/esm/util/point.js.map +1 -1
- package/esm/util/router.d.ts +4 -3
- package/esm/util/router.js +8 -5
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +3 -3
- package/esm/util/shape.js +8 -12
- package/esm/util/shape.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/constant/shape.d.ts +4 -1
- package/lib/constant/shape.js.map +1 -1
- package/lib/index.d.ts +22 -7
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +16 -9
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +20 -3
- package/lib/item/edge.js +98 -42
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +21 -11
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +2 -1
- package/lib/item/node.js +33 -16
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +7 -10
- package/lib/runtime/controller/data.js +125 -281
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +266 -150
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/graph.d.ts +103 -23
- package/lib/runtime/graph.js +460 -88
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.d.ts +9 -9
- package/lib/stdlib/behavior/activate-relations.js +8 -8
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.js +1 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +1 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +211 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/drag-canvas.js +59 -28
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +43 -32
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +76 -63
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +3 -0
- package/lib/stdlib/behavior/index.js +3 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +1 -2
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/lib/stdlib/behavior/shortcuts-call.js +84 -0
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/zoom-canvas.js +55 -24
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/transformV4Data.d.ts +2 -2
- package/lib/stdlib/data/transformV4Data.js +2 -2
- package/lib/stdlib/data/transformV4Data.js.map +1 -1
- package/lib/stdlib/data/validateData.d.ts +2 -2
- package/lib/stdlib/data/validateData.js +9 -9
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +16 -6
- package/lib/stdlib/index.js +20 -10
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +10 -1
- package/lib/stdlib/item/edge/base.js +20 -13
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/line.js +5 -2
- package/lib/stdlib/item/edge/line.js.map +1 -1
- package/lib/stdlib/item/edge/polyline.d.ts +3 -2
- package/lib/stdlib/item/edge/polyline.js +3 -3
- package/lib/stdlib/item/edge/polyline.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +1 -1
- package/lib/stdlib/item/node/base.js +18 -26
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +1 -0
- package/lib/stdlib/item/node/base3d.js +1 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/diamond.js +1 -1
- package/lib/stdlib/item/node/ellipse.js +2 -2
- package/lib/stdlib/item/node/hexagon.js +12 -5
- package/lib/stdlib/item/node/hexagon.js.map +1 -1
- package/lib/stdlib/item/node/image.d.ts +40 -0
- package/lib/stdlib/item/node/image.js +114 -0
- package/lib/stdlib/item/node/image.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/history/combo-command.js +2 -2
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
- package/lib/stdlib/plugin/history/index.d.ts +10 -10
- package/lib/stdlib/plugin/history/index.js +14 -14
- package/lib/stdlib/plugin/history/index.js.map +1 -1
- package/lib/stdlib/plugin/history/item-data-command.js +25 -16
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.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/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +2 -0
- package/lib/stdlib/plugin/index.js +2 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/legend/index.js +1 -1
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/map/index.d.ts +118 -0
- package/lib/stdlib/plugin/map/index.js +687 -0
- package/lib/stdlib/plugin/map/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
- package/lib/stdlib/plugin/minimap/index.js +116 -9
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
- package/lib/stdlib/plugin/snapline/index.js +1067 -0
- package/lib/stdlib/plugin/snapline/index.js.map +1 -0
- package/lib/stdlib/plugin/timebar/index.d.ts +98 -0
- package/lib/stdlib/plugin/timebar/index.js +307 -0
- package/lib/stdlib/plugin/timebar/index.js.map +1 -0
- package/lib/stdlib/plugin/toolbar/index.js +1 -1
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +2 -0
- package/lib/stdlib/theme/dark.js +42 -2
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +4 -4
- package/lib/types/common.d.ts +1 -0
- package/lib/types/event.d.ts +1 -0
- package/lib/types/graph.d.ts +48 -22
- package/lib/types/hook.d.ts +22 -2
- package/lib/types/item.d.ts +6 -0
- package/lib/types/item.js.map +1 -1
- package/lib/types/spec.d.ts +19 -3
- package/lib/types/view.d.ts +5 -0
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +32 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/canvas.d.ts +2 -2
- package/lib/util/canvas.js +5 -11
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/event.d.ts +3 -1
- package/lib/util/event.js +8 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/layout.d.ts +11 -0
- package/lib/util/layout.js +47 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/point.js +9 -2
- package/lib/util/point.js.map +1 -1
- package/lib/util/router.d.ts +4 -3
- package/lib/util/router.js +8 -5
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +3 -3
- package/lib/util/shape.js +8 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +10 -10
- package/src/constant/shape.ts +2 -1
- package/src/index.ts +4 -2
- package/src/item/combo.ts +14 -9
- package/src/item/edge.ts +131 -57
- package/src/item/item.ts +24 -15
- package/src/item/node.ts +38 -24
- package/src/runtime/controller/data.ts +140 -339
- package/src/runtime/controller/item.ts +236 -72
- package/src/runtime/graph.ts +592 -96
- package/src/stdlib/behavior/activate-relations.ts +8 -8
- package/src/stdlib/behavior/brush-select.ts +4 -2
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/create-edge.ts +296 -0
- package/src/stdlib/behavior/drag-canvas.ts +78 -29
- package/src/stdlib/behavior/drag-combo.ts +10 -10
- package/src/stdlib/behavior/drag-node.ts +18 -18
- package/src/stdlib/behavior/index.ts +3 -0
- package/src/stdlib/behavior/lasso-select.ts +5 -3
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/shortcuts-call.ts +120 -0
- package/src/stdlib/behavior/zoom-canvas.ts +72 -25
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/transformV4Data.ts +2 -2
- package/src/stdlib/data/validateData.ts +9 -9
- package/src/stdlib/index.ts +33 -9
- package/src/stdlib/item/edge/base.ts +26 -13
- package/src/stdlib/item/edge/line.ts +8 -2
- package/src/stdlib/item/edge/polyline.ts +7 -5
- package/src/stdlib/item/node/base.ts +24 -29
- package/src/stdlib/item/node/base3d.ts +1 -0
- package/src/stdlib/item/node/diamond.ts +1 -1
- package/src/stdlib/item/node/ellipse.ts +2 -2
- package/src/stdlib/item/node/hexagon.ts +14 -6
- package/src/stdlib/item/node/image.ts +190 -0
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/plugin/history/combo-command.ts +2 -2
- package/src/stdlib/plugin/history/index.ts +14 -14
- package/src/stdlib/plugin/history/item-data-command.ts +35 -17
- package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
- package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
- package/src/stdlib/plugin/index.ts +2 -0
- package/src/stdlib/plugin/legend/index.ts +1 -1
- package/src/stdlib/plugin/map/index.ts +808 -0
- package/src/stdlib/plugin/minimap/index.ts +120 -10
- package/src/stdlib/plugin/snapline/index.ts +1297 -0
- package/src/stdlib/plugin/timebar/index.ts +473 -0
- package/src/stdlib/plugin/toolbar/index.ts +1 -1
- package/src/stdlib/plugin/types.ts +2 -0
- package/src/stdlib/theme/dark.ts +66 -2
- package/src/stdlib/theme/light.ts +4 -4
- package/src/types/common.ts +1 -0
- package/src/types/event.ts +1 -0
- package/src/types/graph.ts +59 -25
- package/src/types/hook.ts +22 -2
- package/src/types/item.ts +10 -0
- package/src/types/spec.ts +22 -3
- package/src/types/view.ts +8 -3
- package/src/util/bbox.ts +38 -1
- package/src/util/canvas.ts +5 -5
- package/src/util/event.ts +14 -1
- package/src/util/item.ts +65 -28
- package/src/util/layout.ts +45 -0
- package/src/util/point.ts +8 -3
- package/src/util/router.ts +15 -6
- package/src/util/shape.ts +16 -14
- package/src/util/warn.ts +20 -0
- package/src/api-doc/readme.md +0 -59
package/src/types/graph.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
|
-
import { AABB, Canvas, DisplayObject, PointLike } from '@antv/g';
|
|
2
|
+
import { AABB, Canvas, Cursor, DisplayObject, PointLike } from '@antv/g';
|
|
3
3
|
import { ID } from '@antv/graphlib';
|
|
4
4
|
import { Command } from '../stdlib/plugin/history/command';
|
|
5
5
|
import { Hooks } from '../types/hook';
|
|
6
6
|
import { CameraAnimationOptions } from './animate';
|
|
7
7
|
import { BehaviorOptionsOf, BehaviorRegistry } from './behavior';
|
|
8
|
-
import {
|
|
8
|
+
import { ComboModel, ComboUserModel } from './combo';
|
|
9
9
|
import { Padding, Point } from './common';
|
|
10
10
|
import { GraphData } from './data';
|
|
11
|
-
import {
|
|
11
|
+
import { EdgeModel, EdgeUserModel } from './edge';
|
|
12
12
|
import type { StackType } from './history';
|
|
13
|
-
import { ITEM_TYPE, SHAPE_TYPE } from './item';
|
|
13
|
+
import { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from './item';
|
|
14
14
|
import { LayoutOptions } from './layout';
|
|
15
|
-
import {
|
|
15
|
+
import { NodeModel, NodeUserModel } from './node';
|
|
16
16
|
import { RendererName } from './render';
|
|
17
|
-
import { Specification } from './spec';
|
|
17
|
+
import { ComboMapper, EdgeMapper, NodeMapper, Specification } from './spec';
|
|
18
18
|
import { ThemeOptionsOf, ThemeRegistry } from './theme';
|
|
19
19
|
import { FitViewRules, GraphTransformOptions } from './view';
|
|
20
20
|
|
|
@@ -36,7 +36,7 @@ export interface IGraph<
|
|
|
36
36
|
* @returns
|
|
37
37
|
* @group Graph Instance
|
|
38
38
|
*/
|
|
39
|
-
destroy: (callback?:
|
|
39
|
+
destroy: (callback?: () => void) => void;
|
|
40
40
|
/**
|
|
41
41
|
* Update the specs (configurations).
|
|
42
42
|
*/
|
|
@@ -45,6 +45,12 @@ export interface IGraph<
|
|
|
45
45
|
* Update the theme specs (configurations).
|
|
46
46
|
*/
|
|
47
47
|
updateTheme: (theme: ThemeOptionsOf<T>) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Update the item display mapper for a specific item type.
|
|
50
|
+
* @param {ITEM_TYPE} type - The type of item (node, edge, or combo).
|
|
51
|
+
* @param {NodeMapper | EdgeMapper | ComboMapper} mapper - The mapper to be updated.
|
|
52
|
+
* */
|
|
53
|
+
updateMapper(type: ITEM_TYPE, mapper: NodeMapper | EdgeMapper | ComboMapper);
|
|
48
54
|
/**
|
|
49
55
|
* Get the copy of specs(configurations).
|
|
50
56
|
* @returns graph specs
|
|
@@ -389,8 +395,8 @@ export interface IGraph<
|
|
|
389
395
|
*/
|
|
390
396
|
fitView: (
|
|
391
397
|
options?: {
|
|
392
|
-
padding
|
|
393
|
-
rules
|
|
398
|
+
padding?: Padding;
|
|
399
|
+
rules?: FitViewRules;
|
|
394
400
|
},
|
|
395
401
|
effectTiming?: CameraAnimationOptions,
|
|
396
402
|
) => Promise<void>;
|
|
@@ -400,7 +406,10 @@ export interface IGraph<
|
|
|
400
406
|
* @returns
|
|
401
407
|
* @group View
|
|
402
408
|
*/
|
|
403
|
-
fitCenter: (
|
|
409
|
+
fitCenter: (
|
|
410
|
+
boundsType?: 'render' | 'layout',
|
|
411
|
+
effectTiming?: CameraAnimationOptions,
|
|
412
|
+
) => Promise<void>;
|
|
404
413
|
/**
|
|
405
414
|
* Move the graph to make the item align the view center.
|
|
406
415
|
* @param item node/edge/combo item or its id
|
|
@@ -470,7 +479,11 @@ export interface IGraph<
|
|
|
470
479
|
* @returns
|
|
471
480
|
* @group Item
|
|
472
481
|
*/
|
|
473
|
-
hideItem: (
|
|
482
|
+
hideItem: (
|
|
483
|
+
ids: ID | ID[],
|
|
484
|
+
disableAnimate?: boolean,
|
|
485
|
+
keepKeyShape?: boolean,
|
|
486
|
+
) => void;
|
|
474
487
|
/**
|
|
475
488
|
* Make the item(s) to the front.
|
|
476
489
|
* @param ids the item id(s) to front
|
|
@@ -591,6 +604,11 @@ export interface IGraph<
|
|
|
591
604
|
* @group Interaction
|
|
592
605
|
*/
|
|
593
606
|
getMode: () => string;
|
|
607
|
+
/**
|
|
608
|
+
* Set the cursor. But the cursor in item's style has higher priority.
|
|
609
|
+
* @param cursor
|
|
610
|
+
*/
|
|
611
|
+
setCursor: (cursor: Cursor) => void;
|
|
594
612
|
/**
|
|
595
613
|
* Add behavior(s) to mode(s).
|
|
596
614
|
* @param behaviors behavior names or configs
|
|
@@ -628,7 +646,22 @@ export interface IGraph<
|
|
|
628
646
|
drawTransient: (
|
|
629
647
|
type: ITEM_TYPE | SHAPE_TYPE,
|
|
630
648
|
id: ID,
|
|
631
|
-
config:
|
|
649
|
+
config: {
|
|
650
|
+
action?: 'remove' | 'add' | 'update' | undefined;
|
|
651
|
+
/** Data to be merged into the transient item. */
|
|
652
|
+
data?: Record<string, any>;
|
|
653
|
+
/** Style to be merged into the transient shape. */
|
|
654
|
+
style?: ShapeStyle;
|
|
655
|
+
/** For type: 'edge' */
|
|
656
|
+
drawSource?: boolean;
|
|
657
|
+
/** For type: 'edge' */
|
|
658
|
+
drawTarget?: boolean;
|
|
659
|
+
/** Only shape with id in shapeIds will be cloned while type is ITEM_TYPE. If shapeIds is not assigned, the whole item will be cloned. */
|
|
660
|
+
shapeIds?: string[];
|
|
661
|
+
/** Whether show the shapes in shapeIds. True by default. */
|
|
662
|
+
visible?: boolean;
|
|
663
|
+
upsertAncestors?: boolean;
|
|
664
|
+
},
|
|
632
665
|
canvas?: Canvas,
|
|
633
666
|
) => DisplayObject;
|
|
634
667
|
|
|
@@ -682,16 +715,16 @@ export interface IGraph<
|
|
|
682
715
|
/**
|
|
683
716
|
* Pause stacking operation.
|
|
684
717
|
*/
|
|
685
|
-
|
|
718
|
+
pauseStack: () => void;
|
|
686
719
|
/**
|
|
687
720
|
* Resume stacking operation.
|
|
688
721
|
*/
|
|
689
|
-
|
|
722
|
+
resumeStack: () => void;
|
|
690
723
|
/**
|
|
691
724
|
* Execute a callback without allowing any stacking operations.
|
|
692
725
|
* @param callback
|
|
693
726
|
*/
|
|
694
|
-
|
|
727
|
+
executeWithNoStack: (callback: () => void) => void;
|
|
695
728
|
/**
|
|
696
729
|
* Retrieve the current redo stack which consists of operations that could be undone
|
|
697
730
|
*/
|
|
@@ -731,33 +764,34 @@ export interface IGraph<
|
|
|
731
764
|
canRedo: () => void;
|
|
732
765
|
|
|
733
766
|
/**
|
|
734
|
-
* Begin a
|
|
735
|
-
* Any operations performed between `
|
|
767
|
+
* Begin a historyBatch operation.
|
|
768
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
736
769
|
* treated as a single operation when undoing or redoing.
|
|
737
770
|
*/
|
|
738
|
-
|
|
771
|
+
startHistoryBatch: () => void;
|
|
739
772
|
|
|
740
773
|
/**
|
|
741
|
-
* End a
|
|
742
|
-
* Any operations performed between `
|
|
774
|
+
* End a historyBatch operation.
|
|
775
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
743
776
|
* treated as a single operation when undoing or redoing.
|
|
744
777
|
*/
|
|
745
|
-
|
|
778
|
+
stopHistoryBatch: () => void;
|
|
746
779
|
|
|
747
780
|
/**
|
|
748
781
|
* Execute a provided function within a batched context
|
|
749
782
|
* All operations performed inside callback will be treated as a composite operation
|
|
750
|
-
* more convenient way without manually invoking `
|
|
783
|
+
* more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
|
|
751
784
|
* @param callback The func containing operations to be batched together.
|
|
752
785
|
*/
|
|
753
|
-
|
|
786
|
+
historyBatch: (callback: () => void) => void;
|
|
787
|
+
|
|
754
788
|
/**
|
|
755
789
|
* Execute a provided function within a batched context
|
|
756
790
|
* All operations performed inside callback will be treated as a composite operation
|
|
757
|
-
* more convenient way without manually invoking `
|
|
791
|
+
* more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
|
|
758
792
|
* @param callback The func containing operations to be batched together.
|
|
759
793
|
*/
|
|
760
|
-
|
|
794
|
+
cleanHistory: (stackType?: StackType) => void;
|
|
761
795
|
// ===== tree operations =====
|
|
762
796
|
/**
|
|
763
797
|
* Collapse sub tree(s).
|
package/src/types/hook.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { ThemeSpecification } from './theme';
|
|
|
11
11
|
import { GraphTransformOptions } from './view';
|
|
12
12
|
import { ComboModel } from './combo';
|
|
13
13
|
import { Plugin as PluginBase } from './plugin';
|
|
14
|
+
import { ComboMapper, EdgeMapper, NodeMapper } from './spec';
|
|
14
15
|
|
|
15
16
|
export interface IHook<T> {
|
|
16
17
|
name: string;
|
|
@@ -24,6 +25,7 @@ export interface IHook<T> {
|
|
|
24
25
|
export type ViewportChangeHookParams = {
|
|
25
26
|
transform: GraphTransformOptions;
|
|
26
27
|
effectTiming?: Partial<CameraAnimationOptions>;
|
|
28
|
+
tileLodSize?: number;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export interface Hooks {
|
|
@@ -53,6 +55,10 @@ export interface Hooks {
|
|
|
53
55
|
graphCore: GraphCore;
|
|
54
56
|
theme: ThemeSpecification;
|
|
55
57
|
transientCanvas: Canvas;
|
|
58
|
+
tileOptimize?: {
|
|
59
|
+
tileFirstRender?: boolean | number;
|
|
60
|
+
tileFirstRenderSize?: number;
|
|
61
|
+
};
|
|
56
62
|
}>; // TODO: define param template
|
|
57
63
|
layout: IHook<{
|
|
58
64
|
graphCore: GraphCore;
|
|
@@ -82,6 +88,7 @@ export interface Hooks {
|
|
|
82
88
|
action?: string;
|
|
83
89
|
enableStack?: boolean;
|
|
84
90
|
changes?: any;
|
|
91
|
+
keepKeyShape?: boolean;
|
|
85
92
|
}>;
|
|
86
93
|
itemzindexchange: IHook<{
|
|
87
94
|
ids: ID[];
|
|
@@ -95,8 +102,17 @@ export interface Hooks {
|
|
|
95
102
|
id: ID;
|
|
96
103
|
canvas: Canvas;
|
|
97
104
|
config: {
|
|
98
|
-
style
|
|
99
|
-
action
|
|
105
|
+
style?: ShapeStyle;
|
|
106
|
+
action?: 'remove' | 'add' | 'update';
|
|
107
|
+
/** For type: 'edge' */
|
|
108
|
+
drawSource?: boolean;
|
|
109
|
+
/** For type: 'edge' */
|
|
110
|
+
drawTarget?: boolean;
|
|
111
|
+
/** Only shape with id in shapeIds will be cloned while type is ITEM_TYPE. If shapeIds is not assigned, the whole item will be cloned. */
|
|
112
|
+
shapeIds?: string[];
|
|
113
|
+
/** Whether show the shapes in shapeIds. True by default. */
|
|
114
|
+
visible?: boolean;
|
|
115
|
+
upsertAncestors?: boolean;
|
|
100
116
|
};
|
|
101
117
|
graphCore: GraphCore;
|
|
102
118
|
}>;
|
|
@@ -118,6 +134,10 @@ export interface Hooks {
|
|
|
118
134
|
transient: Canvas;
|
|
119
135
|
};
|
|
120
136
|
}>;
|
|
137
|
+
mapperchange: IHook<{
|
|
138
|
+
type: ITEM_TYPE;
|
|
139
|
+
mapper: NodeMapper | EdgeMapper | ComboMapper;
|
|
140
|
+
}>;
|
|
121
141
|
treecollapseexpand: IHook<{
|
|
122
142
|
ids: ID[];
|
|
123
143
|
action: 'collapse' | 'expand';
|
package/src/types/item.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Group,
|
|
14
14
|
DisplayObject,
|
|
15
15
|
IAnimation,
|
|
16
|
+
Shape,
|
|
16
17
|
} from '@antv/g';
|
|
17
18
|
import {
|
|
18
19
|
CubeGeometryProps,
|
|
@@ -61,11 +62,20 @@ export type GShapeStyle = CircleStyleProps &
|
|
|
61
62
|
interactive?: boolean;
|
|
62
63
|
};
|
|
63
64
|
|
|
65
|
+
export type ClipCfg = {
|
|
66
|
+
type: SHAPE_TYPE;
|
|
67
|
+
show: boolean;
|
|
68
|
+
} & CircleStyleProps &
|
|
69
|
+
RectStyleProps &
|
|
70
|
+
EllipseStyleProps;
|
|
71
|
+
|
|
64
72
|
export type ShapeStyle = Partial<
|
|
65
73
|
GShapeStyle & {
|
|
66
74
|
animates?: IAnimates;
|
|
67
75
|
lod?: number;
|
|
68
76
|
visible?: boolean;
|
|
77
|
+
} & {
|
|
78
|
+
clipCfg?: ClipCfg;
|
|
69
79
|
}
|
|
70
80
|
>;
|
|
71
81
|
export interface Encode<T> {
|
package/src/types/spec.ts
CHANGED
|
@@ -29,6 +29,12 @@ import { RendererName } from './render';
|
|
|
29
29
|
import { StackCfg } from './history';
|
|
30
30
|
import { Plugin } from './plugin';
|
|
31
31
|
|
|
32
|
+
export type NodeMapper = ((data: NodeModel) => NodeDisplayModel) | NodeEncode;
|
|
33
|
+
export type EdgeMapper = ((data: EdgeModel) => EdgeDisplayModel) | EdgeEncode;
|
|
34
|
+
export type ComboMapper =
|
|
35
|
+
| ((data: ComboModel) => ComboDisplayModel)
|
|
36
|
+
| ComboEncode;
|
|
37
|
+
|
|
32
38
|
export interface Specification<
|
|
33
39
|
B extends BehaviorRegistry,
|
|
34
40
|
T extends ThemeRegistry,
|
|
@@ -47,6 +53,19 @@ export interface Specification<
|
|
|
47
53
|
headless: boolean;
|
|
48
54
|
};
|
|
49
55
|
zoom?: number;
|
|
56
|
+
/** Global optimize configuration. */
|
|
57
|
+
optimize?: {
|
|
58
|
+
/** Whether enable tile rendering for first time. */
|
|
59
|
+
tileFirstRender?: boolean | number;
|
|
60
|
+
/** Tile size for first rendering. */
|
|
61
|
+
tileFirstRenderSize?: number;
|
|
62
|
+
/** Whether enable tile hiding / showing for behaivors, e.g. hiding shapes while drag-canvas, zoom-canvas. The enableOptimize in behavior configuration has higher priority. */
|
|
63
|
+
tileBehavior?: boolean | number;
|
|
64
|
+
/** Tile size for shape optimizing by behaviors, e.g. hiding shapes while drag-canvas, zoom-canvas. The enableOptimize in behavior configuration has higher priority. */
|
|
65
|
+
tileBehaviorSize?: number;
|
|
66
|
+
/** Tile size for level of detial changing. */
|
|
67
|
+
tileLodSize?: number;
|
|
68
|
+
};
|
|
50
69
|
autoFit?:
|
|
51
70
|
| 'view'
|
|
52
71
|
| 'center'
|
|
@@ -79,9 +98,9 @@ export interface Specification<
|
|
|
79
98
|
| TransformerFn[];
|
|
80
99
|
|
|
81
100
|
/** item */
|
|
82
|
-
node?:
|
|
83
|
-
edge?:
|
|
84
|
-
combo?:
|
|
101
|
+
node?: NodeMapper;
|
|
102
|
+
edge?: EdgeMapper;
|
|
103
|
+
combo?: ComboMapper;
|
|
85
104
|
|
|
86
105
|
/** item state styles */
|
|
87
106
|
nodeState?: {
|
package/src/types/view.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export interface FitViewRules {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/** Whehter fit it only when the graph is out of the view. */
|
|
3
|
+
onlyOutOfViewPort?: boolean;
|
|
4
|
+
/** Axis to fit. */
|
|
5
|
+
direction?: 'x' | 'y' | 'both';
|
|
6
|
+
/** Ratio rule to fit. */
|
|
7
|
+
ratioRule?: 'max' | 'min';
|
|
8
|
+
/** Bounds type. 'render' means calculate the bounds by get rendering bounds. 'layout' for the situation that layout algorithm is done but the positions are not animated rendered. */
|
|
9
|
+
boundsType?: 'render' | 'layout';
|
|
5
10
|
}
|
|
6
11
|
|
|
7
12
|
export type GraphAlignment =
|
package/src/util/bbox.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable prefer-spread */
|
|
2
2
|
import { AABB } from '@antv/g';
|
|
3
|
-
import { PolyPoint } from 'types/common';
|
|
3
|
+
import { Point, PolyPoint } from 'types/common';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Retrieve the width of a bounding box
|
|
@@ -296,3 +296,40 @@ export const isSegmentCrossingBBox = (
|
|
|
296
296
|
}
|
|
297
297
|
return false;
|
|
298
298
|
};
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
Determines whether a given point is inside a given bounding box.
|
|
302
|
+
@param {Point} point - The point to be checked.
|
|
303
|
+
@param {AABB} bbox - The bounding box.
|
|
304
|
+
@returns {boolean} - Returns true if the point is inside the bounding box, false otherwise.
|
|
305
|
+
*/
|
|
306
|
+
export const isPointInBBox = (point: Point, bbox: AABB) => {
|
|
307
|
+
const { x, y } = point;
|
|
308
|
+
return (
|
|
309
|
+
x > bbox.min[0] && x < bbox.max[0] && y > bbox.min[1] && y < bbox.max[1]
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
Determines whether a given sub-bounding box is fully contained within a given bounding box.
|
|
315
|
+
@param {AABB} subBBox - The sub-bounding box to be checked.
|
|
316
|
+
@param {AABB} bbox - The bounding box.
|
|
317
|
+
@param {number} [scale] - Optional scaling factor to adjust the size of the bounding box.
|
|
318
|
+
@returns {boolean} - Returns true if the sub-bounding box is fully contained within the bounding box, false otherwise.
|
|
319
|
+
*/
|
|
320
|
+
export const isBBoxInBBox = (subBBox: AABB, bbox: AABB, scale?: number) => {
|
|
321
|
+
if (scale) {
|
|
322
|
+
return (
|
|
323
|
+
subBBox.min[0] > bbox.min[0] - bbox.halfExtents[0] * scale &&
|
|
324
|
+
subBBox.max[0] < bbox.max[0] + bbox.halfExtents[0] * scale &&
|
|
325
|
+
subBBox.min[1] > bbox.min[1] - bbox.halfExtents[1] * scale &&
|
|
326
|
+
subBBox.max[1] < bbox.max[1] + bbox.halfExtents[1] * scale
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return (
|
|
330
|
+
subBBox.min[0] > bbox.min[0] &&
|
|
331
|
+
subBBox.max[0] < bbox.max[0] &&
|
|
332
|
+
subBBox.min[1] > bbox.min[1] &&
|
|
333
|
+
subBBox.max[1] < bbox.max[1]
|
|
334
|
+
);
|
|
335
|
+
};
|
package/src/util/canvas.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Canvas } from '@antv/g';
|
|
1
|
+
import { Canvas, CanvasConfig } from '@antv/g';
|
|
2
2
|
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
3
|
-
import { Renderer as SVGRenderer } from '@antv/g-svg';
|
|
4
|
-
import { Renderer as WebGLRenderer } from '@antv/g-webgl';
|
|
5
3
|
import { Plugin as Plugin3D } from '@antv/g-plugin-3d';
|
|
6
4
|
import { Plugin as DragNDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
5
|
+
import { Renderer as SVGRenderer } from '@antv/g-svg';
|
|
6
|
+
import { Renderer as WebGLRenderer } from '@antv/g-webgl';
|
|
7
7
|
import { RendererName } from '../types/render';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -21,7 +21,7 @@ export const createCanvas = (
|
|
|
21
21
|
width: number,
|
|
22
22
|
height: number,
|
|
23
23
|
pixelRatio?: number,
|
|
24
|
-
|
|
24
|
+
canvasConfig: Partial<CanvasConfig> = {},
|
|
25
25
|
): Canvas => {
|
|
26
26
|
let renderer: any;
|
|
27
27
|
switch (rendererType.toLowerCase()) {
|
|
@@ -53,7 +53,7 @@ export const createCanvas = (
|
|
|
53
53
|
devicePixelRatio: pixelRatio,
|
|
54
54
|
renderer,
|
|
55
55
|
supportsMutipleCanvasesInOneContainer: true,
|
|
56
|
-
|
|
56
|
+
...canvasConfig,
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
|
package/src/util/event.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
NodeDataUpdated,
|
|
10
10
|
NodeRemoved,
|
|
11
11
|
TreeStructureChanged,
|
|
12
|
+
TreeStructureAttached,
|
|
13
|
+
TreeStructureDetached,
|
|
12
14
|
} from '@antv/graphlib';
|
|
13
15
|
import { IG6GraphEvent, IGraph, NodeModelData } from '../types';
|
|
14
16
|
import { GraphCore } from '../types/data';
|
|
@@ -84,6 +86,8 @@ export type GroupedChanges = {
|
|
|
84
86
|
EdgeDataUpdated: EdgeDataUpdated<EdgeModelData>[];
|
|
85
87
|
TreeStructureChanged: TreeStructureChanged[];
|
|
86
88
|
ComboStructureChanged: TreeStructureChanged[];
|
|
89
|
+
TreeStructureAttached: TreeStructureAttached[];
|
|
90
|
+
TreeStructureDetached: TreeStructureDetached[];
|
|
87
91
|
};
|
|
88
92
|
|
|
89
93
|
/**
|
|
@@ -106,6 +110,8 @@ export const getGroupedChanges = (
|
|
|
106
110
|
EdgeDataUpdated: [],
|
|
107
111
|
TreeStructureChanged: [],
|
|
108
112
|
ComboStructureChanged: [],
|
|
113
|
+
TreeStructureAttached: [],
|
|
114
|
+
TreeStructureDetached: [],
|
|
109
115
|
};
|
|
110
116
|
changes.forEach((change) => {
|
|
111
117
|
const { type: changeType } = change;
|
|
@@ -126,7 +132,14 @@ export const getGroupedChanges = (
|
|
|
126
132
|
else if (change.treeKey === 'tree')
|
|
127
133
|
groupedChanges.TreeStructureChanged.push(change);
|
|
128
134
|
return;
|
|
129
|
-
} else if (
|
|
135
|
+
} else if (
|
|
136
|
+
[
|
|
137
|
+
'NodeRemoved',
|
|
138
|
+
'EdgeRemoved',
|
|
139
|
+
'TreeStructureAttached',
|
|
140
|
+
'TreeStructureDetached',
|
|
141
|
+
].includes(changeType)
|
|
142
|
+
) {
|
|
130
143
|
groupedChanges[changeType].push(change);
|
|
131
144
|
} else {
|
|
132
145
|
const { id: oid } = change.value;
|
package/src/util/item.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ID } from '@antv/graphlib';
|
|
2
2
|
import { Group } from '@antv/g';
|
|
3
|
+
import { uniqueId } from '@antv/util';
|
|
3
4
|
import { IGraph } from '../types';
|
|
4
5
|
import Combo from '../item/combo';
|
|
5
6
|
import Edge from '../item/edge';
|
|
@@ -34,43 +35,62 @@ export const upsertTransientItem = (
|
|
|
34
35
|
transientItemMap: Map<ID, Node | Edge | Combo | Group>,
|
|
35
36
|
itemMap: Map<ID, Node | Edge | Combo>,
|
|
36
37
|
graphCore?: GraphCore,
|
|
37
|
-
|
|
38
|
+
drawOptions: {
|
|
39
|
+
shapeIds?: string[];
|
|
40
|
+
/** For transient edge */
|
|
41
|
+
drawSource?: boolean;
|
|
42
|
+
/** For transient edge */
|
|
43
|
+
drawTarget?: boolean;
|
|
44
|
+
visible?: boolean;
|
|
45
|
+
} = {},
|
|
38
46
|
upsertAncestors = true,
|
|
39
47
|
) => {
|
|
40
48
|
let transientItem = transientItemMap.get(item.model.id);
|
|
41
49
|
if (transientItem) {
|
|
42
50
|
return transientItem;
|
|
43
51
|
}
|
|
52
|
+
const {
|
|
53
|
+
shapeIds,
|
|
54
|
+
drawSource = true,
|
|
55
|
+
drawTarget = true,
|
|
56
|
+
visible = true,
|
|
57
|
+
} = drawOptions;
|
|
44
58
|
if (item.type === 'node') {
|
|
45
|
-
transientItem = item.clone(nodeGroup,
|
|
59
|
+
transientItem = item.clone(nodeGroup, shapeIds, true);
|
|
46
60
|
} else if (item.type === 'edge') {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
let source;
|
|
62
|
+
let target;
|
|
63
|
+
if (drawSource) {
|
|
64
|
+
source = upsertTransientItem(
|
|
65
|
+
item.sourceItem,
|
|
66
|
+
nodeGroup,
|
|
67
|
+
edgeGroup,
|
|
68
|
+
comboGroup,
|
|
69
|
+
transientItemMap,
|
|
70
|
+
itemMap,
|
|
71
|
+
graphCore,
|
|
72
|
+
drawOptions,
|
|
73
|
+
false,
|
|
74
|
+
) as Node | Combo;
|
|
75
|
+
}
|
|
76
|
+
if (drawTarget) {
|
|
77
|
+
target = upsertTransientItem(
|
|
78
|
+
item.targetItem,
|
|
79
|
+
nodeGroup,
|
|
80
|
+
edgeGroup,
|
|
81
|
+
comboGroup,
|
|
82
|
+
transientItemMap,
|
|
83
|
+
itemMap,
|
|
84
|
+
graphCore,
|
|
85
|
+
drawOptions,
|
|
86
|
+
false,
|
|
87
|
+
) as Node | Combo;
|
|
88
|
+
}
|
|
69
89
|
transientItem = item.clone(
|
|
70
90
|
edgeGroup,
|
|
71
91
|
source,
|
|
72
92
|
target,
|
|
73
|
-
|
|
93
|
+
shapeIds,
|
|
74
94
|
true,
|
|
75
95
|
) as Edge;
|
|
76
96
|
} else {
|
|
@@ -89,7 +109,7 @@ export const upsertTransientItem = (
|
|
|
89
109
|
transientItemMap,
|
|
90
110
|
itemMap,
|
|
91
111
|
graphCore,
|
|
92
|
-
|
|
112
|
+
drawOptions,
|
|
93
113
|
false,
|
|
94
114
|
),
|
|
95
115
|
);
|
|
@@ -97,7 +117,7 @@ export const upsertTransientItem = (
|
|
|
97
117
|
});
|
|
98
118
|
transientItem = (item as Combo).clone(
|
|
99
119
|
comboGroup,
|
|
100
|
-
|
|
120
|
+
shapeIds,
|
|
101
121
|
true,
|
|
102
122
|
() => getCombinedBoundsByItem(childItems), // getCombinedBounds
|
|
103
123
|
() => childItems,
|
|
@@ -105,6 +125,7 @@ export const upsertTransientItem = (
|
|
|
105
125
|
transientItem.toBack();
|
|
106
126
|
}
|
|
107
127
|
transientItemMap.set(item.model.id, transientItem);
|
|
128
|
+
// @ts-ignore
|
|
108
129
|
transientItem.transient = true;
|
|
109
130
|
|
|
110
131
|
if (
|
|
@@ -125,12 +146,28 @@ export const upsertTransientItem = (
|
|
|
125
146
|
transientItemMap,
|
|
126
147
|
itemMap,
|
|
127
148
|
graphCore,
|
|
128
|
-
|
|
149
|
+
drawOptions,
|
|
129
150
|
);
|
|
130
151
|
transientAncestor.toBack();
|
|
131
152
|
}
|
|
132
153
|
currentAncestor = graphCore.getParent(currentAncestor.id, 'combo');
|
|
133
154
|
}
|
|
134
155
|
}
|
|
156
|
+
|
|
157
|
+
if (shapeIds?.length && visible) {
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
(transientItem as Group).childNodes.forEach((shape) => shape.show());
|
|
160
|
+
}
|
|
135
161
|
return transientItem;
|
|
136
162
|
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* generate unique edge id
|
|
166
|
+
* @todo consider edges with same source and target
|
|
167
|
+
* @param source
|
|
168
|
+
* @param target
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
export function generateEdgeID(source: ID, target: ID) {
|
|
172
|
+
return [source, uniqueId(), target].join('->');
|
|
173
|
+
}
|
package/src/util/layout.ts
CHANGED
|
@@ -163,3 +163,48 @@ export const radialLayout = (
|
|
|
163
163
|
});
|
|
164
164
|
return;
|
|
165
165
|
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get the layout (nodes' positions) bounds of a graph.
|
|
169
|
+
* @param {Graph} graph - The graph object.
|
|
170
|
+
* @returns {Object} - The layout bounds object containing the minimum, maximum, center, and halfExtents values.
|
|
171
|
+
*/
|
|
172
|
+
export const getLayoutBounds = (graph) => {
|
|
173
|
+
const min = [Infinity, Infinity];
|
|
174
|
+
const max = [-Infinity, -Infinity];
|
|
175
|
+
const borderIds = { min: [], max: [] };
|
|
176
|
+
graph.getAllNodesData().forEach((model) => {
|
|
177
|
+
const { x, y } = model.data;
|
|
178
|
+
if (isNaN(x) || isNaN(y)) return;
|
|
179
|
+
if (min[0] > x) {
|
|
180
|
+
min[0] = x;
|
|
181
|
+
borderIds.min[0] = model.id;
|
|
182
|
+
}
|
|
183
|
+
if (min[1] > y) {
|
|
184
|
+
min[1] = y;
|
|
185
|
+
borderIds.min[1] = model.id;
|
|
186
|
+
}
|
|
187
|
+
if (max[0] < x) {
|
|
188
|
+
max[0] = x;
|
|
189
|
+
borderIds.max[0] = model.id;
|
|
190
|
+
}
|
|
191
|
+
if (max[1] < y) {
|
|
192
|
+
max[1] = y;
|
|
193
|
+
borderIds.max[1] = model.id;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
borderIds.min.forEach((id, i) => {
|
|
197
|
+
const { halfExtents: nodeHalfSize } = graph.getRenderBBox(id);
|
|
198
|
+
min[i] -= nodeHalfSize[i];
|
|
199
|
+
});
|
|
200
|
+
borderIds.max.forEach((id, i) => {
|
|
201
|
+
const { halfExtents: nodeHalfSize } = graph.getRenderBBox(id);
|
|
202
|
+
max[i] += nodeHalfSize[i];
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
min,
|
|
206
|
+
max,
|
|
207
|
+
center: min.map((val, i) => (max[i] + val) / 2),
|
|
208
|
+
halfExtents: min.map((val, i) => (max[i] - val) / 2),
|
|
209
|
+
};
|
|
210
|
+
};
|
package/src/util/point.ts
CHANGED
|
@@ -52,7 +52,10 @@ export const distanceVec = (p1: vec2, p2: vec2): number => {
|
|
|
52
52
|
export const distance = (p1: Point, p2: Point): number => {
|
|
53
53
|
const vx = p1.x - p2.x;
|
|
54
54
|
const vy = p1.y - p2.y;
|
|
55
|
-
|
|
55
|
+
const vz = p1.z - p2.z;
|
|
56
|
+
return isNaN(vz)
|
|
57
|
+
? Math.sqrt(vx * vx + vy * vy)
|
|
58
|
+
: Math.sqrt(vx * vx + vy * vy + vz * vz);
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
/**
|
|
@@ -61,8 +64,10 @@ export const distance = (p1: Point, p2: Point): number => {
|
|
|
61
64
|
* @param p2
|
|
62
65
|
* @returns
|
|
63
66
|
*/
|
|
64
|
-
export const isSamePoint = (p1: Point, p2: Point): boolean =>
|
|
65
|
-
|
|
67
|
+
export const isSamePoint = (p1: Point, p2: Point): boolean => {
|
|
68
|
+
if (!p1 || !p2) return false;
|
|
69
|
+
return p1.x === p2.x && p1.y === p2.y && p1.z === p2.z;
|
|
70
|
+
};
|
|
66
71
|
|
|
67
72
|
/**
|
|
68
73
|
* Get point and circle intersect point.
|