@antv/g6 5.0.0-beta.1 → 5.0.0-beta.11
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 +32 -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 +32 -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 +37 -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/lib/util/warn.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.warn = void 0;
|
|
4
|
+
function warn({ optionName, shouldBe, now, scope }) {
|
|
5
|
+
console.warn(`G6 [${scope}]: Invalid option, ${optionName} must be one of ${shouldBe.join(', ')}, but got ${now}`);
|
|
6
|
+
}
|
|
7
|
+
exports.warn = warn;
|
|
8
|
+
//# sourceMappingURL=warn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn.js","sourceRoot":"src/","sources":["util/warn.ts"],"names":[],"mappings":";;;AAaA,SAAgB,IAAI,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAc;IACnE,OAAO,CAAC,IAAI,CACV,OAAO,KAAK,sBAAsB,UAAU,mBAAmB,QAAQ,CAAC,IAAI,CAC1E,IAAI,CACL,aAAa,GAAG,EAAE,CACpB,CAAC;AACJ,CAAC;AAND,oBAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g6",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.11",
|
|
4
4
|
"description": "A Graph Visualization Framework in JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
"@antv/g-plugin-control": "^1.7.43",
|
|
70
70
|
"@antv/g-plugin-dragndrop": "^1.8.1",
|
|
71
71
|
"@antv/g-svg": "^1.8.36",
|
|
72
|
-
"@antv/g-webgl": "^1.9.
|
|
72
|
+
"@antv/g-webgl": "^1.9.19",
|
|
73
73
|
"@antv/graphlib": "^2.0.2",
|
|
74
|
-
"@antv/gui": "
|
|
75
|
-
"@antv/layout": "^1.2.9",
|
|
74
|
+
"@antv/gui": "0.5.1-alpha.1",
|
|
76
75
|
"@antv/hierarchy": "latest",
|
|
76
|
+
"@antv/layout": "^1.2.9",
|
|
77
77
|
"@antv/layout-gpu": "^1.1.5",
|
|
78
78
|
"@antv/layout-wasm": "1.3.1",
|
|
79
79
|
"@antv/matrix-util": "^3.0.4",
|
|
80
|
-
"@antv/util": "~2.0.5",
|
|
81
80
|
"@antv/path-util": "3.0.1",
|
|
81
|
+
"@antv/util": "~2.0.5",
|
|
82
82
|
"color": "^4.2.3",
|
|
83
83
|
"insert-css": "^2.0.0",
|
|
84
84
|
"stats-js": "^1.0.1",
|
|
@@ -95,13 +95,13 @@
|
|
|
95
95
|
"@types/pixelmatch": "^5.2.4",
|
|
96
96
|
"@types/pngjs": "^6.0.1",
|
|
97
97
|
"@types/xmlserializer": "^0.6.3",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
99
|
-
"@typescript-eslint/parser": "^
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
99
|
+
"@typescript-eslint/parser": "^6.5.0",
|
|
100
100
|
"@umijs/fabric": "^2.0.0",
|
|
101
101
|
"babel-loader": "^8.0.6",
|
|
102
102
|
"canvas": "2.11.0",
|
|
103
|
-
"eslint": "^
|
|
104
|
-
"eslint-plugin-import": "^2.
|
|
103
|
+
"eslint": "^8.48.0",
|
|
104
|
+
"eslint-plugin-import": "^2.28.1",
|
|
105
105
|
"father": "^2.29.1",
|
|
106
106
|
"gl": "^6.0.2",
|
|
107
107
|
"jest": "^28.1.3",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"npm-run-all": "^4.1.5",
|
|
114
114
|
"pixelmatch": "5.3.0",
|
|
115
115
|
"pngjs": "^6.0.0",
|
|
116
|
-
"prettier": "^
|
|
116
|
+
"prettier": "^3.0.3",
|
|
117
117
|
"rimraf": "^3.0.0",
|
|
118
118
|
"rollup": "^2.79.1",
|
|
119
119
|
"rollup-plugin-node-resolve": "^5.2.0",
|
package/src/constant/shape.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StandardPadding } from 'types/common';
|
|
1
2
|
import { ShapeStyle } from '../types/item';
|
|
2
3
|
|
|
3
4
|
export const RESERVED_SHAPE_IDS = [
|
|
@@ -12,7 +13,7 @@ export const RESERVED_SHAPE_IDS = [
|
|
|
12
13
|
];
|
|
13
14
|
export const OTHER_SHAPES_FIELD_NAME = 'otherShapes';
|
|
14
15
|
|
|
15
|
-
export const DEFAULT_LABEL_BG_PADDING = [4, 4, 4, 4];
|
|
16
|
+
export const DEFAULT_LABEL_BG_PADDING: StandardPadding = [4, 4, 4, 4];
|
|
16
17
|
/** Default shape style to avoid shape value missing */
|
|
17
18
|
export const DEFAULT_SHAPE_STYLE = {
|
|
18
19
|
opacity: 1,
|
package/src/index.ts
CHANGED
|
@@ -14,10 +14,12 @@ runtime.enableCSSParsing = false;
|
|
|
14
14
|
* Extend the graph class with std lib
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
const version = '5.0.0-beta.11';
|
|
18
|
+
|
|
17
19
|
const Graph = extend(EmptyGraph, stdLib);
|
|
18
20
|
|
|
19
|
-
const G6 = { Graph, Util, stdLib, Extensions, extend };
|
|
21
|
+
const G6 = { Graph, Util, stdLib, Extensions, extend, version };
|
|
20
22
|
|
|
21
|
-
export { Extensions, Graph, Util, extend, stdLib };
|
|
23
|
+
export { Extensions, Graph, Util, extend, stdLib, version };
|
|
22
24
|
|
|
23
25
|
export default G6;
|
package/src/item/combo.ts
CHANGED
|
@@ -264,7 +264,7 @@ export default class Combo extends Node {
|
|
|
264
264
|
// @ts-ignore
|
|
265
265
|
public clone(
|
|
266
266
|
containerGroup: Group,
|
|
267
|
-
|
|
267
|
+
shapeIds?: string[],
|
|
268
268
|
disableAnimate?: boolean,
|
|
269
269
|
getCombinedBounds?: () =>
|
|
270
270
|
| {
|
|
@@ -276,14 +276,19 @@ export default class Combo extends Node {
|
|
|
276
276
|
| false,
|
|
277
277
|
getChildren?: () => (Node | Combo)[],
|
|
278
278
|
) {
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
279
|
+
if (shapeIds?.length) {
|
|
280
|
+
const group = new Group();
|
|
281
|
+
shapeIds.forEach((shapeId) => {
|
|
282
|
+
if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
|
|
283
|
+
const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
|
|
284
|
+
// TODO: other animating attributes?
|
|
285
|
+
clonedKeyShape.style.opacity =
|
|
286
|
+
this.renderExt.mergedStyles[shapeId]?.opacity || 1;
|
|
287
|
+
group.appendChild(clonedKeyShape);
|
|
288
|
+
});
|
|
289
|
+
group.setPosition(this.group.getPosition());
|
|
290
|
+
containerGroup.appendChild(group);
|
|
291
|
+
return group;
|
|
287
292
|
}
|
|
288
293
|
const clonedModel = clone(this.model);
|
|
289
294
|
clonedModel.data.disableAnimate = disableAnimate;
|
package/src/item/edge.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Circle, Group } from '@antv/g';
|
|
2
2
|
import { clone, throttle } from '@antv/util';
|
|
3
|
-
import { EdgeDisplayModel, EdgeModel, ID } from '../types';
|
|
3
|
+
import { EdgeDisplayModel, EdgeModel, ID, Point } from '../types';
|
|
4
4
|
import { EdgeModelData } from '../types/edge';
|
|
5
5
|
import { DisplayMapper, State, LodStrategyObj } from '../types/item';
|
|
6
6
|
import { updateShapes } from '../util/shape';
|
|
@@ -28,6 +28,7 @@ interface IProps {
|
|
|
28
28
|
};
|
|
29
29
|
onframe?: Function;
|
|
30
30
|
nodeMap?: Map<ID, Node>;
|
|
31
|
+
delayFirstDraw?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export default class Edge extends Item {
|
|
@@ -37,11 +38,20 @@ export default class Edge extends Item {
|
|
|
37
38
|
// display data model
|
|
38
39
|
public displayModel: EdgeDisplayModel;
|
|
39
40
|
/** Set to different value in implements */
|
|
40
|
-
public type
|
|
41
|
+
public type = 'edge' as const;
|
|
41
42
|
public nodeMap: Map<ID, Node>;
|
|
42
43
|
public sourceItem: Node | Combo;
|
|
43
44
|
public targetItem: Node | Combo;
|
|
44
45
|
|
|
46
|
+
/** Caches to avoid unnecessary calculations. */
|
|
47
|
+
private cache: {
|
|
48
|
+
sourcePositionCache?: Point;
|
|
49
|
+
targetPositionCache?: Point;
|
|
50
|
+
controlPointsCache?: Point;
|
|
51
|
+
sourcePointCache?: Point;
|
|
52
|
+
targetPointCache?: Point;
|
|
53
|
+
} = {};
|
|
54
|
+
|
|
45
55
|
constructor(props: IProps) {
|
|
46
56
|
super(props);
|
|
47
57
|
this.init({ ...props, type: 'edge' });
|
|
@@ -56,7 +66,9 @@ export default class Edge extends Item {
|
|
|
56
66
|
if (sourceItem.getType() === 'node') {
|
|
57
67
|
this.nodeMap.set(targetItem.getID(), targetItem as Node);
|
|
58
68
|
}
|
|
59
|
-
|
|
69
|
+
if (!props.delayFirstDraw) {
|
|
70
|
+
this.draw(this.displayModel);
|
|
71
|
+
}
|
|
60
72
|
}
|
|
61
73
|
public draw(
|
|
62
74
|
displayModel: EdgeDisplayModel,
|
|
@@ -65,40 +77,7 @@ export default class Edge extends Item {
|
|
|
65
77
|
animate = true,
|
|
66
78
|
onfinish: Function = () => {},
|
|
67
79
|
) {
|
|
68
|
-
|
|
69
|
-
const { sourceAnchor, targetAnchor, keyShape } = displayModel.data;
|
|
70
|
-
const sourcePosition = this.sourceItem.getPosition();
|
|
71
|
-
const targetPosition = this.targetItem.getPosition();
|
|
72
|
-
|
|
73
|
-
let targetPrevious = sourcePosition;
|
|
74
|
-
let sourcePrevious = targetPosition;
|
|
75
|
-
|
|
76
|
-
// TODO: type
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
if (keyShape?.controlPoints?.length) {
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
const controlPointsBesideEnds = keyShape.controlPoints.filter(
|
|
81
|
-
(point) =>
|
|
82
|
-
!isSamePoint(point, sourcePosition) &&
|
|
83
|
-
!isSamePoint(point, targetPosition),
|
|
84
|
-
);
|
|
85
|
-
sourcePrevious = getNearestPoint(
|
|
86
|
-
controlPointsBesideEnds,
|
|
87
|
-
sourcePosition,
|
|
88
|
-
).nearestPoint;
|
|
89
|
-
targetPrevious = getNearestPoint(
|
|
90
|
-
controlPointsBesideEnds,
|
|
91
|
-
targetPosition,
|
|
92
|
-
).nearestPoint;
|
|
93
|
-
}
|
|
94
|
-
const sourcePoint = this.sourceItem.getAnchorPoint(
|
|
95
|
-
sourcePrevious,
|
|
96
|
-
sourceAnchor,
|
|
97
|
-
);
|
|
98
|
-
const targetPoint = this.targetItem.getAnchorPoint(
|
|
99
|
-
targetPrevious,
|
|
100
|
-
targetAnchor,
|
|
101
|
-
);
|
|
80
|
+
const { sourcePoint, targetPoint } = this.getEndPoints(displayModel);
|
|
102
81
|
this.renderExt.mergeStyles(displayModel);
|
|
103
82
|
const firstRendering = !this.shapeMap?.keyShape;
|
|
104
83
|
this.renderExt.setSourcePoint(sourcePoint);
|
|
@@ -161,16 +140,23 @@ export default class Edge extends Item {
|
|
|
161
140
|
* Sometimes no changes on edge data, but need to re-draw it
|
|
162
141
|
* e.g. source and target nodes' position changed
|
|
163
142
|
*/
|
|
164
|
-
public forceUpdate
|
|
165
|
-
()
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
143
|
+
public forceUpdate() {
|
|
144
|
+
if (this.destroyed) return;
|
|
145
|
+
const { sourcePoint, targetPoint, changed } = this.getEndPoints(
|
|
146
|
+
this.displayModel,
|
|
147
|
+
);
|
|
148
|
+
if (!changed) return;
|
|
149
|
+
this.renderExt.setSourcePoint(sourcePoint);
|
|
150
|
+
this.renderExt.setTargetPoint(targetPoint);
|
|
151
|
+
const shapeMap = this.renderExt.draw(
|
|
152
|
+
this.displayModel,
|
|
153
|
+
sourcePoint,
|
|
154
|
+
targetPoint,
|
|
155
|
+
this.shapeMap,
|
|
156
|
+
);
|
|
157
|
+
// add shapes to group, and update shapeMap
|
|
158
|
+
this.shapeMap = updateShapes(this.shapeMap, shapeMap, this.group);
|
|
159
|
+
}
|
|
174
160
|
|
|
175
161
|
/**
|
|
176
162
|
* Update end item for item and re-draw the edge
|
|
@@ -183,23 +169,111 @@ export default class Edge extends Item {
|
|
|
183
169
|
this.draw(this.displayModel);
|
|
184
170
|
}
|
|
185
171
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Calculate the source and target points according to the source and target nodes and the anchorPoints and controlPoints.
|
|
174
|
+
* @param displayModel
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
private getEndPoints(displayModel: EdgeDisplayModel) {
|
|
178
|
+
// get the point near the other end
|
|
179
|
+
const { sourceAnchor, targetAnchor, keyShape } = displayModel.data;
|
|
180
|
+
const sourcePosition = this.sourceItem.getPosition();
|
|
181
|
+
const targetPosition = this.targetItem.getPosition();
|
|
182
|
+
|
|
183
|
+
if (
|
|
184
|
+
!this.shouldUpdatePoints(
|
|
185
|
+
sourcePosition,
|
|
186
|
+
targetPosition,
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
keyShape?.controlPoints,
|
|
189
|
+
)
|
|
190
|
+
) {
|
|
191
|
+
return {
|
|
192
|
+
sourcePoint: this.cache.sourcePointCache,
|
|
193
|
+
targetPoint: this.cache.targetPointCache,
|
|
194
|
+
changed: false,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let targetPrevious = sourcePosition;
|
|
199
|
+
let sourcePrevious = targetPosition;
|
|
200
|
+
|
|
201
|
+
// TODO: type
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
if (keyShape?.controlPoints?.length) {
|
|
204
|
+
// @ts-ignore
|
|
205
|
+
const controlPointsBesideEnds = keyShape.controlPoints.filter(
|
|
206
|
+
(point) =>
|
|
207
|
+
!isSamePoint(point, sourcePosition) &&
|
|
208
|
+
!isSamePoint(point, targetPosition),
|
|
209
|
+
);
|
|
210
|
+
sourcePrevious = getNearestPoint(
|
|
211
|
+
controlPointsBesideEnds,
|
|
212
|
+
sourcePosition,
|
|
213
|
+
).nearestPoint;
|
|
214
|
+
targetPrevious = getNearestPoint(
|
|
215
|
+
controlPointsBesideEnds,
|
|
216
|
+
targetPosition,
|
|
217
|
+
).nearestPoint;
|
|
218
|
+
}
|
|
219
|
+
this.cache.sourcePointCache = this.sourceItem.getAnchorPoint(
|
|
220
|
+
sourcePrevious,
|
|
221
|
+
sourceAnchor,
|
|
222
|
+
);
|
|
223
|
+
this.cache.targetPointCache = this.targetItem.getAnchorPoint(
|
|
224
|
+
targetPrevious,
|
|
225
|
+
targetAnchor,
|
|
226
|
+
);
|
|
227
|
+
return {
|
|
228
|
+
sourcePoint: this.cache.sourcePointCache,
|
|
229
|
+
targetPoint: this.cache.targetPointCache,
|
|
230
|
+
changed: true,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Returns false if the source, target, controlPoints are not changed, avoiding unnecessary computations.
|
|
236
|
+
* @param sourcePosition
|
|
237
|
+
* @param targetPosition
|
|
238
|
+
* @param controlPoints
|
|
239
|
+
* @returns
|
|
240
|
+
*/
|
|
241
|
+
private shouldUpdatePoints(sourcePosition, targetPosition, controlPoints) {
|
|
242
|
+
const isComboEnd =
|
|
243
|
+
this.sourceItem.type === 'combo' || this.targetItem.type === 'combo';
|
|
244
|
+
const changed =
|
|
245
|
+
!(
|
|
246
|
+
isSamePoint(sourcePosition, this.cache.sourcePositionCache) &&
|
|
247
|
+
isSamePoint(targetPosition, this.cache.targetPositionCache) &&
|
|
248
|
+
controlPoints === this.cache.controlPointsCache
|
|
249
|
+
) || isComboEnd;
|
|
250
|
+
if (changed) {
|
|
251
|
+
this.cache.sourcePositionCache = sourcePosition;
|
|
252
|
+
this.cache.targetPositionCache = targetPosition;
|
|
253
|
+
this.cache.controlPointsCache = controlPoints;
|
|
254
|
+
}
|
|
255
|
+
return changed;
|
|
256
|
+
}
|
|
189
257
|
|
|
190
258
|
public clone(
|
|
191
259
|
containerGroup: Group,
|
|
192
260
|
sourceItem: Node | Combo,
|
|
193
261
|
targetItem: Node | Combo,
|
|
194
|
-
|
|
262
|
+
shapeIds?: string[],
|
|
195
263
|
disableAnimate?: boolean,
|
|
196
264
|
) {
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
265
|
+
if (shapeIds?.length) {
|
|
266
|
+
const group = new Group();
|
|
267
|
+
shapeIds.forEach((shapeId) => {
|
|
268
|
+
if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
|
|
269
|
+
const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
|
|
270
|
+
// TODO: other animating attributes?
|
|
271
|
+
clonedKeyShape.style.opacity =
|
|
272
|
+
this.renderExt.mergedStyles[shapeId]?.opacity || 1;
|
|
273
|
+
group.appendChild(clonedKeyShape);
|
|
274
|
+
});
|
|
275
|
+
containerGroup.appendChild(group);
|
|
276
|
+
return group;
|
|
203
277
|
}
|
|
204
278
|
const clonedModel = clone(this.model);
|
|
205
279
|
clonedModel.data.disableAnimate = disableAnimate;
|
package/src/item/item.ts
CHANGED
|
@@ -90,7 +90,8 @@ export default abstract class Item implements IItem {
|
|
|
90
90
|
/** Cache the dirty tags for states when data changed, to re-map the state styles when state changed */
|
|
91
91
|
private stateDirtyMap: { [stateName: string]: boolean } = {};
|
|
92
92
|
private cacheStateStyles: { [stateName: string]: ItemShapeStyles } = {};
|
|
93
|
-
private
|
|
93
|
+
private cacheNotHiddenByItem: { [shapeId: string]: boolean } = {};
|
|
94
|
+
private cacheHiddenByItem: { [shapeId: string]: boolean } = {};
|
|
94
95
|
|
|
95
96
|
// TODO: props type
|
|
96
97
|
constructor(props) {
|
|
@@ -411,7 +412,7 @@ export default abstract class Item implements IItem {
|
|
|
411
412
|
/** Show the item. */
|
|
412
413
|
public show(animate = true) {
|
|
413
414
|
Promise.all(this.stopAnimations()).finally(() => {
|
|
414
|
-
if (this.destroyed
|
|
415
|
+
if (this.destroyed) return;
|
|
415
416
|
const { animates = {} } = this.displayModel.data;
|
|
416
417
|
if (animate && animates.show?.length) {
|
|
417
418
|
const showAnimateFieldsMap: any = {};
|
|
@@ -424,7 +425,7 @@ export default abstract class Item implements IItem {
|
|
|
424
425
|
const targetStyleMap = {};
|
|
425
426
|
Object.keys(this.shapeMap).forEach((id) => {
|
|
426
427
|
const shape = this.shapeMap[id];
|
|
427
|
-
if (
|
|
428
|
+
if (this.cacheHiddenByItem[id]) {
|
|
428
429
|
// set the animate fields to initial value
|
|
429
430
|
if (showAnimateFieldsMap[id]) {
|
|
430
431
|
targetStyleMap[id] = targetStyleMap[id] || {};
|
|
@@ -439,7 +440,7 @@ export default abstract class Item implements IItem {
|
|
|
439
440
|
shape.show();
|
|
440
441
|
}
|
|
441
442
|
});
|
|
442
|
-
if (showAnimateFieldsMap.group) {
|
|
443
|
+
if (showAnimateFieldsMap.group && !this.shapeMap.keyShape.isVisible()) {
|
|
443
444
|
showAnimateFieldsMap.group.forEach((field) => {
|
|
444
445
|
const usingField = field === 'size' ? 'transform' : field;
|
|
445
446
|
if (GROUP_ANIMATE_STYLES[0].hasOwnProperty(usingField)) {
|
|
@@ -449,34 +450,42 @@ export default abstract class Item implements IItem {
|
|
|
449
450
|
});
|
|
450
451
|
}
|
|
451
452
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
453
|
+
if (Object.keys(targetStyleMap).length) {
|
|
454
|
+
this.animations = this.runWithAnimates(
|
|
455
|
+
animates,
|
|
456
|
+
'show',
|
|
457
|
+
targetStyleMap,
|
|
458
|
+
);
|
|
459
|
+
}
|
|
457
460
|
} else {
|
|
458
461
|
Object.keys(this.shapeMap).forEach((id) => {
|
|
459
462
|
const shape = this.shapeMap[id];
|
|
460
|
-
if (
|
|
463
|
+
if (this.cacheHiddenByItem[id]) shape.show();
|
|
461
464
|
});
|
|
462
465
|
}
|
|
463
466
|
|
|
464
467
|
this.visible = true;
|
|
468
|
+
this.cacheHiddenByItem = {};
|
|
465
469
|
});
|
|
466
470
|
}
|
|
467
471
|
|
|
468
472
|
/** Hides the item. */
|
|
469
|
-
public hide(animate = true) {
|
|
473
|
+
public hide(animate = true, keepKeyShape = false) {
|
|
474
|
+
this.cacheNotHiddenByItem = {};
|
|
470
475
|
const func = () => {
|
|
471
476
|
Object.keys(this.shapeMap).forEach((id) => {
|
|
477
|
+
if (keepKeyShape && id === 'keyShape') return;
|
|
472
478
|
const shape = this.shapeMap[id];
|
|
473
|
-
if (!
|
|
474
|
-
this.
|
|
479
|
+
if (!shape.isVisible()) {
|
|
480
|
+
this.cacheNotHiddenByItem[id] = true;
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
475
483
|
shape.hide();
|
|
484
|
+
this.cacheHiddenByItem[id] = true;
|
|
476
485
|
});
|
|
477
486
|
};
|
|
478
487
|
Promise.all(this.stopAnimations()).then(() => {
|
|
479
|
-
if (this.destroyed
|
|
488
|
+
if (this.destroyed) return;
|
|
480
489
|
const { animates = {} } = this.displayModel.data;
|
|
481
490
|
if (animate && animates.hide?.length) {
|
|
482
491
|
this.animations = this.runWithAnimates(
|
|
@@ -802,7 +811,7 @@ export default abstract class Item implements IItem {
|
|
|
802
811
|
*/
|
|
803
812
|
public updateZoom(zoom) {
|
|
804
813
|
this.zoom = zoom;
|
|
805
|
-
this.renderExt.onZoom(this.shapeMap, zoom);
|
|
814
|
+
this.renderExt.onZoom(this.shapeMap, zoom, this.cacheHiddenByItem);
|
|
806
815
|
}
|
|
807
816
|
|
|
808
817
|
/** Destroy the item. */
|
package/src/item/node.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Group } from '@antv/g';
|
|
2
2
|
import { clone } from '@antv/util';
|
|
3
3
|
import { Point } from '../types/common';
|
|
4
4
|
import { ComboDisplayModel, ComboModel, NodeModel } from '../types';
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
getRectIntersectByPoint,
|
|
15
15
|
} from '../util/point';
|
|
16
16
|
import { ComboModelData } from '../types/combo';
|
|
17
|
-
import { isArraySame } from '../util/array';
|
|
18
17
|
import Item from './item';
|
|
19
18
|
|
|
20
19
|
interface IProps {
|
|
@@ -34,6 +33,7 @@ interface IProps {
|
|
|
34
33
|
onframe?: Function;
|
|
35
34
|
onfinish?: Function;
|
|
36
35
|
type?: 'node' | 'combo';
|
|
36
|
+
delayFirstDraw?: boolean;
|
|
37
37
|
}
|
|
38
38
|
export default class Node extends Item {
|
|
39
39
|
public type: 'node' | 'combo';
|
|
@@ -41,13 +41,15 @@ export default class Node extends Item {
|
|
|
41
41
|
constructor(props: IProps) {
|
|
42
42
|
super(props);
|
|
43
43
|
this.init({ ...props, type: props.type || 'node' });
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (!props.delayFirstDraw) {
|
|
45
|
+
this.draw(
|
|
46
|
+
this.displayModel as NodeDisplayModel | ComboDisplayModel,
|
|
47
|
+
undefined,
|
|
48
|
+
undefined,
|
|
49
|
+
!this.displayModel.data.disableAnimate,
|
|
50
|
+
props.onfinish,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
public draw(
|
|
53
55
|
displayModel: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -76,7 +78,9 @@ export default class Node extends Item {
|
|
|
76
78
|
const { animates, disableAnimate, x = 0, y = 0, z = 0 } = displayModel.data;
|
|
77
79
|
if (firstRendering) {
|
|
78
80
|
// first rendering, move the group
|
|
79
|
-
group.
|
|
81
|
+
group.style.x = x;
|
|
82
|
+
group.style.y = y;
|
|
83
|
+
group.style.z = z;
|
|
80
84
|
} else {
|
|
81
85
|
// terminate previous animations
|
|
82
86
|
this.stopAnimations();
|
|
@@ -192,23 +196,30 @@ export default class Node extends Item {
|
|
|
192
196
|
return;
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
|
-
group.
|
|
199
|
+
group.style.x = position.x;
|
|
200
|
+
group.style.y = position.y;
|
|
201
|
+
group.style.z = position.z;
|
|
196
202
|
onfinish(displayModel.id, !animate);
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
public clone(
|
|
200
206
|
containerGroup: Group,
|
|
201
|
-
|
|
207
|
+
shapeIds?: string[],
|
|
202
208
|
disableAnimate?: boolean,
|
|
203
209
|
) {
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
if (shapeIds?.length) {
|
|
211
|
+
const group = new Group();
|
|
212
|
+
shapeIds.forEach((shapeId) => {
|
|
213
|
+
if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
|
|
214
|
+
const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
|
|
215
|
+
// TODO: other animating attributes?
|
|
216
|
+
clonedKeyShape.style.opacity =
|
|
217
|
+
this.renderExt.mergedStyles[shapeId]?.opacity || 1;
|
|
218
|
+
group.appendChild(clonedKeyShape);
|
|
219
|
+
});
|
|
220
|
+
group.setPosition(this.group.getPosition());
|
|
221
|
+
containerGroup.appendChild(group);
|
|
222
|
+
return group;
|
|
212
223
|
}
|
|
213
224
|
const clonedModel = clone(this.model);
|
|
214
225
|
clonedModel.data.disableAnimate = disableAnimate;
|
|
@@ -297,12 +308,13 @@ export default class Node extends Item {
|
|
|
297
308
|
intersectPoint = innerPoint;
|
|
298
309
|
break;
|
|
299
310
|
default: {
|
|
311
|
+
// boundsCache can be removed here since `getBounds` has already done.
|
|
300
312
|
intersectPoint = getRectIntersectByPoint(
|
|
301
313
|
{
|
|
302
314
|
x: keyShapeRenderBBox.min[0],
|
|
303
315
|
y: keyShapeRenderBBox.min[1],
|
|
304
|
-
width:
|
|
305
|
-
height:
|
|
316
|
+
width: keyShapeWidth,
|
|
317
|
+
height: keyShapeHeight,
|
|
306
318
|
},
|
|
307
319
|
point,
|
|
308
320
|
);
|
|
@@ -321,15 +333,16 @@ export default class Node extends Item {
|
|
|
321
333
|
}
|
|
322
334
|
if (!linkPoint) {
|
|
323
335
|
// If the calculations above are all failed, return the data's position
|
|
324
|
-
return { x, y };
|
|
336
|
+
return { x, y, z };
|
|
325
337
|
}
|
|
338
|
+
if (!isNaN(z)) linkPoint.z = z;
|
|
326
339
|
return linkPoint;
|
|
327
340
|
}
|
|
328
341
|
|
|
329
342
|
public getPosition(): Point {
|
|
330
343
|
const initiated =
|
|
331
344
|
this.shapeMap.keyShape && this.group.attributes.x !== undefined;
|
|
332
|
-
if (initiated) {
|
|
345
|
+
if (initiated && this.renderExt.dimensions !== 3) {
|
|
333
346
|
const { center } = this.shapeMap.keyShape.getRenderBounds();
|
|
334
347
|
return { x: center[0], y: center[1], z: center[2] };
|
|
335
348
|
}
|