@antv/g6 5.0.0-beta.0 → 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/api-doc/item.d.ts +2 -0
- package/esm/api-doc/item.js +2 -0
- package/esm/api-doc/item.js.map +1 -1
- 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 +127 -283
- 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/controller/plugin.js +3 -3
- package/esm/runtime/controller/plugin.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 +57 -26
- 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 +16 -11
- 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 +96 -6
- package/esm/stdlib/item/edge/base.js +92 -19
- 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 +90 -16
- package/esm/stdlib/item/node/base.js +91 -41
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +24 -0
- package/esm/stdlib/item/node/base3d.js +24 -8
- 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 +5 -3
- 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 +20 -4
- 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/api-doc/item.d.ts +2 -0
- package/lib/api-doc/item.js +5 -1
- package/lib/api-doc/item.js.map +1 -1
- 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 +127 -283
- 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/controller/plugin.js +3 -3
- package/lib/runtime/controller/plugin.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 +57 -26
- 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 +16 -11
- 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 +96 -6
- package/lib/stdlib/item/edge/base.js +92 -19
- 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 +90 -16
- package/lib/stdlib/item/node/base.js +91 -41
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +24 -0
- package/lib/stdlib/item/node/base3d.js +24 -8
- 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 +5 -3
- 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 +20 -4
- 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/api-doc/item.ts +2 -0
- 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 +142 -341
- package/src/runtime/controller/item.ts +236 -72
- package/src/runtime/controller/plugin.ts +15 -3
- 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 +76 -27
- 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 +16 -11
- package/src/stdlib/index.ts +33 -9
- package/src/stdlib/item/edge/base.ts +118 -19
- 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 +117 -46
- package/src/stdlib/item/node/base3d.ts +24 -9
- 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 +5 -4
- 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 +23 -4
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNumber } from '@antv/util';
|
|
2
|
+
import { ID, IG6GraphEvent } from '../../types';
|
|
2
3
|
import { Behavior } from '../../types/behavior';
|
|
3
4
|
|
|
4
5
|
const VALID_TRIGGERS = ['wheel', 'upDownKeys'];
|
|
@@ -56,7 +57,7 @@ export interface ZoomCanvasOptions {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
|
|
59
|
-
enableOptimize:
|
|
60
|
+
enableOptimize: undefined,
|
|
60
61
|
triggerOnItems: true,
|
|
61
62
|
sensitivity: 2,
|
|
62
63
|
trigger: 'wheel',
|
|
@@ -75,6 +76,7 @@ export class ZoomCanvas extends Behavior {
|
|
|
75
76
|
private hiddenEdgeIds: ID[];
|
|
76
77
|
private hiddenNodeIds: ID[];
|
|
77
78
|
private zoomTimer: ReturnType<typeof setTimeout>;
|
|
79
|
+
private tileRequestId?: number;
|
|
78
80
|
|
|
79
81
|
constructor(options: Partial<ZoomCanvasOptions>) {
|
|
80
82
|
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
@@ -114,43 +116,88 @@ export class ZoomCanvas extends Behavior {
|
|
|
114
116
|
|
|
115
117
|
private hideShapes() {
|
|
116
118
|
const { graph } = this;
|
|
117
|
-
|
|
119
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
120
|
+
graph.getSpecification().optimize || {};
|
|
121
|
+
const optimize =
|
|
122
|
+
this.options.enableOptimize !== undefined
|
|
123
|
+
? this.options.enableOptimize
|
|
124
|
+
: graphBehaviorOptimize;
|
|
125
|
+
const shouldOptimze = isNumber(optimize)
|
|
126
|
+
? graph.getAllNodesData().length > optimize
|
|
127
|
+
: optimize;
|
|
128
|
+
if (shouldOptimze) {
|
|
118
129
|
this.hiddenEdgeIds = graph
|
|
119
130
|
.getAllEdgesData()
|
|
120
131
|
.map((edge) => edge.id)
|
|
121
132
|
.filter((id) => graph.getItemVisible(id) === true);
|
|
122
|
-
// TODO
|
|
123
|
-
graph.hideItem(this.hiddenEdgeIds, false);
|
|
124
133
|
this.hiddenNodeIds = graph
|
|
125
134
|
.getAllNodesData()
|
|
126
135
|
.map((node) => node.id)
|
|
127
136
|
.filter((id) => graph.getItemVisible(id) === true);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
|
|
138
|
+
const hiddenIds = [...this.hiddenNodeIds];
|
|
139
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
140
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
141
|
+
hiddenIds.slice(
|
|
142
|
+
i * tileBehaviorSize,
|
|
143
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
const update = () => {
|
|
147
|
+
if (!sections.length && this.tileRequestId) {
|
|
148
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
149
|
+
this.tileRequestId = undefined;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const section = sections.shift();
|
|
153
|
+
graph.startHistoryBatch();
|
|
154
|
+
graph.hideItem(section, false, true);
|
|
155
|
+
graph.stopHistoryBatch();
|
|
156
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
157
|
+
};
|
|
158
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
135
159
|
}
|
|
136
160
|
}
|
|
137
161
|
|
|
138
162
|
private endZoom() {
|
|
139
|
-
const { graph, hiddenEdgeIds, hiddenNodeIds } = this;
|
|
140
|
-
const {
|
|
163
|
+
const { graph, hiddenEdgeIds = [], hiddenNodeIds } = this;
|
|
164
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
165
|
+
graph.getSpecification().optimize || {};
|
|
166
|
+
const optimize =
|
|
167
|
+
this.options.enableOptimize !== undefined
|
|
168
|
+
? this.options.enableOptimize
|
|
169
|
+
: graphBehaviorOptimize;
|
|
170
|
+
const shouldOptimze = isNumber(optimize)
|
|
171
|
+
? graph.getAllNodesData().length > optimize
|
|
172
|
+
: optimize;
|
|
141
173
|
this.zooming = false;
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
174
|
+
if (shouldOptimze) {
|
|
175
|
+
if (this.tileRequestId) {
|
|
176
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
177
|
+
this.tileRequestId = undefined;
|
|
178
|
+
}
|
|
179
|
+
if (hiddenNodeIds) {
|
|
180
|
+
const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
|
|
181
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
182
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
183
|
+
hiddenIds.slice(
|
|
184
|
+
i * tileBehaviorSize,
|
|
185
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
186
|
+
),
|
|
187
|
+
);
|
|
188
|
+
const update = () => {
|
|
189
|
+
if (!sections.length && this.tileRequestId) {
|
|
190
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
191
|
+
this.tileRequestId = undefined;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
graph.executeWithNoStack(() => {
|
|
195
|
+
graph.showItem(sections.shift(), false);
|
|
196
|
+
});
|
|
197
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
198
|
+
};
|
|
199
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
146
200
|
}
|
|
147
|
-
// TODO
|
|
148
|
-
// if (hiddenNodeIds) {
|
|
149
|
-
// hiddenNodeIds.forEach((id) => {
|
|
150
|
-
// graph.drawTransient('node', id, { action: 'remove' });
|
|
151
|
-
// });
|
|
152
|
-
// graph.showItem(hiddenNodeIds, false);
|
|
153
|
-
// }
|
|
154
201
|
}
|
|
155
202
|
this.hiddenEdgeIds = [];
|
|
156
203
|
this.hiddenNodeIds = [];
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
/**
|
|
10
10
|
* Validate and format the graph data.
|
|
11
11
|
* @param data input user data.
|
|
12
|
-
* @param
|
|
12
|
+
* @param graphCore the graph core stores the previous data.
|
|
13
13
|
* @returns formatted data.
|
|
14
14
|
*/
|
|
15
15
|
export const MapNodeSize = (
|
|
@@ -18,7 +18,7 @@ export const MapNodeSize = (
|
|
|
18
18
|
field?: string;
|
|
19
19
|
range?: [number, number];
|
|
20
20
|
} = {},
|
|
21
|
-
|
|
21
|
+
graphCore?: GraphCore,
|
|
22
22
|
): GraphData => {
|
|
23
23
|
const { field, range = [8, 40] } = options;
|
|
24
24
|
if (!field) return data;
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
/**
|
|
11
11
|
* Validate and format the graph data.
|
|
12
12
|
* @param data input user data.
|
|
13
|
-
* @param
|
|
13
|
+
* @param graphCore the graph core stores the previous data.
|
|
14
14
|
* @returns formatted data.
|
|
15
15
|
*/
|
|
16
16
|
export const TransformV4Data = (
|
|
17
17
|
data: GraphData,
|
|
18
18
|
options = {},
|
|
19
|
-
|
|
19
|
+
graphCore?: GraphCore,
|
|
20
20
|
): GraphData => {
|
|
21
21
|
const { nodes = [], edges = [], combos = [] } = data;
|
|
22
22
|
const formattedNodes = nodes.map((node: any) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { uniqueId } from '@antv/util';
|
|
1
2
|
import { GraphCore } from '../../types/data';
|
|
2
3
|
import {
|
|
3
4
|
GraphData,
|
|
@@ -9,21 +10,25 @@ import {
|
|
|
9
10
|
/**
|
|
10
11
|
* Validate and format the graph data.
|
|
11
12
|
* @param data input user data.
|
|
12
|
-
* @param
|
|
13
|
+
* @param graphCore the graph core stores the previous data.
|
|
13
14
|
* @returns formatted data.
|
|
14
15
|
*/
|
|
15
16
|
export const ValidateData = (
|
|
16
17
|
data: GraphData,
|
|
17
18
|
options = {},
|
|
18
|
-
|
|
19
|
+
graphCore?: GraphCore,
|
|
19
20
|
): GraphData => {
|
|
20
21
|
const { nodes, edges, combos } = data;
|
|
21
22
|
const idMap = new Map();
|
|
22
23
|
const nodeIdMap = new Map();
|
|
23
24
|
const comboIdMap = new Map();
|
|
24
25
|
|
|
25
|
-
const idAndDataCheck = (item, type) => {
|
|
26
|
+
const idAndDataCheck = (item, type, generateId = false) => {
|
|
26
27
|
if (item.id === undefined) {
|
|
28
|
+
if (generateId) {
|
|
29
|
+
item.id = `${type}-${uniqueId()}`;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
console.error(
|
|
28
33
|
`Unique global id is neccessary for graph items. The ${type} ${JSON.stringify(
|
|
29
34
|
item,
|
|
@@ -59,7 +64,7 @@ export const ValidateData = (
|
|
|
59
64
|
if (
|
|
60
65
|
parentId !== undefined &&
|
|
61
66
|
!comboIdMap.has(parentId) &&
|
|
62
|
-
(!
|
|
67
|
+
(!graphCore || !graphCore.hasNode(parentId))
|
|
63
68
|
) {
|
|
64
69
|
console.error(
|
|
65
70
|
`The parentId of combo with id ${combo.id} will be removed since it is not exist in combos.`,
|
|
@@ -75,9 +80,9 @@ export const ValidateData = (
|
|
|
75
80
|
if (
|
|
76
81
|
parentId !== undefined &&
|
|
77
82
|
!comboIdMap.has(parentId) &&
|
|
78
|
-
(!
|
|
83
|
+
(!graphCore || !graphCore.hasNode(parentId))
|
|
79
84
|
) {
|
|
80
|
-
// TODO: parentId is a node in
|
|
85
|
+
// TODO: parentId is a node in graphCore
|
|
81
86
|
console.error(
|
|
82
87
|
`The parentId of node with id ${node.id} will be removed since it is not exist in combos.`,
|
|
83
88
|
);
|
|
@@ -93,10 +98,10 @@ export const ValidateData = (
|
|
|
93
98
|
?.map((edge) => {
|
|
94
99
|
const { id } = edge;
|
|
95
100
|
let { source, target } = edge;
|
|
96
|
-
if (!idAndDataCheck(edge, 'edge')) return false;
|
|
101
|
+
if (!idAndDataCheck(edge, 'edge', true)) return false;
|
|
97
102
|
|
|
98
|
-
if (
|
|
99
|
-
const existEdge =
|
|
103
|
+
if (graphCore?.hasEdge(id)) {
|
|
104
|
+
const existEdge = graphCore?.getEdge(id);
|
|
100
105
|
if (source === undefined) source = existEdge.source;
|
|
101
106
|
if (target === undefined) target = existEdge.target;
|
|
102
107
|
}
|
|
@@ -116,7 +121,7 @@ export const ValidateData = (
|
|
|
116
121
|
if (
|
|
117
122
|
!nodeIdMap.has(source) &&
|
|
118
123
|
!comboIdMap.has(source) &&
|
|
119
|
-
(!
|
|
124
|
+
(!graphCore || !graphCore.hasNode(source))
|
|
120
125
|
) {
|
|
121
126
|
console.error(
|
|
122
127
|
`The edge with id ${id} will be ignored since its source ${source} is not existed in nodes and combos.`,
|
|
@@ -126,7 +131,7 @@ export const ValidateData = (
|
|
|
126
131
|
if (
|
|
127
132
|
!nodeIdMap.has(target) &&
|
|
128
133
|
!comboIdMap.has(target) &&
|
|
129
|
-
(!
|
|
134
|
+
(!graphCore || !graphCore.hasNode(target))
|
|
130
135
|
) {
|
|
131
136
|
console.error(
|
|
132
137
|
`The edge with id ${id} will be ignored since its target ${target} is not existed in nodes and combos.`,
|
package/src/stdlib/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
TriangleNode,
|
|
32
32
|
EllipseNode,
|
|
33
33
|
ModelRectNode,
|
|
34
|
+
ImageNode,
|
|
34
35
|
} = Nodes;
|
|
35
36
|
|
|
36
37
|
const {
|
|
@@ -60,9 +61,22 @@ const {
|
|
|
60
61
|
DragNode,
|
|
61
62
|
DragCombo,
|
|
62
63
|
ClickSelect,
|
|
64
|
+
CreateEdge,
|
|
65
|
+
ShortcutsCall,
|
|
66
|
+
ScrollCanvas,
|
|
63
67
|
} = Behaviors;
|
|
64
|
-
const {
|
|
65
|
-
|
|
68
|
+
const {
|
|
69
|
+
History,
|
|
70
|
+
Tooltip,
|
|
71
|
+
Minimap,
|
|
72
|
+
Grid,
|
|
73
|
+
Menu,
|
|
74
|
+
Fisheye,
|
|
75
|
+
Legend,
|
|
76
|
+
Toolbar,
|
|
77
|
+
Timebar,
|
|
78
|
+
Snapline,
|
|
79
|
+
} = Plugins;
|
|
66
80
|
|
|
67
81
|
const {
|
|
68
82
|
ForceLayout,
|
|
@@ -81,6 +95,7 @@ const {
|
|
|
81
95
|
|
|
82
96
|
import lassoSelector from './selector/lasso';
|
|
83
97
|
import rectSelector from './selector/rect';
|
|
98
|
+
import Hull from './plugin/hull';
|
|
84
99
|
|
|
85
100
|
const stdLib = {
|
|
86
101
|
transforms: {
|
|
@@ -108,6 +123,7 @@ const stdLib = {
|
|
|
108
123
|
'zoom-canvas': ZoomCanvas,
|
|
109
124
|
'drag-node': DragNode,
|
|
110
125
|
'drag-combo': DragCombo,
|
|
126
|
+
'create-edge': CreateEdge,
|
|
111
127
|
'collapse-expand-combo': CollapseExpandCombo,
|
|
112
128
|
'collapse-expand-tree': CollapseExpandTree,
|
|
113
129
|
'click-select': ClickSelect,
|
|
@@ -118,9 +134,11 @@ const stdLib = {
|
|
|
118
134
|
nodes: {
|
|
119
135
|
'circle-node': CircleNode,
|
|
120
136
|
'rect-node': RectNode,
|
|
137
|
+
'image-node': ImageNode,
|
|
121
138
|
},
|
|
122
139
|
edges: {
|
|
123
140
|
'line-edge': LineEdge,
|
|
141
|
+
'loop-edge': LoopEdge,
|
|
124
142
|
},
|
|
125
143
|
combos: {
|
|
126
144
|
'circle-combo': CircleCombo,
|
|
@@ -193,13 +211,13 @@ const Extensions = {
|
|
|
193
211
|
ValidateData,
|
|
194
212
|
TransformV4Data,
|
|
195
213
|
MapNodeSize,
|
|
196
|
-
//themes
|
|
214
|
+
// themes
|
|
197
215
|
LightTheme,
|
|
198
216
|
DarkTheme,
|
|
199
|
-
//themeSolvers
|
|
217
|
+
// themeSolvers
|
|
200
218
|
SpecThemeSolver,
|
|
201
219
|
SubjectThemeSolver,
|
|
202
|
-
//layout
|
|
220
|
+
// layout
|
|
203
221
|
ForceLayout,
|
|
204
222
|
GridLayout,
|
|
205
223
|
CircularLayout,
|
|
@@ -212,12 +230,12 @@ const Extensions = {
|
|
|
212
230
|
ForceAtlas2Layout,
|
|
213
231
|
DagreLayout,
|
|
214
232
|
ComboCombinedLayout,
|
|
215
|
-
//Hierarchy
|
|
233
|
+
// Hierarchy
|
|
216
234
|
compactBox,
|
|
217
235
|
dendrogram,
|
|
218
236
|
indented,
|
|
219
237
|
mindmap,
|
|
220
|
-
//nodes
|
|
238
|
+
// nodes
|
|
221
239
|
CircleNode,
|
|
222
240
|
RectNode,
|
|
223
241
|
DiamondNode,
|
|
@@ -239,7 +257,7 @@ const Extensions = {
|
|
|
239
257
|
// combos
|
|
240
258
|
CircleCombo,
|
|
241
259
|
RectCombo,
|
|
242
|
-
//behaviors
|
|
260
|
+
// behaviors
|
|
243
261
|
BaseBehavior,
|
|
244
262
|
ActivateRelations,
|
|
245
263
|
BrushSelect,
|
|
@@ -255,7 +273,10 @@ const Extensions = {
|
|
|
255
273
|
CollapseExpandCombo,
|
|
256
274
|
DragNode,
|
|
257
275
|
DragCombo,
|
|
258
|
-
|
|
276
|
+
CreateEdge,
|
|
277
|
+
ShortcutsCall,
|
|
278
|
+
ScrollCanvas,
|
|
279
|
+
// plugins
|
|
259
280
|
BasePlugin,
|
|
260
281
|
History,
|
|
261
282
|
Toolbar,
|
|
@@ -265,6 +286,9 @@ const Extensions = {
|
|
|
265
286
|
Menu,
|
|
266
287
|
Fisheye,
|
|
267
288
|
Legend,
|
|
289
|
+
Timebar,
|
|
290
|
+
Hull,
|
|
291
|
+
Snapline,
|
|
268
292
|
};
|
|
269
293
|
|
|
270
294
|
export default registery;
|
|
@@ -97,9 +97,20 @@ export abstract class BaseEdge {
|
|
|
97
97
|
...lodStrategy?.animateCfg,
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get merged styles from `getMergedStyles` and assigns the merged styles to the 'mergedStyles' property.
|
|
103
|
+
* @param model - The EdgeDisplayModel to merge the styles from.
|
|
104
|
+
*/
|
|
100
105
|
public mergeStyles(model: EdgeDisplayModel) {
|
|
101
106
|
this.mergedStyles = this.getMergedStyles(model);
|
|
102
107
|
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Merge style
|
|
111
|
+
* @param model - The EdgeDisplayModel to retrieve the merged styles from.
|
|
112
|
+
* @returns The merged styles as a EdgeShapeStyles object.
|
|
113
|
+
*/
|
|
103
114
|
public getMergedStyles(model: EdgeDisplayModel) {
|
|
104
115
|
const { data } = model;
|
|
105
116
|
const dataStyles = {} as EdgeShapeStyles;
|
|
@@ -131,6 +142,7 @@ export abstract class BaseEdge {
|
|
|
131
142
|
|
|
132
143
|
/**
|
|
133
144
|
* Call it after calling draw function to update cache about bounds and zoom levels.
|
|
145
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
134
146
|
*/
|
|
135
147
|
public updateCache(shapeMap) {
|
|
136
148
|
['labelShape', 'labelBackgroundShape'].forEach((id) => {
|
|
@@ -165,6 +177,15 @@ export abstract class BaseEdge {
|
|
|
165
177
|
if (zoom !== 1) this.onZoom(shapeMap, zoom);
|
|
166
178
|
}
|
|
167
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Draw all elements related to the edge.
|
|
182
|
+
* You should call `drawKeyShape` and `drawAnchorShape`,`drawLabelShape`,`drawIconShape`...as you like.
|
|
183
|
+
* @param model The displayed model of this edge, only for drawing and not received by users.
|
|
184
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
185
|
+
* @param diffData An object that contains previous and current data.
|
|
186
|
+
* @param diffState An object that contains previous and current edge's state.
|
|
187
|
+
* @returns An object containing the keyShape and optional labelShape, iconShape, and some otherShapes properties
|
|
188
|
+
*/
|
|
168
189
|
abstract draw(
|
|
169
190
|
model: EdgeDisplayModel,
|
|
170
191
|
sourcePoint: Point,
|
|
@@ -178,6 +199,14 @@ export abstract class BaseEdge {
|
|
|
178
199
|
iconShape?: DisplayObject;
|
|
179
200
|
[otherShapeId: string]: DisplayObject;
|
|
180
201
|
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Perform additional drawing operations or add custom shapes after drawing edge.
|
|
205
|
+
* @param model The displayed model of this edge, only for drawing and not received by users.
|
|
206
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
207
|
+
* @param shapesChanged An array of shape IDs that have changed and need to be updated.
|
|
208
|
+
* @returns An object that contains some new shapes to be added to the edge.
|
|
209
|
+
*/
|
|
181
210
|
public afterDraw(
|
|
182
211
|
model: EdgeDisplayModel,
|
|
183
212
|
shapeMap: { [shapeId: string]: DisplayObject },
|
|
@@ -186,12 +215,27 @@ export abstract class BaseEdge {
|
|
|
186
215
|
return {};
|
|
187
216
|
}
|
|
188
217
|
// shouldUpdate: (model: EdgeDisplayModel, prevModel: EdgeDisplayModel) => boolean = () => true;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Set the state for the edge.
|
|
221
|
+
* @param state state name
|
|
222
|
+
* @param value state value
|
|
223
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
224
|
+
*/
|
|
189
225
|
public setState: (
|
|
190
226
|
name: string,
|
|
191
227
|
value: boolean,
|
|
192
228
|
shapeMap: { [shapeId: string]: DisplayObject },
|
|
193
229
|
) => void;
|
|
194
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Draw the label shape of the edge
|
|
233
|
+
* @param model The displayed model of this edge, only for drawing and not received by users.
|
|
234
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
235
|
+
* @param diffData An object that contains previous and current data.
|
|
236
|
+
* @param diffState An object that contains previous and current edge's state.
|
|
237
|
+
* @returns The display object representing the label shape of the edge.
|
|
238
|
+
*/
|
|
195
239
|
public drawLabelShape(
|
|
196
240
|
model: EdgeDisplayModel,
|
|
197
241
|
shapeMap: EdgeShapeMap,
|
|
@@ -201,7 +245,8 @@ export abstract class BaseEdge {
|
|
|
201
245
|
const { keyShape } = shapeMap;
|
|
202
246
|
|
|
203
247
|
const { labelShape: shapeStyle } = this.mergedStyles;
|
|
204
|
-
if (!shapeStyle) return;
|
|
248
|
+
if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
|
|
249
|
+
|
|
205
250
|
const {
|
|
206
251
|
position,
|
|
207
252
|
offsetX: propsOffsetX,
|
|
@@ -297,6 +342,14 @@ export abstract class BaseEdge {
|
|
|
297
342
|
return this.upsertShape('text', 'labelShape', style, shapeMap, model);
|
|
298
343
|
}
|
|
299
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Draw the label background shape of the edge
|
|
347
|
+
* @param model The displayed model of this edge, only for drawing and not received by users.
|
|
348
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
349
|
+
* @param diffData An object that contains previous and current data.
|
|
350
|
+
* @param diffState An object that contains previous and current edge's state.
|
|
351
|
+
* @returns The display object representing the label background shape of the edge.
|
|
352
|
+
*/
|
|
300
353
|
public drawLabelBackgroundShape(
|
|
301
354
|
model: EdgeDisplayModel,
|
|
302
355
|
shapeMap: EdgeShapeMap,
|
|
@@ -356,6 +409,14 @@ export abstract class BaseEdge {
|
|
|
356
409
|
);
|
|
357
410
|
}
|
|
358
411
|
|
|
412
|
+
/**
|
|
413
|
+
* Draw the icon shape of the edge
|
|
414
|
+
* @param model The displayed model of this edge, only for drawing and not received by users.
|
|
415
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
416
|
+
* @param diffData An object that contains previous and current data.
|
|
417
|
+
* @param diffState An object that contains previous and current edge's state.
|
|
418
|
+
* @returns The display object representing the icon shape of the edge.
|
|
419
|
+
*/
|
|
359
420
|
public drawIconShape(
|
|
360
421
|
model: EdgeDisplayModel,
|
|
361
422
|
shapeMap: EdgeShapeMap,
|
|
@@ -442,6 +503,14 @@ export abstract class BaseEdge {
|
|
|
442
503
|
);
|
|
443
504
|
}
|
|
444
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Draw the halo shape of the edge
|
|
508
|
+
* @param model The displayed model of this edge, only for drawing and not received by users.
|
|
509
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
510
|
+
* @param diffData An object that contains previous and current data.
|
|
511
|
+
* @param diffState An object that contains previous and current edge's state.
|
|
512
|
+
* @returns The display object representing the halo shape of the edge.
|
|
513
|
+
*/
|
|
445
514
|
public drawHaloShape(
|
|
446
515
|
model: EdgeDisplayModel,
|
|
447
516
|
shapeMap: EdgeShapeMap,
|
|
@@ -465,14 +534,27 @@ export abstract class BaseEdge {
|
|
|
465
534
|
);
|
|
466
535
|
}
|
|
467
536
|
|
|
537
|
+
public drawOtherShapes(
|
|
538
|
+
model: EdgeDisplayModel,
|
|
539
|
+
shapeMap: EdgeShapeMap,
|
|
540
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
541
|
+
diffState?: { previous: State[]; current: State[] },
|
|
542
|
+
): { [id: string]: DisplayObject } {
|
|
543
|
+
return {};
|
|
544
|
+
}
|
|
545
|
+
|
|
468
546
|
/**
|
|
469
547
|
* The listener for graph zooming.
|
|
470
548
|
* 1. show / hide some shapes while zoom level changed;
|
|
471
549
|
* 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
|
|
472
|
-
* @param shapeMap
|
|
473
|
-
* @param zoom
|
|
550
|
+
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
551
|
+
* @param zoom The zoom level of the graph.
|
|
474
552
|
*/
|
|
475
|
-
public onZoom = (
|
|
553
|
+
public onZoom = (
|
|
554
|
+
shapeMap: EdgeShapeMap,
|
|
555
|
+
zoom: number,
|
|
556
|
+
cacheHiddenShape = {},
|
|
557
|
+
) => {
|
|
476
558
|
// balance the size for label, badges
|
|
477
559
|
this.balanceShapeSize(shapeMap, zoom);
|
|
478
560
|
|
|
@@ -496,7 +578,10 @@ export abstract class BaseEdge {
|
|
|
496
578
|
// zoomLevel changed, from higher to lower, hide something
|
|
497
579
|
if (firstRender) {
|
|
498
580
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
499
|
-
levelShapes[String(i)]?.forEach((id) =>
|
|
581
|
+
levelShapes[String(i)]?.forEach((id) => {
|
|
582
|
+
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
583
|
+
shapeMap[id]?.hide();
|
|
584
|
+
});
|
|
500
585
|
}
|
|
501
586
|
} else {
|
|
502
587
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
@@ -508,7 +593,8 @@ export abstract class BaseEdge {
|
|
|
508
593
|
} else if (currentLevel > previousLevel) {
|
|
509
594
|
// zoomLevel changed, from lower to higher, show something
|
|
510
595
|
for (let i = currentLevel; i >= minLevel; i--) {
|
|
511
|
-
levelShapes[String(i)]?.forEach((id) =>
|
|
596
|
+
levelShapes[String(i)]?.forEach((id) => {
|
|
597
|
+
if (hiddenShape[id]) return;
|
|
512
598
|
fadeIn(
|
|
513
599
|
id,
|
|
514
600
|
shapeMap[id],
|
|
@@ -516,8 +602,8 @@ export abstract class BaseEdge {
|
|
|
516
602
|
this.mergedStyles[id.replace('Background', '')],
|
|
517
603
|
hiddenShape,
|
|
518
604
|
animateConfig,
|
|
519
|
-
)
|
|
520
|
-
);
|
|
605
|
+
);
|
|
606
|
+
});
|
|
521
607
|
}
|
|
522
608
|
}
|
|
523
609
|
|
|
@@ -557,7 +643,7 @@ export abstract class BaseEdge {
|
|
|
557
643
|
|
|
558
644
|
/**
|
|
559
645
|
* Update the source point { x, y } for the edge. Called in item's draw func.
|
|
560
|
-
* @param point
|
|
646
|
+
* @param point source point
|
|
561
647
|
*/
|
|
562
648
|
public setSourcePoint(point: Point) {
|
|
563
649
|
this.sourcePoint = point;
|
|
@@ -565,7 +651,7 @@ export abstract class BaseEdge {
|
|
|
565
651
|
|
|
566
652
|
/**
|
|
567
653
|
* Update the target point { x, y } for the edge. Called in item's draw func.
|
|
568
|
-
* @param point
|
|
654
|
+
* @param point target point
|
|
569
655
|
*/
|
|
570
656
|
public setTargetPoint(point: Point) {
|
|
571
657
|
this.targetPoint = point;
|
|
@@ -573,12 +659,20 @@ export abstract class BaseEdge {
|
|
|
573
659
|
|
|
574
660
|
/**
|
|
575
661
|
* Update all visible nodes on the canvas to be aware of obstacles. Called in item's draw func.
|
|
576
|
-
* @param nodeMap
|
|
662
|
+
* @param nodeMap The Map object representing the node map, where keys are node IDs and values are nodes.
|
|
577
663
|
*/
|
|
578
664
|
public setNodeMap(nodeMap: Map<ID, Node>) {
|
|
579
665
|
this.nodeMap = nodeMap;
|
|
580
666
|
}
|
|
581
667
|
|
|
668
|
+
/**
|
|
669
|
+
* Adds or updates an arrow marker on the specified position of an edge.
|
|
670
|
+
* @param position - The position where the arrow marker should be added or updated. Can be either 'start' or 'end'.
|
|
671
|
+
* @param arrowConfig - The configuration for the arrow marker. Can be a boolean indicating whether to use the default arrow configuration, or an ArrowStyle object with custom arrow properties.
|
|
672
|
+
* @param bodyStyle - The style of the edge body.
|
|
673
|
+
* @param model - The EdgeDisplayModel that contains the data and style information for the edge.
|
|
674
|
+
* @param resultStyle - The style object where the arrow marker properties will be added or updated.
|
|
675
|
+
*/
|
|
582
676
|
public upsertArrow(
|
|
583
677
|
position: 'start' | 'end',
|
|
584
678
|
arrowConfig: boolean | ArrowStyle,
|
|
@@ -592,12 +686,9 @@ export abstract class BaseEdge {
|
|
|
592
686
|
resultStyle[`${markerField}Offset`] = 0;
|
|
593
687
|
return;
|
|
594
688
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
} else {
|
|
599
|
-
arrowStyle = arrowConfig;
|
|
600
|
-
}
|
|
689
|
+
const arrowStyle = isBoolean(arrowConfig)
|
|
690
|
+
? ({ ...DEFAULT_ARROW_CONFIG } as ArrowStyle)
|
|
691
|
+
: arrowConfig;
|
|
601
692
|
const {
|
|
602
693
|
type = 'triangle',
|
|
603
694
|
width = 10,
|
|
@@ -606,14 +697,13 @@ export abstract class BaseEdge {
|
|
|
606
697
|
offset = 0,
|
|
607
698
|
...others
|
|
608
699
|
} = arrowStyle;
|
|
609
|
-
const path = propPath ? propPath : getArrowPath(type, width, height);
|
|
610
700
|
resultStyle[markerField] = this.upsertShape(
|
|
611
701
|
'path',
|
|
612
702
|
`${markerField}Shape`,
|
|
613
703
|
{
|
|
614
704
|
...bodyStyle,
|
|
615
705
|
fill: type === 'simple' ? '' : bodyStyle.stroke,
|
|
616
|
-
path,
|
|
706
|
+
path: propPath || getArrowPath(type, width, height),
|
|
617
707
|
anchor: '0.5 0.5',
|
|
618
708
|
transformOrigin: 'center',
|
|
619
709
|
...others,
|
|
@@ -624,6 +714,15 @@ export abstract class BaseEdge {
|
|
|
624
714
|
resultStyle[`${markerField}Offset`] = width / 2 + offset;
|
|
625
715
|
}
|
|
626
716
|
|
|
717
|
+
/**
|
|
718
|
+
* Create (if does not exit in shapeMap) or update the shape according to the configurations.
|
|
719
|
+
* @param type shape's type
|
|
720
|
+
* @param id unique string to indicates the shape
|
|
721
|
+
* @param style style to be updated
|
|
722
|
+
* @param shapeMap the shape map of a edge
|
|
723
|
+
* @param model data model of the edge
|
|
724
|
+
* @returns The display object representing the shape.
|
|
725
|
+
*/
|
|
627
726
|
public upsertShape(
|
|
628
727
|
type: SHAPE_TYPE,
|
|
629
728
|
id: string,
|
|
@@ -35,7 +35,7 @@ export class LineEdge extends BaseEdge {
|
|
|
35
35
|
): EdgeShapeMap {
|
|
36
36
|
const { data = {} } = model;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
let shapes: EdgeShapeMap = { keyShape: undefined };
|
|
39
39
|
|
|
40
40
|
shapes.keyShape = this.drawKeyShape(
|
|
41
41
|
model,
|
|
@@ -66,7 +66,13 @@ export class LineEdge extends BaseEdge {
|
|
|
66
66
|
shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// otherShapes
|
|
70
|
+
if (data.otherShapes) {
|
|
71
|
+
shapes = {
|
|
72
|
+
...shapes,
|
|
73
|
+
...this.drawOtherShapes(model, shapeMap, diffData),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
70
76
|
|
|
71
77
|
return shapes;
|
|
72
78
|
}
|