@antv/g6 5.0.0-beta.2 → 5.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g6.min.js +2 -2
- package/esm/api-doc/graph.d.ts +3 -3
- package/esm/api-doc/graph.js +3 -3
- package/esm/api-doc/graph.js.map +1 -1
- package/esm/api-doc/types.d.ts +1 -0
- package/esm/api-doc/types.js +1 -2
- package/esm/api-doc/types.js.map +1 -1
- package/esm/constant/shape.d.ts +3 -1
- package/esm/index.d.ts +33 -65
- package/esm/index.js +4 -5
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +18 -14
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +19 -2
- package/esm/item/edge.js +100 -44
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +27 -13
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +2 -8
- package/esm/item/node.js +31 -19
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +30 -16
- package/esm/runtime/controller/data.js +290 -422
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/interaction.js +9 -4
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +285 -150
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +1 -3
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.js +9 -5
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/graph.d.ts +104 -24
- package/esm/runtime/graph.js +472 -94
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.js +2 -2
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.d.ts +7 -1
- package/esm/stdlib/behavior/brush-select.js +10 -12
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +1 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +215 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
- package/esm/stdlib/behavior/drag-canvas.js +78 -33
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +43 -32
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +80 -63
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +3 -0
- package/esm/stdlib/behavior/index.js +3 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +3 -4
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/esm/stdlib/behavior/shortcuts-call.js +87 -0
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
- package/esm/stdlib/behavior/zoom-canvas.js +70 -26
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/index.d.ts +1 -0
- package/esm/stdlib/data/index.js +1 -0
- package/esm/stdlib/data/index.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.d.ts +4 -5
- package/esm/stdlib/data/mapNodeSize.js +12 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/processParallelEdges.d.ts +21 -0
- package/esm/stdlib/data/processParallelEdges.js +127 -0
- package/esm/stdlib/data/processParallelEdges.js.map +1 -0
- package/esm/stdlib/data/transformV4Data.d.ts +3 -4
- package/esm/stdlib/data/transformV4Data.js +10 -2
- package/esm/stdlib/data/transformV4Data.js.map +1 -1
- package/esm/stdlib/data/validateData.d.ts +4 -5
- package/esm/stdlib/data/validateData.js +22 -13
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +27 -8
- package/esm/stdlib/index.js +24 -11
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +3 -5
- package/esm/stdlib/item/edge/base.js +32 -31
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/esm/stdlib/item/edge/cubic.js +1 -1
- package/esm/stdlib/item/edge/cubic.js.map +1 -1
- package/esm/stdlib/item/edge/loop.js +1 -1
- package/esm/stdlib/item/edge/loop.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +3 -6
- package/esm/stdlib/item/node/base.js +30 -60
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +1 -0
- package/esm/stdlib/item/node/base3d.js +1 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/cube.d.ts +35 -0
- package/esm/stdlib/item/node/cube.js +54 -0
- package/esm/stdlib/item/node/cube.js.map +1 -0
- package/esm/stdlib/item/node/diamond.js +1 -1
- package/esm/stdlib/item/node/ellipse.js +2 -2
- package/esm/stdlib/item/node/hexagon.js +6 -2
- package/esm/stdlib/item/node/hexagon.js.map +1 -1
- package/esm/stdlib/item/node/image.d.ts +40 -0
- package/esm/stdlib/item/node/image.js +110 -0
- package/esm/stdlib/item/node/image.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +4 -0
- package/esm/stdlib/item/node/index.js +4 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/esm/stdlib/plugin/grid/index.d.ts +1 -1
- package/esm/stdlib/plugin/grid/index.js +3 -4
- package/esm/stdlib/plugin/grid/index.js.map +1 -1
- package/esm/stdlib/plugin/history/combo-command.js +2 -2
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
- package/esm/stdlib/plugin/history/index.d.ts +10 -10
- package/esm/stdlib/plugin/history/index.js +14 -14
- package/esm/stdlib/plugin/history/index.js.map +1 -1
- package/esm/stdlib/plugin/history/item-data-command.js +25 -16
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/hull/util.d.ts +2 -2
- package/esm/stdlib/plugin/hull/util.js +6 -2
- package/esm/stdlib/plugin/hull/util.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +2 -0
- package/esm/stdlib/plugin/index.js +2 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/legend/index.d.ts +2 -2
- package/esm/stdlib/plugin/legend/index.js +3 -3
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/menu/index.d.ts +4 -4
- package/esm/stdlib/plugin/menu/index.js +3 -3
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
- package/esm/stdlib/plugin/minimap/index.js +119 -12
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
- package/esm/stdlib/plugin/snapline/index.js +1063 -0
- package/esm/stdlib/plugin/snapline/index.js.map +1 -0
- package/esm/stdlib/plugin/timebar/index.js +2 -2
- package/esm/stdlib/plugin/timebar/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/esm/stdlib/plugin/toolbar/index.js +4 -4
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
- package/esm/stdlib/plugin/tooltip/index.js +3 -4
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +2 -0
- package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/esm/stdlib/plugin/watermaker/index.js +243 -0
- package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
- package/esm/stdlib/theme/dark.js +42 -2
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +4 -4
- package/esm/types/data.d.ts +5 -0
- package/esm/types/event.d.ts +1 -0
- package/esm/types/graph.d.ts +48 -22
- package/esm/types/hook.d.ts +22 -2
- package/esm/types/index.d.ts +2 -1
- package/esm/types/index.js +1 -0
- package/esm/types/index.js.map +1 -1
- package/esm/types/item.d.ts +7 -1
- package/esm/types/item.js.map +1 -1
- package/esm/types/plugin.d.ts +1 -1
- package/esm/types/spec.d.ts +20 -3
- package/esm/types/view.d.ts +5 -0
- package/esm/util/array.d.ts +1 -0
- package/esm/util/array.js +3 -0
- package/esm/util/array.js.map +1 -1
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +33 -5
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/behavior.d.ts +2 -2
- package/esm/util/behavior.js +2 -2
- package/esm/util/behavior.js.map +1 -1
- package/esm/util/data.d.ts +5 -2
- package/esm/util/data.js +15 -0
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.d.ts +15 -0
- package/esm/util/dom.js +29 -0
- package/esm/util/dom.js.map +1 -0
- package/esm/util/event.d.ts +3 -1
- package/esm/util/event.js +8 -1
- package/esm/util/event.js.map +1 -1
- package/esm/util/extend.d.ts +1 -1
- package/esm/util/extend.js +0 -1
- package/esm/util/extend.js.map +1 -1
- package/esm/util/index.d.ts +7 -52
- package/esm/util/index.js +7 -23
- package/esm/util/index.js.map +1 -1
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/layout.d.ts +12 -1
- package/esm/util/layout.js +45 -0
- package/esm/util/layout.js.map +1 -1
- package/esm/util/loop.d.ts +2 -1
- package/esm/util/loop.js +14 -0
- package/esm/util/loop.js.map +1 -1
- package/esm/util/math.d.ts +1 -1
- package/esm/util/matrix.d.ts +6 -0
- package/esm/util/matrix.js +48 -0
- package/esm/util/matrix.js.map +1 -0
- package/esm/util/path.js +1 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/point.d.ts +1 -1
- package/esm/util/point.js +9 -2
- package/esm/util/point.js.map +1 -1
- package/esm/util/polyline.d.ts +2 -1
- package/esm/util/polyline.js +2 -1
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/shape.d.ts +3 -3
- package/esm/util/shape.js +17 -26
- package/esm/util/shape.js.map +1 -1
- package/esm/util/shape3d.d.ts +1 -1
- package/esm/util/shape3d.js +16 -17
- package/esm/util/shape3d.js.map +1 -1
- package/esm/util/text.d.ts +1 -1
- package/esm/util/text.js +3 -2
- package/esm/util/text.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/api-doc/graph.d.ts +3 -3
- package/lib/api-doc/graph.js +27 -7
- package/lib/api-doc/graph.js.map +1 -1
- package/lib/api-doc/types.d.ts +1 -0
- package/lib/api-doc/types.js +2 -2
- package/lib/api-doc/types.js.map +1 -1
- package/lib/constant/shape.d.ts +3 -1
- package/lib/index.d.ts +33 -65
- package/lib/index.js +18 -10
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +18 -14
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +19 -2
- package/lib/item/edge.js +99 -43
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +27 -13
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +2 -8
- package/lib/item/node.js +31 -19
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +30 -16
- package/lib/runtime/controller/data.js +288 -420
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/interaction.js +9 -4
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +284 -149
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +1 -3
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.js +9 -5
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/graph.d.ts +104 -24
- package/lib/runtime/graph.js +473 -94
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.js +2 -2
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.d.ts +7 -1
- package/lib/stdlib/behavior/brush-select.js +13 -12
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +1 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +219 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
- package/lib/stdlib/behavior/drag-canvas.js +78 -33
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +43 -32
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +80 -63
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +3 -0
- package/lib/stdlib/behavior/index.js +3 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +6 -4
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/lib/stdlib/behavior/shortcuts-call.js +91 -0
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
- package/lib/stdlib/behavior/zoom-canvas.js +70 -26
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/index.d.ts +1 -0
- package/lib/stdlib/data/index.js +1 -0
- package/lib/stdlib/data/index.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.d.ts +4 -5
- package/lib/stdlib/data/mapNodeSize.js +13 -3
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/processParallelEdges.d.ts +21 -0
- package/lib/stdlib/data/processParallelEdges.js +131 -0
- package/lib/stdlib/data/processParallelEdges.js.map +1 -0
- package/lib/stdlib/data/transformV4Data.d.ts +3 -4
- package/lib/stdlib/data/transformV4Data.js +11 -3
- package/lib/stdlib/data/transformV4Data.js.map +1 -1
- package/lib/stdlib/data/validateData.d.ts +4 -5
- package/lib/stdlib/data/validateData.js +23 -14
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +27 -8
- package/lib/stdlib/index.js +24 -11
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +3 -5
- package/lib/stdlib/item/edge/base.js +30 -29
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/lib/stdlib/item/edge/cubic.js +2 -2
- package/lib/stdlib/item/edge/cubic.js.map +1 -1
- package/lib/stdlib/item/edge/loop.js +3 -3
- package/lib/stdlib/item/edge/loop.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +3 -6
- package/lib/stdlib/item/node/base.js +29 -59
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +1 -0
- package/lib/stdlib/item/node/base3d.js +1 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/cube.d.ts +35 -0
- package/lib/stdlib/item/node/cube.js +58 -0
- package/lib/stdlib/item/node/cube.js.map +1 -0
- package/lib/stdlib/item/node/diamond.js +1 -1
- package/lib/stdlib/item/node/ellipse.js +2 -2
- package/lib/stdlib/item/node/hexagon.js +6 -2
- package/lib/stdlib/item/node/hexagon.js.map +1 -1
- package/lib/stdlib/item/node/image.d.ts +40 -0
- package/lib/stdlib/item/node/image.js +114 -0
- package/lib/stdlib/item/node/image.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +4 -0
- package/lib/stdlib/item/node/index.js +4 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/lib/stdlib/plugin/grid/index.d.ts +1 -1
- package/lib/stdlib/plugin/grid/index.js +6 -7
- package/lib/stdlib/plugin/grid/index.js.map +1 -1
- package/lib/stdlib/plugin/history/combo-command.js +2 -2
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
- package/lib/stdlib/plugin/history/index.d.ts +10 -10
- package/lib/stdlib/plugin/history/index.js +14 -14
- package/lib/stdlib/plugin/history/index.js.map +1 -1
- package/lib/stdlib/plugin/history/item-data-command.js +25 -16
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/hull/util.d.ts +2 -2
- package/lib/stdlib/plugin/hull/util.js +26 -22
- package/lib/stdlib/plugin/hull/util.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +2 -0
- package/lib/stdlib/plugin/index.js +2 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/legend/index.d.ts +2 -2
- package/lib/stdlib/plugin/legend/index.js +3 -3
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/menu/index.d.ts +4 -4
- package/lib/stdlib/plugin/menu/index.js +6 -6
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
- package/lib/stdlib/plugin/minimap/index.js +121 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
- package/lib/stdlib/plugin/snapline/index.js +1067 -0
- package/lib/stdlib/plugin/snapline/index.js.map +1 -0
- package/lib/stdlib/plugin/timebar/index.js +2 -2
- package/lib/stdlib/plugin/timebar/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/lib/stdlib/plugin/toolbar/index.js +5 -5
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
- package/lib/stdlib/plugin/tooltip/index.js +10 -11
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +2 -0
- package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/lib/stdlib/plugin/watermaker/index.js +247 -0
- package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
- package/lib/stdlib/theme/dark.js +42 -2
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +4 -4
- package/lib/types/data.d.ts +5 -0
- package/lib/types/event.d.ts +1 -0
- package/lib/types/graph.d.ts +48 -22
- package/lib/types/hook.d.ts +22 -2
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +3 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/item.d.ts +7 -1
- package/lib/types/item.js.map +1 -1
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/spec.d.ts +20 -3
- package/lib/types/view.d.ts +5 -0
- package/lib/util/array.d.ts +1 -0
- package/lib/util/array.js +5 -1
- package/lib/util/array.js.map +1 -1
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +36 -6
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/behavior.d.ts +2 -2
- package/lib/util/behavior.js +2 -2
- package/lib/util/behavior.js.map +1 -1
- package/lib/util/data.d.ts +5 -2
- package/lib/util/data.js +16 -1
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.d.ts +15 -0
- package/lib/util/dom.js +34 -0
- package/lib/util/dom.js.map +1 -0
- package/lib/util/event.d.ts +3 -1
- package/lib/util/event.js +8 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/extend.d.ts +1 -1
- package/lib/util/extend.js +0 -1
- package/lib/util/extend.js.map +1 -1
- package/lib/util/index.d.ts +7 -52
- package/lib/util/index.js +23 -23
- package/lib/util/index.js.map +1 -1
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/layout.d.ts +12 -1
- package/lib/util/layout.js +47 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/loop.d.ts +2 -1
- package/lib/util/loop.js +15 -1
- package/lib/util/loop.js.map +1 -1
- package/lib/util/math.d.ts +1 -1
- package/lib/util/matrix.d.ts +6 -0
- package/lib/util/matrix.js +52 -0
- package/lib/util/matrix.js.map +1 -0
- package/lib/util/path.js +2 -2
- package/lib/util/path.js.map +1 -1
- package/lib/util/point.d.ts +1 -1
- package/lib/util/point.js +9 -2
- package/lib/util/point.js.map +1 -1
- package/lib/util/polyline.d.ts +2 -1
- package/lib/util/polyline.js +2 -1
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/shape.d.ts +3 -3
- package/lib/util/shape.js +17 -26
- package/lib/util/shape.js.map +1 -1
- package/lib/util/shape3d.d.ts +1 -1
- package/lib/util/shape3d.js +15 -16
- package/lib/util/shape3d.js.map +1 -1
- package/lib/util/text.d.ts +1 -1
- package/lib/util/text.js +3 -2
- package/lib/util/text.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +42 -51
- package/src/api-doc/graph.ts +4 -3
- package/src/api-doc/types.ts +1 -0
- package/src/constant/shape.ts +1 -1
- package/src/index.ts +5 -6
- package/src/item/combo.ts +16 -15
- package/src/item/edge.ts +135 -57
- package/src/item/item.ts +32 -19
- package/src/item/node.ts +36 -50
- package/src/runtime/controller/data.ts +371 -490
- package/src/runtime/controller/interaction.ts +10 -4
- package/src/runtime/controller/item.ts +261 -78
- package/src/runtime/controller/layout.ts +1 -5
- package/src/runtime/controller/plugin.ts +15 -4
- package/src/runtime/graph.ts +605 -103
- package/src/stdlib/behavior/activate-relations.ts +2 -2
- package/src/stdlib/behavior/brush-select.ts +14 -13
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/create-edge.ts +305 -0
- package/src/stdlib/behavior/drag-canvas.ts +107 -35
- package/src/stdlib/behavior/drag-combo.ts +10 -10
- package/src/stdlib/behavior/drag-node.ts +27 -18
- package/src/stdlib/behavior/index.ts +3 -0
- package/src/stdlib/behavior/lasso-select.ts +7 -5
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/shortcuts-call.ts +129 -0
- package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
- package/src/stdlib/behavior/zoom-canvas.ts +98 -27
- package/src/stdlib/data/index.ts +1 -0
- package/src/stdlib/data/mapNodeSize.ts +22 -3
- package/src/stdlib/data/processParallelEdges.ts +203 -0
- package/src/stdlib/data/transformV4Data.ts +16 -3
- package/src/stdlib/data/validateData.ts +32 -18
- package/src/stdlib/index.ts +31 -8
- package/src/stdlib/item/edge/base.ts +32 -41
- package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
- package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
- package/src/stdlib/item/edge/cubic.ts +1 -1
- package/src/stdlib/item/edge/loop.ts +1 -1
- package/src/stdlib/item/node/base.ts +38 -65
- package/src/stdlib/item/node/base3d.ts +1 -0
- package/src/stdlib/item/node/cube.ts +102 -0
- package/src/stdlib/item/node/diamond.ts +1 -1
- package/src/stdlib/item/node/ellipse.ts +2 -2
- package/src/stdlib/item/node/hexagon.ts +6 -2
- package/src/stdlib/item/node/image.ts +190 -0
- package/src/stdlib/item/node/index.ts +4 -0
- package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
- package/src/stdlib/plugin/grid/index.ts +6 -6
- package/src/stdlib/plugin/history/combo-command.ts +2 -2
- package/src/stdlib/plugin/history/index.ts +14 -14
- package/src/stdlib/plugin/history/item-data-command.ts +35 -17
- package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
- package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/hull/convexHull.ts +1 -1
- package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
- package/src/stdlib/plugin/hull/util.ts +6 -2
- package/src/stdlib/plugin/index.ts +2 -0
- package/src/stdlib/plugin/legend/index.ts +6 -6
- package/src/stdlib/plugin/menu/index.ts +13 -13
- package/src/stdlib/plugin/minimap/index.ts +126 -16
- package/src/stdlib/plugin/snapline/index.ts +1297 -0
- package/src/stdlib/plugin/timebar/index.ts +4 -4
- package/src/stdlib/plugin/toolbar/index.ts +8 -8
- package/src/stdlib/plugin/tooltip/index.ts +10 -10
- package/src/stdlib/plugin/types.ts +2 -0
- package/src/stdlib/plugin/watermaker/index.ts +302 -0
- package/src/stdlib/theme/dark.ts +66 -2
- package/src/stdlib/theme/light.ts +4 -4
- package/src/types/data.ts +6 -0
- package/src/types/event.ts +1 -0
- package/src/types/graph.ts +62 -25
- package/src/types/hook.ts +22 -2
- package/src/types/index.ts +2 -1
- package/src/types/item.ts +12 -1
- package/src/types/plugin.ts +1 -1
- package/src/types/spec.ts +23 -3
- package/src/types/view.ts +8 -3
- package/src/util/array.ts +12 -0
- package/src/util/bbox.ts +42 -6
- package/src/util/behavior.ts +4 -4
- package/src/util/data.ts +26 -4
- package/src/util/dom.ts +33 -0
- package/src/util/event.ts +14 -1
- package/src/util/extend.ts +2 -3
- package/src/util/index.ts +7 -24
- package/src/util/item.ts +65 -28
- package/src/util/layout.ts +48 -2
- package/src/util/loop.ts +16 -1
- package/src/util/math.ts +1 -1
- package/src/util/matrix.ts +66 -0
- package/src/util/path.ts +1 -1
- package/src/util/point.ts +9 -4
- package/src/util/polyline.ts +2 -1
- package/src/util/router.ts +1 -1
- package/src/util/shape.ts +23 -26
- package/src/util/shape3d.ts +20 -20
- package/src/util/text.ts +3 -1
- package/src/util/warn.ts +20 -0
package/esm/runtime/graph.js
CHANGED
|
@@ -19,13 +19,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
21
|
import EventEmitter from '@antv/event-emitter';
|
|
22
|
+
import { Rect, } from '@antv/g';
|
|
22
23
|
import { clone, groupBy, isArray, isEmpty, isEqual, isNil, isNumber, isObject, isString, map, } from '@antv/util';
|
|
23
24
|
import { changeRenderer, createCanvas } from '../util/canvas';
|
|
24
25
|
import { formatPadding } from '../util/shape';
|
|
26
|
+
import { getLayoutBounds } from '../util/layout';
|
|
27
|
+
import { createDOM } from '../util/dom';
|
|
25
28
|
import { DataController, ExtensionController, InteractionController, ItemController, LayoutController, ThemeController, ViewportController, } from './controller';
|
|
26
29
|
import { PluginController } from './controller/plugin';
|
|
27
30
|
import Hook from './hooks';
|
|
28
|
-
export
|
|
31
|
+
export class Graph extends EventEmitter {
|
|
29
32
|
constructor(spec) {
|
|
30
33
|
super();
|
|
31
34
|
this.defaultSpecification = {
|
|
@@ -39,17 +42,17 @@ export default class Graph extends EventEmitter {
|
|
|
39
42
|
* Execute a callback without allowing any stacking operations.
|
|
40
43
|
* @param callback
|
|
41
44
|
*/
|
|
42
|
-
this.
|
|
45
|
+
this.executeWithNoStack = (callback) => {
|
|
43
46
|
const history = this.getHistoryPlugin();
|
|
44
|
-
history === null || history === void 0 ? void 0 : history.
|
|
47
|
+
history === null || history === void 0 ? void 0 : history.pauseStack();
|
|
45
48
|
try {
|
|
46
49
|
callback();
|
|
47
50
|
}
|
|
48
51
|
finally {
|
|
49
|
-
history === null || history === void 0 ? void 0 : history.
|
|
52
|
+
history === null || history === void 0 ? void 0 : history.resumeStack();
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
|
-
this.specification = Object.assign({}, this.defaultSpecification, spec);
|
|
55
|
+
this.specification = Object.assign({}, this.defaultSpecification, this.formatSpecification(spec));
|
|
53
56
|
this.initHooks();
|
|
54
57
|
this.initCanvas();
|
|
55
58
|
this.initControllers();
|
|
@@ -129,11 +132,12 @@ export default class Graph extends EventEmitter {
|
|
|
129
132
|
.getContextService()
|
|
130
133
|
.getDomElement();
|
|
131
134
|
if ($domElement && $domElement.style) {
|
|
132
|
-
|
|
135
|
+
// Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
|
|
136
|
+
$domElement.style.position = 'absolute';
|
|
133
137
|
$domElement.style.outline = 'none';
|
|
134
138
|
$domElement.tabIndex = 1; // Enable keyboard events
|
|
135
139
|
// Transient canvas should let interactive events go through.
|
|
136
|
-
if (i
|
|
140
|
+
if (i !== 1) {
|
|
137
141
|
$domElement.style.pointerEvents = 'none';
|
|
138
142
|
}
|
|
139
143
|
}
|
|
@@ -193,16 +197,23 @@ export default class Graph extends EventEmitter {
|
|
|
193
197
|
}),
|
|
194
198
|
transientupdate: new Hook({ name: 'transientupdate' }),
|
|
195
199
|
pluginchange: new Hook({ name: 'pluginchange' }),
|
|
196
|
-
themechange: new Hook({ name: '
|
|
200
|
+
themechange: new Hook({ name: 'themechange' }),
|
|
201
|
+
mapperchange: new Hook({ name: 'mapperchange' }),
|
|
197
202
|
treecollapseexpand: new Hook({ name: 'treecollapseexpand' }),
|
|
198
203
|
destroy: new Hook({ name: 'destroy' }),
|
|
199
204
|
};
|
|
200
205
|
}
|
|
206
|
+
formatSpecification(spec) {
|
|
207
|
+
var _a;
|
|
208
|
+
return Object.assign(Object.assign(Object.assign({}, this.specification), spec), { optimize: Object.assign(Object.assign({ tileBehavior: 2000, tileBehaviorSize: 1000, tileFirstRender: 10000, tileFirstRenderSize: 1000 }, (_a = this.specification) === null || _a === void 0 ? void 0 : _a.optimize), spec.optimize) });
|
|
209
|
+
}
|
|
201
210
|
/**
|
|
202
211
|
* Update the specs(configurations).
|
|
203
212
|
*/
|
|
204
213
|
updateSpecification(spec) {
|
|
205
|
-
|
|
214
|
+
const newSpec = Object.assign(this.specification, this.formatSpecification(spec));
|
|
215
|
+
// TODO: update something
|
|
216
|
+
return newSpec;
|
|
206
217
|
}
|
|
207
218
|
/**
|
|
208
219
|
* Update the theme specs (configurations).
|
|
@@ -223,6 +234,28 @@ export default class Graph extends EventEmitter {
|
|
|
223
234
|
theme: this.themeController.specification,
|
|
224
235
|
});
|
|
225
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Update the item display mapper for a specific item type.
|
|
239
|
+
* @param {ITEM_TYPE} type - The type of item (node, edge, or combo).
|
|
240
|
+
* @param {NodeMapper | EdgeMapper | ComboMapper} mapper - The mapper to be updated.
|
|
241
|
+
* */
|
|
242
|
+
updateMapper(type, mapper) {
|
|
243
|
+
switch (type) {
|
|
244
|
+
case 'node':
|
|
245
|
+
this.specification.node = mapper;
|
|
246
|
+
break;
|
|
247
|
+
case 'edge':
|
|
248
|
+
this.specification.edge = mapper;
|
|
249
|
+
break;
|
|
250
|
+
case 'combo':
|
|
251
|
+
this.specification.combo = mapper;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
this.hooks.mapperchange.emit({
|
|
255
|
+
type,
|
|
256
|
+
mapper,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
226
259
|
/**
|
|
227
260
|
* Get the copy of specs(configurations).
|
|
228
261
|
* @returns graph specs
|
|
@@ -239,30 +272,39 @@ export default class Graph extends EventEmitter {
|
|
|
239
272
|
*/
|
|
240
273
|
read(data) {
|
|
241
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
275
|
+
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
242
276
|
this.hooks.datachange.emit({ data, type: 'replace' });
|
|
243
277
|
const emitRender = () => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
this.hooks.render.
|
|
278
|
+
yield this.hooks.render.emitLinearAsync({
|
|
245
279
|
graphCore: this.dataController.graphCore,
|
|
246
280
|
theme: this.themeController.specification,
|
|
247
281
|
transientCanvas: this.transientCanvas,
|
|
282
|
+
tileOptimize: {
|
|
283
|
+
tileFirstRender,
|
|
284
|
+
tileFirstRenderSize,
|
|
285
|
+
},
|
|
248
286
|
});
|
|
249
287
|
this.emit('afterrender');
|
|
250
288
|
this.once('afterlayout', () => __awaiter(this, void 0, void 0, function* () {
|
|
251
289
|
const { autoFit } = this.specification;
|
|
252
290
|
if (autoFit) {
|
|
253
291
|
if (autoFit === 'view') {
|
|
254
|
-
yield this.fitView();
|
|
292
|
+
yield this.fitView({ rules: { boundsType: 'layout' } });
|
|
255
293
|
}
|
|
256
294
|
else if (autoFit === 'center') {
|
|
257
|
-
yield this.fitCenter();
|
|
295
|
+
yield this.fitCenter('layout');
|
|
258
296
|
}
|
|
259
297
|
else {
|
|
260
298
|
const { type, effectTiming } = autoFit, others = __rest(autoFit, ["type", "effectTiming"]);
|
|
261
299
|
if (type === 'view') {
|
|
262
|
-
|
|
300
|
+
const { padding, rules } = others;
|
|
301
|
+
yield this.fitView({
|
|
302
|
+
padding,
|
|
303
|
+
rules: Object.assign(Object.assign({}, rules), { boundsType: 'layout' }),
|
|
304
|
+
}, effectTiming);
|
|
263
305
|
}
|
|
264
306
|
else if (type === 'center') {
|
|
265
|
-
yield this.fitCenter(effectTiming);
|
|
307
|
+
yield this.fitCenter('layout', effectTiming);
|
|
266
308
|
}
|
|
267
309
|
else if (type === 'position') {
|
|
268
310
|
// TODO: align
|
|
@@ -291,11 +333,16 @@ export default class Graph extends EventEmitter {
|
|
|
291
333
|
*/
|
|
292
334
|
changeData(data, type = 'mergeReplace') {
|
|
293
335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
336
|
+
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
294
337
|
this.hooks.datachange.emit({ data, type });
|
|
295
338
|
this.hooks.render.emit({
|
|
296
339
|
graphCore: this.dataController.graphCore,
|
|
297
340
|
theme: this.themeController.specification,
|
|
298
341
|
transientCanvas: this.transientCanvas,
|
|
342
|
+
tileOptimize: {
|
|
343
|
+
tileFirstRender,
|
|
344
|
+
tileFirstRenderSize,
|
|
345
|
+
},
|
|
299
346
|
});
|
|
300
347
|
this.emit('afterrender');
|
|
301
348
|
yield this.layout();
|
|
@@ -306,11 +353,11 @@ export default class Graph extends EventEmitter {
|
|
|
306
353
|
* @returns
|
|
307
354
|
*/
|
|
308
355
|
clear() {
|
|
309
|
-
this.
|
|
356
|
+
this.startHistoryBatch();
|
|
310
357
|
this.removeData('edge', this.getAllEdgesData().map((edge) => edge.id));
|
|
311
358
|
this.removeData('node', this.getAllNodesData().map((node) => node.id));
|
|
312
359
|
this.removeData('combo', this.getAllCombosData().map((combo) => combo.id));
|
|
313
|
-
this.
|
|
360
|
+
this.stopHistoryBatch();
|
|
314
361
|
}
|
|
315
362
|
getViewportCenter() {
|
|
316
363
|
const { width, height } = this.canvas.getConfig();
|
|
@@ -318,9 +365,11 @@ export default class Graph extends EventEmitter {
|
|
|
318
365
|
}
|
|
319
366
|
transform(options, effectTiming) {
|
|
320
367
|
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
+
const { tileLodSize } = this.specification.optimize || {};
|
|
321
369
|
yield this.hooks.viewportchange.emitLinearAsync({
|
|
322
370
|
transform: options,
|
|
323
371
|
effectTiming,
|
|
372
|
+
tileLodSize,
|
|
324
373
|
});
|
|
325
374
|
this.emit('viewportchange', options);
|
|
326
375
|
});
|
|
@@ -428,9 +477,12 @@ export default class Graph extends EventEmitter {
|
|
|
428
477
|
const [top, right, bottom, left] = padding
|
|
429
478
|
? formatPadding(padding)
|
|
430
479
|
: [0, 0, 0, 0];
|
|
431
|
-
const { direction = 'both', ratioRule = 'min' } = rules || {};
|
|
432
|
-
|
|
433
|
-
|
|
480
|
+
const { direction = 'both', ratioRule = 'min', boundsType = 'render', } = rules || {};
|
|
481
|
+
const { center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
|
|
482
|
+
? // Get the bounds of the whole graph content.
|
|
483
|
+
this.canvas.document.documentElement.getBounds()
|
|
484
|
+
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
485
|
+
getLayoutBounds(this);
|
|
434
486
|
const origin = this.canvas.canvas2Viewport({
|
|
435
487
|
x: graphCenterX,
|
|
436
488
|
y: graphCenterY,
|
|
@@ -475,10 +527,13 @@ export default class Graph extends EventEmitter {
|
|
|
475
527
|
* Fit the graph center to the view center.
|
|
476
528
|
* @param effectTiming animation configurations
|
|
477
529
|
*/
|
|
478
|
-
fitCenter(effectTiming) {
|
|
530
|
+
fitCenter(boundsType = 'render', effectTiming) {
|
|
479
531
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
-
|
|
481
|
-
|
|
532
|
+
const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
|
|
533
|
+
? // Get the bounds of the whole graph content.
|
|
534
|
+
this.canvas.document.documentElement.getBounds()
|
|
535
|
+
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
536
|
+
getLayoutBounds(this);
|
|
482
537
|
yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
|
|
483
538
|
});
|
|
484
539
|
}
|
|
@@ -535,9 +590,33 @@ export default class Graph extends EventEmitter {
|
|
|
535
590
|
console.warn(`Failed to setSize. The parameter size: ${size} is invalid. It must be an array with 2 number elements.`);
|
|
536
591
|
return;
|
|
537
592
|
}
|
|
593
|
+
const oldSize = [this.specification.width, this.specification.height];
|
|
594
|
+
this.emit('beforesetsize', { oldSize, size: size });
|
|
538
595
|
this.specification.width = size[0];
|
|
539
596
|
this.specification.height = size[1];
|
|
540
597
|
this.canvas.resize(size[0], size[1]);
|
|
598
|
+
this.transientCanvas.resize(size[0], size[1]);
|
|
599
|
+
this.backgroundCanvas.resize(size[0], size[1]);
|
|
600
|
+
this.emit('aftersetsize', { oldSize, size: size });
|
|
601
|
+
}
|
|
602
|
+
getCanvasRange() {
|
|
603
|
+
const [width, height] = this.getSize();
|
|
604
|
+
const leftTop = this.getCanvasByViewport({ x: 0, y: 0 });
|
|
605
|
+
const rightBottom = this.getCanvasByViewport({ x: width, y: height });
|
|
606
|
+
return {
|
|
607
|
+
min: [leftTop.x, leftTop.y, leftTop.z],
|
|
608
|
+
max: [rightBottom.x, rightBottom.y, rightBottom.z],
|
|
609
|
+
center: [
|
|
610
|
+
(leftTop.x + rightBottom.x) / 2,
|
|
611
|
+
(leftTop.y + rightBottom.y) / 2,
|
|
612
|
+
(leftTop.z + rightBottom.z) / 2,
|
|
613
|
+
],
|
|
614
|
+
halfExtents: [
|
|
615
|
+
(rightBottom.x - leftTop.x) / 2,
|
|
616
|
+
(rightBottom.y - leftTop.y) / 2,
|
|
617
|
+
(rightBottom.z - leftTop.z) / 2,
|
|
618
|
+
],
|
|
619
|
+
};
|
|
541
620
|
}
|
|
542
621
|
/**
|
|
543
622
|
* Get the rendering coordinate according to the canvas dom (viewport) coordinate.
|
|
@@ -717,19 +796,21 @@ export default class Graph extends EventEmitter {
|
|
|
717
796
|
if (!event.changes.length)
|
|
718
797
|
return;
|
|
719
798
|
const changes = event.changes;
|
|
720
|
-
|
|
721
|
-
type: itemType,
|
|
722
|
-
changes: graphCore.reduceChanges(event.changes),
|
|
723
|
-
graphCore,
|
|
724
|
-
theme: specification,
|
|
725
|
-
});
|
|
726
|
-
this.emit('afteritemchange', {
|
|
799
|
+
const timingParameters = {
|
|
727
800
|
type: itemType,
|
|
728
801
|
action: 'add',
|
|
729
802
|
models,
|
|
730
803
|
apiName: 'addData',
|
|
731
804
|
changes,
|
|
805
|
+
};
|
|
806
|
+
this.emit('beforeitemchange', timingParameters);
|
|
807
|
+
this.hooks.itemchange.emit({
|
|
808
|
+
type: itemType,
|
|
809
|
+
changes: graphCore.reduceChanges(event.changes),
|
|
810
|
+
graphCore,
|
|
811
|
+
theme: specification,
|
|
732
812
|
});
|
|
813
|
+
this.emit('afteritemchange', timingParameters);
|
|
733
814
|
});
|
|
734
815
|
const modelArr = isArray(models) ? models : [models];
|
|
735
816
|
const data = { nodes: [], edges: [], combos: [] };
|
|
@@ -750,27 +831,38 @@ export default class Graph extends EventEmitter {
|
|
|
750
831
|
removeData(itemType, ids) {
|
|
751
832
|
const idArr = isArray(ids) ? ids : [ids];
|
|
752
833
|
const data = { nodes: [], edges: [], combos: [] };
|
|
753
|
-
const {
|
|
834
|
+
const { graphCore } = this.dataController;
|
|
754
835
|
const { specification } = this.themeController;
|
|
755
|
-
const getItem = itemType === 'edge' ?
|
|
756
|
-
|
|
836
|
+
const getItem = itemType === 'edge' ? graphCore.getEdge : graphCore.getNode;
|
|
837
|
+
const hasItem = itemType === 'edge' ? graphCore.hasEdge : graphCore.hasNode;
|
|
838
|
+
data[`${itemType}s`] = idArr
|
|
839
|
+
.map((id) => {
|
|
840
|
+
if (!hasItem.bind(graphCore)(id)) {
|
|
841
|
+
console.warn(`The ${itemType} data with id ${id} does not exist. It will be ignored`);
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
return getItem.bind(graphCore)(id);
|
|
845
|
+
})
|
|
846
|
+
.filter(Boolean);
|
|
757
847
|
graphCore.once('changed', (event) => {
|
|
758
848
|
if (!event.changes.length)
|
|
759
849
|
return;
|
|
760
850
|
const changes = event.changes;
|
|
761
|
-
|
|
762
|
-
type: itemType,
|
|
763
|
-
changes: event.changes,
|
|
764
|
-
graphCore,
|
|
765
|
-
theme: specification,
|
|
766
|
-
});
|
|
767
|
-
this.emit('afteritemchange', {
|
|
851
|
+
const timingParameters = {
|
|
768
852
|
type: itemType,
|
|
769
853
|
action: 'remove',
|
|
770
854
|
ids: idArr,
|
|
771
855
|
apiName: 'removeData',
|
|
772
856
|
changes,
|
|
857
|
+
};
|
|
858
|
+
this.emit('beforeitemchange', timingParameters);
|
|
859
|
+
this.hooks.itemchange.emit({
|
|
860
|
+
type: itemType,
|
|
861
|
+
changes: event.changes,
|
|
862
|
+
graphCore,
|
|
863
|
+
theme: specification,
|
|
773
864
|
});
|
|
865
|
+
this.emit('afteritemchange', timingParameters);
|
|
774
866
|
});
|
|
775
867
|
this.hooks.datachange.emit({
|
|
776
868
|
data,
|
|
@@ -838,19 +930,21 @@ export default class Graph extends EventEmitter {
|
|
|
838
930
|
const { specification } = this.themeController;
|
|
839
931
|
graphCore.once('changed', (event) => {
|
|
840
932
|
const changes = this.extendChanges(clone(event.changes));
|
|
841
|
-
|
|
842
|
-
type: itemType,
|
|
843
|
-
changes: event.changes,
|
|
844
|
-
graphCore,
|
|
845
|
-
theme: specification,
|
|
846
|
-
});
|
|
847
|
-
this.emit('afteritemchange', {
|
|
933
|
+
const timingParameters = {
|
|
848
934
|
type: itemType,
|
|
849
935
|
action: 'update',
|
|
850
936
|
models,
|
|
851
937
|
apiName: 'updateData',
|
|
852
938
|
changes,
|
|
939
|
+
};
|
|
940
|
+
this.emit('beforeitemchange', timingParameters);
|
|
941
|
+
this.hooks.itemchange.emit({
|
|
942
|
+
type: itemType,
|
|
943
|
+
changes: event.changes,
|
|
944
|
+
graphCore,
|
|
945
|
+
theme: specification,
|
|
853
946
|
});
|
|
947
|
+
this.emit('afteritemchange', timingParameters);
|
|
854
948
|
});
|
|
855
949
|
this.hooks.datachange.emit({
|
|
856
950
|
data,
|
|
@@ -893,10 +987,19 @@ export default class Graph extends EventEmitter {
|
|
|
893
987
|
const modelArr = isArray(models) ? models : [models];
|
|
894
988
|
const { graphCore } = this.dataController;
|
|
895
989
|
const { specification } = this.themeController;
|
|
896
|
-
graphCore.once('changed', (event) => {
|
|
990
|
+
graphCore === null || graphCore === void 0 ? void 0 : graphCore.once('changed', (event) => {
|
|
897
991
|
if (!event.changes.length)
|
|
898
992
|
return;
|
|
899
993
|
const changes = event.changes.filter((change) => !isEqual(change.newValue, change.oldValue));
|
|
994
|
+
const timingParameters = {
|
|
995
|
+
type,
|
|
996
|
+
action: 'updatePosition',
|
|
997
|
+
upsertAncestors,
|
|
998
|
+
models,
|
|
999
|
+
apiName: 'updatePosition',
|
|
1000
|
+
changes,
|
|
1001
|
+
};
|
|
1002
|
+
this.emit('beforeitemchange', timingParameters);
|
|
900
1003
|
this.hooks.itemchange.emit({
|
|
901
1004
|
type,
|
|
902
1005
|
changes: event.changes,
|
|
@@ -907,14 +1010,7 @@ export default class Graph extends EventEmitter {
|
|
|
907
1010
|
animate: !disableAnimate,
|
|
908
1011
|
callback,
|
|
909
1012
|
});
|
|
910
|
-
this.emit('afteritemchange',
|
|
911
|
-
type,
|
|
912
|
-
action: 'updatePosition',
|
|
913
|
-
upsertAncestors,
|
|
914
|
-
models,
|
|
915
|
-
apiName: 'updatePosition',
|
|
916
|
-
changes,
|
|
917
|
-
});
|
|
1013
|
+
this.emit('afteritemchange', timingParameters);
|
|
918
1014
|
});
|
|
919
1015
|
this.hooks.datachange.emit({
|
|
920
1016
|
data: {
|
|
@@ -974,7 +1070,7 @@ export default class Graph extends EventEmitter {
|
|
|
974
1070
|
* @returns
|
|
975
1071
|
* @group Item
|
|
976
1072
|
*/
|
|
977
|
-
hideItem(ids, disableAnimate = false) {
|
|
1073
|
+
hideItem(ids, disableAnimate = false, keepKeyShape = false) {
|
|
978
1074
|
const idArr = isArray(ids) ? ids : [ids];
|
|
979
1075
|
if (isEmpty(idArr))
|
|
980
1076
|
return;
|
|
@@ -987,6 +1083,7 @@ export default class Graph extends EventEmitter {
|
|
|
987
1083
|
value: false,
|
|
988
1084
|
graphCore: this.dataController.graphCore,
|
|
989
1085
|
animate: !disableAnimate,
|
|
1086
|
+
keepKeyShape,
|
|
990
1087
|
});
|
|
991
1088
|
this.emit('afteritemvisibilitychange', {
|
|
992
1089
|
ids,
|
|
@@ -994,6 +1091,7 @@ export default class Graph extends EventEmitter {
|
|
|
994
1091
|
animate: !disableAnimate,
|
|
995
1092
|
action: 'updateVisibility',
|
|
996
1093
|
apiName: 'hideItem',
|
|
1094
|
+
keepKeyShape,
|
|
997
1095
|
changes,
|
|
998
1096
|
});
|
|
999
1097
|
}
|
|
@@ -1071,7 +1169,7 @@ export default class Graph extends EventEmitter {
|
|
|
1071
1169
|
value,
|
|
1072
1170
|
});
|
|
1073
1171
|
this.emit('afteritemstatechange', {
|
|
1074
|
-
ids,
|
|
1172
|
+
ids: idArr,
|
|
1075
1173
|
states,
|
|
1076
1174
|
value,
|
|
1077
1175
|
action: 'updateState',
|
|
@@ -1118,7 +1216,7 @@ export default class Graph extends EventEmitter {
|
|
|
1118
1216
|
value: false,
|
|
1119
1217
|
});
|
|
1120
1218
|
this.emit('afteritemstatechange', {
|
|
1121
|
-
ids,
|
|
1219
|
+
ids: idArr,
|
|
1122
1220
|
states,
|
|
1123
1221
|
value: false,
|
|
1124
1222
|
action: 'updateState',
|
|
@@ -1161,19 +1259,21 @@ export default class Graph extends EventEmitter {
|
|
|
1161
1259
|
if (!event.changes.length)
|
|
1162
1260
|
return;
|
|
1163
1261
|
const changes = event.changes;
|
|
1164
|
-
|
|
1165
|
-
type: 'combo',
|
|
1166
|
-
changes: graphCore.reduceChanges(event.changes),
|
|
1167
|
-
graphCore,
|
|
1168
|
-
theme: specification,
|
|
1169
|
-
});
|
|
1170
|
-
this.emit('afteritemchange', {
|
|
1262
|
+
const timingParameters = {
|
|
1171
1263
|
type: 'combo',
|
|
1172
1264
|
action: 'add',
|
|
1173
1265
|
models: [model],
|
|
1174
1266
|
apiName: 'addCombo',
|
|
1175
1267
|
changes,
|
|
1268
|
+
};
|
|
1269
|
+
this.emit('beforeitemchange', timingParameters);
|
|
1270
|
+
this.hooks.itemchange.emit({
|
|
1271
|
+
type: 'combo',
|
|
1272
|
+
changes: graphCore.reduceChanges(event.changes),
|
|
1273
|
+
graphCore,
|
|
1274
|
+
theme: specification,
|
|
1176
1275
|
});
|
|
1276
|
+
this.emit('afteritemchange', timingParameters);
|
|
1177
1277
|
});
|
|
1178
1278
|
const data = {
|
|
1179
1279
|
nodes: [],
|
|
@@ -1195,7 +1295,7 @@ export default class Graph extends EventEmitter {
|
|
|
1195
1295
|
*/
|
|
1196
1296
|
collapseCombo(comboIds) {
|
|
1197
1297
|
const ids = isArray(comboIds) ? comboIds : [comboIds];
|
|
1198
|
-
this.
|
|
1298
|
+
this.executeWithNoStack(() => {
|
|
1199
1299
|
this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: true } })));
|
|
1200
1300
|
});
|
|
1201
1301
|
this.emit('aftercollapsecombo', {
|
|
@@ -1212,7 +1312,7 @@ export default class Graph extends EventEmitter {
|
|
|
1212
1312
|
*/
|
|
1213
1313
|
expandCombo(comboIds) {
|
|
1214
1314
|
const ids = isArray(comboIds) ? comboIds : [comboIds];
|
|
1215
|
-
this.
|
|
1315
|
+
this.executeWithNoStack(() => {
|
|
1216
1316
|
this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: false } })));
|
|
1217
1317
|
});
|
|
1218
1318
|
this.emit('afterexpandcombo', {
|
|
@@ -1237,16 +1337,7 @@ export default class Graph extends EventEmitter {
|
|
|
1237
1337
|
if (!event.changes.length)
|
|
1238
1338
|
return;
|
|
1239
1339
|
const changes = this.extendChanges(clone(event.changes));
|
|
1240
|
-
|
|
1241
|
-
type: 'combo',
|
|
1242
|
-
changes: event.changes,
|
|
1243
|
-
graphCore,
|
|
1244
|
-
theme: specification,
|
|
1245
|
-
upsertAncestors,
|
|
1246
|
-
action: 'updatePosition',
|
|
1247
|
-
callback,
|
|
1248
|
-
});
|
|
1249
|
-
this.emit('afteritemchange', {
|
|
1340
|
+
const timingParameters = {
|
|
1250
1341
|
type: 'combo',
|
|
1251
1342
|
ids: idArr,
|
|
1252
1343
|
dx,
|
|
@@ -1255,7 +1346,18 @@ export default class Graph extends EventEmitter {
|
|
|
1255
1346
|
upsertAncestors,
|
|
1256
1347
|
apiName: 'moveCombo',
|
|
1257
1348
|
changes,
|
|
1349
|
+
};
|
|
1350
|
+
this.emit('beforeitemchange', timingParameters);
|
|
1351
|
+
this.hooks.itemchange.emit({
|
|
1352
|
+
type: 'combo',
|
|
1353
|
+
changes: event.changes,
|
|
1354
|
+
graphCore,
|
|
1355
|
+
theme: specification,
|
|
1356
|
+
upsertAncestors,
|
|
1357
|
+
action: 'updatePosition',
|
|
1358
|
+
callback,
|
|
1258
1359
|
});
|
|
1360
|
+
this.emit('afteritemchange', timingParameters);
|
|
1259
1361
|
});
|
|
1260
1362
|
this.hooks.datachange.emit({
|
|
1261
1363
|
data: {
|
|
@@ -1340,6 +1442,14 @@ export default class Graph extends EventEmitter {
|
|
|
1340
1442
|
getMode() {
|
|
1341
1443
|
return this.interactionController.getMode();
|
|
1342
1444
|
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Set the cursor. But the cursor in item's style has higher priority.
|
|
1447
|
+
* @param cursor
|
|
1448
|
+
*/
|
|
1449
|
+
setCursor(cursor) {
|
|
1450
|
+
this.canvas.setCursor(cursor);
|
|
1451
|
+
this.transientCanvas.setCursor(cursor);
|
|
1452
|
+
}
|
|
1343
1453
|
/**
|
|
1344
1454
|
* Add behavior(s) to mode(s).
|
|
1345
1455
|
* @param behaviors behavior names or configs
|
|
@@ -1510,6 +1620,274 @@ export default class Graph extends EventEmitter {
|
|
|
1510
1620
|
});
|
|
1511
1621
|
return this.itemController.getTransient(String(id));
|
|
1512
1622
|
}
|
|
1623
|
+
// ===== download operations =====
|
|
1624
|
+
/**
|
|
1625
|
+
* Asynchronously generates a Data URL representation of the canvas content, including
|
|
1626
|
+
* background, main content, and transient canvas.
|
|
1627
|
+
* @param The type of the Data URL (e.g., 'image/png', 'image/jpeg').
|
|
1628
|
+
* @returns A Promise that resolves to the Data URL string.
|
|
1629
|
+
*/
|
|
1630
|
+
toDataURL(type) {
|
|
1631
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1632
|
+
const backgroundCanvas = this.backgroundCanvas;
|
|
1633
|
+
const canvas = this.canvas;
|
|
1634
|
+
const transientCanvas = this.transientCanvas;
|
|
1635
|
+
const rendererType = this.rendererType;
|
|
1636
|
+
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1637
|
+
const width = this.getSize()[0];
|
|
1638
|
+
const height = this.getSize()[1];
|
|
1639
|
+
const vContainerDOM = createDOM('<div id="virtual-image"></div>');
|
|
1640
|
+
const vCanvas = createCanvas(rendererType, vContainerDOM, width, height, pixelRatio);
|
|
1641
|
+
const vCanvasContextService = vCanvas.getContextService();
|
|
1642
|
+
let bgRect;
|
|
1643
|
+
if (rendererType !== 'svg') {
|
|
1644
|
+
bgRect = new Rect({
|
|
1645
|
+
style: {
|
|
1646
|
+
x: 0,
|
|
1647
|
+
y: 0,
|
|
1648
|
+
z: -1,
|
|
1649
|
+
width: vCanvasContextService.getDomElement().width,
|
|
1650
|
+
height: vCanvasContextService.getDomElement().height,
|
|
1651
|
+
//@ts-ignore
|
|
1652
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1653
|
+
},
|
|
1654
|
+
});
|
|
1655
|
+
vCanvas.appendChild(bgRect);
|
|
1656
|
+
}
|
|
1657
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1658
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1659
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1660
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1661
|
+
vCanvas.appendChild(clonedGroup);
|
|
1662
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1663
|
+
vCanvas.render();
|
|
1664
|
+
if (!type)
|
|
1665
|
+
type = 'image/png';
|
|
1666
|
+
let dataURL = '';
|
|
1667
|
+
yield vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1668
|
+
dataURL = url;
|
|
1669
|
+
});
|
|
1670
|
+
return dataURL;
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Asynchronously generates a Data URL representation of the full canvas content,
|
|
1675
|
+
* including background, main content, and transient canvas, with optional padding.
|
|
1676
|
+
* @param type The type of the Data URL (e.g., 'image/png', 'image/jpeg').
|
|
1677
|
+
* @param imageConfig Configuration options for the image (optional).
|
|
1678
|
+
* @returns A Promise that resolves to the Data URL string.
|
|
1679
|
+
*/
|
|
1680
|
+
toFullDataURL(type, imageConfig) {
|
|
1681
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1682
|
+
const backgroundCanvas = this.backgroundCanvas;
|
|
1683
|
+
const canvas = this.canvas;
|
|
1684
|
+
const transientCanvas = this.transientCanvas;
|
|
1685
|
+
const backgroundRoot = canvas.getRoot();
|
|
1686
|
+
const root = canvas.getRoot();
|
|
1687
|
+
const transientRoot = transientCanvas.getRoot();
|
|
1688
|
+
const rendererType = this.rendererType;
|
|
1689
|
+
const backgroundBBox = backgroundRoot.getBBox();
|
|
1690
|
+
const BBox = root.getBBox();
|
|
1691
|
+
const transientBBox = transientRoot.getBBox();
|
|
1692
|
+
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
1693
|
+
if (!padding) {
|
|
1694
|
+
padding = [0, 0, 0, 0];
|
|
1695
|
+
}
|
|
1696
|
+
else if (isNumber(padding)) {
|
|
1697
|
+
padding = [padding, padding, padding, padding];
|
|
1698
|
+
}
|
|
1699
|
+
const left = (transientBBox.left
|
|
1700
|
+
? backgroundBBox.left
|
|
1701
|
+
? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
|
|
1702
|
+
: Math.min(BBox.left, transientBBox.left)
|
|
1703
|
+
: BBox.left) - padding[3];
|
|
1704
|
+
const right = (transientBBox.right
|
|
1705
|
+
? backgroundBBox.right
|
|
1706
|
+
? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
|
|
1707
|
+
: Math.max(BBox.right, transientBBox.right)
|
|
1708
|
+
: BBox.right) + padding[1];
|
|
1709
|
+
const top = (transientBBox.top
|
|
1710
|
+
? backgroundBBox.top
|
|
1711
|
+
? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
|
|
1712
|
+
: Math.min(BBox.top, transientBBox.top)
|
|
1713
|
+
: BBox.top) - padding[0];
|
|
1714
|
+
const bottom = (transientBBox.bottom
|
|
1715
|
+
? backgroundBBox.bottom
|
|
1716
|
+
? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
|
|
1717
|
+
: Math.max(BBox.bottom, transientBBox.bottom)
|
|
1718
|
+
: BBox.bottom) + padding[2];
|
|
1719
|
+
const graphCenterX = (left + right) / 2;
|
|
1720
|
+
const graphCenterY = (top + bottom) / 2;
|
|
1721
|
+
const halfX = (right - left) / 2;
|
|
1722
|
+
const halfY = (bottom - top) / 2;
|
|
1723
|
+
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1724
|
+
const vWidth = halfX * 2;
|
|
1725
|
+
const vHeight = halfY * 2;
|
|
1726
|
+
const vContainerDOM = createDOM('<div id="virtual-image"></div>');
|
|
1727
|
+
const vCanvas = createCanvas(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
|
|
1728
|
+
const vCanvasContextService = vCanvas.getContextService();
|
|
1729
|
+
if (rendererType !== 'svg') {
|
|
1730
|
+
const bgRect = new Rect({
|
|
1731
|
+
style: {
|
|
1732
|
+
x: 0,
|
|
1733
|
+
y: 0,
|
|
1734
|
+
z: -1,
|
|
1735
|
+
width: vCanvasContextService.getDomElement().width,
|
|
1736
|
+
height: vCanvasContextService.getDomElement().height,
|
|
1737
|
+
//@ts-ignore
|
|
1738
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1739
|
+
},
|
|
1740
|
+
});
|
|
1741
|
+
vCanvas.appendChild(bgRect);
|
|
1742
|
+
}
|
|
1743
|
+
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
1744
|
+
const clonedGroup = root.cloneNode(true);
|
|
1745
|
+
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
1746
|
+
const transPosition = [
|
|
1747
|
+
-graphCenterX + halfX,
|
|
1748
|
+
-graphCenterY + halfY,
|
|
1749
|
+
];
|
|
1750
|
+
backgroundClonedGroup.setPosition(transPosition);
|
|
1751
|
+
clonedGroup.setPosition(transPosition);
|
|
1752
|
+
transientClonedGroup.setPosition(transPosition);
|
|
1753
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1754
|
+
vCanvas.appendChild(clonedGroup);
|
|
1755
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1756
|
+
vCanvas.render();
|
|
1757
|
+
if (!type)
|
|
1758
|
+
type = 'image/png';
|
|
1759
|
+
let dataURL = '';
|
|
1760
|
+
yield vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1761
|
+
dataURL = url;
|
|
1762
|
+
});
|
|
1763
|
+
return dataURL;
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Converts a Data URL to an image file and handles the download of the image.
|
|
1768
|
+
* @param dataURL The Data URL of the image to be converted and downloaded.
|
|
1769
|
+
* @param renderer The renderer type ('svg' or other) used for the canvas.
|
|
1770
|
+
* @param link The HTML link element used for image download.
|
|
1771
|
+
* @param fileName The desired name for the downloaded image file.
|
|
1772
|
+
*/
|
|
1773
|
+
dataURLToImage(dataURL, renderer, link, fileName) {
|
|
1774
|
+
if (!dataURL || dataURL === 'data:') {
|
|
1775
|
+
console.error('Download image failed. The graph is too large or there is invalid attribute values in graph items');
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
if (typeof window !== 'undefined') {
|
|
1779
|
+
if (window.Blob && window.URL && renderer !== 'svg') {
|
|
1780
|
+
const arr = dataURL.split(',');
|
|
1781
|
+
let mime = '';
|
|
1782
|
+
if (arr && arr.length > 0) {
|
|
1783
|
+
const match = arr[0].match(/:(.*?);/);
|
|
1784
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1785
|
+
if (match && match.length >= 2)
|
|
1786
|
+
mime = match[1];
|
|
1787
|
+
}
|
|
1788
|
+
const bstr = atob(arr[1]);
|
|
1789
|
+
let n = bstr.length;
|
|
1790
|
+
const u8arr = new Uint8Array(n);
|
|
1791
|
+
while (n--) {
|
|
1792
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
1793
|
+
}
|
|
1794
|
+
const blobObj = new Blob([u8arr], { type: mime });
|
|
1795
|
+
if (window.navigator.msSaveBlob) {
|
|
1796
|
+
window.navigator.msSaveBlob(blobObj, fileName);
|
|
1797
|
+
}
|
|
1798
|
+
else {
|
|
1799
|
+
link.addEventListener('click', () => {
|
|
1800
|
+
link.download = fileName;
|
|
1801
|
+
link.href = window.URL.createObjectURL(blobObj);
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
else {
|
|
1806
|
+
link.addEventListener('click', () => {
|
|
1807
|
+
link.download = fileName;
|
|
1808
|
+
link.href = dataURL;
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Initiates the download of the graph as an image with an optional name and type.
|
|
1815
|
+
* @param name The desired name for the downloaded image file (optional).
|
|
1816
|
+
* @param type The type of the image to download (optional, defaults to 'image/png').
|
|
1817
|
+
*/
|
|
1818
|
+
downloadImage(name, type) {
|
|
1819
|
+
const self = this;
|
|
1820
|
+
// self.stopAnimate();
|
|
1821
|
+
const rendererType = this.rendererType;
|
|
1822
|
+
if (!type)
|
|
1823
|
+
type = 'image/png';
|
|
1824
|
+
const fileName = (name || 'graph') +
|
|
1825
|
+
(rendererType === 'svg' ? '.svg' : type.split('/')[1]);
|
|
1826
|
+
const link = document.createElement('a');
|
|
1827
|
+
self.asyncToDataUrl(type, (dataURL) => {
|
|
1828
|
+
this.dataURLToImage(dataURL, rendererType, link, fileName);
|
|
1829
|
+
const e = document.createEvent('MouseEvents');
|
|
1830
|
+
e.initEvent('click', false, false);
|
|
1831
|
+
link.dispatchEvent(e);
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Initiates the download of the entire graph as an image with optional name, type, and padding configuration.
|
|
1836
|
+
* @param name The desired name for the downloaded image file (optional).
|
|
1837
|
+
* @param type The type of the image to download (optional, defaults to 'image/png').
|
|
1838
|
+
* @param imageConfig Configuration options for the image (optional).
|
|
1839
|
+
*/
|
|
1840
|
+
downloadFullImage(name, type, imageConfig) {
|
|
1841
|
+
const self = this;
|
|
1842
|
+
const rendererType = this.rendererType;
|
|
1843
|
+
if (!type)
|
|
1844
|
+
type = 'image/png';
|
|
1845
|
+
const fileName = (name || 'graph') +
|
|
1846
|
+
(rendererType === 'svg' ? '.svg' : type.split('/')[1]);
|
|
1847
|
+
const link = document.createElement('a');
|
|
1848
|
+
self.asyncToFullDataUrl(type, imageConfig, (dataURL) => {
|
|
1849
|
+
this.dataURLToImage(dataURL, rendererType, link, fileName);
|
|
1850
|
+
const e = document.createEvent('MouseEvents');
|
|
1851
|
+
e.initEvent('click', false, false);
|
|
1852
|
+
link.dispatchEvent(e);
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Asynchronously converts the canvas content to a Data URL of the specified type and invokes the provided callback.
|
|
1857
|
+
* @param type The type of the Data URL (optional, defaults to 'image/png').
|
|
1858
|
+
* @param callback A callback function to handle the Data URL (optional).
|
|
1859
|
+
*/
|
|
1860
|
+
asyncToDataUrl(type, callback) {
|
|
1861
|
+
let dataURL = '';
|
|
1862
|
+
if (!type)
|
|
1863
|
+
type = 'image/png';
|
|
1864
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
1865
|
+
yield this.toDataURL(type).then((url) => {
|
|
1866
|
+
dataURL = url;
|
|
1867
|
+
});
|
|
1868
|
+
if (callback)
|
|
1869
|
+
callback(dataURL);
|
|
1870
|
+
}), 16);
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Asynchronously converts the entire canvas content to a Data URL of the specified type
|
|
1874
|
+
* with optional padding, and invokes the provided callback.
|
|
1875
|
+
* @param type The type of the Data URL (optional, defaults to 'image/png').
|
|
1876
|
+
* @param imageConfig Configuration options for the image (optional).
|
|
1877
|
+
* @param callback A callback function to handle the Data URL (optional).
|
|
1878
|
+
*/
|
|
1879
|
+
asyncToFullDataUrl(type, imageConfig, callback) {
|
|
1880
|
+
let dataURL = '';
|
|
1881
|
+
if (!type)
|
|
1882
|
+
type = 'image/png';
|
|
1883
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
1884
|
+
yield this.toFullDataURL(type, imageConfig).then((url) => {
|
|
1885
|
+
dataURL = url;
|
|
1886
|
+
});
|
|
1887
|
+
if (callback)
|
|
1888
|
+
callback(dataURL);
|
|
1889
|
+
}), 16);
|
|
1890
|
+
}
|
|
1513
1891
|
// ===== history operations =====
|
|
1514
1892
|
/**
|
|
1515
1893
|
* Determine if history (redo/undo) is enabled.
|
|
@@ -1531,16 +1909,16 @@ export default class Graph extends EventEmitter {
|
|
|
1531
1909
|
/**
|
|
1532
1910
|
* Pause stacking operation.
|
|
1533
1911
|
*/
|
|
1534
|
-
|
|
1912
|
+
pauseStack() {
|
|
1535
1913
|
const history = this.getHistoryPlugin();
|
|
1536
|
-
return history === null || history === void 0 ? void 0 : history.
|
|
1914
|
+
return history === null || history === void 0 ? void 0 : history.pauseStack();
|
|
1537
1915
|
}
|
|
1538
1916
|
/**
|
|
1539
1917
|
* Resume stacking operation.
|
|
1540
1918
|
*/
|
|
1541
|
-
|
|
1919
|
+
resumeStack() {
|
|
1542
1920
|
const history = this.getHistoryPlugin();
|
|
1543
|
-
return history === null || history === void 0 ? void 0 : history.
|
|
1921
|
+
return history === null || history === void 0 ? void 0 : history.resumeStack();
|
|
1544
1922
|
}
|
|
1545
1923
|
/**
|
|
1546
1924
|
* Retrieve the current redo stack which consists of operations that could be undone
|
|
@@ -1597,38 +1975,38 @@ export default class Graph extends EventEmitter {
|
|
|
1597
1975
|
return history === null || history === void 0 ? void 0 : history.canRedo();
|
|
1598
1976
|
}
|
|
1599
1977
|
/**
|
|
1600
|
-
* Begin a
|
|
1601
|
-
* Any operations performed between `
|
|
1978
|
+
* Begin a historyBatch operation.
|
|
1979
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
1602
1980
|
* treated as a single operation when undoing or redoing.
|
|
1603
1981
|
*/
|
|
1604
|
-
|
|
1982
|
+
startHistoryBatch() {
|
|
1605
1983
|
const history = this.getHistoryPlugin();
|
|
1606
|
-
history === null || history === void 0 ? void 0 : history.
|
|
1984
|
+
history === null || history === void 0 ? void 0 : history.startHistoryBatch();
|
|
1607
1985
|
}
|
|
1608
1986
|
/**
|
|
1609
|
-
* End a
|
|
1610
|
-
* Any operations performed between `
|
|
1987
|
+
* End a historyBatch operation.
|
|
1988
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
1611
1989
|
* treated as a single operation when undoing or redoing.
|
|
1612
1990
|
*/
|
|
1613
|
-
|
|
1991
|
+
stopHistoryBatch() {
|
|
1614
1992
|
const history = this.getHistoryPlugin();
|
|
1615
|
-
history === null || history === void 0 ? void 0 : history.
|
|
1993
|
+
history === null || history === void 0 ? void 0 : history.stopHistoryBatch();
|
|
1616
1994
|
}
|
|
1617
1995
|
/**
|
|
1618
1996
|
* Execute a provided function within a batched context
|
|
1619
1997
|
* All operations performed inside callback will be treated as a composite operation
|
|
1620
|
-
* more convenient way without manually invoking `
|
|
1998
|
+
* more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
|
|
1621
1999
|
* @param callback The func containing operations to be batched together.
|
|
1622
2000
|
*/
|
|
1623
|
-
|
|
2001
|
+
historyBatch(callback) {
|
|
1624
2002
|
const history = this.getHistoryPlugin();
|
|
1625
|
-
history === null || history === void 0 ? void 0 : history.
|
|
2003
|
+
history === null || history === void 0 ? void 0 : history.historyBatch(callback);
|
|
1626
2004
|
}
|
|
1627
2005
|
/**
|
|
1628
2006
|
* Clear history stack
|
|
1629
2007
|
* @param {StackType} stackType undo/redo stack
|
|
1630
2008
|
*/
|
|
1631
|
-
|
|
2009
|
+
cleanHistory(stackType) {
|
|
1632
2010
|
const history = this.getHistoryPlugin();
|
|
1633
2011
|
if (!stackType)
|
|
1634
2012
|
return history === null || history === void 0 ? void 0 : history.clear();
|
|
@@ -1680,7 +2058,7 @@ export default class Graph extends EventEmitter {
|
|
|
1680
2058
|
this.backgroundCanvas.destroy();
|
|
1681
2059
|
this.transientCanvas.destroy();
|
|
1682
2060
|
// clear history stack
|
|
1683
|
-
this.
|
|
2061
|
+
this.cleanHistory();
|
|
1684
2062
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
1685
2063
|
// }, 500);
|
|
1686
2064
|
this.hooks.destroy.emit({});
|