@antv/g6 5.0.0-alpha.8 → 5.0.0-beta.0
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 +6 -19
- package/esm/api-doc/behaviors.d.ts +2 -0
- package/esm/api-doc/behaviors.js +2 -0
- package/esm/api-doc/behaviors.js.map +1 -0
- package/esm/api-doc/graph.d.ts +4 -0
- package/esm/api-doc/graph.js +4 -0
- package/esm/api-doc/graph.js.map +1 -0
- package/esm/api-doc/item.d.ts +9 -0
- package/esm/api-doc/item.js +3 -0
- package/esm/api-doc/item.js.map +1 -0
- package/esm/api-doc/layout.d.ts +1 -0
- package/esm/api-doc/layout.js +2 -0
- package/esm/api-doc/layout.js.map +1 -0
- package/esm/api-doc/plugins.d.ts +1 -0
- package/esm/api-doc/plugins.js +2 -0
- package/esm/api-doc/plugins.js.map +1 -0
- package/esm/api-doc/types.d.ts +0 -0
- package/esm/api-doc/types.js +3 -0
- package/esm/api-doc/types.js.map +1 -0
- package/esm/api-doc/util.d.ts +3 -0
- package/esm/api-doc/util.js +4 -0
- package/esm/api-doc/util.js.map +1 -0
- package/esm/constant/shape.d.ts +7 -14
- package/esm/constant/shape.js +1 -0
- package/esm/constant/shape.js.map +1 -1
- package/esm/index.d.ts +215 -95
- package/esm/index.js +11 -4
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +79 -2
- package/esm/item/combo.js +186 -2
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +15 -12
- package/esm/item/edge.js +40 -14
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +12 -10
- package/esm/item/item.js +155 -83
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +32 -23
- package/esm/item/node.js +70 -49
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +28 -4
- package/esm/runtime/controller/data.js +562 -173
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/interaction.d.ts +1 -0
- package/esm/runtime/controller/interaction.js +23 -8
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +47 -5
- package/esm/runtime/controller/item.js +712 -122
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +4 -1
- package/esm/runtime/controller/layout.js +109 -13
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +11 -0
- package/esm/runtime/controller/plugin.js +39 -6
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/theme.js +8 -4
- package/esm/runtime/controller/theme.js.map +1 -1
- package/esm/runtime/graph.d.ts +226 -47
- package/esm/runtime/graph.js +710 -90
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.d.ts +2 -3
- package/esm/stdlib/behavior/activate-relations.js +13 -9
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.d.ts +3 -4
- package/esm/stdlib/behavior/brush-select.js +2 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.d.ts +5 -3
- package/esm/stdlib/behavior/click-select.js +21 -7
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/collapse-expand-combo.d.ts +28 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js +35 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/esm/stdlib/behavior/collapse-expand-tree.d.ts +44 -0
- package/esm/stdlib/behavior/collapse-expand-tree.js +69 -0
- package/esm/stdlib/behavior/collapse-expand-tree.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +1 -2
- package/esm/stdlib/behavior/drag-canvas.js +15 -11
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +111 -0
- package/esm/stdlib/behavior/drag-combo.js +380 -0
- package/esm/stdlib/behavior/drag-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +33 -13
- package/esm/stdlib/behavior/drag-node.js +252 -67
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/hover-activate.d.ts +2 -1
- package/esm/stdlib/behavior/hover-activate.js +2 -0
- package/esm/stdlib/behavior/hover-activate.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +15 -0
- package/esm/stdlib/behavior/index.js +16 -0
- package/esm/stdlib/behavior/index.js.map +1 -0
- package/esm/stdlib/behavior/lasso-select.d.ts +7 -3
- package/esm/stdlib/behavior/lasso-select.js +2 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +2 -3
- package/esm/stdlib/behavior/orbit-canvas-3d.js +2 -2
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +1 -2
- package/esm/stdlib/behavior/rotate-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/rotate-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.d.ts +2 -3
- package/esm/stdlib/behavior/track-canvas-3d.js +2 -2
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/types.d.ts +13 -0
- package/esm/stdlib/behavior/types.js +2 -0
- package/esm/stdlib/behavior/types.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +1 -2
- package/esm/stdlib/behavior/zoom-canvas-3d.js +7 -7
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -2
- package/esm/stdlib/behavior/zoom-canvas.js +20 -18
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/index.d.ts +3 -0
- package/esm/stdlib/data/index.js +4 -0
- package/esm/stdlib/data/index.js.map +1 -0
- package/esm/stdlib/data/mapNodeSize.d.ts +12 -0
- package/esm/stdlib/data/mapNodeSize.js +43 -0
- package/esm/stdlib/data/mapNodeSize.js.map +1 -0
- package/esm/stdlib/data/transformV4Data.d.ts +9 -0
- package/esm/stdlib/data/transformV4Data.js +142 -0
- package/esm/stdlib/data/transformV4Data.js.map +1 -0
- package/esm/stdlib/data/validateData.d.ts +9 -0
- package/esm/stdlib/data/validateData.js +98 -0
- package/esm/stdlib/data/validateData.js.map +1 -0
- package/esm/stdlib/index.d.ts +115 -49
- package/esm/stdlib/index.js +156 -37
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/combo/circle.d.ts +29 -0
- package/esm/stdlib/item/combo/circle.js +56 -0
- package/esm/stdlib/item/combo/circle.js.map +1 -0
- package/esm/stdlib/item/combo/index.d.ts +2 -0
- package/esm/stdlib/item/combo/index.js +3 -0
- package/esm/stdlib/item/combo/index.js.map +1 -0
- package/esm/stdlib/item/combo/rect.d.ts +31 -0
- package/esm/stdlib/item/combo/rect.js +65 -0
- package/esm/stdlib/item/combo/rect.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +12 -3
- package/esm/stdlib/item/edge/base.js +39 -5
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizontal.d.ts +36 -0
- package/esm/stdlib/item/edge/cubic-horizontal.js +56 -0
- package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -0
- package/esm/stdlib/item/edge/cubic-vertical.d.ts +36 -0
- package/esm/stdlib/item/edge/cubic-vertical.js +56 -0
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/esm/stdlib/item/edge/cubic.d.ts +59 -0
- package/esm/stdlib/item/edge/cubic.js +116 -0
- package/esm/stdlib/item/edge/cubic.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +6 -0
- package/esm/stdlib/item/edge/index.js +6 -0
- package/esm/stdlib/item/edge/index.js.map +1 -1
- package/esm/stdlib/item/edge/line.d.ts +1 -1
- package/esm/stdlib/item/edge/line.js +16 -1
- package/esm/stdlib/item/edge/line.js.map +1 -1
- package/esm/stdlib/item/edge/loop.d.ts +32 -0
- package/esm/stdlib/item/edge/loop.js +115 -0
- package/esm/stdlib/item/edge/loop.js.map +1 -0
- package/esm/stdlib/item/edge/polyline.d.ts +44 -0
- package/esm/stdlib/item/edge/polyline.js +92 -0
- package/esm/stdlib/item/edge/polyline.js.map +1 -0
- package/esm/stdlib/item/edge/quadratic.d.ts +40 -0
- package/esm/stdlib/item/edge/quadratic.js +78 -0
- package/esm/stdlib/item/edge/quadratic.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +83 -38
- package/esm/stdlib/item/node/base.js +100 -15
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.js +1 -1
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/circle.js +5 -5
- package/esm/stdlib/item/node/circle.js.map +1 -1
- package/esm/stdlib/item/node/diamond.d.ts +32 -0
- package/esm/stdlib/item/node/diamond.js +79 -0
- package/esm/stdlib/item/node/diamond.js.map +1 -0
- package/esm/stdlib/item/node/donut.d.ts +70 -0
- package/esm/stdlib/item/node/donut.js +207 -0
- package/esm/stdlib/item/node/donut.js.map +1 -0
- package/esm/stdlib/item/node/ellipse.d.ts +32 -0
- package/esm/stdlib/item/node/ellipse.js +71 -0
- package/esm/stdlib/item/node/ellipse.js.map +1 -0
- package/esm/stdlib/item/node/hexagon.d.ts +33 -0
- package/esm/stdlib/item/node/hexagon.js +102 -0
- package/esm/stdlib/item/node/hexagon.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +8 -0
- package/esm/stdlib/item/node/index.js +8 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/item/node/modelRect.d.ts +61 -0
- package/esm/stdlib/item/node/modelRect.js +186 -0
- package/esm/stdlib/item/node/modelRect.js.map +1 -0
- package/esm/stdlib/item/node/rect.d.ts +32 -0
- package/esm/stdlib/item/node/rect.js +75 -0
- package/esm/stdlib/item/node/rect.js.map +1 -0
- package/esm/stdlib/item/node/star.d.ts +34 -0
- package/esm/stdlib/item/node/star.js +115 -0
- package/esm/stdlib/item/node/star.js.map +1 -0
- package/esm/stdlib/item/node/triangle.d.ts +44 -0
- package/esm/stdlib/item/node/triangle.js +177 -0
- package/esm/stdlib/item/node/triangle.js.map +1 -0
- package/esm/stdlib/plugin/fisheye/index.d.ts +130 -0
- package/esm/stdlib/plugin/fisheye/index.js +488 -0
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -0
- package/esm/stdlib/plugin/grid/index.d.ts +36 -0
- package/esm/stdlib/plugin/grid/index.js +81 -0
- package/esm/stdlib/plugin/grid/index.js.map +1 -0
- package/esm/stdlib/plugin/history/combo-command.d.ts +9 -0
- package/esm/stdlib/plugin/history/combo-command.js +21 -0
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -0
- package/esm/stdlib/plugin/history/command.d.ts +18 -0
- package/esm/stdlib/plugin/history/command.js +51 -0
- package/esm/stdlib/plugin/history/command.js.map +1 -0
- package/esm/stdlib/plugin/history/index.d.ts +112 -0
- package/esm/stdlib/plugin/history/index.js +275 -0
- package/esm/stdlib/plugin/history/index.js.map +1 -0
- package/esm/stdlib/plugin/history/item-data-command.d.ts +14 -0
- package/esm/stdlib/plugin/history/item-data-command.js +63 -0
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -0
- package/esm/stdlib/plugin/history/layer-updated-command.d.ts +9 -0
- package/esm/stdlib/plugin/history/layer-updated-command.js +21 -0
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -0
- package/esm/stdlib/plugin/history/state-updated-command.d.ts +9 -0
- package/esm/stdlib/plugin/history/state-updated-command.js +20 -0
- package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -0
- package/esm/stdlib/plugin/history/visibility-updated-command.d.ts +10 -0
- package/esm/stdlib/plugin/history/visibility-updated-command.js +23 -0
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -0
- package/esm/stdlib/plugin/hull/bubbleset.d.ts +9 -0
- package/esm/stdlib/plugin/hull/bubbleset.js +592 -0
- package/esm/stdlib/plugin/hull/bubbleset.js.map +1 -0
- package/esm/stdlib/plugin/hull/convexHull.d.ts +14 -0
- package/esm/stdlib/plugin/hull/convexHull.js +56 -0
- package/esm/stdlib/plugin/hull/convexHull.js.map +1 -0
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +87 -0
- package/esm/stdlib/plugin/hull/hullComponent.js +382 -0
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -0
- package/esm/stdlib/plugin/hull/index.d.ts +59 -0
- package/esm/stdlib/plugin/hull/index.js +161 -0
- package/esm/stdlib/plugin/hull/index.js.map +1 -0
- package/esm/stdlib/plugin/hull/types.d.ts +15 -0
- package/esm/stdlib/plugin/hull/types.js +2 -0
- package/esm/stdlib/plugin/hull/types.js.map +1 -0
- package/esm/stdlib/plugin/hull/util.d.ts +77 -0
- package/esm/stdlib/plugin/hull/util.js +401 -0
- package/esm/stdlib/plugin/hull/util.js.map +1 -0
- package/esm/stdlib/plugin/index.d.ts +8 -0
- package/esm/stdlib/plugin/index.js +9 -0
- package/esm/stdlib/plugin/index.js.map +1 -0
- package/esm/stdlib/plugin/legend/index.d.ts +45 -3
- package/esm/stdlib/plugin/legend/index.js +47 -42
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/menu/index.d.ts +55 -0
- package/esm/stdlib/plugin/menu/index.js +237 -0
- package/esm/stdlib/plugin/menu/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +11 -3
- package/esm/stdlib/plugin/minimap/index.js +19 -21
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +59 -0
- package/esm/stdlib/plugin/toolbar/index.js +215 -0
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -0
- package/esm/stdlib/plugin/tooltip/index.d.ts +96 -0
- package/esm/stdlib/plugin/tooltip/index.js +378 -0
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -0
- package/esm/stdlib/plugin/types.d.ts +8 -0
- package/esm/stdlib/plugin/types.js +2 -0
- package/esm/stdlib/plugin/types.js.map +1 -0
- package/esm/stdlib/theme/dark.d.ts +1 -2
- package/esm/stdlib/theme/dark.js +13 -1
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/index.d.ts +2 -0
- package/esm/stdlib/theme/index.js +3 -0
- package/esm/stdlib/theme/index.js.map +1 -0
- package/esm/stdlib/theme/light.d.ts +1 -2
- package/esm/stdlib/theme/light.js +65 -10
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/base.d.ts +1 -1
- package/esm/stdlib/themeSolver/base.js +1 -1
- package/esm/stdlib/themeSolver/base.js.map +1 -1
- package/esm/stdlib/themeSolver/index.d.ts +3 -0
- package/esm/stdlib/themeSolver/index.js +4 -0
- package/esm/stdlib/themeSolver/index.js.map +1 -0
- package/esm/stdlib/themeSolver/spec.d.ts +2 -4
- package/esm/stdlib/themeSolver/spec.js +2 -2
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/stdlib/themeSolver/subject.d.ts +2 -4
- package/esm/stdlib/themeSolver/subject.js +2 -2
- package/esm/stdlib/themeSolver/subject.js.map +1 -1
- package/esm/types/behavior.js.map +1 -1
- package/esm/types/combo.d.ts +51 -3
- package/esm/types/common.d.ts +10 -0
- package/esm/types/data.d.ts +13 -7
- package/esm/types/edge.d.ts +19 -5
- package/esm/types/event.d.ts +9 -1
- package/esm/types/event.js +8 -8
- package/esm/types/event.js.map +1 -1
- package/esm/types/graph.d.ts +169 -20
- package/esm/types/history.d.ts +28 -0
- package/esm/types/history.js +6 -0
- package/esm/types/history.js.map +1 -0
- package/esm/types/hook.d.ts +33 -6
- package/esm/types/index.d.ts +11 -5
- package/esm/types/index.js.map +1 -1
- package/esm/types/item.d.ts +14 -8
- package/esm/types/item.js.map +1 -1
- package/esm/types/layout.d.ts +4 -1
- package/esm/types/loop.d.ts +21 -0
- package/esm/types/loop.js +12 -0
- package/esm/types/loop.js.map +1 -0
- package/esm/types/node.d.ts +90 -10
- package/esm/types/plugin.d.ts +4 -0
- package/esm/types/plugin.js +1 -1
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +26 -9
- package/esm/types/theme.d.ts +76 -10
- package/esm/types/theme.js +1 -2
- package/esm/types/theme.js.map +1 -1
- package/esm/util/animate.d.ts +2 -2
- package/esm/util/animate.js +52 -17
- package/esm/util/animate.js.map +1 -1
- package/esm/util/array.d.ts +8 -0
- package/esm/util/array.js +11 -1
- package/esm/util/array.js.map +1 -1
- package/esm/util/arrow.d.ts +17 -0
- package/esm/util/arrow.js +56 -0
- package/esm/util/arrow.js.map +1 -0
- package/esm/util/bbox.d.ts +106 -0
- package/esm/util/bbox.js +255 -0
- package/esm/util/bbox.js.map +1 -0
- package/esm/util/behavior.d.ts +2 -0
- package/esm/util/behavior.js +12 -0
- package/esm/util/behavior.js.map +1 -0
- package/esm/util/canvas.d.ts +1 -2
- package/esm/util/canvas.js +11 -20
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/data.d.ts +96 -0
- package/esm/util/data.js +262 -0
- package/esm/util/data.js.map +1 -0
- package/esm/util/event.d.ts +29 -1
- package/esm/util/event.js +70 -0
- package/esm/util/event.js.map +1 -1
- package/esm/util/extend.d.ts +8 -2
- package/esm/util/extend.js.map +1 -1
- package/esm/util/index.d.ts +41 -3
- package/esm/util/index.js +20 -1
- package/esm/util/index.js.map +1 -1
- package/esm/util/item.d.ts +2 -1
- package/esm/util/item.js +38 -13
- package/esm/util/item.js.map +1 -1
- package/esm/util/layout.d.ts +40 -0
- package/esm/util/layout.js +160 -0
- package/esm/util/layout.js.map +1 -0
- package/esm/util/loop.d.ts +37 -0
- package/esm/util/loop.js +104 -0
- package/esm/util/loop.js.map +1 -0
- package/esm/util/mapper.js +4 -9
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/math.d.ts +15 -0
- package/esm/util/math.js +14 -0
- package/esm/util/math.js.map +1 -1
- package/esm/util/mock.d.ts +30 -0
- package/esm/util/mock.js +69 -0
- package/esm/util/mock.js.map +1 -0
- package/esm/util/path.d.ts +11 -0
- package/esm/util/path.js +44 -0
- package/esm/util/path.js.map +1 -0
- package/esm/util/point.d.ts +24 -2
- package/esm/util/point.js +27 -2
- package/esm/util/point.js.map +1 -1
- package/esm/util/polyline.d.ts +113 -0
- package/esm/util/polyline.js +505 -0
- package/esm/util/polyline.js.map +1 -0
- package/esm/util/router.d.ts +31 -0
- package/esm/util/router.js +380 -0
- package/esm/util/router.js.map +1 -0
- package/esm/util/shape.d.ts +39 -4
- package/esm/util/shape.js +118 -2
- package/esm/util/shape.js.map +1 -1
- package/esm/util/shape3d.d.ts +1 -1
- package/esm/util/shape3d.js +12 -6
- package/esm/util/shape3d.js.map +1 -1
- package/esm/util/type.d.ts +6 -0
- package/esm/util/type.js +7 -1
- package/esm/util/type.js.map +1 -1
- package/esm/util/zoom.d.ts +2 -2
- package/esm/util/zoom.js +6 -2
- package/esm/util/zoom.js.map +1 -1
- package/lib/api-doc/behaviors.d.ts +2 -0
- package/lib/api-doc/behaviors.js +18 -0
- package/lib/api-doc/behaviors.js.map +1 -0
- package/lib/api-doc/graph.d.ts +4 -0
- package/lib/api-doc/graph.js +11 -0
- package/lib/api-doc/graph.js.map +1 -0
- package/lib/api-doc/item.d.ts +9 -0
- package/lib/api-doc/item.js +21 -0
- package/lib/api-doc/item.js.map +1 -0
- package/lib/api-doc/layout.d.ts +1 -0
- package/lib/api-doc/layout.js +3 -0
- package/lib/api-doc/layout.js.map +1 -0
- package/lib/api-doc/plugins.d.ts +1 -0
- package/lib/api-doc/plugins.js +18 -0
- package/lib/api-doc/plugins.js.map +1 -0
- package/lib/api-doc/types.d.ts +0 -0
- package/lib/api-doc/types.js +3 -0
- package/lib/api-doc/types.js.map +1 -0
- package/lib/api-doc/util.d.ts +3 -0
- package/lib/api-doc/util.js +10 -0
- package/lib/api-doc/util.js.map +1 -0
- package/lib/constant/shape.d.ts +7 -14
- package/lib/constant/shape.js +1 -0
- package/lib/constant/shape.js.map +1 -1
- package/lib/index.d.ts +215 -95
- package/lib/index.js +13 -3
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +79 -2
- package/lib/item/combo.js +186 -2
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +15 -12
- package/lib/item/edge.js +40 -14
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +12 -10
- package/lib/item/item.js +153 -81
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +32 -23
- package/lib/item/node.js +70 -49
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +28 -4
- package/lib/runtime/controller/data.js +561 -172
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/interaction.d.ts +1 -0
- package/lib/runtime/controller/interaction.js +22 -7
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +47 -5
- package/lib/runtime/controller/item.js +710 -120
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +4 -1
- package/lib/runtime/controller/layout.js +132 -13
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +11 -0
- package/lib/runtime/controller/plugin.js +39 -6
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/theme.js +8 -4
- package/lib/runtime/controller/theme.js.map +1 -1
- package/lib/runtime/graph.d.ts +226 -47
- package/lib/runtime/graph.js +709 -89
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.d.ts +2 -3
- package/lib/stdlib/behavior/activate-relations.js +14 -9
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.d.ts +3 -4
- package/lib/stdlib/behavior/brush-select.js +3 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.d.ts +5 -3
- package/lib/stdlib/behavior/click-select.js +22 -7
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/collapse-expand-combo.d.ts +28 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js +39 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/lib/stdlib/behavior/collapse-expand-tree.d.ts +44 -0
- package/lib/stdlib/behavior/collapse-expand-tree.js +73 -0
- package/lib/stdlib/behavior/collapse-expand-tree.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +1 -2
- package/lib/stdlib/behavior/drag-canvas.js +16 -11
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +111 -0
- package/lib/stdlib/behavior/drag-combo.js +384 -0
- package/lib/stdlib/behavior/drag-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +33 -13
- package/lib/stdlib/behavior/drag-node.js +252 -66
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/hover-activate.d.ts +2 -1
- package/lib/stdlib/behavior/hover-activate.js +2 -0
- package/lib/stdlib/behavior/hover-activate.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +15 -0
- package/lib/stdlib/behavior/index.js +32 -0
- package/lib/stdlib/behavior/index.js.map +1 -0
- package/lib/stdlib/behavior/lasso-select.d.ts +7 -3
- package/lib/stdlib/behavior/lasso-select.js +4 -6
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +2 -3
- package/lib/stdlib/behavior/orbit-canvas-3d.js +4 -6
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +1 -2
- package/lib/stdlib/behavior/rotate-canvas-3d.js +2 -1
- package/lib/stdlib/behavior/rotate-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.d.ts +2 -3
- package/lib/stdlib/behavior/track-canvas-3d.js +4 -6
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/types.d.ts +13 -0
- package/lib/stdlib/behavior/types.js +3 -0
- package/lib/stdlib/behavior/types.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +1 -2
- package/lib/stdlib/behavior/zoom-canvas-3d.js +8 -7
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -2
- package/lib/stdlib/behavior/zoom-canvas.js +21 -18
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/index.d.ts +3 -0
- package/lib/stdlib/data/index.js +20 -0
- package/lib/stdlib/data/index.js.map +1 -0
- package/lib/stdlib/data/mapNodeSize.d.ts +12 -0
- package/lib/stdlib/data/mapNodeSize.js +47 -0
- package/lib/stdlib/data/mapNodeSize.js.map +1 -0
- package/lib/stdlib/data/transformV4Data.d.ts +9 -0
- package/lib/stdlib/data/transformV4Data.js +146 -0
- package/lib/stdlib/data/transformV4Data.js.map +1 -0
- package/lib/stdlib/data/validateData.d.ts +9 -0
- package/lib/stdlib/data/validateData.js +102 -0
- package/lib/stdlib/data/validateData.js.map +1 -0
- package/lib/stdlib/index.d.ts +115 -49
- package/lib/stdlib/index.js +190 -47
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/combo/circle.d.ts +29 -0
- package/lib/stdlib/item/combo/circle.js +60 -0
- package/lib/stdlib/item/combo/circle.js.map +1 -0
- package/lib/stdlib/item/combo/index.d.ts +2 -0
- package/lib/stdlib/item/combo/index.js +19 -0
- package/lib/stdlib/item/combo/index.js.map +1 -0
- package/lib/stdlib/item/combo/rect.d.ts +31 -0
- package/lib/stdlib/item/combo/rect.js +69 -0
- package/lib/stdlib/item/combo/rect.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +12 -3
- package/lib/stdlib/item/edge/base.js +38 -4
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizontal.d.ts +36 -0
- package/lib/stdlib/item/edge/cubic-horizontal.js +60 -0
- package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -0
- package/lib/stdlib/item/edge/cubic-vertical.d.ts +36 -0
- package/lib/stdlib/item/edge/cubic-vertical.js +60 -0
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/lib/stdlib/item/edge/cubic.d.ts +59 -0
- package/lib/stdlib/item/edge/cubic.js +120 -0
- package/lib/stdlib/item/edge/cubic.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +6 -0
- package/lib/stdlib/item/edge/index.js +6 -0
- package/lib/stdlib/item/edge/index.js.map +1 -1
- package/lib/stdlib/item/edge/line.d.ts +1 -1
- package/lib/stdlib/item/edge/line.js +16 -1
- package/lib/stdlib/item/edge/line.js.map +1 -1
- package/lib/stdlib/item/edge/loop.d.ts +32 -0
- package/lib/stdlib/item/edge/loop.js +119 -0
- package/lib/stdlib/item/edge/loop.js.map +1 -0
- package/lib/stdlib/item/edge/polyline.d.ts +44 -0
- package/lib/stdlib/item/edge/polyline.js +96 -0
- package/lib/stdlib/item/edge/polyline.js.map +1 -0
- package/lib/stdlib/item/edge/quadratic.d.ts +40 -0
- package/lib/stdlib/item/edge/quadratic.js +82 -0
- package/lib/stdlib/item/edge/quadratic.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +83 -38
- package/lib/stdlib/item/node/base.js +100 -15
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.js +1 -1
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/circle.js +5 -5
- package/lib/stdlib/item/node/circle.js.map +1 -1
- package/lib/stdlib/item/node/diamond.d.ts +32 -0
- package/lib/stdlib/item/node/diamond.js +83 -0
- package/lib/stdlib/item/node/diamond.js.map +1 -0
- package/lib/stdlib/item/node/donut.d.ts +70 -0
- package/lib/stdlib/item/node/donut.js +211 -0
- package/lib/stdlib/item/node/donut.js.map +1 -0
- package/lib/stdlib/item/node/ellipse.d.ts +32 -0
- package/lib/stdlib/item/node/ellipse.js +75 -0
- package/lib/stdlib/item/node/ellipse.js.map +1 -0
- package/lib/stdlib/item/node/hexagon.d.ts +33 -0
- package/lib/stdlib/item/node/hexagon.js +106 -0
- package/lib/stdlib/item/node/hexagon.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +8 -0
- package/lib/stdlib/item/node/index.js +8 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/item/node/modelRect.d.ts +61 -0
- package/lib/stdlib/item/node/modelRect.js +190 -0
- package/lib/stdlib/item/node/modelRect.js.map +1 -0
- package/lib/stdlib/item/node/rect.d.ts +32 -0
- package/lib/stdlib/item/node/rect.js +79 -0
- package/lib/stdlib/item/node/rect.js.map +1 -0
- package/lib/stdlib/item/node/star.d.ts +34 -0
- package/lib/stdlib/item/node/star.js +119 -0
- package/lib/stdlib/item/node/star.js.map +1 -0
- package/lib/stdlib/item/node/triangle.d.ts +44 -0
- package/lib/stdlib/item/node/triangle.js +181 -0
- package/lib/stdlib/item/node/triangle.js.map +1 -0
- package/lib/stdlib/plugin/fisheye/index.d.ts +130 -0
- package/lib/stdlib/plugin/fisheye/index.js +492 -0
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -0
- package/lib/stdlib/plugin/grid/index.d.ts +36 -0
- package/lib/stdlib/plugin/grid/index.js +85 -0
- package/lib/stdlib/plugin/grid/index.js.map +1 -0
- package/lib/stdlib/plugin/history/combo-command.d.ts +9 -0
- package/lib/stdlib/plugin/history/combo-command.js +25 -0
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -0
- package/lib/stdlib/plugin/history/command.d.ts +18 -0
- package/lib/stdlib/plugin/history/command.js +54 -0
- package/lib/stdlib/plugin/history/command.js.map +1 -0
- package/lib/stdlib/plugin/history/index.d.ts +112 -0
- package/lib/stdlib/plugin/history/index.js +283 -0
- package/lib/stdlib/plugin/history/index.js.map +1 -0
- package/lib/stdlib/plugin/history/item-data-command.d.ts +14 -0
- package/lib/stdlib/plugin/history/item-data-command.js +67 -0
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -0
- package/lib/stdlib/plugin/history/layer-updated-command.d.ts +9 -0
- package/lib/stdlib/plugin/history/layer-updated-command.js +25 -0
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -0
- package/lib/stdlib/plugin/history/state-updated-command.d.ts +9 -0
- package/lib/stdlib/plugin/history/state-updated-command.js +24 -0
- package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -0
- package/lib/stdlib/plugin/history/visibility-updated-command.d.ts +10 -0
- package/lib/stdlib/plugin/history/visibility-updated-command.js +27 -0
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -0
- package/lib/stdlib/plugin/hull/bubbleset.d.ts +9 -0
- package/lib/stdlib/plugin/hull/bubbleset.js +596 -0
- package/lib/stdlib/plugin/hull/bubbleset.js.map +1 -0
- package/lib/stdlib/plugin/hull/convexHull.d.ts +14 -0
- package/lib/stdlib/plugin/hull/convexHull.js +61 -0
- package/lib/stdlib/plugin/hull/convexHull.js.map +1 -0
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +87 -0
- package/lib/stdlib/plugin/hull/hullComponent.js +385 -0
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -0
- package/lib/stdlib/plugin/hull/index.d.ts +59 -0
- package/lib/stdlib/plugin/hull/index.js +167 -0
- package/lib/stdlib/plugin/hull/index.js.map +1 -0
- package/lib/stdlib/plugin/hull/types.d.ts +15 -0
- package/lib/stdlib/plugin/hull/types.js +3 -0
- package/lib/stdlib/plugin/hull/types.js.map +1 -0
- package/lib/stdlib/plugin/hull/util.d.ts +77 -0
- package/lib/stdlib/plugin/hull/util.js +419 -0
- package/lib/stdlib/plugin/hull/util.js.map +1 -0
- package/lib/stdlib/plugin/index.d.ts +8 -0
- package/lib/stdlib/plugin/index.js +25 -0
- package/lib/stdlib/plugin/index.js.map +1 -0
- package/lib/stdlib/plugin/legend/index.d.ts +45 -3
- package/lib/stdlib/plugin/legend/index.js +46 -40
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/menu/index.d.ts +55 -0
- package/lib/stdlib/plugin/menu/index.js +244 -0
- package/lib/stdlib/plugin/menu/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +11 -3
- package/lib/stdlib/plugin/minimap/index.js +19 -20
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +59 -0
- package/lib/stdlib/plugin/toolbar/index.js +222 -0
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -0
- package/lib/stdlib/plugin/tooltip/index.d.ts +96 -0
- package/lib/stdlib/plugin/tooltip/index.js +385 -0
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -0
- package/lib/stdlib/plugin/types.d.ts +8 -0
- package/lib/stdlib/plugin/types.js +3 -0
- package/lib/stdlib/plugin/types.js.map +1 -0
- package/lib/stdlib/theme/dark.d.ts +1 -2
- package/lib/stdlib/theme/dark.js +14 -1
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/index.d.ts +2 -0
- package/lib/stdlib/theme/index.js +19 -0
- package/lib/stdlib/theme/index.js.map +1 -0
- package/lib/stdlib/theme/light.d.ts +1 -2
- package/lib/stdlib/theme/light.js +66 -10
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/base.d.ts +1 -1
- package/lib/stdlib/themeSolver/base.js +2 -1
- package/lib/stdlib/themeSolver/base.js.map +1 -1
- package/lib/stdlib/themeSolver/index.d.ts +3 -0
- package/lib/stdlib/themeSolver/index.js +20 -0
- package/lib/stdlib/themeSolver/index.js.map +1 -0
- package/lib/stdlib/themeSolver/spec.d.ts +2 -4
- package/lib/stdlib/themeSolver/spec.js +4 -6
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/stdlib/themeSolver/subject.d.ts +2 -4
- package/lib/stdlib/themeSolver/subject.js +4 -4
- package/lib/stdlib/themeSolver/subject.js.map +1 -1
- package/lib/types/behavior.js.map +1 -1
- package/lib/types/combo.d.ts +51 -3
- package/lib/types/common.d.ts +10 -0
- package/lib/types/data.d.ts +13 -7
- package/lib/types/edge.d.ts +19 -5
- package/lib/types/event.d.ts +9 -1
- package/lib/types/event.js +10 -10
- package/lib/types/event.js.map +1 -1
- package/lib/types/graph.d.ts +169 -20
- package/lib/types/history.d.ts +28 -0
- package/lib/types/history.js +9 -0
- package/lib/types/history.js.map +1 -0
- package/lib/types/hook.d.ts +33 -6
- package/lib/types/index.d.ts +11 -5
- package/lib/types/index.js.map +1 -1
- package/lib/types/item.d.ts +14 -8
- package/lib/types/item.js +1 -1
- package/lib/types/item.js.map +1 -1
- package/lib/types/layout.d.ts +4 -1
- package/lib/types/loop.d.ts +21 -0
- package/lib/types/loop.js +15 -0
- package/lib/types/loop.js.map +1 -0
- package/lib/types/node.d.ts +90 -10
- package/lib/types/plugin.d.ts +4 -0
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +26 -9
- package/lib/types/theme.d.ts +76 -10
- package/lib/types/theme.js +1 -2
- package/lib/types/theme.js.map +1 -1
- package/lib/util/animate.d.ts +2 -2
- package/lib/util/animate.js +52 -17
- package/lib/util/animate.js.map +1 -1
- package/lib/util/array.d.ts +8 -0
- package/lib/util/array.js +13 -2
- package/lib/util/array.js.map +1 -1
- package/lib/util/arrow.d.ts +17 -0
- package/lib/util/arrow.js +60 -0
- package/lib/util/arrow.js.map +1 -0
- package/lib/util/bbox.d.ts +106 -0
- package/lib/util/bbox.js +273 -0
- package/lib/util/bbox.js.map +1 -0
- package/lib/util/behavior.d.ts +2 -0
- package/lib/util/behavior.js +16 -0
- package/lib/util/behavior.js.map +1 -0
- package/lib/util/canvas.d.ts +1 -2
- package/lib/util/canvas.js +11 -20
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/data.d.ts +96 -0
- package/lib/util/data.js +276 -0
- package/lib/util/data.js.map +1 -0
- package/lib/util/event.d.ts +29 -1
- package/lib/util/event.js +73 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/extend.d.ts +8 -2
- package/lib/util/extend.js.map +1 -1
- package/lib/util/index.d.ts +41 -3
- package/lib/util/index.js +20 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/item.d.ts +2 -1
- package/lib/util/item.js +38 -13
- package/lib/util/item.js.map +1 -1
- package/lib/util/layout.d.ts +40 -0
- package/lib/util/layout.js +172 -0
- package/lib/util/layout.js.map +1 -0
- package/lib/util/loop.d.ts +37 -0
- package/lib/util/loop.js +111 -0
- package/lib/util/loop.js.map +1 -0
- package/lib/util/mapper.js +4 -9
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/math.d.ts +15 -0
- package/lib/util/math.js +17 -1
- package/lib/util/math.js.map +1 -1
- package/lib/util/mock.d.ts +30 -0
- package/lib/util/mock.js +73 -0
- package/lib/util/mock.js.map +1 -0
- package/lib/util/path.d.ts +11 -0
- package/lib/util/path.js +49 -0
- package/lib/util/path.js.map +1 -0
- package/lib/util/point.d.ts +24 -2
- package/lib/util/point.js +31 -3
- package/lib/util/point.js.map +1 -1
- package/lib/util/polyline.d.ts +113 -0
- package/lib/util/polyline.js +524 -0
- package/lib/util/polyline.js.map +1 -0
- package/lib/util/router.d.ts +31 -0
- package/lib/util/router.js +384 -0
- package/lib/util/router.js.map +1 -0
- package/lib/util/shape.d.ts +39 -4
- package/lib/util/shape.js +122 -3
- package/lib/util/shape.js.map +1 -1
- package/lib/util/shape3d.d.ts +1 -1
- package/lib/util/shape3d.js +11 -5
- package/lib/util/shape3d.js.map +1 -1
- package/lib/util/type.d.ts +6 -0
- package/lib/util/type.js +9 -2
- package/lib/util/type.js.map +1 -1
- package/lib/util/zoom.d.ts +2 -2
- package/lib/util/zoom.js +6 -2
- package/lib/util/zoom.js.map +1 -1
- package/package.json +42 -22
- package/src/api-doc/behaviors.ts +2 -0
- package/src/api-doc/graph.ts +4 -0
- package/src/api-doc/item.ts +43 -0
- package/src/api-doc/layout.ts +13 -0
- package/src/api-doc/plugins.ts +1 -0
- package/src/api-doc/readme.md +59 -0
- package/src/api-doc/types.ts +2 -0
- package/src/api-doc/util.ts +3 -0
- package/src/constant/shape.ts +4 -1
- package/src/index.ts +14 -4
- package/src/item/combo.ts +307 -2
- package/src/item/edge.ts +73 -24
- package/src/item/item.ts +184 -85
- package/src/item/node.ts +138 -69
- package/src/runtime/controller/data.ts +665 -191
- package/src/runtime/controller/interaction.ts +31 -7
- package/src/runtime/controller/item.ts +990 -172
- package/src/runtime/controller/layout.ts +165 -13
- package/src/runtime/controller/plugin.ts +47 -10
- package/src/runtime/controller/theme.ts +8 -4
- package/src/runtime/graph.ts +922 -144
- package/src/stdlib/behavior/activate-relations.ts +14 -11
- package/src/stdlib/behavior/brush-select.ts +4 -5
- package/src/stdlib/behavior/click-select.ts +26 -11
- package/src/stdlib/behavior/collapse-expand-combo.ts +57 -0
- package/src/stdlib/behavior/collapse-expand-tree.ts +106 -0
- package/src/stdlib/behavior/drag-canvas.ts +15 -13
- package/src/stdlib/behavior/drag-combo.ts +589 -0
- package/src/stdlib/behavior/drag-node.ts +380 -110
- package/src/stdlib/behavior/hover-activate.ts +3 -5
- package/src/stdlib/behavior/index.ts +15 -0
- package/src/stdlib/behavior/lasso-select.ts +6 -2
- package/src/stdlib/behavior/orbit-canvas-3d.ts +3 -5
- package/src/stdlib/behavior/rotate-canvas-3d.ts +1 -3
- package/src/stdlib/behavior/track-canvas-3d.ts +3 -5
- package/src/stdlib/behavior/types.ts +15 -0
- package/src/stdlib/behavior/zoom-canvas-3d.ts +5 -7
- package/src/stdlib/behavior/zoom-canvas.ts +19 -19
- package/src/stdlib/data/index.ts +3 -0
- package/src/stdlib/data/mapNodeSize.ts +67 -0
- package/src/stdlib/data/transformV4Data.ts +207 -0
- package/src/stdlib/data/validateData.ts +146 -0
- package/src/stdlib/index.ts +221 -37
- package/src/stdlib/item/combo/circle.ts +113 -0
- package/src/stdlib/item/combo/index.ts +2 -0
- package/src/stdlib/item/combo/rect.ts +123 -0
- package/src/stdlib/item/edge/base.ts +71 -6
- package/src/stdlib/item/edge/cubic-horizontal.ts +86 -0
- package/src/stdlib/item/edge/cubic-vertical.ts +85 -0
- package/src/stdlib/item/edge/cubic.ts +198 -0
- package/src/stdlib/item/edge/index.ts +6 -0
- package/src/stdlib/item/edge/line.ts +14 -15
- package/src/stdlib/item/edge/loop.ts +162 -0
- package/src/stdlib/item/edge/polyline.ts +161 -0
- package/src/stdlib/item/edge/quadratic.ts +133 -0
- package/src/stdlib/item/node/base.ts +195 -53
- package/src/stdlib/item/node/base3d.ts +2 -0
- package/src/stdlib/item/node/circle.ts +5 -5
- package/src/stdlib/item/node/diamond.ts +144 -0
- package/src/stdlib/item/node/donut.ts +368 -0
- package/src/stdlib/item/node/ellipse.ts +128 -0
- package/src/stdlib/item/node/hexagon.ts +168 -0
- package/src/stdlib/item/node/index.ts +8 -0
- package/src/stdlib/item/node/modelRect.ts +405 -0
- package/src/stdlib/item/node/rect.ts +141 -0
- package/src/stdlib/item/node/star.ts +181 -0
- package/src/stdlib/item/node/triangle.ts +265 -0
- package/src/stdlib/plugin/fisheye/index.ts +607 -0
- package/src/stdlib/plugin/grid/index.ts +125 -0
- package/src/stdlib/plugin/history/combo-command.ts +28 -0
- package/src/stdlib/plugin/history/command.ts +81 -0
- package/src/stdlib/plugin/history/index.ts +347 -0
- package/src/stdlib/plugin/history/item-data-command.ts +96 -0
- package/src/stdlib/plugin/history/layer-updated-command.ts +28 -0
- package/src/stdlib/plugin/history/state-updated-command.ts +36 -0
- package/src/stdlib/plugin/history/visibility-updated-command.ts +41 -0
- package/src/stdlib/plugin/hull/bubbleset.ts +828 -0
- package/src/stdlib/plugin/hull/convexHull.ts +68 -0
- package/src/stdlib/plugin/hull/hullComponent.ts +501 -0
- package/src/stdlib/plugin/hull/index.ts +234 -0
- package/src/stdlib/plugin/hull/types.ts +15 -0
- package/src/stdlib/plugin/hull/util.ts +511 -0
- package/src/stdlib/plugin/index.ts +8 -0
- package/src/stdlib/plugin/legend/index.ts +122 -61
- package/src/stdlib/plugin/menu/index.ts +275 -0
- package/src/stdlib/plugin/minimap/index.ts +35 -26
- package/src/stdlib/plugin/toolbar/index.ts +257 -0
- package/src/stdlib/plugin/tooltip/index.ts +444 -0
- package/src/stdlib/plugin/types.ts +8 -0
- package/src/stdlib/theme/dark.ts +13 -1
- package/src/stdlib/theme/index.ts +2 -0
- package/src/stdlib/theme/light.ts +88 -10
- package/src/stdlib/themeSolver/base.ts +1 -1
- package/src/stdlib/themeSolver/index.ts +3 -0
- package/src/stdlib/themeSolver/spec.ts +2 -5
- package/src/stdlib/themeSolver/subject.ts +2 -5
- package/src/types/behavior.ts +0 -1
- package/src/types/combo.ts +61 -4
- package/src/types/common.ts +13 -0
- package/src/types/data.ts +28 -7
- package/src/types/edge.ts +30 -6
- package/src/types/event.ts +8 -8
- package/src/types/graph.ts +232 -25
- package/src/types/history.ts +30 -0
- package/src/types/hook.ts +37 -7
- package/src/types/index.ts +37 -12
- package/src/types/item.ts +25 -11
- package/src/types/layout.ts +20 -16
- package/src/types/loop.ts +23 -0
- package/src/types/node.ts +94 -14
- package/src/types/plugin.ts +7 -1
- package/src/types/spec.ts +30 -13
- package/src/types/theme.ts +80 -10
- package/src/util/animate.ts +60 -20
- package/src/util/array.ts +12 -1
- package/src/util/arrow.ts +62 -0
- package/src/util/bbox.ts +298 -0
- package/src/util/behavior.ts +14 -0
- package/src/util/canvas.ts +16 -24
- package/src/util/data.ts +307 -0
- package/src/util/event.ts +114 -1
- package/src/util/extend.ts +8 -2
- package/src/util/index.ts +31 -1
- package/src/util/item.ts +79 -13
- package/src/util/layout.ts +165 -0
- package/src/util/loop.ts +145 -0
- package/src/util/mapper.ts +10 -9
- package/src/util/math.ts +24 -0
- package/src/util/mock.ts +72 -0
- package/src/util/path.ts +52 -0
- package/src/util/point.ts +33 -2
- package/src/util/polyline.ts +676 -0
- package/src/util/router.ts +552 -0
- package/src/util/shape.ts +159 -6
- package/src/util/shape3d.ts +16 -11
- package/src/util/type.ts +8 -1
- package/src/util/zoom.ts +8 -4
- package/esm/stdlib/data/comboFromNode.d.ts +0 -9
- package/esm/stdlib/data/comboFromNode.js +0 -28
- package/esm/stdlib/data/comboFromNode.js.map +0 -1
- package/lib/stdlib/data/comboFromNode.d.ts +0 -9
- package/lib/stdlib/data/comboFromNode.js +0 -32
- package/lib/stdlib/data/comboFromNode.js.map +0 -1
- package/src/stdlib/data/comboFromNode.ts +0 -28
package/src/runtime/graph.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
|
-
import { AABB, Canvas, DisplayObject, PointLike
|
|
2
|
+
import { AABB, Canvas, DisplayObject, PointLike } from '@antv/g';
|
|
3
3
|
import { GraphChange, ID } from '@antv/graphlib';
|
|
4
|
-
import { isArray, isNil, isNumber, isObject, isString } from '@antv/util';
|
|
5
4
|
import {
|
|
5
|
+
clone,
|
|
6
|
+
groupBy,
|
|
7
|
+
isArray,
|
|
8
|
+
isEmpty,
|
|
9
|
+
isEqual,
|
|
10
|
+
isNil,
|
|
11
|
+
isNumber,
|
|
12
|
+
isObject,
|
|
13
|
+
isString,
|
|
14
|
+
map,
|
|
15
|
+
} from '@antv/util';
|
|
16
|
+
import { History } from '../stdlib/plugin/history';
|
|
17
|
+
import { Command } from '../stdlib/plugin/history/command';
|
|
18
|
+
import type {
|
|
6
19
|
ComboUserModel,
|
|
7
20
|
EdgeUserModel,
|
|
8
21
|
GraphData,
|
|
@@ -10,22 +23,23 @@ import {
|
|
|
10
23
|
NodeUserModel,
|
|
11
24
|
Specification,
|
|
12
25
|
} from '../types';
|
|
13
|
-
import { CameraAnimationOptions } from '../types/animate';
|
|
14
|
-
import { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
|
|
15
|
-
import { ComboModel } from '../types/combo';
|
|
16
|
-
import { Padding, Point } from '../types/common';
|
|
17
|
-
import { DataChangeType, GraphCore } from '../types/data';
|
|
18
|
-
import { EdgeModel, EdgeModelData } from '../types/edge';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
26
|
+
import type { CameraAnimationOptions } from '../types/animate';
|
|
27
|
+
import type { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
|
|
28
|
+
import type { ComboDisplayModel, ComboModel } from '../types/combo';
|
|
29
|
+
import type { Padding, Point } from '../types/common';
|
|
30
|
+
import type { DataChangeType, DataConfig, GraphCore } from '../types/data';
|
|
31
|
+
import type { EdgeDisplayModel, EdgeModel, EdgeModelData } from '../types/edge';
|
|
32
|
+
import type { StackType } from '../types/history';
|
|
33
|
+
import type { Hooks, ViewportChangeHookParams } from '../types/hook';
|
|
34
|
+
import type { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from '../types/item';
|
|
35
|
+
import type {
|
|
22
36
|
ImmediatelyInvokedLayoutOptions,
|
|
23
37
|
LayoutOptions,
|
|
24
38
|
StandardLayoutOptions,
|
|
25
39
|
} from '../types/layout';
|
|
26
|
-
import { NodeModel, NodeModelData } from '../types/node';
|
|
27
|
-
import { RendererName } from '../types/render';
|
|
28
|
-
import {
|
|
40
|
+
import type { NodeDisplayModel, NodeModel, NodeModelData } from '../types/node';
|
|
41
|
+
import type { RendererName } from '../types/render';
|
|
42
|
+
import type {
|
|
29
43
|
ThemeOptionsOf,
|
|
30
44
|
ThemeRegistry,
|
|
31
45
|
ThemeSpecification,
|
|
@@ -33,6 +47,7 @@ import {
|
|
|
33
47
|
import { FitViewRules, GraphTransformOptions } from '../types/view';
|
|
34
48
|
import { changeRenderer, createCanvas } from '../util/canvas';
|
|
35
49
|
import { formatPadding } from '../util/shape';
|
|
50
|
+
import { Plugin as PluginBase } from '../types/plugin';
|
|
36
51
|
import {
|
|
37
52
|
DataController,
|
|
38
53
|
ExtensionController,
|
|
@@ -45,11 +60,6 @@ import {
|
|
|
45
60
|
import { PluginController } from './controller/plugin';
|
|
46
61
|
import Hook from './hooks';
|
|
47
62
|
|
|
48
|
-
/**
|
|
49
|
-
* Disable CSS parsing for better performance.
|
|
50
|
-
*/
|
|
51
|
-
runtime.enableCSSParsing = false;
|
|
52
|
-
|
|
53
63
|
export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
54
64
|
extends EventEmitter
|
|
55
65
|
implements IGraph<B, T>
|
|
@@ -70,6 +80,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
70
80
|
// the tag indicates all the three canvases are all ready
|
|
71
81
|
private canvasReady: boolean;
|
|
72
82
|
private specification: Specification<B, T>;
|
|
83
|
+
|
|
73
84
|
private dataController: DataController;
|
|
74
85
|
private interactionController: InteractionController;
|
|
75
86
|
private layoutController: LayoutController;
|
|
@@ -84,16 +95,17 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
84
95
|
type: 'spec',
|
|
85
96
|
base: 'light',
|
|
86
97
|
},
|
|
98
|
+
enableStack: true,
|
|
87
99
|
};
|
|
88
100
|
|
|
89
101
|
constructor(spec: Specification<B, T>) {
|
|
90
102
|
super();
|
|
91
|
-
// TODO: analyse cfg
|
|
92
103
|
|
|
93
104
|
this.specification = Object.assign({}, this.defaultSpecification, spec);
|
|
94
105
|
this.initHooks();
|
|
95
106
|
this.initCanvas();
|
|
96
107
|
this.initControllers();
|
|
108
|
+
this.initHistory();
|
|
97
109
|
|
|
98
110
|
this.hooks.init.emit({
|
|
99
111
|
canvases: {
|
|
@@ -125,8 +137,17 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
private initCanvas() {
|
|
128
|
-
const {
|
|
129
|
-
|
|
140
|
+
const {
|
|
141
|
+
renderer,
|
|
142
|
+
container,
|
|
143
|
+
canvas,
|
|
144
|
+
backgroundCanvas,
|
|
145
|
+
transientCanvas,
|
|
146
|
+
width,
|
|
147
|
+
height,
|
|
148
|
+
} = this.specification;
|
|
149
|
+
|
|
150
|
+
let pixelRatio: number;
|
|
130
151
|
if (renderer && !isString(renderer)) {
|
|
131
152
|
// @ts-ignore
|
|
132
153
|
this.rendererType = renderer.type || 'canvas';
|
|
@@ -136,55 +157,99 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
136
157
|
// @ts-ignore
|
|
137
158
|
this.rendererType = renderer || 'canvas';
|
|
138
159
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
|
|
163
|
+
*/
|
|
164
|
+
if (canvas) {
|
|
165
|
+
this.canvas = canvas;
|
|
166
|
+
this.backgroundCanvas = backgroundCanvas;
|
|
167
|
+
this.transientCanvas = transientCanvas;
|
|
168
|
+
this.container = container as HTMLDivElement;
|
|
169
|
+
} else {
|
|
170
|
+
const containerDOM = isString(container)
|
|
171
|
+
? document.getElementById(container as string)
|
|
172
|
+
: (container as HTMLElement);
|
|
173
|
+
|
|
174
|
+
if (!containerDOM) {
|
|
175
|
+
console.error(
|
|
176
|
+
`Create graph failed. The container for graph ${containerDOM} is not exist.`,
|
|
177
|
+
);
|
|
178
|
+
this.destroy();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.container = containerDOM;
|
|
183
|
+
const size = [width, height];
|
|
184
|
+
if (size[0] === undefined) {
|
|
185
|
+
size[0] = containerDOM.scrollWidth;
|
|
186
|
+
}
|
|
187
|
+
if (size[1] === undefined) {
|
|
188
|
+
size[1] = containerDOM.scrollHeight;
|
|
189
|
+
}
|
|
190
|
+
this.backgroundCanvas = createCanvas(
|
|
191
|
+
this.rendererType,
|
|
192
|
+
containerDOM,
|
|
193
|
+
size[0],
|
|
194
|
+
size[1],
|
|
195
|
+
pixelRatio,
|
|
196
|
+
);
|
|
197
|
+
this.canvas = createCanvas(
|
|
198
|
+
this.rendererType,
|
|
199
|
+
containerDOM,
|
|
200
|
+
size[0],
|
|
201
|
+
size[1],
|
|
202
|
+
pixelRatio,
|
|
203
|
+
);
|
|
204
|
+
this.transientCanvas = createCanvas(
|
|
205
|
+
this.rendererType,
|
|
206
|
+
containerDOM,
|
|
207
|
+
size[0],
|
|
208
|
+
size[1],
|
|
209
|
+
pixelRatio,
|
|
145
210
|
);
|
|
146
|
-
this.destroy();
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this.container = containerDOM;
|
|
150
|
-
const size = [width, height];
|
|
151
|
-
if (size[0] === undefined) {
|
|
152
|
-
size[0] = containerDOM.scrollWidth;
|
|
153
|
-
}
|
|
154
|
-
if (size[1] === undefined) {
|
|
155
|
-
size[1] = containerDOM.scrollHeight;
|
|
156
211
|
}
|
|
157
212
|
|
|
158
|
-
this.backgroundCanvas = createCanvas(
|
|
159
|
-
this.rendererType,
|
|
160
|
-
containerDOM,
|
|
161
|
-
size[0],
|
|
162
|
-
size[1],
|
|
163
|
-
pixelRatio,
|
|
164
|
-
);
|
|
165
|
-
this.canvas = createCanvas(
|
|
166
|
-
this.rendererType,
|
|
167
|
-
containerDOM,
|
|
168
|
-
size[0],
|
|
169
|
-
size[1],
|
|
170
|
-
pixelRatio,
|
|
171
|
-
);
|
|
172
|
-
this.transientCanvas = createCanvas(
|
|
173
|
-
this.rendererType,
|
|
174
|
-
containerDOM,
|
|
175
|
-
size[0],
|
|
176
|
-
size[1],
|
|
177
|
-
pixelRatio,
|
|
178
|
-
true,
|
|
179
|
-
{
|
|
180
|
-
pointerEvents: 'none',
|
|
181
|
-
},
|
|
182
|
-
);
|
|
183
213
|
Promise.all(
|
|
184
214
|
[this.backgroundCanvas, this.canvas, this.transientCanvas].map(
|
|
185
215
|
(canvas) => canvas.ready,
|
|
186
216
|
),
|
|
187
|
-
).then(() =>
|
|
217
|
+
).then(() => {
|
|
218
|
+
[this.backgroundCanvas, this.canvas, this.transientCanvas].forEach(
|
|
219
|
+
(canvas, i) => {
|
|
220
|
+
const $domElement = canvas
|
|
221
|
+
.getContextService()
|
|
222
|
+
.getDomElement() as unknown as HTMLElement;
|
|
223
|
+
if ($domElement && $domElement.style) {
|
|
224
|
+
$domElement.style.position = 'fixed';
|
|
225
|
+
$domElement.style.outline = 'none';
|
|
226
|
+
$domElement.tabIndex = 1; // Enable keyboard events
|
|
227
|
+
// Transient canvas should let interactive events go through.
|
|
228
|
+
if (i === 2) {
|
|
229
|
+
$domElement.style.pointerEvents = 'none';
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
this.canvasReady = true;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private initHistory() {
|
|
240
|
+
const { enableStack, stackCfg } = this.specification;
|
|
241
|
+
if (enableStack) {
|
|
242
|
+
const history = {
|
|
243
|
+
type: 'history',
|
|
244
|
+
key: 'history',
|
|
245
|
+
enableStack,
|
|
246
|
+
stackCfg,
|
|
247
|
+
};
|
|
248
|
+
if (!this.specification.plugins) {
|
|
249
|
+
this.specification.plugins = [];
|
|
250
|
+
}
|
|
251
|
+
this.specification.plugins.push(history);
|
|
252
|
+
}
|
|
188
253
|
}
|
|
189
254
|
|
|
190
255
|
/**
|
|
@@ -217,6 +282,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
217
282
|
changes: GraphChange<NodeModelData, EdgeModelData>[];
|
|
218
283
|
graphCore: GraphCore;
|
|
219
284
|
theme: ThemeSpecification;
|
|
285
|
+
animate?: boolean;
|
|
286
|
+
upsertAncestors?: boolean;
|
|
220
287
|
}>({ name: 'itemchange' }),
|
|
221
288
|
render: new Hook<{
|
|
222
289
|
graphCore: GraphCore;
|
|
@@ -225,7 +292,11 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
225
292
|
}>({
|
|
226
293
|
name: 'render',
|
|
227
294
|
}),
|
|
228
|
-
layout: new Hook<{
|
|
295
|
+
layout: new Hook<{
|
|
296
|
+
graphCore: GraphCore;
|
|
297
|
+
options?: LayoutOptions;
|
|
298
|
+
animate?: boolean;
|
|
299
|
+
}>({ name: 'layout' }),
|
|
229
300
|
viewportchange: new Hook<ViewportChangeHookParams>({ name: 'viewport' }),
|
|
230
301
|
modechange: new Hook<{ mode: string }>({ name: 'modechange' }),
|
|
231
302
|
behaviorchange: new Hook<{
|
|
@@ -243,6 +314,13 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
243
314
|
itemvisibilitychange: new Hook<{ ids: ID[]; value: boolean }>({
|
|
244
315
|
name: 'itemvisibilitychange',
|
|
245
316
|
}),
|
|
317
|
+
itemzindexchange: new Hook<{
|
|
318
|
+
ids: ID[];
|
|
319
|
+
action: 'front' | 'back';
|
|
320
|
+
graphCore: GraphCore;
|
|
321
|
+
}>({
|
|
322
|
+
name: 'itemzindexchange',
|
|
323
|
+
}),
|
|
246
324
|
transientupdate: new Hook<{
|
|
247
325
|
type: ITEM_TYPE | SHAPE_TYPE;
|
|
248
326
|
id: ID;
|
|
@@ -251,6 +329,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
251
329
|
action: 'remove' | 'add' | 'update' | undefined;
|
|
252
330
|
};
|
|
253
331
|
canvas: Canvas;
|
|
332
|
+
graphCore: GraphCore;
|
|
254
333
|
}>({ name: 'transientupdate' }),
|
|
255
334
|
pluginchange: new Hook<{
|
|
256
335
|
action: 'update' | 'add' | 'remove';
|
|
@@ -267,6 +346,12 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
267
346
|
transient: Canvas;
|
|
268
347
|
};
|
|
269
348
|
}>({ name: 'init' }),
|
|
349
|
+
treecollapseexpand: new Hook<{
|
|
350
|
+
ids: ID[];
|
|
351
|
+
animate: boolean;
|
|
352
|
+
action: 'collapse' | 'expand';
|
|
353
|
+
graphCore: GraphCore;
|
|
354
|
+
}>({ name: 'treecollapseexpand' }),
|
|
270
355
|
destroy: new Hook<{}>({ name: 'destroy' }),
|
|
271
356
|
};
|
|
272
357
|
}
|
|
@@ -277,7 +362,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
277
362
|
public updateSpecification(spec: Specification<B, T>): Specification<B, T> {
|
|
278
363
|
return Object.assign(this.specification, spec);
|
|
279
364
|
}
|
|
280
|
-
|
|
281
365
|
/**
|
|
282
366
|
* Update the theme specs (configurations).
|
|
283
367
|
*/
|
|
@@ -313,7 +397,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
313
397
|
* @returns
|
|
314
398
|
* @group Data
|
|
315
399
|
*/
|
|
316
|
-
public async read(data:
|
|
400
|
+
public async read(data: DataConfig) {
|
|
317
401
|
this.hooks.datachange.emit({ data, type: 'replace' });
|
|
318
402
|
const emitRender = async () => {
|
|
319
403
|
this.hooks.render.emit({
|
|
@@ -323,6 +407,26 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
323
407
|
});
|
|
324
408
|
this.emit('afterrender');
|
|
325
409
|
|
|
410
|
+
this.once('afterlayout', async () => {
|
|
411
|
+
const { autoFit } = this.specification;
|
|
412
|
+
if (autoFit) {
|
|
413
|
+
if (autoFit === 'view') {
|
|
414
|
+
await this.fitView();
|
|
415
|
+
} else if (autoFit === 'center') {
|
|
416
|
+
await this.fitCenter();
|
|
417
|
+
} else {
|
|
418
|
+
const { type, effectTiming, ...others } = autoFit;
|
|
419
|
+
if (type === 'view') {
|
|
420
|
+
await this.fitView(others as any, effectTiming);
|
|
421
|
+
} else if (type === 'center') {
|
|
422
|
+
await this.fitCenter(effectTiming);
|
|
423
|
+
} else if (type === 'position') {
|
|
424
|
+
// TODO: align
|
|
425
|
+
await this.translateTo((others as any).position, effectTiming);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
326
430
|
await this.layout();
|
|
327
431
|
};
|
|
328
432
|
if (this.canvasReady) {
|
|
@@ -345,7 +449,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
345
449
|
* @group Data
|
|
346
450
|
*/
|
|
347
451
|
public async changeData(
|
|
348
|
-
data:
|
|
452
|
+
data: DataConfig,
|
|
349
453
|
type: 'replace' | 'mergeReplace' = 'mergeReplace',
|
|
350
454
|
) {
|
|
351
455
|
this.hooks.datachange.emit({ data, type });
|
|
@@ -364,7 +468,20 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
364
468
|
* @returns
|
|
365
469
|
*/
|
|
366
470
|
public clear() {
|
|
367
|
-
|
|
471
|
+
this.startBatch();
|
|
472
|
+
this.removeData(
|
|
473
|
+
'edge',
|
|
474
|
+
this.getAllEdgesData().map((edge) => edge.id),
|
|
475
|
+
);
|
|
476
|
+
this.removeData(
|
|
477
|
+
'node',
|
|
478
|
+
this.getAllNodesData().map((node) => node.id),
|
|
479
|
+
);
|
|
480
|
+
this.removeData(
|
|
481
|
+
'combo',
|
|
482
|
+
this.getAllCombosData().map((combo) => combo.id),
|
|
483
|
+
);
|
|
484
|
+
this.stopBatch();
|
|
368
485
|
}
|
|
369
486
|
|
|
370
487
|
public getViewportCenter(): PointLike {
|
|
@@ -417,7 +534,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
417
534
|
* @param effectTiming animation configurations
|
|
418
535
|
*/
|
|
419
536
|
public async translateTo(
|
|
420
|
-
{ x, y }:
|
|
537
|
+
{ x, y }: Point,
|
|
421
538
|
effectTiming?: CameraAnimationOptions,
|
|
422
539
|
) {
|
|
423
540
|
const { x: cx, y: cy } = this.getViewportCenter();
|
|
@@ -432,7 +549,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
432
549
|
*/
|
|
433
550
|
public async zoom(
|
|
434
551
|
ratio: number,
|
|
435
|
-
origin?:
|
|
552
|
+
origin?: Point,
|
|
436
553
|
effectTiming?: CameraAnimationOptions,
|
|
437
554
|
) {
|
|
438
555
|
await this.transform(
|
|
@@ -604,7 +721,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
604
721
|
public async focusItem(id: ID | ID[], effectTiming?: CameraAnimationOptions) {
|
|
605
722
|
let bounds: AABB | null = null;
|
|
606
723
|
for (const itemId of !isArray(id) ? [id] : id) {
|
|
607
|
-
const item = this.
|
|
724
|
+
const item = this.getItemById(itemId);
|
|
608
725
|
if (item) {
|
|
609
726
|
const itemBounds = item.group.getBounds();
|
|
610
727
|
if (!bounds) {
|
|
@@ -626,6 +743,15 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
626
743
|
}
|
|
627
744
|
}
|
|
628
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Get item by id. We don't want to
|
|
748
|
+
* @param id
|
|
749
|
+
* @returns Node | Edge | Combo
|
|
750
|
+
*/
|
|
751
|
+
private getItemById(id: ID) {
|
|
752
|
+
return this.itemController.getItemById(id);
|
|
753
|
+
}
|
|
754
|
+
|
|
629
755
|
/**
|
|
630
756
|
* Get the size of the graph canvas.
|
|
631
757
|
* @returns [width, height]
|
|
@@ -737,7 +863,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
737
863
|
* @group Data
|
|
738
864
|
*/
|
|
739
865
|
public getAllNodesData(): NodeModel[] {
|
|
740
|
-
return this.dataController.findAllData('node');
|
|
866
|
+
return this.dataController.findAllData('node') as NodeModel[];
|
|
741
867
|
}
|
|
742
868
|
/**
|
|
743
869
|
* Get all the edges' inner data
|
|
@@ -758,26 +884,57 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
758
884
|
/**
|
|
759
885
|
* Get one-hop edge ids from a start node.
|
|
760
886
|
* @param nodeId id of the start node
|
|
761
|
-
* @returns one-hop
|
|
887
|
+
* @returns one-hop edges' data array
|
|
762
888
|
* @group Data
|
|
763
889
|
*/
|
|
764
890
|
public getRelatedEdgesData(
|
|
765
891
|
nodeId: ID,
|
|
766
892
|
direction: 'in' | 'out' | 'both' = 'both',
|
|
767
893
|
): EdgeModel[] {
|
|
768
|
-
return this.dataController.
|
|
894
|
+
return this.dataController.findRelatedEdges(nodeId, direction);
|
|
769
895
|
}
|
|
770
896
|
/**
|
|
771
897
|
* Get one-hop node ids from a start node.
|
|
772
898
|
* @param nodeId id of the start node
|
|
773
|
-
* @returns one-hop
|
|
899
|
+
* @returns one-hop nodes' data array
|
|
774
900
|
* @group Data
|
|
775
901
|
*/
|
|
776
902
|
public getNeighborNodesData(
|
|
777
903
|
nodeId: ID,
|
|
778
904
|
direction: 'in' | 'out' | 'both' = 'both',
|
|
779
905
|
): NodeModel[] {
|
|
780
|
-
return this.dataController.
|
|
906
|
+
return this.dataController.findNeighborNodes(nodeId, direction);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Get the children's data of a combo.
|
|
910
|
+
* @param comboId combo id
|
|
911
|
+
* @returns children's data array
|
|
912
|
+
* @group Data
|
|
913
|
+
*/
|
|
914
|
+
public getComboChildrenData(comboId: ID): (ComboModel | NodeModel)[] {
|
|
915
|
+
return this.dataController.findChildren(comboId, 'combo');
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/*
|
|
919
|
+
* Get the display model of a node / edge / combo.
|
|
920
|
+
* @param id item id
|
|
921
|
+
* @returns display model
|
|
922
|
+
* @group Data
|
|
923
|
+
*/
|
|
924
|
+
protected getDisplayModel(
|
|
925
|
+
id: ID,
|
|
926
|
+
): NodeDisplayModel | EdgeDisplayModel | ComboDisplayModel {
|
|
927
|
+
return this.itemController.findDisplayModel(id);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Retrieve the nearby edges for a given node using quadtree collision detection.
|
|
932
|
+
* @param nodeId node id
|
|
933
|
+
* @group Data
|
|
934
|
+
*/
|
|
935
|
+
public getNearEdgesForNode(nodeId: ID): EdgeModel[] {
|
|
936
|
+
const { graphCore } = this.dataController;
|
|
937
|
+
return this.itemController.findNearEdgesByNode(nodeId, graphCore);
|
|
781
938
|
}
|
|
782
939
|
|
|
783
940
|
/**
|
|
@@ -796,8 +953,9 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
796
953
|
): ID[] {
|
|
797
954
|
let ids = this.itemController.findIdByState(itemType, state, value);
|
|
798
955
|
if (additionalFilter) {
|
|
799
|
-
|
|
800
|
-
|
|
956
|
+
let getDataFunc: any = this.getEdgeData;
|
|
957
|
+
if (itemType === 'node') getDataFunc = this.getNodeData;
|
|
958
|
+
else if (itemType === 'combo') getDataFunc = this.getComboData;
|
|
801
959
|
ids = ids.filter((id) => additionalFilter(getDataFunc(id)));
|
|
802
960
|
}
|
|
803
961
|
return ids;
|
|
@@ -806,7 +964,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
806
964
|
* Add one or more node/edge/combo data to the graph.
|
|
807
965
|
* @param itemType item type
|
|
808
966
|
* @param model user data
|
|
809
|
-
* @param stack whether push this operation to stack
|
|
810
967
|
* @returns whether success
|
|
811
968
|
* @group Data
|
|
812
969
|
*/
|
|
@@ -819,7 +976,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
819
976
|
| NodeUserModel[]
|
|
820
977
|
| EdgeUserModel[]
|
|
821
978
|
| ComboUserModel[],
|
|
822
|
-
stack?: boolean,
|
|
823
979
|
):
|
|
824
980
|
| NodeModel
|
|
825
981
|
| EdgeModel
|
|
@@ -833,13 +989,20 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
833
989
|
const { specification } = this.themeController;
|
|
834
990
|
graphCore.once('changed', (event) => {
|
|
835
991
|
if (!event.changes.length) return;
|
|
992
|
+
const changes = event.changes;
|
|
836
993
|
this.hooks.itemchange.emit({
|
|
837
994
|
type: itemType,
|
|
838
995
|
changes: graphCore.reduceChanges(event.changes),
|
|
839
996
|
graphCore,
|
|
840
997
|
theme: specification,
|
|
841
998
|
});
|
|
842
|
-
this.emit('afteritemchange', {
|
|
999
|
+
this.emit('afteritemchange', {
|
|
1000
|
+
type: itemType,
|
|
1001
|
+
action: 'add',
|
|
1002
|
+
models,
|
|
1003
|
+
apiName: 'addData',
|
|
1004
|
+
changes,
|
|
1005
|
+
});
|
|
843
1006
|
});
|
|
844
1007
|
|
|
845
1008
|
const modelArr = isArray(models) ? models : [models];
|
|
@@ -858,38 +1021,97 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
858
1021
|
/**
|
|
859
1022
|
* Remove one or more node/edge/combo data from the graph.
|
|
860
1023
|
* @param item the item to be removed
|
|
861
|
-
* @param stack whether push this operation to stack
|
|
862
1024
|
* @returns whether success
|
|
863
1025
|
* @group Data
|
|
864
1026
|
*/
|
|
865
|
-
public removeData(itemType: ITEM_TYPE, ids: ID | ID[]
|
|
1027
|
+
public removeData(itemType: ITEM_TYPE, ids: ID | ID[]) {
|
|
866
1028
|
const idArr = isArray(ids) ? ids : [ids];
|
|
867
1029
|
const data = { nodes: [], edges: [], combos: [] };
|
|
868
1030
|
const { userGraphCore, graphCore } = this.dataController;
|
|
869
1031
|
const { specification } = this.themeController;
|
|
870
1032
|
const getItem =
|
|
871
|
-
itemType === 'edge' ? userGraphCore.getEdge : userGraphCore.getNode;
|
|
1033
|
+
itemType === 'edge' ? userGraphCore.getEdge : userGraphCore.getNode;
|
|
872
1034
|
data[`${itemType}s`] = idArr.map((id) => getItem.bind(userGraphCore)(id));
|
|
873
1035
|
graphCore.once('changed', (event) => {
|
|
874
1036
|
if (!event.changes.length) return;
|
|
1037
|
+
const changes = event.changes;
|
|
875
1038
|
this.hooks.itemchange.emit({
|
|
876
1039
|
type: itemType,
|
|
877
1040
|
changes: event.changes,
|
|
878
1041
|
graphCore,
|
|
879
1042
|
theme: specification,
|
|
880
1043
|
});
|
|
881
|
-
this.emit('afteritemchange', {
|
|
1044
|
+
this.emit('afteritemchange', {
|
|
1045
|
+
type: itemType,
|
|
1046
|
+
action: 'remove',
|
|
1047
|
+
ids: idArr,
|
|
1048
|
+
apiName: 'removeData',
|
|
1049
|
+
changes,
|
|
1050
|
+
});
|
|
882
1051
|
});
|
|
883
1052
|
this.hooks.datachange.emit({
|
|
884
1053
|
data,
|
|
885
1054
|
type: 'remove',
|
|
886
1055
|
});
|
|
887
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Extends the fields of oldValue and newValue
|
|
1059
|
+
* to make sure they both contain the union set of their original fields.
|
|
1060
|
+
* The missing fields' values are filled using data from displayModel data.
|
|
1061
|
+
* @param changes
|
|
1062
|
+
* @returns
|
|
1063
|
+
*/
|
|
1064
|
+
private extendChanges(changes) {
|
|
1065
|
+
return changes
|
|
1066
|
+
.map((change) => {
|
|
1067
|
+
const { id, propertyName, oldValue, newValue } = change;
|
|
1068
|
+
if (!oldValue || !newValue) return change;
|
|
1069
|
+
if (propertyName) {
|
|
1070
|
+
if (oldValue !== newValue) return change;
|
|
1071
|
+
return false;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
const displayData = this.getItemById(id).displayModel.data;
|
|
1075
|
+
const oldFields = Object.keys(oldValue);
|
|
1076
|
+
const newFields = Object.keys(newValue);
|
|
1077
|
+
const commonFields = [...new Set([...oldFields, ...newFields])];
|
|
1078
|
+
|
|
1079
|
+
commonFields.forEach((field) => {
|
|
1080
|
+
if (!Object.prototype.hasOwnProperty.call(oldValue, field)) {
|
|
1081
|
+
oldValue[field] = displayData[field];
|
|
1082
|
+
}
|
|
1083
|
+
if (!Object.prototype.hasOwnProperty.call(newValue, field)) {
|
|
1084
|
+
newValue[field] = displayData[field];
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
if (
|
|
1089
|
+
(oldValue.x === undefined || Number.isNaN(oldValue.x)) &&
|
|
1090
|
+
!oldValue._isCombo
|
|
1091
|
+
)
|
|
1092
|
+
oldValue.x = 0;
|
|
1093
|
+
if (
|
|
1094
|
+
(oldValue.y === undefined || Number.isNaN(oldValue.x)) &&
|
|
1095
|
+
!oldValue._isCombo
|
|
1096
|
+
)
|
|
1097
|
+
oldValue.y = 0;
|
|
1098
|
+
if (Number.isNaN(newValue.x)) delete newValue.x;
|
|
1099
|
+
if (Number.isNaN(newValue.y)) delete newValue.y;
|
|
1100
|
+
|
|
1101
|
+
if (isEqual(newValue, oldValue)) return false;
|
|
1102
|
+
|
|
1103
|
+
return {
|
|
1104
|
+
...change,
|
|
1105
|
+
newValue,
|
|
1106
|
+
oldValue,
|
|
1107
|
+
};
|
|
1108
|
+
})
|
|
1109
|
+
.filter(Boolean);
|
|
1110
|
+
}
|
|
888
1111
|
/**
|
|
889
1112
|
* Update one or more node/edge/combo data on the graph.
|
|
890
1113
|
* @param {ITEM_TYPE} itemType 'node' | 'edge' | 'combo'
|
|
891
1114
|
* @param models new configurations for every node/edge/combo, which has id field to indicate the specific item
|
|
892
|
-
* @param {boolean} stack whether push this operation into graph's stack, true by default
|
|
893
1115
|
* @group Data
|
|
894
1116
|
*/
|
|
895
1117
|
public updateData(
|
|
@@ -903,7 +1125,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
903
1125
|
| Partial<EdgeUserModel>[]
|
|
904
1126
|
| Partial<ComboUserModel>[]
|
|
905
1127
|
>,
|
|
906
|
-
stack?: boolean,
|
|
907
1128
|
):
|
|
908
1129
|
| NodeModel
|
|
909
1130
|
| EdgeModel
|
|
@@ -918,6 +1139,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
918
1139
|
const { graphCore } = this.dataController;
|
|
919
1140
|
const { specification } = this.themeController;
|
|
920
1141
|
graphCore.once('changed', (event) => {
|
|
1142
|
+
const changes = this.extendChanges(clone(event.changes));
|
|
921
1143
|
this.hooks.itemchange.emit({
|
|
922
1144
|
type: itemType,
|
|
923
1145
|
changes: event.changes,
|
|
@@ -928,6 +1150,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
928
1150
|
type: itemType,
|
|
929
1151
|
action: 'update',
|
|
930
1152
|
models,
|
|
1153
|
+
apiName: 'updateData',
|
|
1154
|
+
changes,
|
|
931
1155
|
});
|
|
932
1156
|
});
|
|
933
1157
|
|
|
@@ -946,7 +1170,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
946
1170
|
* Update one or more nodes' positions,
|
|
947
1171
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
948
1172
|
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
949
|
-
* @param {boolean} stack whether push this operation into graph's stack, true by default
|
|
950
1173
|
* @group Data
|
|
951
1174
|
*/
|
|
952
1175
|
public updateNodePosition(
|
|
@@ -955,6 +1178,79 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
955
1178
|
| Partial<
|
|
956
1179
|
ComboUserModel | Partial<NodeUserModel>[] | Partial<ComboUserModel>[]
|
|
957
1180
|
>,
|
|
1181
|
+
upsertAncestors?: boolean,
|
|
1182
|
+
disableAnimate = false,
|
|
1183
|
+
callback?: (
|
|
1184
|
+
model: NodeModel | EdgeModel | ComboModel,
|
|
1185
|
+
canceled?: boolean,
|
|
1186
|
+
) => void,
|
|
1187
|
+
stack?: boolean,
|
|
1188
|
+
) {
|
|
1189
|
+
return this.updatePosition(
|
|
1190
|
+
'node',
|
|
1191
|
+
models,
|
|
1192
|
+
upsertAncestors,
|
|
1193
|
+
disableAnimate,
|
|
1194
|
+
callback,
|
|
1195
|
+
stack,
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Update one or more combos' positions,
|
|
1201
|
+
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1202
|
+
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1203
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1204
|
+
* @group Data
|
|
1205
|
+
*/
|
|
1206
|
+
public updateComboPosition(
|
|
1207
|
+
models:
|
|
1208
|
+
| Partial<NodeUserModel>
|
|
1209
|
+
| Partial<
|
|
1210
|
+
ComboUserModel | Partial<NodeUserModel>[] | Partial<ComboUserModel>[]
|
|
1211
|
+
>,
|
|
1212
|
+
upsertAncestors?: boolean,
|
|
1213
|
+
disableAnimate = false,
|
|
1214
|
+
callback?: (model: NodeModel | EdgeModel | ComboModel) => void,
|
|
1215
|
+
stack?: boolean,
|
|
1216
|
+
) {
|
|
1217
|
+
return this.updatePosition(
|
|
1218
|
+
'combo',
|
|
1219
|
+
models,
|
|
1220
|
+
upsertAncestors,
|
|
1221
|
+
disableAnimate,
|
|
1222
|
+
callback,
|
|
1223
|
+
stack,
|
|
1224
|
+
);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* Get history plugin instance
|
|
1229
|
+
*/
|
|
1230
|
+
private getHistoryPlugin(): History {
|
|
1231
|
+
if (
|
|
1232
|
+
!this.specification.enableStack ||
|
|
1233
|
+
!this.pluginController.hasPlugin('history')
|
|
1234
|
+
) {
|
|
1235
|
+
console.error('The history plugin is not loaded or initialized.');
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
return this.pluginController.getPlugin('history') as History;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
private updatePosition(
|
|
1242
|
+
type: 'node' | 'combo',
|
|
1243
|
+
models:
|
|
1244
|
+
| Partial<NodeUserModel>
|
|
1245
|
+
| Partial<
|
|
1246
|
+
ComboUserModel | Partial<NodeUserModel>[] | Partial<ComboUserModel>[]
|
|
1247
|
+
>,
|
|
1248
|
+
upsertAncestors?: boolean,
|
|
1249
|
+
disableAnimate = false,
|
|
1250
|
+
callback?: (
|
|
1251
|
+
model: NodeModel | EdgeModel | ComboModel,
|
|
1252
|
+
canceled?: boolean,
|
|
1253
|
+
) => void,
|
|
958
1254
|
stack?: boolean,
|
|
959
1255
|
) {
|
|
960
1256
|
const modelArr = isArray(models) ? models : [models];
|
|
@@ -962,45 +1258,84 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
962
1258
|
const { specification } = this.themeController;
|
|
963
1259
|
graphCore.once('changed', (event) => {
|
|
964
1260
|
if (!event.changes.length) return;
|
|
1261
|
+
const changes = event.changes.filter(
|
|
1262
|
+
(change) => !isEqual(change.newValue, change.oldValue),
|
|
1263
|
+
);
|
|
965
1264
|
this.hooks.itemchange.emit({
|
|
966
|
-
type
|
|
1265
|
+
type,
|
|
967
1266
|
changes: event.changes,
|
|
968
1267
|
graphCore,
|
|
969
1268
|
theme: specification,
|
|
970
|
-
|
|
1269
|
+
upsertAncestors,
|
|
1270
|
+
action: 'updatePosition',
|
|
1271
|
+
animate: !disableAnimate,
|
|
1272
|
+
callback,
|
|
971
1273
|
});
|
|
972
1274
|
this.emit('afteritemchange', {
|
|
973
|
-
type
|
|
974
|
-
action: '
|
|
1275
|
+
type,
|
|
1276
|
+
action: 'updatePosition',
|
|
1277
|
+
upsertAncestors,
|
|
975
1278
|
models,
|
|
1279
|
+
apiName: 'updatePosition',
|
|
1280
|
+
changes,
|
|
976
1281
|
});
|
|
977
1282
|
});
|
|
978
1283
|
|
|
979
1284
|
this.hooks.datachange.emit({
|
|
980
1285
|
data: {
|
|
981
|
-
nodes: modelArr as NodeUserModel[],
|
|
1286
|
+
nodes: type === 'node' ? (modelArr as NodeUserModel[]) : [],
|
|
982
1287
|
edges: [],
|
|
1288
|
+
combos: type === 'combo' ? (modelArr as ComboUserModel[]) : [],
|
|
983
1289
|
},
|
|
984
1290
|
type: 'update',
|
|
985
1291
|
});
|
|
986
1292
|
const dataList = this.dataController.findData(
|
|
987
|
-
|
|
1293
|
+
type,
|
|
988
1294
|
modelArr.map((model) => model.id),
|
|
989
1295
|
);
|
|
990
1296
|
return isArray(models) ? dataList : dataList[0];
|
|
991
1297
|
}
|
|
1298
|
+
|
|
1299
|
+
private getItemPreviousVisibility(ids: ID[]) {
|
|
1300
|
+
const objs = ids.map((id) => ({ id, visible: this.getItemVisible(id) }));
|
|
1301
|
+
const groupedByVisible = groupBy(objs, 'visible');
|
|
1302
|
+
|
|
1303
|
+
const values = [];
|
|
1304
|
+
for (const visible in groupedByVisible) {
|
|
1305
|
+
values.push({
|
|
1306
|
+
ids: map(groupedByVisible[visible], (item) => item.id),
|
|
1307
|
+
visible: visible === 'true',
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
return values;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
992
1313
|
/**
|
|
993
1314
|
* Show the item(s).
|
|
994
1315
|
* @param item the item to be shown
|
|
995
1316
|
* @returns
|
|
996
1317
|
* @group Item
|
|
997
1318
|
*/
|
|
998
|
-
public showItem(ids: ID | ID[],
|
|
1319
|
+
public showItem(ids: ID | ID[], disableAnimate = false) {
|
|
999
1320
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1321
|
+
if (isEmpty(idArr)) return;
|
|
1322
|
+
const changes = {
|
|
1323
|
+
newValue: [{ ids: idArr, visible: true }],
|
|
1324
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1325
|
+
};
|
|
1000
1326
|
this.hooks.itemvisibilitychange.emit({
|
|
1001
1327
|
ids: idArr as ID[],
|
|
1002
1328
|
value: true,
|
|
1003
|
-
|
|
1329
|
+
graphCore: this.dataController.graphCore,
|
|
1330
|
+
animate: !disableAnimate,
|
|
1331
|
+
});
|
|
1332
|
+
this.emit('afteritemvisibilitychange', {
|
|
1333
|
+
ids,
|
|
1334
|
+
value: true,
|
|
1335
|
+
animate: !disableAnimate,
|
|
1336
|
+
action: 'updateVisibility',
|
|
1337
|
+
apiName: 'showItem',
|
|
1338
|
+
changes,
|
|
1004
1339
|
});
|
|
1005
1340
|
}
|
|
1006
1341
|
/**
|
|
@@ -1009,12 +1344,83 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1009
1344
|
* @returns
|
|
1010
1345
|
* @group Item
|
|
1011
1346
|
*/
|
|
1012
|
-
public hideItem(ids: ID | ID[],
|
|
1347
|
+
public hideItem(ids: ID | ID[], disableAnimate = false) {
|
|
1013
1348
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1349
|
+
if (isEmpty(idArr)) return;
|
|
1350
|
+
const changes = {
|
|
1351
|
+
newValue: [{ ids: idArr, visible: false }],
|
|
1352
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1353
|
+
};
|
|
1014
1354
|
this.hooks.itemvisibilitychange.emit({
|
|
1015
1355
|
ids: idArr as ID[],
|
|
1016
1356
|
value: false,
|
|
1017
|
-
|
|
1357
|
+
graphCore: this.dataController.graphCore,
|
|
1358
|
+
animate: !disableAnimate,
|
|
1359
|
+
});
|
|
1360
|
+
this.emit('afteritemvisibilitychange', {
|
|
1361
|
+
ids,
|
|
1362
|
+
value: false,
|
|
1363
|
+
animate: !disableAnimate,
|
|
1364
|
+
action: 'updateVisibility',
|
|
1365
|
+
apiName: 'hideItem',
|
|
1366
|
+
changes,
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Make the item(s) to the front.
|
|
1372
|
+
* @param ids
|
|
1373
|
+
* @returns
|
|
1374
|
+
* @group Item
|
|
1375
|
+
*/
|
|
1376
|
+
public frontItem(ids: ID | ID[]) {
|
|
1377
|
+
const idArr = isArray(ids) ? ids : [ids];
|
|
1378
|
+
this.hooks.itemzindexchange.emit({
|
|
1379
|
+
ids: idArr as ID[],
|
|
1380
|
+
action: 'front',
|
|
1381
|
+
graphCore: this.dataController.graphCore,
|
|
1382
|
+
});
|
|
1383
|
+
this.emit('afteritemzindexchange', {
|
|
1384
|
+
ids: idArr,
|
|
1385
|
+
action: 'front',
|
|
1386
|
+
apiName: 'frontItem',
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Make the item(s) to the back.
|
|
1391
|
+
* @param ids
|
|
1392
|
+
* @returns
|
|
1393
|
+
* @group Item
|
|
1394
|
+
*/
|
|
1395
|
+
public backItem(ids: ID | ID[]) {
|
|
1396
|
+
const idArr = isArray(ids) ? ids : [ids];
|
|
1397
|
+
this.hooks.itemzindexchange.emit({
|
|
1398
|
+
ids: idArr as ID[],
|
|
1399
|
+
action: 'back',
|
|
1400
|
+
graphCore: this.dataController.graphCore,
|
|
1401
|
+
});
|
|
1402
|
+
this.emit('afteritemzindexchange', {
|
|
1403
|
+
ids: idArr,
|
|
1404
|
+
action: 'back',
|
|
1405
|
+
apiName: 'backItem',
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
private getItemPreviousStates(stateOption: {
|
|
1410
|
+
ids: ID | ID[];
|
|
1411
|
+
states: string | string[];
|
|
1412
|
+
value: boolean;
|
|
1413
|
+
}) {
|
|
1414
|
+
const { ids, states } = stateOption;
|
|
1415
|
+
const idArr = Array.isArray(ids) ? ids : [ids];
|
|
1416
|
+
const stateArr = Array.isArray(states) ? states : [states];
|
|
1417
|
+
if (isEmpty(idArr)) return;
|
|
1418
|
+
return idArr.flatMap((id) => {
|
|
1419
|
+
return stateArr.map((state) => ({
|
|
1420
|
+
ids: id,
|
|
1421
|
+
states: state,
|
|
1422
|
+
value: this.getItemState(id, state),
|
|
1423
|
+
}));
|
|
1018
1424
|
});
|
|
1019
1425
|
}
|
|
1020
1426
|
/**
|
|
@@ -1032,12 +1438,24 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1032
1438
|
) {
|
|
1033
1439
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1034
1440
|
const stateArr = isArray(states) ? states : [states];
|
|
1441
|
+
const stateOption = { ids: idArr, states: stateArr, value };
|
|
1442
|
+
const changes = {
|
|
1443
|
+
newValue: [stateOption],
|
|
1444
|
+
oldValue: this.getItemPreviousStates(stateOption),
|
|
1445
|
+
};
|
|
1035
1446
|
this.hooks.itemstatechange.emit({
|
|
1036
1447
|
ids: idArr as ID[],
|
|
1037
1448
|
states: stateArr as string[],
|
|
1038
1449
|
value,
|
|
1039
1450
|
});
|
|
1040
|
-
this.emit('afteritemstatechange', {
|
|
1451
|
+
this.emit('afteritemstatechange', {
|
|
1452
|
+
ids,
|
|
1453
|
+
states,
|
|
1454
|
+
value,
|
|
1455
|
+
action: 'updateState',
|
|
1456
|
+
apiName: 'setItemState',
|
|
1457
|
+
changes,
|
|
1458
|
+
});
|
|
1041
1459
|
}
|
|
1042
1460
|
/**
|
|
1043
1461
|
* Get the state value for an item.
|
|
@@ -1050,6 +1468,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1050
1468
|
return this.itemController.getItemState(id, state);
|
|
1051
1469
|
}
|
|
1052
1470
|
|
|
1471
|
+
/**
|
|
1472
|
+
* Get all the state names with value true for an item.
|
|
1473
|
+
* @param id the id for the item
|
|
1474
|
+
* @returns {string[]} the state names with value true
|
|
1475
|
+
* @group Item
|
|
1476
|
+
*/
|
|
1477
|
+
public getItemAllStates(id: ID): string[] {
|
|
1478
|
+
return this.itemController.getItemAllStates(id);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1053
1481
|
/**
|
|
1054
1482
|
* Clear all the states for item(s).
|
|
1055
1483
|
* @param ids the id(s) for the item(s) to be clear
|
|
@@ -1059,12 +1487,24 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1059
1487
|
*/
|
|
1060
1488
|
public clearItemState(ids: ID | ID[], states?: string[]) {
|
|
1061
1489
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1490
|
+
const stateOptions = { ids: idArr, states, value: false };
|
|
1491
|
+
const changes = {
|
|
1492
|
+
newValue: [stateOptions],
|
|
1493
|
+
oldValue: this.getItemPreviousStates(stateOptions),
|
|
1494
|
+
};
|
|
1062
1495
|
this.hooks.itemstatechange.emit({
|
|
1063
1496
|
ids: idArr as ID[],
|
|
1064
1497
|
states,
|
|
1065
1498
|
value: false,
|
|
1066
1499
|
});
|
|
1067
|
-
this.emit('afteritemstatechange', {
|
|
1500
|
+
this.emit('afteritemstatechange', {
|
|
1501
|
+
ids,
|
|
1502
|
+
states,
|
|
1503
|
+
value: false,
|
|
1504
|
+
action: 'updateState',
|
|
1505
|
+
apiName: 'clearItemState',
|
|
1506
|
+
changes,
|
|
1507
|
+
});
|
|
1068
1508
|
}
|
|
1069
1509
|
|
|
1070
1510
|
/**
|
|
@@ -1073,9 +1513,13 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1073
1513
|
* @returns rendering bounding box. returns false if the item is not exist
|
|
1074
1514
|
* @group Item
|
|
1075
1515
|
*/
|
|
1076
|
-
public getRenderBBox(
|
|
1516
|
+
public getRenderBBox(
|
|
1517
|
+
id: ID | undefined,
|
|
1518
|
+
onlyKeyShape = false,
|
|
1519
|
+
isTransient = false,
|
|
1520
|
+
): AABB | false {
|
|
1077
1521
|
if (!id) return this.canvas.getRoot().getRenderBounds();
|
|
1078
|
-
return this.itemController.getItemBBox(id);
|
|
1522
|
+
return this.itemController.getItemBBox(id, onlyKeyShape, isTransient);
|
|
1079
1523
|
}
|
|
1080
1524
|
|
|
1081
1525
|
/**
|
|
@@ -1089,56 +1533,167 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1089
1533
|
}
|
|
1090
1534
|
|
|
1091
1535
|
// ===== combo operations =====
|
|
1536
|
+
|
|
1092
1537
|
/**
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
* @param
|
|
1538
|
+
* Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
|
|
1539
|
+
* Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
|
|
1540
|
+
* @param model combo user data
|
|
1541
|
+
* @returns whether success
|
|
1096
1542
|
* @group Combo
|
|
1097
1543
|
*/
|
|
1098
|
-
public
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1544
|
+
public addCombo(model: ComboUserModel, childrenIds: ID[]): ComboModel {
|
|
1545
|
+
const { graphCore } = this.dataController;
|
|
1546
|
+
const { specification } = this.themeController;
|
|
1547
|
+
graphCore.once('changed', (event) => {
|
|
1548
|
+
if (!event.changes.length) return;
|
|
1549
|
+
const changes = event.changes;
|
|
1550
|
+
this.hooks.itemchange.emit({
|
|
1551
|
+
type: 'combo',
|
|
1552
|
+
changes: graphCore.reduceChanges(event.changes),
|
|
1553
|
+
graphCore,
|
|
1554
|
+
theme: specification,
|
|
1555
|
+
});
|
|
1556
|
+
this.emit('afteritemchange', {
|
|
1557
|
+
type: 'combo',
|
|
1558
|
+
action: 'add',
|
|
1559
|
+
models: [model],
|
|
1560
|
+
apiName: 'addCombo',
|
|
1561
|
+
changes,
|
|
1562
|
+
});
|
|
1563
|
+
});
|
|
1564
|
+
|
|
1565
|
+
const data = {
|
|
1566
|
+
nodes: [],
|
|
1567
|
+
edges: [],
|
|
1568
|
+
combos: [
|
|
1569
|
+
{
|
|
1570
|
+
...model,
|
|
1571
|
+
data: {
|
|
1572
|
+
...model.data,
|
|
1573
|
+
_children: childrenIds,
|
|
1574
|
+
},
|
|
1575
|
+
},
|
|
1576
|
+
],
|
|
1577
|
+
};
|
|
1578
|
+
this.hooks.datachange.emit({
|
|
1579
|
+
data,
|
|
1580
|
+
type: 'addCombo',
|
|
1581
|
+
});
|
|
1582
|
+
return this.dataController.findData('combo', [model.id])[0] as ComboModel;
|
|
1104
1583
|
}
|
|
1105
1584
|
/**
|
|
1106
|
-
*
|
|
1107
|
-
* @param
|
|
1585
|
+
* Collapse a combo.
|
|
1586
|
+
* @param comboId combo ids
|
|
1108
1587
|
* @group Combo
|
|
1109
1588
|
*/
|
|
1110
|
-
public
|
|
1111
|
-
|
|
1589
|
+
public collapseCombo(comboIds: ID | ID[]) {
|
|
1590
|
+
const ids = isArray(comboIds) ? comboIds : [comboIds];
|
|
1591
|
+
this.executeWithoutStacking(() => {
|
|
1592
|
+
this.updateData(
|
|
1593
|
+
'combo',
|
|
1594
|
+
ids.map((id) => ({ id, data: { collapsed: true } })),
|
|
1595
|
+
);
|
|
1596
|
+
});
|
|
1597
|
+
this.emit('aftercollapsecombo', {
|
|
1598
|
+
type: 'combo',
|
|
1599
|
+
action: 'collapseCombo',
|
|
1600
|
+
ids: comboIds,
|
|
1601
|
+
apiName: 'collapseCombo',
|
|
1602
|
+
});
|
|
1112
1603
|
}
|
|
1113
1604
|
/**
|
|
1114
|
-
*
|
|
1115
|
-
* @param
|
|
1605
|
+
* Expand a combo.
|
|
1606
|
+
* @param combo combo ids
|
|
1116
1607
|
* @group Combo
|
|
1117
1608
|
*/
|
|
1118
|
-
public
|
|
1119
|
-
|
|
1609
|
+
public expandCombo(comboIds: ID | ID[]) {
|
|
1610
|
+
const ids = isArray(comboIds) ? comboIds : [comboIds];
|
|
1611
|
+
this.executeWithoutStacking(() => {
|
|
1612
|
+
this.updateData(
|
|
1613
|
+
'combo',
|
|
1614
|
+
ids.map((id) => ({ id, data: { collapsed: false } })),
|
|
1615
|
+
);
|
|
1616
|
+
});
|
|
1617
|
+
this.emit('afterexpandcombo', {
|
|
1618
|
+
type: 'combo',
|
|
1619
|
+
action: 'expandCombo',
|
|
1620
|
+
ids: comboIds,
|
|
1621
|
+
apiName: 'expandCombo',
|
|
1622
|
+
});
|
|
1120
1623
|
}
|
|
1624
|
+
|
|
1121
1625
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1626
|
+
* Move one or more combos a distance (dx, dy) relatively,
|
|
1627
|
+
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1628
|
+
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1629
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1124
1630
|
* @group Combo
|
|
1125
1631
|
*/
|
|
1126
|
-
public
|
|
1127
|
-
|
|
1632
|
+
public moveCombo(
|
|
1633
|
+
ids: ID | ID[],
|
|
1634
|
+
dx: number,
|
|
1635
|
+
dy: number,
|
|
1636
|
+
upsertAncestors?: boolean,
|
|
1637
|
+
callback?: (
|
|
1638
|
+
model: NodeModel | EdgeModel | ComboModel,
|
|
1639
|
+
canceled?: boolean,
|
|
1640
|
+
) => void,
|
|
1641
|
+
): ComboModel[] {
|
|
1642
|
+
const idArr = isArray(ids) ? ids : [ids];
|
|
1643
|
+
const { graphCore } = this.dataController;
|
|
1644
|
+
const { specification } = this.themeController;
|
|
1645
|
+
graphCore.once('changed', (event) => {
|
|
1646
|
+
if (!event.changes.length) return;
|
|
1647
|
+
const changes = this.extendChanges(clone(event.changes));
|
|
1648
|
+
this.hooks.itemchange.emit({
|
|
1649
|
+
type: 'combo',
|
|
1650
|
+
changes: event.changes,
|
|
1651
|
+
graphCore,
|
|
1652
|
+
theme: specification,
|
|
1653
|
+
upsertAncestors,
|
|
1654
|
+
action: 'updatePosition',
|
|
1655
|
+
callback,
|
|
1656
|
+
});
|
|
1657
|
+
this.emit('afteritemchange', {
|
|
1658
|
+
type: 'combo',
|
|
1659
|
+
ids: idArr,
|
|
1660
|
+
dx,
|
|
1661
|
+
dy,
|
|
1662
|
+
action: 'updatePosition',
|
|
1663
|
+
upsertAncestors,
|
|
1664
|
+
apiName: 'moveCombo',
|
|
1665
|
+
changes,
|
|
1666
|
+
});
|
|
1667
|
+
});
|
|
1668
|
+
|
|
1669
|
+
this.hooks.datachange.emit({
|
|
1670
|
+
data: {
|
|
1671
|
+
nodes: [],
|
|
1672
|
+
edges: [],
|
|
1673
|
+
combos: idArr.map((id) => ({ id, data: { dx, dy } })),
|
|
1674
|
+
},
|
|
1675
|
+
type: 'moveCombo',
|
|
1676
|
+
});
|
|
1677
|
+
return this.dataController.findData('combo', idArr) as ComboModel[];
|
|
1128
1678
|
}
|
|
1129
1679
|
|
|
1130
1680
|
// ===== layout =====
|
|
1131
1681
|
/**
|
|
1132
1682
|
* Layout the graph (with current configurations if cfg is not assigned).
|
|
1133
1683
|
*/
|
|
1134
|
-
public async layout(options?: LayoutOptions) {
|
|
1684
|
+
public async layout(options?: LayoutOptions, disableAnimate = false) {
|
|
1685
|
+
this.emit('beforelayout');
|
|
1135
1686
|
const { graphCore } = this.dataController;
|
|
1136
1687
|
const formattedOptions = {
|
|
1137
1688
|
...this.getSpecification().layout,
|
|
1138
1689
|
...options,
|
|
1139
1690
|
} as LayoutOptions;
|
|
1140
1691
|
|
|
1141
|
-
|
|
1692
|
+
this.updateSpecification({ layout: formattedOptions });
|
|
1693
|
+
|
|
1694
|
+
const layoutUnset =
|
|
1695
|
+
(!options && !this.getSpecification().layout) ||
|
|
1696
|
+
!Object.keys(formattedOptions).length;
|
|
1142
1697
|
if (layoutUnset) {
|
|
1143
1698
|
const nodes = graphCore.getAllNodes();
|
|
1144
1699
|
if (nodes.every((node) => isNil(node.data.x) && isNil(node.data.y))) {
|
|
@@ -1167,7 +1722,9 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1167
1722
|
await this.hooks.layout.emitLinearAsync({
|
|
1168
1723
|
graphCore,
|
|
1169
1724
|
options: formattedOptions,
|
|
1725
|
+
animate: !disableAnimate,
|
|
1170
1726
|
});
|
|
1727
|
+
|
|
1171
1728
|
this.emit('afterlayout');
|
|
1172
1729
|
}
|
|
1173
1730
|
|
|
@@ -1178,6 +1735,14 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1178
1735
|
this.layoutController.stopLayout();
|
|
1179
1736
|
}
|
|
1180
1737
|
|
|
1738
|
+
/**
|
|
1739
|
+
*
|
|
1740
|
+
* @returns
|
|
1741
|
+
*/
|
|
1742
|
+
public getLayoutCurrentAnimation() {
|
|
1743
|
+
return this.layoutController.getCurrentAnimation();
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1181
1746
|
/**
|
|
1182
1747
|
* Switch mode.
|
|
1183
1748
|
* @param mode mode name
|
|
@@ -1188,6 +1753,15 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1188
1753
|
this.hooks.modechange.emit({ mode });
|
|
1189
1754
|
}
|
|
1190
1755
|
|
|
1756
|
+
/**
|
|
1757
|
+
* Get current mode.
|
|
1758
|
+
* @returns mode name
|
|
1759
|
+
* @group Interaction
|
|
1760
|
+
*/
|
|
1761
|
+
public getMode(): string {
|
|
1762
|
+
return this.interactionController.getMode();
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1191
1765
|
/**
|
|
1192
1766
|
* Add behavior(s) to mode(s).
|
|
1193
1767
|
* @param behaviors behavior names or configs
|
|
@@ -1196,7 +1770,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1196
1770
|
* @group Interaction
|
|
1197
1771
|
*/
|
|
1198
1772
|
public addBehaviors(
|
|
1199
|
-
behaviors: BehaviorOptionsOf<B>[],
|
|
1773
|
+
behaviors: BehaviorOptionsOf<B> | BehaviorOptionsOf<B>[],
|
|
1200
1774
|
modes: string | string[],
|
|
1201
1775
|
) {
|
|
1202
1776
|
const modesArr = isArray(modes) ? modes : [modes];
|
|
@@ -1323,16 +1897,21 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1323
1897
|
* @returns
|
|
1324
1898
|
* @group Plugin
|
|
1325
1899
|
*/
|
|
1326
|
-
public removePlugins(pluginKeys: string[]) {
|
|
1900
|
+
public removePlugins(pluginKeys: (PluginBase | string)[]) {
|
|
1901
|
+
const pluginArr = isArray(pluginKeys) ? pluginKeys : [pluginKeys];
|
|
1327
1902
|
this.hooks.pluginchange.emit({
|
|
1328
1903
|
action: 'remove',
|
|
1329
|
-
plugins:
|
|
1904
|
+
plugins: pluginArr,
|
|
1330
1905
|
});
|
|
1331
1906
|
// update the graph specification
|
|
1332
1907
|
const { plugins } = this.specification;
|
|
1333
1908
|
this.specification.plugins = plugins?.filter((plugin) => {
|
|
1334
|
-
if (isObject(plugin))
|
|
1335
|
-
|
|
1909
|
+
if (isObject(plugin))
|
|
1910
|
+
return !(
|
|
1911
|
+
pluginArr.includes(plugin.key) ||
|
|
1912
|
+
pluginArr.includes(plugin as PluginBase)
|
|
1913
|
+
);
|
|
1914
|
+
return !pluginArr.includes(plugin);
|
|
1336
1915
|
});
|
|
1337
1916
|
}
|
|
1338
1917
|
|
|
@@ -1342,11 +1921,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1342
1921
|
* @returns
|
|
1343
1922
|
* @group Interaction
|
|
1344
1923
|
*/
|
|
1345
|
-
public updatePlugin(
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1924
|
+
public updatePlugin(
|
|
1925
|
+
plugin:
|
|
1926
|
+
| {
|
|
1927
|
+
key: string;
|
|
1928
|
+
type: string;
|
|
1929
|
+
[cfg: string]: unknown;
|
|
1930
|
+
}
|
|
1931
|
+
| PluginBase,
|
|
1932
|
+
) {
|
|
1933
|
+
const { plugins } = this.specification;
|
|
1350
1934
|
const { key } = plugin;
|
|
1351
1935
|
if (!key) {
|
|
1352
1936
|
console.warn(
|
|
@@ -1354,7 +1938,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1354
1938
|
);
|
|
1355
1939
|
return;
|
|
1356
1940
|
}
|
|
1357
|
-
const { plugins } = this.specification;
|
|
1358
1941
|
if (!plugins) {
|
|
1359
1942
|
console.warn(
|
|
1360
1943
|
'Update plugin failed, the plugin to be updated does not exist.',
|
|
@@ -1399,17 +1982,208 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1399
1982
|
action: 'remove' | 'add' | 'update' | undefined;
|
|
1400
1983
|
style: ShapeStyle;
|
|
1401
1984
|
onlyDrawKeyShape?: boolean;
|
|
1985
|
+
upsertAncestors?: boolean;
|
|
1402
1986
|
},
|
|
1987
|
+
canvas?: Canvas,
|
|
1403
1988
|
): DisplayObject {
|
|
1404
1989
|
this.hooks.transientupdate.emit({
|
|
1405
1990
|
type,
|
|
1406
1991
|
id,
|
|
1407
1992
|
config,
|
|
1408
|
-
canvas: this.transientCanvas,
|
|
1993
|
+
canvas: canvas || this.transientCanvas,
|
|
1994
|
+
graphCore: this.dataController.graphCore,
|
|
1409
1995
|
});
|
|
1410
1996
|
return this.itemController.getTransient(String(id));
|
|
1411
1997
|
}
|
|
1412
1998
|
|
|
1999
|
+
// ===== history operations =====
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* Determine if history (redo/undo) is enabled.
|
|
2003
|
+
*/
|
|
2004
|
+
public isHistoryEnabled() {
|
|
2005
|
+
const history = this.getHistoryPlugin();
|
|
2006
|
+
return history?.isEnable();
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Push the operation(s) onto the specified stack
|
|
2011
|
+
* @param cmd commands to be pushed
|
|
2012
|
+
* @param stackType undo/redo stack
|
|
2013
|
+
* @param isNew
|
|
2014
|
+
*/
|
|
2015
|
+
public pushStack(cmd: Command[], stackType: StackType, isNew?: boolean) {
|
|
2016
|
+
const history = this.getHistoryPlugin();
|
|
2017
|
+
return history?.push(cmd, stackType, isNew);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
/**
|
|
2021
|
+
* Pause stacking operation.
|
|
2022
|
+
*/
|
|
2023
|
+
public pauseStacking(): void {
|
|
2024
|
+
const history = this.getHistoryPlugin();
|
|
2025
|
+
return history?.pauseStacking();
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Resume stacking operation.
|
|
2030
|
+
*/
|
|
2031
|
+
public resumeStacking(): void {
|
|
2032
|
+
const history = this.getHistoryPlugin();
|
|
2033
|
+
return history?.resumeStacking();
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* Execute a callback without allowing any stacking operations.
|
|
2038
|
+
* @param callback
|
|
2039
|
+
*/
|
|
2040
|
+
public executeWithoutStacking = (callback: () => void): void => {
|
|
2041
|
+
const history = this.getHistoryPlugin();
|
|
2042
|
+
history?.pauseStacking();
|
|
2043
|
+
try {
|
|
2044
|
+
callback();
|
|
2045
|
+
} finally {
|
|
2046
|
+
history?.resumeStacking();
|
|
2047
|
+
}
|
|
2048
|
+
};
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* Retrieve the current redo stack which consists of operations that could be undone
|
|
2052
|
+
*/
|
|
2053
|
+
public getUndoStack() {
|
|
2054
|
+
const history = this.getHistoryPlugin();
|
|
2055
|
+
return history?.getUndoStack();
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
/**
|
|
2059
|
+
* Retrieve the current undo stack which consists of operations that were undone
|
|
2060
|
+
*/
|
|
2061
|
+
public getRedoStack() {
|
|
2062
|
+
const history = this.getHistoryPlugin();
|
|
2063
|
+
return history?.getRedoStack();
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Retrieve the complete history stack
|
|
2068
|
+
* @returns
|
|
2069
|
+
*/
|
|
2070
|
+
public getStack() {
|
|
2071
|
+
const history = this.getHistoryPlugin();
|
|
2072
|
+
return history?.getStack();
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Restore n operations that were last n reverted on the graph.
|
|
2077
|
+
* @param steps The number of operations to undo. Default to 1.
|
|
2078
|
+
* @returns
|
|
2079
|
+
*/
|
|
2080
|
+
public undo() {
|
|
2081
|
+
const history = this.getHistoryPlugin();
|
|
2082
|
+
history?.undo();
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
/**
|
|
2086
|
+
* Revert recent n operation(s) performed on the graph.
|
|
2087
|
+
* @param steps The number of operations to redo. Default to 1.
|
|
2088
|
+
* @returns
|
|
2089
|
+
*/
|
|
2090
|
+
public redo() {
|
|
2091
|
+
const history = this.getHistoryPlugin();
|
|
2092
|
+
history?.redo();
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
/**
|
|
2096
|
+
* Indicate whether there are any actions available in the undo stack.
|
|
2097
|
+
*/
|
|
2098
|
+
public canUndo() {
|
|
2099
|
+
const history = this.getHistoryPlugin();
|
|
2100
|
+
return history?.canUndo();
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* Indicate whether there are any actions available in the redo stack.
|
|
2105
|
+
*/
|
|
2106
|
+
public canRedo() {
|
|
2107
|
+
const history = this.getHistoryPlugin();
|
|
2108
|
+
return history?.canRedo();
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
/**
|
|
2112
|
+
* Begin a batch operation.
|
|
2113
|
+
* Any operations performed between `startBatch` and `stopBatch` are grouped together.
|
|
2114
|
+
* treated as a single operation when undoing or redoing.
|
|
2115
|
+
*/
|
|
2116
|
+
public startBatch() {
|
|
2117
|
+
const history = this.getHistoryPlugin();
|
|
2118
|
+
history?.startBatch();
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* End a batch operation.
|
|
2123
|
+
* Any operations performed between `startBatch` and `stopBatch` are grouped together.
|
|
2124
|
+
* treated as a single operation when undoing or redoing.
|
|
2125
|
+
*/
|
|
2126
|
+
public stopBatch() {
|
|
2127
|
+
const history = this.getHistoryPlugin();
|
|
2128
|
+
history?.stopBatch();
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* Execute a provided function within a batched context
|
|
2133
|
+
* All operations performed inside callback will be treated as a composite operation
|
|
2134
|
+
* more convenient way without manually invoking `startBatch` and `stopBatch`.
|
|
2135
|
+
* @param callback The func containing operations to be batched together.
|
|
2136
|
+
*/
|
|
2137
|
+
public batch(callback: () => void) {
|
|
2138
|
+
const history = this.getHistoryPlugin();
|
|
2139
|
+
history?.batch(callback);
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
/**
|
|
2143
|
+
* Clear history stack
|
|
2144
|
+
* @param {StackType} stackType undo/redo stack
|
|
2145
|
+
*/
|
|
2146
|
+
public clearStack(stackType?: StackType) {
|
|
2147
|
+
const history = this.getHistoryPlugin();
|
|
2148
|
+
if (!stackType) return history?.clear();
|
|
2149
|
+
return stackType === 'undo'
|
|
2150
|
+
? history?.clearUndoStack()
|
|
2151
|
+
: history?.clearRedoStack();
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* Collapse sub tree(s).
|
|
2156
|
+
* @param ids Root id(s) of the sub trees.
|
|
2157
|
+
* @param disableAnimate Whether disable the animations for this operation.
|
|
2158
|
+
* @param stack Whether push this operation to stack.
|
|
2159
|
+
* @returns
|
|
2160
|
+
* @group Tree
|
|
2161
|
+
*/
|
|
2162
|
+
public collapse(ids: ID | ID[], disableAnimate = false, stack?: boolean) {
|
|
2163
|
+
this.hooks.treecollapseexpand.emit({
|
|
2164
|
+
ids: isArray(ids) ? ids : [ids],
|
|
2165
|
+
action: 'collapse',
|
|
2166
|
+
animate: !disableAnimate,
|
|
2167
|
+
graphCore: this.dataController.graphCore,
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Expand sub tree(s).
|
|
2172
|
+
* @param ids Root id(s) of the sub trees.
|
|
2173
|
+
* @param disableAnimate Whether disable the animations for this operation.
|
|
2174
|
+
* @param stack Whether push this operation to stack.
|
|
2175
|
+
* @returns
|
|
2176
|
+
* @group Tree
|
|
2177
|
+
*/
|
|
2178
|
+
public expand(ids: ID | ID[], disableAnimate = false, stack?: boolean) {
|
|
2179
|
+
this.hooks.treecollapseexpand.emit({
|
|
2180
|
+
ids: isArray(ids) ? ids : [ids],
|
|
2181
|
+
action: 'expand',
|
|
2182
|
+
animate: !disableAnimate,
|
|
2183
|
+
graphCore: this.dataController.graphCore,
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
|
|
1413
2187
|
/**
|
|
1414
2188
|
* Destroy the graph instance and remove the related canvases.
|
|
1415
2189
|
* @returns
|
|
@@ -1417,12 +2191,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1417
2191
|
*/
|
|
1418
2192
|
public destroy(callback?: Function) {
|
|
1419
2193
|
// TODO: call the destroy functions after items' buildOut animations finished
|
|
1420
|
-
setTimeout(() => {
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
2194
|
+
// setTimeout(() => {
|
|
2195
|
+
this.canvas.destroy();
|
|
2196
|
+
this.backgroundCanvas.destroy();
|
|
2197
|
+
this.transientCanvas.destroy();
|
|
2198
|
+
|
|
2199
|
+
// clear history stack
|
|
2200
|
+
this.clearStack();
|
|
2201
|
+
|
|
2202
|
+
callback?.();
|
|
2203
|
+
// }, 500);
|
|
1426
2204
|
|
|
1427
2205
|
this.hooks.destroy.emit({});
|
|
1428
2206
|
|