@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/lib/runtime/graph.js
CHANGED
|
@@ -23,10 +23,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Graph = void 0;
|
|
26
27
|
const event_emitter_1 = __importDefault(require("@antv/event-emitter"));
|
|
28
|
+
const g_1 = require("@antv/g");
|
|
27
29
|
const util_1 = require("@antv/util");
|
|
28
30
|
const canvas_1 = require("../util/canvas");
|
|
29
31
|
const shape_1 = require("../util/shape");
|
|
32
|
+
const layout_1 = require("../util/layout");
|
|
33
|
+
const dom_1 = require("../util/dom");
|
|
30
34
|
const controller_1 = require("./controller");
|
|
31
35
|
const plugin_1 = require("./controller/plugin");
|
|
32
36
|
const hooks_1 = __importDefault(require("./hooks"));
|
|
@@ -44,17 +48,17 @@ class Graph extends event_emitter_1.default {
|
|
|
44
48
|
* Execute a callback without allowing any stacking operations.
|
|
45
49
|
* @param callback
|
|
46
50
|
*/
|
|
47
|
-
this.
|
|
51
|
+
this.executeWithNoStack = (callback) => {
|
|
48
52
|
const history = this.getHistoryPlugin();
|
|
49
|
-
history === null || history === void 0 ? void 0 : history.
|
|
53
|
+
history === null || history === void 0 ? void 0 : history.pauseStack();
|
|
50
54
|
try {
|
|
51
55
|
callback();
|
|
52
56
|
}
|
|
53
57
|
finally {
|
|
54
|
-
history === null || history === void 0 ? void 0 : history.
|
|
58
|
+
history === null || history === void 0 ? void 0 : history.resumeStack();
|
|
55
59
|
}
|
|
56
60
|
};
|
|
57
|
-
this.specification = Object.assign({}, this.defaultSpecification, spec);
|
|
61
|
+
this.specification = Object.assign({}, this.defaultSpecification, this.formatSpecification(spec));
|
|
58
62
|
this.initHooks();
|
|
59
63
|
this.initCanvas();
|
|
60
64
|
this.initControllers();
|
|
@@ -134,11 +138,12 @@ class Graph extends event_emitter_1.default {
|
|
|
134
138
|
.getContextService()
|
|
135
139
|
.getDomElement();
|
|
136
140
|
if ($domElement && $domElement.style) {
|
|
137
|
-
|
|
141
|
+
// Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
|
|
142
|
+
$domElement.style.position = 'absolute';
|
|
138
143
|
$domElement.style.outline = 'none';
|
|
139
144
|
$domElement.tabIndex = 1; // Enable keyboard events
|
|
140
145
|
// Transient canvas should let interactive events go through.
|
|
141
|
-
if (i
|
|
146
|
+
if (i !== 1) {
|
|
142
147
|
$domElement.style.pointerEvents = 'none';
|
|
143
148
|
}
|
|
144
149
|
}
|
|
@@ -198,16 +203,23 @@ class Graph extends event_emitter_1.default {
|
|
|
198
203
|
}),
|
|
199
204
|
transientupdate: new hooks_1.default({ name: 'transientupdate' }),
|
|
200
205
|
pluginchange: new hooks_1.default({ name: 'pluginchange' }),
|
|
201
|
-
themechange: new hooks_1.default({ name: '
|
|
206
|
+
themechange: new hooks_1.default({ name: 'themechange' }),
|
|
207
|
+
mapperchange: new hooks_1.default({ name: 'mapperchange' }),
|
|
202
208
|
treecollapseexpand: new hooks_1.default({ name: 'treecollapseexpand' }),
|
|
203
209
|
destroy: new hooks_1.default({ name: 'destroy' }),
|
|
204
210
|
};
|
|
205
211
|
}
|
|
212
|
+
formatSpecification(spec) {
|
|
213
|
+
var _a;
|
|
214
|
+
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) });
|
|
215
|
+
}
|
|
206
216
|
/**
|
|
207
217
|
* Update the specs(configurations).
|
|
208
218
|
*/
|
|
209
219
|
updateSpecification(spec) {
|
|
210
|
-
|
|
220
|
+
const newSpec = Object.assign(this.specification, this.formatSpecification(spec));
|
|
221
|
+
// TODO: update something
|
|
222
|
+
return newSpec;
|
|
211
223
|
}
|
|
212
224
|
/**
|
|
213
225
|
* Update the theme specs (configurations).
|
|
@@ -228,6 +240,28 @@ class Graph extends event_emitter_1.default {
|
|
|
228
240
|
theme: this.themeController.specification,
|
|
229
241
|
});
|
|
230
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Update the item display mapper for a specific item type.
|
|
245
|
+
* @param {ITEM_TYPE} type - The type of item (node, edge, or combo).
|
|
246
|
+
* @param {NodeMapper | EdgeMapper | ComboMapper} mapper - The mapper to be updated.
|
|
247
|
+
* */
|
|
248
|
+
updateMapper(type, mapper) {
|
|
249
|
+
switch (type) {
|
|
250
|
+
case 'node':
|
|
251
|
+
this.specification.node = mapper;
|
|
252
|
+
break;
|
|
253
|
+
case 'edge':
|
|
254
|
+
this.specification.edge = mapper;
|
|
255
|
+
break;
|
|
256
|
+
case 'combo':
|
|
257
|
+
this.specification.combo = mapper;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
this.hooks.mapperchange.emit({
|
|
261
|
+
type,
|
|
262
|
+
mapper,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
231
265
|
/**
|
|
232
266
|
* Get the copy of specs(configurations).
|
|
233
267
|
* @returns graph specs
|
|
@@ -244,30 +278,39 @@ class Graph extends event_emitter_1.default {
|
|
|
244
278
|
*/
|
|
245
279
|
read(data) {
|
|
246
280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
+
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
247
282
|
this.hooks.datachange.emit({ data, type: 'replace' });
|
|
248
283
|
const emitRender = () => __awaiter(this, void 0, void 0, function* () {
|
|
249
|
-
this.hooks.render.
|
|
284
|
+
yield this.hooks.render.emitLinearAsync({
|
|
250
285
|
graphCore: this.dataController.graphCore,
|
|
251
286
|
theme: this.themeController.specification,
|
|
252
287
|
transientCanvas: this.transientCanvas,
|
|
288
|
+
tileOptimize: {
|
|
289
|
+
tileFirstRender,
|
|
290
|
+
tileFirstRenderSize,
|
|
291
|
+
},
|
|
253
292
|
});
|
|
254
293
|
this.emit('afterrender');
|
|
255
294
|
this.once('afterlayout', () => __awaiter(this, void 0, void 0, function* () {
|
|
256
295
|
const { autoFit } = this.specification;
|
|
257
296
|
if (autoFit) {
|
|
258
297
|
if (autoFit === 'view') {
|
|
259
|
-
yield this.fitView();
|
|
298
|
+
yield this.fitView({ rules: { boundsType: 'layout' } });
|
|
260
299
|
}
|
|
261
300
|
else if (autoFit === 'center') {
|
|
262
|
-
yield this.fitCenter();
|
|
301
|
+
yield this.fitCenter('layout');
|
|
263
302
|
}
|
|
264
303
|
else {
|
|
265
304
|
const { type, effectTiming } = autoFit, others = __rest(autoFit, ["type", "effectTiming"]);
|
|
266
305
|
if (type === 'view') {
|
|
267
|
-
|
|
306
|
+
const { padding, rules } = others;
|
|
307
|
+
yield this.fitView({
|
|
308
|
+
padding,
|
|
309
|
+
rules: Object.assign(Object.assign({}, rules), { boundsType: 'layout' }),
|
|
310
|
+
}, effectTiming);
|
|
268
311
|
}
|
|
269
312
|
else if (type === 'center') {
|
|
270
|
-
yield this.fitCenter(effectTiming);
|
|
313
|
+
yield this.fitCenter('layout', effectTiming);
|
|
271
314
|
}
|
|
272
315
|
else if (type === 'position') {
|
|
273
316
|
// TODO: align
|
|
@@ -296,11 +339,16 @@ class Graph extends event_emitter_1.default {
|
|
|
296
339
|
*/
|
|
297
340
|
changeData(data, type = 'mergeReplace') {
|
|
298
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
|
+
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
299
343
|
this.hooks.datachange.emit({ data, type });
|
|
300
344
|
this.hooks.render.emit({
|
|
301
345
|
graphCore: this.dataController.graphCore,
|
|
302
346
|
theme: this.themeController.specification,
|
|
303
347
|
transientCanvas: this.transientCanvas,
|
|
348
|
+
tileOptimize: {
|
|
349
|
+
tileFirstRender,
|
|
350
|
+
tileFirstRenderSize,
|
|
351
|
+
},
|
|
304
352
|
});
|
|
305
353
|
this.emit('afterrender');
|
|
306
354
|
yield this.layout();
|
|
@@ -311,11 +359,11 @@ class Graph extends event_emitter_1.default {
|
|
|
311
359
|
* @returns
|
|
312
360
|
*/
|
|
313
361
|
clear() {
|
|
314
|
-
this.
|
|
362
|
+
this.startHistoryBatch();
|
|
315
363
|
this.removeData('edge', this.getAllEdgesData().map((edge) => edge.id));
|
|
316
364
|
this.removeData('node', this.getAllNodesData().map((node) => node.id));
|
|
317
365
|
this.removeData('combo', this.getAllCombosData().map((combo) => combo.id));
|
|
318
|
-
this.
|
|
366
|
+
this.stopHistoryBatch();
|
|
319
367
|
}
|
|
320
368
|
getViewportCenter() {
|
|
321
369
|
const { width, height } = this.canvas.getConfig();
|
|
@@ -323,9 +371,11 @@ class Graph extends event_emitter_1.default {
|
|
|
323
371
|
}
|
|
324
372
|
transform(options, effectTiming) {
|
|
325
373
|
return __awaiter(this, void 0, void 0, function* () {
|
|
374
|
+
const { tileLodSize } = this.specification.optimize || {};
|
|
326
375
|
yield this.hooks.viewportchange.emitLinearAsync({
|
|
327
376
|
transform: options,
|
|
328
377
|
effectTiming,
|
|
378
|
+
tileLodSize,
|
|
329
379
|
});
|
|
330
380
|
this.emit('viewportchange', options);
|
|
331
381
|
});
|
|
@@ -433,9 +483,12 @@ class Graph extends event_emitter_1.default {
|
|
|
433
483
|
const [top, right, bottom, left] = padding
|
|
434
484
|
? (0, shape_1.formatPadding)(padding)
|
|
435
485
|
: [0, 0, 0, 0];
|
|
436
|
-
const { direction = 'both', ratioRule = 'min' } = rules || {};
|
|
437
|
-
|
|
438
|
-
|
|
486
|
+
const { direction = 'both', ratioRule = 'min', boundsType = 'render', } = rules || {};
|
|
487
|
+
const { center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
|
|
488
|
+
? // Get the bounds of the whole graph content.
|
|
489
|
+
this.canvas.document.documentElement.getBounds()
|
|
490
|
+
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
491
|
+
(0, layout_1.getLayoutBounds)(this);
|
|
439
492
|
const origin = this.canvas.canvas2Viewport({
|
|
440
493
|
x: graphCenterX,
|
|
441
494
|
y: graphCenterY,
|
|
@@ -480,10 +533,13 @@ class Graph extends event_emitter_1.default {
|
|
|
480
533
|
* Fit the graph center to the view center.
|
|
481
534
|
* @param effectTiming animation configurations
|
|
482
535
|
*/
|
|
483
|
-
fitCenter(effectTiming) {
|
|
536
|
+
fitCenter(boundsType = 'render', effectTiming) {
|
|
484
537
|
return __awaiter(this, void 0, void 0, function* () {
|
|
485
|
-
|
|
486
|
-
|
|
538
|
+
const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
|
|
539
|
+
? // Get the bounds of the whole graph content.
|
|
540
|
+
this.canvas.document.documentElement.getBounds()
|
|
541
|
+
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
542
|
+
(0, layout_1.getLayoutBounds)(this);
|
|
487
543
|
yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
|
|
488
544
|
});
|
|
489
545
|
}
|
|
@@ -540,9 +596,33 @@ class Graph extends event_emitter_1.default {
|
|
|
540
596
|
console.warn(`Failed to setSize. The parameter size: ${size} is invalid. It must be an array with 2 number elements.`);
|
|
541
597
|
return;
|
|
542
598
|
}
|
|
599
|
+
const oldSize = [this.specification.width, this.specification.height];
|
|
600
|
+
this.emit('beforesetsize', { oldSize, size: size });
|
|
543
601
|
this.specification.width = size[0];
|
|
544
602
|
this.specification.height = size[1];
|
|
545
603
|
this.canvas.resize(size[0], size[1]);
|
|
604
|
+
this.transientCanvas.resize(size[0], size[1]);
|
|
605
|
+
this.backgroundCanvas.resize(size[0], size[1]);
|
|
606
|
+
this.emit('aftersetsize', { oldSize, size: size });
|
|
607
|
+
}
|
|
608
|
+
getCanvasRange() {
|
|
609
|
+
const [width, height] = this.getSize();
|
|
610
|
+
const leftTop = this.getCanvasByViewport({ x: 0, y: 0 });
|
|
611
|
+
const rightBottom = this.getCanvasByViewport({ x: width, y: height });
|
|
612
|
+
return {
|
|
613
|
+
min: [leftTop.x, leftTop.y, leftTop.z],
|
|
614
|
+
max: [rightBottom.x, rightBottom.y, rightBottom.z],
|
|
615
|
+
center: [
|
|
616
|
+
(leftTop.x + rightBottom.x) / 2,
|
|
617
|
+
(leftTop.y + rightBottom.y) / 2,
|
|
618
|
+
(leftTop.z + rightBottom.z) / 2,
|
|
619
|
+
],
|
|
620
|
+
halfExtents: [
|
|
621
|
+
(rightBottom.x - leftTop.x) / 2,
|
|
622
|
+
(rightBottom.y - leftTop.y) / 2,
|
|
623
|
+
(rightBottom.z - leftTop.z) / 2,
|
|
624
|
+
],
|
|
625
|
+
};
|
|
546
626
|
}
|
|
547
627
|
/**
|
|
548
628
|
* Get the rendering coordinate according to the canvas dom (viewport) coordinate.
|
|
@@ -722,19 +802,21 @@ class Graph extends event_emitter_1.default {
|
|
|
722
802
|
if (!event.changes.length)
|
|
723
803
|
return;
|
|
724
804
|
const changes = event.changes;
|
|
725
|
-
|
|
726
|
-
type: itemType,
|
|
727
|
-
changes: graphCore.reduceChanges(event.changes),
|
|
728
|
-
graphCore,
|
|
729
|
-
theme: specification,
|
|
730
|
-
});
|
|
731
|
-
this.emit('afteritemchange', {
|
|
805
|
+
const timingParameters = {
|
|
732
806
|
type: itemType,
|
|
733
807
|
action: 'add',
|
|
734
808
|
models,
|
|
735
809
|
apiName: 'addData',
|
|
736
810
|
changes,
|
|
811
|
+
};
|
|
812
|
+
this.emit('beforeitemchange', timingParameters);
|
|
813
|
+
this.hooks.itemchange.emit({
|
|
814
|
+
type: itemType,
|
|
815
|
+
changes: graphCore.reduceChanges(event.changes),
|
|
816
|
+
graphCore,
|
|
817
|
+
theme: specification,
|
|
737
818
|
});
|
|
819
|
+
this.emit('afteritemchange', timingParameters);
|
|
738
820
|
});
|
|
739
821
|
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
740
822
|
const data = { nodes: [], edges: [], combos: [] };
|
|
@@ -755,27 +837,38 @@ class Graph extends event_emitter_1.default {
|
|
|
755
837
|
removeData(itemType, ids) {
|
|
756
838
|
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
757
839
|
const data = { nodes: [], edges: [], combos: [] };
|
|
758
|
-
const {
|
|
840
|
+
const { graphCore } = this.dataController;
|
|
759
841
|
const { specification } = this.themeController;
|
|
760
|
-
const getItem = itemType === 'edge' ?
|
|
761
|
-
|
|
842
|
+
const getItem = itemType === 'edge' ? graphCore.getEdge : graphCore.getNode;
|
|
843
|
+
const hasItem = itemType === 'edge' ? graphCore.hasEdge : graphCore.hasNode;
|
|
844
|
+
data[`${itemType}s`] = idArr
|
|
845
|
+
.map((id) => {
|
|
846
|
+
if (!hasItem.bind(graphCore)(id)) {
|
|
847
|
+
console.warn(`The ${itemType} data with id ${id} does not exist. It will be ignored`);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
return getItem.bind(graphCore)(id);
|
|
851
|
+
})
|
|
852
|
+
.filter(Boolean);
|
|
762
853
|
graphCore.once('changed', (event) => {
|
|
763
854
|
if (!event.changes.length)
|
|
764
855
|
return;
|
|
765
856
|
const changes = event.changes;
|
|
766
|
-
|
|
767
|
-
type: itemType,
|
|
768
|
-
changes: event.changes,
|
|
769
|
-
graphCore,
|
|
770
|
-
theme: specification,
|
|
771
|
-
});
|
|
772
|
-
this.emit('afteritemchange', {
|
|
857
|
+
const timingParameters = {
|
|
773
858
|
type: itemType,
|
|
774
859
|
action: 'remove',
|
|
775
860
|
ids: idArr,
|
|
776
861
|
apiName: 'removeData',
|
|
777
862
|
changes,
|
|
863
|
+
};
|
|
864
|
+
this.emit('beforeitemchange', timingParameters);
|
|
865
|
+
this.hooks.itemchange.emit({
|
|
866
|
+
type: itemType,
|
|
867
|
+
changes: event.changes,
|
|
868
|
+
graphCore,
|
|
869
|
+
theme: specification,
|
|
778
870
|
});
|
|
871
|
+
this.emit('afteritemchange', timingParameters);
|
|
779
872
|
});
|
|
780
873
|
this.hooks.datachange.emit({
|
|
781
874
|
data,
|
|
@@ -843,19 +936,21 @@ class Graph extends event_emitter_1.default {
|
|
|
843
936
|
const { specification } = this.themeController;
|
|
844
937
|
graphCore.once('changed', (event) => {
|
|
845
938
|
const changes = this.extendChanges((0, util_1.clone)(event.changes));
|
|
846
|
-
|
|
847
|
-
type: itemType,
|
|
848
|
-
changes: event.changes,
|
|
849
|
-
graphCore,
|
|
850
|
-
theme: specification,
|
|
851
|
-
});
|
|
852
|
-
this.emit('afteritemchange', {
|
|
939
|
+
const timingParameters = {
|
|
853
940
|
type: itemType,
|
|
854
941
|
action: 'update',
|
|
855
942
|
models,
|
|
856
943
|
apiName: 'updateData',
|
|
857
944
|
changes,
|
|
945
|
+
};
|
|
946
|
+
this.emit('beforeitemchange', timingParameters);
|
|
947
|
+
this.hooks.itemchange.emit({
|
|
948
|
+
type: itemType,
|
|
949
|
+
changes: event.changes,
|
|
950
|
+
graphCore,
|
|
951
|
+
theme: specification,
|
|
858
952
|
});
|
|
953
|
+
this.emit('afteritemchange', timingParameters);
|
|
859
954
|
});
|
|
860
955
|
this.hooks.datachange.emit({
|
|
861
956
|
data,
|
|
@@ -898,10 +993,19 @@ class Graph extends event_emitter_1.default {
|
|
|
898
993
|
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
899
994
|
const { graphCore } = this.dataController;
|
|
900
995
|
const { specification } = this.themeController;
|
|
901
|
-
graphCore.once('changed', (event) => {
|
|
996
|
+
graphCore === null || graphCore === void 0 ? void 0 : graphCore.once('changed', (event) => {
|
|
902
997
|
if (!event.changes.length)
|
|
903
998
|
return;
|
|
904
999
|
const changes = event.changes.filter((change) => !(0, util_1.isEqual)(change.newValue, change.oldValue));
|
|
1000
|
+
const timingParameters = {
|
|
1001
|
+
type,
|
|
1002
|
+
action: 'updatePosition',
|
|
1003
|
+
upsertAncestors,
|
|
1004
|
+
models,
|
|
1005
|
+
apiName: 'updatePosition',
|
|
1006
|
+
changes,
|
|
1007
|
+
};
|
|
1008
|
+
this.emit('beforeitemchange', timingParameters);
|
|
905
1009
|
this.hooks.itemchange.emit({
|
|
906
1010
|
type,
|
|
907
1011
|
changes: event.changes,
|
|
@@ -912,14 +1016,7 @@ class Graph extends event_emitter_1.default {
|
|
|
912
1016
|
animate: !disableAnimate,
|
|
913
1017
|
callback,
|
|
914
1018
|
});
|
|
915
|
-
this.emit('afteritemchange',
|
|
916
|
-
type,
|
|
917
|
-
action: 'updatePosition',
|
|
918
|
-
upsertAncestors,
|
|
919
|
-
models,
|
|
920
|
-
apiName: 'updatePosition',
|
|
921
|
-
changes,
|
|
922
|
-
});
|
|
1019
|
+
this.emit('afteritemchange', timingParameters);
|
|
923
1020
|
});
|
|
924
1021
|
this.hooks.datachange.emit({
|
|
925
1022
|
data: {
|
|
@@ -979,7 +1076,7 @@ class Graph extends event_emitter_1.default {
|
|
|
979
1076
|
* @returns
|
|
980
1077
|
* @group Item
|
|
981
1078
|
*/
|
|
982
|
-
hideItem(ids, disableAnimate = false) {
|
|
1079
|
+
hideItem(ids, disableAnimate = false, keepKeyShape = false) {
|
|
983
1080
|
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
984
1081
|
if ((0, util_1.isEmpty)(idArr))
|
|
985
1082
|
return;
|
|
@@ -992,6 +1089,7 @@ class Graph extends event_emitter_1.default {
|
|
|
992
1089
|
value: false,
|
|
993
1090
|
graphCore: this.dataController.graphCore,
|
|
994
1091
|
animate: !disableAnimate,
|
|
1092
|
+
keepKeyShape,
|
|
995
1093
|
});
|
|
996
1094
|
this.emit('afteritemvisibilitychange', {
|
|
997
1095
|
ids,
|
|
@@ -999,6 +1097,7 @@ class Graph extends event_emitter_1.default {
|
|
|
999
1097
|
animate: !disableAnimate,
|
|
1000
1098
|
action: 'updateVisibility',
|
|
1001
1099
|
apiName: 'hideItem',
|
|
1100
|
+
keepKeyShape,
|
|
1002
1101
|
changes,
|
|
1003
1102
|
});
|
|
1004
1103
|
}
|
|
@@ -1076,7 +1175,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1076
1175
|
value,
|
|
1077
1176
|
});
|
|
1078
1177
|
this.emit('afteritemstatechange', {
|
|
1079
|
-
ids,
|
|
1178
|
+
ids: idArr,
|
|
1080
1179
|
states,
|
|
1081
1180
|
value,
|
|
1082
1181
|
action: 'updateState',
|
|
@@ -1123,7 +1222,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1123
1222
|
value: false,
|
|
1124
1223
|
});
|
|
1125
1224
|
this.emit('afteritemstatechange', {
|
|
1126
|
-
ids,
|
|
1225
|
+
ids: idArr,
|
|
1127
1226
|
states,
|
|
1128
1227
|
value: false,
|
|
1129
1228
|
action: 'updateState',
|
|
@@ -1166,19 +1265,21 @@ class Graph extends event_emitter_1.default {
|
|
|
1166
1265
|
if (!event.changes.length)
|
|
1167
1266
|
return;
|
|
1168
1267
|
const changes = event.changes;
|
|
1169
|
-
|
|
1170
|
-
type: 'combo',
|
|
1171
|
-
changes: graphCore.reduceChanges(event.changes),
|
|
1172
|
-
graphCore,
|
|
1173
|
-
theme: specification,
|
|
1174
|
-
});
|
|
1175
|
-
this.emit('afteritemchange', {
|
|
1268
|
+
const timingParameters = {
|
|
1176
1269
|
type: 'combo',
|
|
1177
1270
|
action: 'add',
|
|
1178
1271
|
models: [model],
|
|
1179
1272
|
apiName: 'addCombo',
|
|
1180
1273
|
changes,
|
|
1274
|
+
};
|
|
1275
|
+
this.emit('beforeitemchange', timingParameters);
|
|
1276
|
+
this.hooks.itemchange.emit({
|
|
1277
|
+
type: 'combo',
|
|
1278
|
+
changes: graphCore.reduceChanges(event.changes),
|
|
1279
|
+
graphCore,
|
|
1280
|
+
theme: specification,
|
|
1181
1281
|
});
|
|
1282
|
+
this.emit('afteritemchange', timingParameters);
|
|
1182
1283
|
});
|
|
1183
1284
|
const data = {
|
|
1184
1285
|
nodes: [],
|
|
@@ -1200,7 +1301,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1200
1301
|
*/
|
|
1201
1302
|
collapseCombo(comboIds) {
|
|
1202
1303
|
const ids = (0, util_1.isArray)(comboIds) ? comboIds : [comboIds];
|
|
1203
|
-
this.
|
|
1304
|
+
this.executeWithNoStack(() => {
|
|
1204
1305
|
this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: true } })));
|
|
1205
1306
|
});
|
|
1206
1307
|
this.emit('aftercollapsecombo', {
|
|
@@ -1217,7 +1318,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1217
1318
|
*/
|
|
1218
1319
|
expandCombo(comboIds) {
|
|
1219
1320
|
const ids = (0, util_1.isArray)(comboIds) ? comboIds : [comboIds];
|
|
1220
|
-
this.
|
|
1321
|
+
this.executeWithNoStack(() => {
|
|
1221
1322
|
this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: false } })));
|
|
1222
1323
|
});
|
|
1223
1324
|
this.emit('afterexpandcombo', {
|
|
@@ -1242,16 +1343,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1242
1343
|
if (!event.changes.length)
|
|
1243
1344
|
return;
|
|
1244
1345
|
const changes = this.extendChanges((0, util_1.clone)(event.changes));
|
|
1245
|
-
|
|
1246
|
-
type: 'combo',
|
|
1247
|
-
changes: event.changes,
|
|
1248
|
-
graphCore,
|
|
1249
|
-
theme: specification,
|
|
1250
|
-
upsertAncestors,
|
|
1251
|
-
action: 'updatePosition',
|
|
1252
|
-
callback,
|
|
1253
|
-
});
|
|
1254
|
-
this.emit('afteritemchange', {
|
|
1346
|
+
const timingParameters = {
|
|
1255
1347
|
type: 'combo',
|
|
1256
1348
|
ids: idArr,
|
|
1257
1349
|
dx,
|
|
@@ -1260,7 +1352,18 @@ class Graph extends event_emitter_1.default {
|
|
|
1260
1352
|
upsertAncestors,
|
|
1261
1353
|
apiName: 'moveCombo',
|
|
1262
1354
|
changes,
|
|
1355
|
+
};
|
|
1356
|
+
this.emit('beforeitemchange', timingParameters);
|
|
1357
|
+
this.hooks.itemchange.emit({
|
|
1358
|
+
type: 'combo',
|
|
1359
|
+
changes: event.changes,
|
|
1360
|
+
graphCore,
|
|
1361
|
+
theme: specification,
|
|
1362
|
+
upsertAncestors,
|
|
1363
|
+
action: 'updatePosition',
|
|
1364
|
+
callback,
|
|
1263
1365
|
});
|
|
1366
|
+
this.emit('afteritemchange', timingParameters);
|
|
1264
1367
|
});
|
|
1265
1368
|
this.hooks.datachange.emit({
|
|
1266
1369
|
data: {
|
|
@@ -1345,6 +1448,14 @@ class Graph extends event_emitter_1.default {
|
|
|
1345
1448
|
getMode() {
|
|
1346
1449
|
return this.interactionController.getMode();
|
|
1347
1450
|
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Set the cursor. But the cursor in item's style has higher priority.
|
|
1453
|
+
* @param cursor
|
|
1454
|
+
*/
|
|
1455
|
+
setCursor(cursor) {
|
|
1456
|
+
this.canvas.setCursor(cursor);
|
|
1457
|
+
this.transientCanvas.setCursor(cursor);
|
|
1458
|
+
}
|
|
1348
1459
|
/**
|
|
1349
1460
|
* Add behavior(s) to mode(s).
|
|
1350
1461
|
* @param behaviors behavior names or configs
|
|
@@ -1515,6 +1626,274 @@ class Graph extends event_emitter_1.default {
|
|
|
1515
1626
|
});
|
|
1516
1627
|
return this.itemController.getTransient(String(id));
|
|
1517
1628
|
}
|
|
1629
|
+
// ===== download operations =====
|
|
1630
|
+
/**
|
|
1631
|
+
* Asynchronously generates a Data URL representation of the canvas content, including
|
|
1632
|
+
* background, main content, and transient canvas.
|
|
1633
|
+
* @param The type of the Data URL (e.g., 'image/png', 'image/jpeg').
|
|
1634
|
+
* @returns A Promise that resolves to the Data URL string.
|
|
1635
|
+
*/
|
|
1636
|
+
toDataURL(type) {
|
|
1637
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1638
|
+
const backgroundCanvas = this.backgroundCanvas;
|
|
1639
|
+
const canvas = this.canvas;
|
|
1640
|
+
const transientCanvas = this.transientCanvas;
|
|
1641
|
+
const rendererType = this.rendererType;
|
|
1642
|
+
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1643
|
+
const width = this.getSize()[0];
|
|
1644
|
+
const height = this.getSize()[1];
|
|
1645
|
+
const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
|
|
1646
|
+
const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, width, height, pixelRatio);
|
|
1647
|
+
const vCanvasContextService = vCanvas.getContextService();
|
|
1648
|
+
let bgRect;
|
|
1649
|
+
if (rendererType !== 'svg') {
|
|
1650
|
+
bgRect = new g_1.Rect({
|
|
1651
|
+
style: {
|
|
1652
|
+
x: 0,
|
|
1653
|
+
y: 0,
|
|
1654
|
+
z: -1,
|
|
1655
|
+
width: vCanvasContextService.getDomElement().width,
|
|
1656
|
+
height: vCanvasContextService.getDomElement().height,
|
|
1657
|
+
//@ts-ignore
|
|
1658
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1659
|
+
},
|
|
1660
|
+
});
|
|
1661
|
+
vCanvas.appendChild(bgRect);
|
|
1662
|
+
}
|
|
1663
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1664
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1665
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1666
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1667
|
+
vCanvas.appendChild(clonedGroup);
|
|
1668
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1669
|
+
vCanvas.render();
|
|
1670
|
+
if (!type)
|
|
1671
|
+
type = 'image/png';
|
|
1672
|
+
let dataURL = '';
|
|
1673
|
+
yield vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1674
|
+
dataURL = url;
|
|
1675
|
+
});
|
|
1676
|
+
return dataURL;
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Asynchronously generates a Data URL representation of the full canvas content,
|
|
1681
|
+
* including background, main content, and transient canvas, with optional padding.
|
|
1682
|
+
* @param type The type of the Data URL (e.g., 'image/png', 'image/jpeg').
|
|
1683
|
+
* @param imageConfig Configuration options for the image (optional).
|
|
1684
|
+
* @returns A Promise that resolves to the Data URL string.
|
|
1685
|
+
*/
|
|
1686
|
+
toFullDataURL(type, imageConfig) {
|
|
1687
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1688
|
+
const backgroundCanvas = this.backgroundCanvas;
|
|
1689
|
+
const canvas = this.canvas;
|
|
1690
|
+
const transientCanvas = this.transientCanvas;
|
|
1691
|
+
const backgroundRoot = canvas.getRoot();
|
|
1692
|
+
const root = canvas.getRoot();
|
|
1693
|
+
const transientRoot = transientCanvas.getRoot();
|
|
1694
|
+
const rendererType = this.rendererType;
|
|
1695
|
+
const backgroundBBox = backgroundRoot.getBBox();
|
|
1696
|
+
const BBox = root.getBBox();
|
|
1697
|
+
const transientBBox = transientRoot.getBBox();
|
|
1698
|
+
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
1699
|
+
if (!padding) {
|
|
1700
|
+
padding = [0, 0, 0, 0];
|
|
1701
|
+
}
|
|
1702
|
+
else if ((0, util_1.isNumber)(padding)) {
|
|
1703
|
+
padding = [padding, padding, padding, padding];
|
|
1704
|
+
}
|
|
1705
|
+
const left = (transientBBox.left
|
|
1706
|
+
? backgroundBBox.left
|
|
1707
|
+
? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
|
|
1708
|
+
: Math.min(BBox.left, transientBBox.left)
|
|
1709
|
+
: BBox.left) - padding[3];
|
|
1710
|
+
const right = (transientBBox.right
|
|
1711
|
+
? backgroundBBox.right
|
|
1712
|
+
? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
|
|
1713
|
+
: Math.max(BBox.right, transientBBox.right)
|
|
1714
|
+
: BBox.right) + padding[1];
|
|
1715
|
+
const top = (transientBBox.top
|
|
1716
|
+
? backgroundBBox.top
|
|
1717
|
+
? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
|
|
1718
|
+
: Math.min(BBox.top, transientBBox.top)
|
|
1719
|
+
: BBox.top) - padding[0];
|
|
1720
|
+
const bottom = (transientBBox.bottom
|
|
1721
|
+
? backgroundBBox.bottom
|
|
1722
|
+
? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
|
|
1723
|
+
: Math.max(BBox.bottom, transientBBox.bottom)
|
|
1724
|
+
: BBox.bottom) + padding[2];
|
|
1725
|
+
const graphCenterX = (left + right) / 2;
|
|
1726
|
+
const graphCenterY = (top + bottom) / 2;
|
|
1727
|
+
const halfX = (right - left) / 2;
|
|
1728
|
+
const halfY = (bottom - top) / 2;
|
|
1729
|
+
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1730
|
+
const vWidth = halfX * 2;
|
|
1731
|
+
const vHeight = halfY * 2;
|
|
1732
|
+
const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
|
|
1733
|
+
const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
|
|
1734
|
+
const vCanvasContextService = vCanvas.getContextService();
|
|
1735
|
+
if (rendererType !== 'svg') {
|
|
1736
|
+
const bgRect = new g_1.Rect({
|
|
1737
|
+
style: {
|
|
1738
|
+
x: 0,
|
|
1739
|
+
y: 0,
|
|
1740
|
+
z: -1,
|
|
1741
|
+
width: vCanvasContextService.getDomElement().width,
|
|
1742
|
+
height: vCanvasContextService.getDomElement().height,
|
|
1743
|
+
//@ts-ignore
|
|
1744
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1745
|
+
},
|
|
1746
|
+
});
|
|
1747
|
+
vCanvas.appendChild(bgRect);
|
|
1748
|
+
}
|
|
1749
|
+
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
1750
|
+
const clonedGroup = root.cloneNode(true);
|
|
1751
|
+
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
1752
|
+
const transPosition = [
|
|
1753
|
+
-graphCenterX + halfX,
|
|
1754
|
+
-graphCenterY + halfY,
|
|
1755
|
+
];
|
|
1756
|
+
backgroundClonedGroup.setPosition(transPosition);
|
|
1757
|
+
clonedGroup.setPosition(transPosition);
|
|
1758
|
+
transientClonedGroup.setPosition(transPosition);
|
|
1759
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1760
|
+
vCanvas.appendChild(clonedGroup);
|
|
1761
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1762
|
+
vCanvas.render();
|
|
1763
|
+
if (!type)
|
|
1764
|
+
type = 'image/png';
|
|
1765
|
+
let dataURL = '';
|
|
1766
|
+
yield vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1767
|
+
dataURL = url;
|
|
1768
|
+
});
|
|
1769
|
+
return dataURL;
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Converts a Data URL to an image file and handles the download of the image.
|
|
1774
|
+
* @param dataURL The Data URL of the image to be converted and downloaded.
|
|
1775
|
+
* @param renderer The renderer type ('svg' or other) used for the canvas.
|
|
1776
|
+
* @param link The HTML link element used for image download.
|
|
1777
|
+
* @param fileName The desired name for the downloaded image file.
|
|
1778
|
+
*/
|
|
1779
|
+
dataURLToImage(dataURL, renderer, link, fileName) {
|
|
1780
|
+
if (!dataURL || dataURL === 'data:') {
|
|
1781
|
+
console.error('Download image failed. The graph is too large or there is invalid attribute values in graph items');
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
if (typeof window !== 'undefined') {
|
|
1785
|
+
if (window.Blob && window.URL && renderer !== 'svg') {
|
|
1786
|
+
const arr = dataURL.split(',');
|
|
1787
|
+
let mime = '';
|
|
1788
|
+
if (arr && arr.length > 0) {
|
|
1789
|
+
const match = arr[0].match(/:(.*?);/);
|
|
1790
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1791
|
+
if (match && match.length >= 2)
|
|
1792
|
+
mime = match[1];
|
|
1793
|
+
}
|
|
1794
|
+
const bstr = atob(arr[1]);
|
|
1795
|
+
let n = bstr.length;
|
|
1796
|
+
const u8arr = new Uint8Array(n);
|
|
1797
|
+
while (n--) {
|
|
1798
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
1799
|
+
}
|
|
1800
|
+
const blobObj = new Blob([u8arr], { type: mime });
|
|
1801
|
+
if (window.navigator.msSaveBlob) {
|
|
1802
|
+
window.navigator.msSaveBlob(blobObj, fileName);
|
|
1803
|
+
}
|
|
1804
|
+
else {
|
|
1805
|
+
link.addEventListener('click', () => {
|
|
1806
|
+
link.download = fileName;
|
|
1807
|
+
link.href = window.URL.createObjectURL(blobObj);
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
else {
|
|
1812
|
+
link.addEventListener('click', () => {
|
|
1813
|
+
link.download = fileName;
|
|
1814
|
+
link.href = dataURL;
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Initiates the download of the graph as an image with an optional name and type.
|
|
1821
|
+
* @param name The desired name for the downloaded image file (optional).
|
|
1822
|
+
* @param type The type of the image to download (optional, defaults to 'image/png').
|
|
1823
|
+
*/
|
|
1824
|
+
downloadImage(name, type) {
|
|
1825
|
+
const self = this;
|
|
1826
|
+
// self.stopAnimate();
|
|
1827
|
+
const rendererType = this.rendererType;
|
|
1828
|
+
if (!type)
|
|
1829
|
+
type = 'image/png';
|
|
1830
|
+
const fileName = (name || 'graph') +
|
|
1831
|
+
(rendererType === 'svg' ? '.svg' : type.split('/')[1]);
|
|
1832
|
+
const link = document.createElement('a');
|
|
1833
|
+
self.asyncToDataUrl(type, (dataURL) => {
|
|
1834
|
+
this.dataURLToImage(dataURL, rendererType, link, fileName);
|
|
1835
|
+
const e = document.createEvent('MouseEvents');
|
|
1836
|
+
e.initEvent('click', false, false);
|
|
1837
|
+
link.dispatchEvent(e);
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Initiates the download of the entire graph as an image with optional name, type, and padding configuration.
|
|
1842
|
+
* @param name The desired name for the downloaded image file (optional).
|
|
1843
|
+
* @param type The type of the image to download (optional, defaults to 'image/png').
|
|
1844
|
+
* @param imageConfig Configuration options for the image (optional).
|
|
1845
|
+
*/
|
|
1846
|
+
downloadFullImage(name, type, imageConfig) {
|
|
1847
|
+
const self = this;
|
|
1848
|
+
const rendererType = this.rendererType;
|
|
1849
|
+
if (!type)
|
|
1850
|
+
type = 'image/png';
|
|
1851
|
+
const fileName = (name || 'graph') +
|
|
1852
|
+
(rendererType === 'svg' ? '.svg' : type.split('/')[1]);
|
|
1853
|
+
const link = document.createElement('a');
|
|
1854
|
+
self.asyncToFullDataUrl(type, imageConfig, (dataURL) => {
|
|
1855
|
+
this.dataURLToImage(dataURL, rendererType, link, fileName);
|
|
1856
|
+
const e = document.createEvent('MouseEvents');
|
|
1857
|
+
e.initEvent('click', false, false);
|
|
1858
|
+
link.dispatchEvent(e);
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Asynchronously converts the canvas content to a Data URL of the specified type and invokes the provided callback.
|
|
1863
|
+
* @param type The type of the Data URL (optional, defaults to 'image/png').
|
|
1864
|
+
* @param callback A callback function to handle the Data URL (optional).
|
|
1865
|
+
*/
|
|
1866
|
+
asyncToDataUrl(type, callback) {
|
|
1867
|
+
let dataURL = '';
|
|
1868
|
+
if (!type)
|
|
1869
|
+
type = 'image/png';
|
|
1870
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
1871
|
+
yield this.toDataURL(type).then((url) => {
|
|
1872
|
+
dataURL = url;
|
|
1873
|
+
});
|
|
1874
|
+
if (callback)
|
|
1875
|
+
callback(dataURL);
|
|
1876
|
+
}), 16);
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Asynchronously converts the entire canvas content to a Data URL of the specified type
|
|
1880
|
+
* with optional padding, and invokes the provided callback.
|
|
1881
|
+
* @param type The type of the Data URL (optional, defaults to 'image/png').
|
|
1882
|
+
* @param imageConfig Configuration options for the image (optional).
|
|
1883
|
+
* @param callback A callback function to handle the Data URL (optional).
|
|
1884
|
+
*/
|
|
1885
|
+
asyncToFullDataUrl(type, imageConfig, callback) {
|
|
1886
|
+
let dataURL = '';
|
|
1887
|
+
if (!type)
|
|
1888
|
+
type = 'image/png';
|
|
1889
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
1890
|
+
yield this.toFullDataURL(type, imageConfig).then((url) => {
|
|
1891
|
+
dataURL = url;
|
|
1892
|
+
});
|
|
1893
|
+
if (callback)
|
|
1894
|
+
callback(dataURL);
|
|
1895
|
+
}), 16);
|
|
1896
|
+
}
|
|
1518
1897
|
// ===== history operations =====
|
|
1519
1898
|
/**
|
|
1520
1899
|
* Determine if history (redo/undo) is enabled.
|
|
@@ -1536,16 +1915,16 @@ class Graph extends event_emitter_1.default {
|
|
|
1536
1915
|
/**
|
|
1537
1916
|
* Pause stacking operation.
|
|
1538
1917
|
*/
|
|
1539
|
-
|
|
1918
|
+
pauseStack() {
|
|
1540
1919
|
const history = this.getHistoryPlugin();
|
|
1541
|
-
return history === null || history === void 0 ? void 0 : history.
|
|
1920
|
+
return history === null || history === void 0 ? void 0 : history.pauseStack();
|
|
1542
1921
|
}
|
|
1543
1922
|
/**
|
|
1544
1923
|
* Resume stacking operation.
|
|
1545
1924
|
*/
|
|
1546
|
-
|
|
1925
|
+
resumeStack() {
|
|
1547
1926
|
const history = this.getHistoryPlugin();
|
|
1548
|
-
return history === null || history === void 0 ? void 0 : history.
|
|
1927
|
+
return history === null || history === void 0 ? void 0 : history.resumeStack();
|
|
1549
1928
|
}
|
|
1550
1929
|
/**
|
|
1551
1930
|
* Retrieve the current redo stack which consists of operations that could be undone
|
|
@@ -1602,38 +1981,38 @@ class Graph extends event_emitter_1.default {
|
|
|
1602
1981
|
return history === null || history === void 0 ? void 0 : history.canRedo();
|
|
1603
1982
|
}
|
|
1604
1983
|
/**
|
|
1605
|
-
* Begin a
|
|
1606
|
-
* Any operations performed between `
|
|
1984
|
+
* Begin a historyBatch operation.
|
|
1985
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
1607
1986
|
* treated as a single operation when undoing or redoing.
|
|
1608
1987
|
*/
|
|
1609
|
-
|
|
1988
|
+
startHistoryBatch() {
|
|
1610
1989
|
const history = this.getHistoryPlugin();
|
|
1611
|
-
history === null || history === void 0 ? void 0 : history.
|
|
1990
|
+
history === null || history === void 0 ? void 0 : history.startHistoryBatch();
|
|
1612
1991
|
}
|
|
1613
1992
|
/**
|
|
1614
|
-
* End a
|
|
1615
|
-
* Any operations performed between `
|
|
1993
|
+
* End a historyBatch operation.
|
|
1994
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
1616
1995
|
* treated as a single operation when undoing or redoing.
|
|
1617
1996
|
*/
|
|
1618
|
-
|
|
1997
|
+
stopHistoryBatch() {
|
|
1619
1998
|
const history = this.getHistoryPlugin();
|
|
1620
|
-
history === null || history === void 0 ? void 0 : history.
|
|
1999
|
+
history === null || history === void 0 ? void 0 : history.stopHistoryBatch();
|
|
1621
2000
|
}
|
|
1622
2001
|
/**
|
|
1623
2002
|
* Execute a provided function within a batched context
|
|
1624
2003
|
* All operations performed inside callback will be treated as a composite operation
|
|
1625
|
-
* more convenient way without manually invoking `
|
|
2004
|
+
* more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
|
|
1626
2005
|
* @param callback The func containing operations to be batched together.
|
|
1627
2006
|
*/
|
|
1628
|
-
|
|
2007
|
+
historyBatch(callback) {
|
|
1629
2008
|
const history = this.getHistoryPlugin();
|
|
1630
|
-
history === null || history === void 0 ? void 0 : history.
|
|
2009
|
+
history === null || history === void 0 ? void 0 : history.historyBatch(callback);
|
|
1631
2010
|
}
|
|
1632
2011
|
/**
|
|
1633
2012
|
* Clear history stack
|
|
1634
2013
|
* @param {StackType} stackType undo/redo stack
|
|
1635
2014
|
*/
|
|
1636
|
-
|
|
2015
|
+
cleanHistory(stackType) {
|
|
1637
2016
|
const history = this.getHistoryPlugin();
|
|
1638
2017
|
if (!stackType)
|
|
1639
2018
|
return history === null || history === void 0 ? void 0 : history.clear();
|
|
@@ -1685,7 +2064,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1685
2064
|
this.backgroundCanvas.destroy();
|
|
1686
2065
|
this.transientCanvas.destroy();
|
|
1687
2066
|
// clear history stack
|
|
1688
|
-
this.
|
|
2067
|
+
this.cleanHistory();
|
|
1689
2068
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
1690
2069
|
// }, 500);
|
|
1691
2070
|
this.hooks.destroy.emit({});
|
|
@@ -1699,5 +2078,5 @@ class Graph extends event_emitter_1.default {
|
|
|
1699
2078
|
this.destroyed = true;
|
|
1700
2079
|
}
|
|
1701
2080
|
}
|
|
1702
|
-
exports.
|
|
2081
|
+
exports.Graph = Graph;
|
|
1703
2082
|
//# sourceMappingURL=graph.js.map
|