@antv/g6 5.0.0-beta.26 → 5.0.0-beta.28
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/LICENSE +21 -0
- package/dist/g6.min.js +2 -2
- package/esm/constant/shape.d.ts +2 -2
- package/esm/index.d.ts +6 -2
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +6 -4
- package/esm/item/combo.js +13 -4
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +12 -4
- package/esm/item/edge.js +106 -18
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +20 -10
- package/esm/item/item.js +114 -63
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +11 -4
- package/esm/item/node.js +102 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +5 -1
- package/esm/runtime/controller/data.js +53 -11
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/index.d.ts +1 -1
- package/esm/runtime/controller/index.js +1 -1
- package/esm/runtime/controller/index.js.map +1 -1
- package/esm/runtime/controller/interaction.js +4 -3
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +25 -13
- package/esm/runtime/controller/item.js +284 -116
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +3 -0
- package/esm/runtime/controller/layout.js +176 -99
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +3 -0
- package/esm/runtime/controller/plugin.js +66 -24
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/viewport.js +9 -2
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.d.ts +75 -31
- package/esm/runtime/graph.js +320 -161
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/hooks.d.ts +2 -2
- package/esm/runtime/hooks.js +2 -2
- package/esm/stdlib/behavior/click-select.js +9 -3
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +1 -1
- package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +6 -3
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.js +8 -8
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +5 -1
- package/esm/stdlib/behavior/drag-node.js +122 -28
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/hover-activate.d.ts +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +1 -1
- package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +2 -2
- package/esm/stdlib/behavior/scroll-canvas.js +8 -8
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.d.ts +1 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +1 -1
- package/esm/stdlib/behavior/zoom-canvas.d.ts +16 -0
- package/esm/stdlib/behavior/zoom-canvas.js +110 -8
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/transformV4Data.js +12 -6
- package/esm/stdlib/data/transformV4Data.js.map +1 -1
- package/esm/stdlib/data/validateData.js +2 -2
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +8 -4
- package/esm/stdlib/index.js +10 -6
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/combo/circle.js +12 -7
- package/esm/stdlib/item/combo/circle.js.map +1 -1
- package/esm/stdlib/item/combo/rect.js +12 -7
- package/esm/stdlib/item/combo/rect.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +24 -16
- package/esm/stdlib/item/edge/base.js +60 -121
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic.js +11 -6
- package/esm/stdlib/item/edge/cubic.js.map +1 -1
- package/esm/stdlib/item/edge/line.js +12 -7
- package/esm/stdlib/item/edge/line.js.map +1 -1
- package/esm/stdlib/item/edge/loop.js +6 -1
- package/esm/stdlib/item/edge/loop.js.map +1 -1
- package/esm/stdlib/item/edge/polyline.js +11 -6
- package/esm/stdlib/item/edge/polyline.js.map +1 -1
- package/esm/stdlib/item/edge/quadratic.js +11 -6
- package/esm/stdlib/item/edge/quadratic.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +26 -33
- package/esm/stdlib/item/node/base.js +98 -196
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +11 -2
- package/esm/stdlib/item/node/base3d.js +14 -3
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/circle.js +13 -7
- package/esm/stdlib/item/node/circle.js.map +1 -1
- package/esm/stdlib/item/node/cube.d.ts +0 -2
- package/esm/stdlib/item/node/cube.js +12 -9
- package/esm/stdlib/item/node/cube.js.map +1 -1
- package/esm/stdlib/item/node/diamond.js +20 -11
- package/esm/stdlib/item/node/diamond.js.map +1 -1
- package/esm/stdlib/item/node/donut.js +18 -8
- package/esm/stdlib/item/node/donut.js.map +1 -1
- package/esm/stdlib/item/node/ellipse.js +11 -6
- package/esm/stdlib/item/node/ellipse.js.map +1 -1
- package/esm/stdlib/item/node/hexagon.js +12 -7
- package/esm/stdlib/item/node/hexagon.js.map +1 -1
- package/esm/stdlib/item/node/image.js +13 -3
- package/esm/stdlib/item/node/image.js.map +1 -1
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/item/node/modelRect.d.ts +33 -1
- package/esm/stdlib/item/node/modelRect.js +135 -78
- package/esm/stdlib/item/node/modelRect.js.map +1 -1
- package/esm/stdlib/item/node/plane.d.ts +38 -0
- package/esm/stdlib/item/node/plane.js +62 -0
- package/esm/stdlib/item/node/plane.js.map +1 -0
- package/esm/stdlib/item/node/rect.js +12 -7
- package/esm/stdlib/item/node/rect.js.map +1 -1
- package/esm/stdlib/item/node/sphere.js +12 -7
- package/esm/stdlib/item/node/sphere.js.map +1 -1
- package/esm/stdlib/item/node/star.d.ts +1 -3
- package/esm/stdlib/item/node/star.js +16 -10
- package/esm/stdlib/item/node/star.js.map +1 -1
- package/esm/stdlib/item/node/triangle.js +17 -7
- package/esm/stdlib/item/node/triangle.js.map +1 -1
- package/esm/stdlib/plugin/edgeBundling/index.d.ts +75 -0
- package/esm/stdlib/plugin/edgeBundling/index.js +364 -0
- package/esm/stdlib/plugin/edgeBundling/index.js.map +1 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/esm/stdlib/plugin/fisheye/index.js +3 -2
- package/esm/stdlib/plugin/fisheye/index.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/bubbleset.d.ts +1 -1
- package/esm/stdlib/plugin/hull/bubbleset.js +13 -13
- package/esm/stdlib/plugin/hull/bubbleset.js.map +1 -1
- package/esm/stdlib/plugin/hull/index.d.ts +1 -1
- package/esm/stdlib/plugin/hull/index.js +4 -4
- package/esm/stdlib/plugin/hull/util.js +1 -1
- 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 +10 -10
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
- package/esm/stdlib/plugin/lodController/index.js +558 -0
- package/esm/stdlib/plugin/lodController/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.js +1 -1
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.js +12 -14
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +2 -2
- package/esm/stdlib/plugin/snapline/index.js +2 -2
- package/esm/stdlib/plugin/snapline/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/esm/stdlib/plugin/toolbar/index.js +27 -29
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/tooltip/index.d.ts +1 -1
- package/esm/stdlib/plugin/tooltip/index.js +3 -3
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
- package/{lib/stdlib/plugin/watermaker → esm/stdlib/plugin/watermarker}/index.d.ts +1 -1
- package/esm/stdlib/plugin/{watermaker → watermarker}/index.js +7 -7
- package/esm/stdlib/plugin/watermarker/index.js.map +1 -0
- package/esm/stdlib/selector/lasso.js +3 -3
- package/esm/stdlib/selector/lasso.js.map +1 -1
- package/esm/stdlib/theme/dark.js +31 -34
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +29 -29
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/spec.js +5 -5
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/stdlib/themeSolver/subject.d.ts +1 -1
- package/esm/stdlib/themeSolver/subject.js +1 -1
- package/esm/types/animate.d.ts +2 -2
- package/esm/types/combo.d.ts +2 -2
- package/esm/types/data.d.ts +3 -1
- package/esm/types/edge.d.ts +2 -2
- package/esm/types/graph.d.ts +113 -51
- package/esm/types/hook.d.ts +18 -3
- 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 +17 -25
- package/esm/types/item.js.map +1 -1
- package/esm/types/layout.d.ts +8 -3
- package/esm/types/layout.js.map +1 -1
- package/esm/types/node.d.ts +4 -33
- package/esm/types/plugin.d.ts +2 -1
- package/esm/types/plugin.js +2 -1
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +6 -5
- package/esm/types/theme.d.ts +8 -8
- package/esm/types/view.d.ts +1 -1
- package/esm/util/animate.d.ts +7 -2
- package/esm/util/animate.js +38 -24
- package/esm/util/animate.js.map +1 -1
- package/esm/util/bbox.d.ts +7 -1
- package/esm/util/bbox.js +16 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/canvas.d.ts +1 -1
- package/esm/util/canvas.js +7 -1
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/data.d.ts +16 -10
- package/esm/util/data.js +27 -14
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.js +5 -5
- package/esm/util/dom.js.map +1 -1
- package/esm/util/extend.js +1 -1
- package/esm/util/extend.js.map +1 -1
- package/esm/util/item.d.ts +1 -1
- package/esm/util/item.js +9 -9
- package/esm/util/item.js.map +1 -1
- package/esm/util/mapper.js +1 -1
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/math.d.ts +1 -1
- package/esm/util/math.js +1 -1
- package/esm/util/path.d.ts +7 -2
- package/esm/util/path.js +73 -2
- package/esm/util/path.js.map +1 -1
- package/esm/util/polyline.d.ts +12 -2
- package/esm/util/polyline.js +25 -20
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/router.js +26 -25
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +26 -14
- package/esm/util/shape.js +56 -32
- package/esm/util/shape.js.map +1 -1
- package/esm/util/shape3d.d.ts +2 -2
- package/esm/util/shape3d.js +9 -12
- package/esm/util/shape3d.js.map +1 -1
- package/esm/util/zoom.d.ts +5 -8
- package/esm/util/zoom.js +15 -20
- package/esm/util/zoom.js.map +1 -1
- package/lib/constant/shape.d.ts +2 -2
- package/lib/index.d.ts +6 -2
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +6 -4
- package/lib/item/combo.js +13 -4
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +12 -4
- package/lib/item/edge.js +105 -17
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +20 -10
- package/lib/item/item.js +112 -61
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +11 -4
- package/lib/item/node.js +102 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +5 -1
- package/lib/runtime/controller/data.js +52 -10
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/index.d.ts +1 -1
- package/lib/runtime/controller/index.js +1 -1
- package/lib/runtime/controller/index.js.map +1 -1
- package/lib/runtime/controller/interaction.js +3 -2
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +25 -13
- package/lib/runtime/controller/item.js +281 -113
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +3 -0
- package/lib/runtime/controller/layout.js +176 -122
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +3 -0
- package/lib/runtime/controller/plugin.js +66 -24
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/viewport.js +9 -2
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.d.ts +75 -31
- package/lib/runtime/graph.js +320 -161
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/hooks.d.ts +2 -2
- package/lib/runtime/hooks.js +2 -2
- package/lib/stdlib/behavior/click-select.js +9 -3
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +1 -1
- package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +6 -3
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.js +8 -8
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +5 -1
- package/lib/stdlib/behavior/drag-node.js +122 -28
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/hover-activate.d.ts +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +1 -1
- package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +2 -2
- package/lib/stdlib/behavior/scroll-canvas.js +8 -8
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.d.ts +1 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +1 -1
- package/lib/stdlib/behavior/zoom-canvas.d.ts +16 -0
- package/lib/stdlib/behavior/zoom-canvas.js +109 -7
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/transformV4Data.js +12 -6
- package/lib/stdlib/data/transformV4Data.js.map +1 -1
- package/lib/stdlib/data/validateData.js +2 -2
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +8 -4
- package/lib/stdlib/index.js +12 -8
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/combo/circle.js +12 -7
- package/lib/stdlib/item/combo/circle.js.map +1 -1
- package/lib/stdlib/item/combo/rect.js +12 -7
- package/lib/stdlib/item/combo/rect.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +24 -16
- package/lib/stdlib/item/edge/base.js +60 -121
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic.js +11 -6
- package/lib/stdlib/item/edge/cubic.js.map +1 -1
- package/lib/stdlib/item/edge/line.js +12 -7
- package/lib/stdlib/item/edge/line.js.map +1 -1
- package/lib/stdlib/item/edge/loop.js +6 -1
- package/lib/stdlib/item/edge/loop.js.map +1 -1
- package/lib/stdlib/item/edge/polyline.js +11 -6
- package/lib/stdlib/item/edge/polyline.js.map +1 -1
- package/lib/stdlib/item/edge/quadratic.js +11 -6
- package/lib/stdlib/item/edge/quadratic.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +26 -33
- package/lib/stdlib/item/node/base.js +98 -196
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +11 -2
- package/lib/stdlib/item/node/base3d.js +14 -3
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/circle.js +13 -7
- package/lib/stdlib/item/node/circle.js.map +1 -1
- package/lib/stdlib/item/node/cube.d.ts +0 -2
- package/lib/stdlib/item/node/cube.js +12 -9
- package/lib/stdlib/item/node/cube.js.map +1 -1
- package/lib/stdlib/item/node/diamond.js +20 -11
- package/lib/stdlib/item/node/diamond.js.map +1 -1
- package/lib/stdlib/item/node/donut.js +18 -8
- package/lib/stdlib/item/node/donut.js.map +1 -1
- package/lib/stdlib/item/node/ellipse.js +11 -6
- package/lib/stdlib/item/node/ellipse.js.map +1 -1
- package/lib/stdlib/item/node/hexagon.js +12 -7
- package/lib/stdlib/item/node/hexagon.js.map +1 -1
- package/lib/stdlib/item/node/image.js +13 -3
- package/lib/stdlib/item/node/image.js.map +1 -1
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/item/node/modelRect.d.ts +33 -1
- package/lib/stdlib/item/node/modelRect.js +135 -78
- package/lib/stdlib/item/node/modelRect.js.map +1 -1
- package/lib/stdlib/item/node/plane.d.ts +38 -0
- package/lib/stdlib/item/node/plane.js +66 -0
- package/lib/stdlib/item/node/plane.js.map +1 -0
- package/lib/stdlib/item/node/rect.js +12 -7
- package/lib/stdlib/item/node/rect.js.map +1 -1
- package/lib/stdlib/item/node/sphere.js +12 -7
- package/lib/stdlib/item/node/sphere.js.map +1 -1
- package/lib/stdlib/item/node/star.d.ts +1 -3
- package/lib/stdlib/item/node/star.js +16 -10
- package/lib/stdlib/item/node/star.js.map +1 -1
- package/lib/stdlib/item/node/triangle.js +17 -7
- package/lib/stdlib/item/node/triangle.js.map +1 -1
- package/lib/stdlib/plugin/edgeBundling/index.d.ts +75 -0
- package/lib/stdlib/plugin/edgeBundling/index.js +368 -0
- package/lib/stdlib/plugin/edgeBundling/index.js.map +1 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/lib/stdlib/plugin/fisheye/index.js +2 -1
- package/lib/stdlib/plugin/fisheye/index.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/bubbleset.d.ts +1 -1
- package/lib/stdlib/plugin/hull/bubbleset.js +13 -13
- package/lib/stdlib/plugin/hull/bubbleset.js.map +1 -1
- package/lib/stdlib/plugin/hull/index.d.ts +1 -1
- package/lib/stdlib/plugin/hull/index.js +4 -4
- package/lib/stdlib/plugin/hull/util.js +1 -1
- 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 +10 -10
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
- package/lib/stdlib/plugin/lodController/index.js +562 -0
- package/lib/stdlib/plugin/lodController/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.js +1 -1
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.js +12 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +2 -2
- package/lib/stdlib/plugin/snapline/index.js +2 -2
- package/lib/stdlib/plugin/snapline/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/lib/stdlib/plugin/toolbar/index.js +27 -29
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/tooltip/index.d.ts +1 -1
- package/lib/stdlib/plugin/tooltip/index.js +3 -3
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
- package/{esm/stdlib/plugin/watermaker → lib/stdlib/plugin/watermarker}/index.d.ts +1 -1
- package/lib/stdlib/plugin/{watermaker → watermarker}/index.js +7 -7
- package/lib/stdlib/plugin/watermarker/index.js.map +1 -0
- package/lib/stdlib/selector/lasso.js +3 -3
- package/lib/stdlib/selector/lasso.js.map +1 -1
- package/lib/stdlib/theme/dark.js +31 -34
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +29 -29
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/spec.js +5 -5
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/stdlib/themeSolver/subject.d.ts +1 -1
- package/lib/stdlib/themeSolver/subject.js +1 -1
- package/lib/types/animate.d.ts +2 -2
- package/lib/types/combo.d.ts +2 -2
- package/lib/types/data.d.ts +3 -1
- package/lib/types/edge.d.ts +2 -2
- package/lib/types/graph.d.ts +113 -51
- package/lib/types/hook.d.ts +18 -3
- 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 +17 -25
- package/lib/types/item.js.map +1 -1
- package/lib/types/layout.d.ts +8 -3
- package/lib/types/layout.js.map +1 -1
- package/lib/types/node.d.ts +4 -33
- package/lib/types/plugin.d.ts +2 -1
- package/lib/types/plugin.js +2 -1
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +6 -5
- package/lib/types/theme.d.ts +8 -8
- package/lib/types/view.d.ts +1 -1
- package/lib/util/animate.d.ts +7 -2
- package/lib/util/animate.js +38 -24
- package/lib/util/animate.js.map +1 -1
- package/lib/util/bbox.d.ts +7 -1
- package/lib/util/bbox.js +18 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/canvas.d.ts +1 -1
- package/lib/util/canvas.js +7 -1
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/data.d.ts +16 -10
- package/lib/util/data.js +30 -16
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.js +5 -5
- package/lib/util/dom.js.map +1 -1
- package/lib/util/extend.js +4 -7
- package/lib/util/extend.js.map +1 -1
- package/lib/util/item.d.ts +1 -1
- package/lib/util/item.js +9 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/mapper.js +1 -1
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/math.d.ts +1 -1
- package/lib/util/math.js +1 -1
- package/lib/util/path.d.ts +7 -2
- package/lib/util/path.js +73 -2
- package/lib/util/path.js.map +1 -1
- package/lib/util/polyline.d.ts +12 -2
- package/lib/util/polyline.js +28 -21
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/router.js +26 -25
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +26 -14
- package/lib/util/shape.js +54 -30
- package/lib/util/shape.js.map +1 -1
- package/lib/util/shape3d.d.ts +2 -2
- package/lib/util/shape3d.js +9 -12
- package/lib/util/shape3d.js.map +1 -1
- package/lib/util/zoom.d.ts +5 -8
- package/lib/util/zoom.js +17 -22
- package/lib/util/zoom.js.map +1 -1
- package/package.json +37 -53
- package/src/index.ts +1 -1
- package/src/item/combo.ts +15 -6
- package/src/item/edge.ts +135 -19
- package/src/item/item.ts +139 -66
- package/src/item/node.ts +125 -12
- package/src/runtime/controller/data.ts +80 -17
- package/src/runtime/controller/index.ts +1 -1
- package/src/runtime/controller/interaction.ts +5 -4
- package/src/runtime/controller/item.ts +398 -170
- package/src/runtime/controller/layout.ts +252 -113
- package/src/runtime/controller/plugin.ts +86 -33
- package/src/runtime/controller/viewport.ts +8 -2
- package/src/runtime/graph.ts +494 -212
- package/src/runtime/hooks.ts +2 -2
- package/src/stdlib/behavior/click-select.ts +8 -3
- package/src/stdlib/behavior/create-edge.ts +1 -1
- package/src/stdlib/behavior/drag-canvas.ts +7 -4
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +166 -51
- package/src/stdlib/behavior/hover-activate.ts +1 -1
- package/src/stdlib/behavior/orbit-canvas-3d.ts +1 -1
- package/src/stdlib/behavior/rotate-canvas-3d.ts +2 -2
- package/src/stdlib/behavior/scroll-canvas.ts +8 -8
- package/src/stdlib/behavior/track-canvas-3d.ts +1 -1
- package/src/stdlib/behavior/zoom-canvas-3d.ts +1 -1
- package/src/stdlib/behavior/zoom-canvas.ts +137 -16
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/transformV4Data.ts +27 -3
- package/src/stdlib/data/validateData.ts +2 -2
- package/src/stdlib/index.ts +11 -4
- package/src/stdlib/item/combo/circle.ts +26 -11
- package/src/stdlib/item/combo/rect.ts +26 -11
- package/src/stdlib/item/edge/base.ts +60 -163
- package/src/stdlib/item/edge/cubic.ts +26 -4
- package/src/stdlib/item/edge/line.ts +27 -5
- package/src/stdlib/item/edge/loop.ts +6 -1
- package/src/stdlib/item/edge/polyline.ts +26 -4
- package/src/stdlib/item/edge/quadratic.ts +26 -4
- package/src/stdlib/item/node/base.ts +91 -260
- package/src/stdlib/item/node/base3d.ts +19 -3
- package/src/stdlib/item/node/circle.ts +29 -8
- package/src/stdlib/item/node/cube.ts +26 -12
- package/src/stdlib/item/node/diamond.ts +35 -11
- package/src/stdlib/item/node/donut.ts +32 -18
- package/src/stdlib/item/node/ellipse.ts +25 -11
- package/src/stdlib/item/node/hexagon.ts +27 -7
- package/src/stdlib/item/node/image.ts +13 -5
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/item/node/modelRect.ts +230 -136
- package/src/stdlib/item/node/plane.ts +121 -0
- package/src/stdlib/item/node/rect.ts +27 -7
- package/src/stdlib/item/node/sphere.ts +26 -10
- package/src/stdlib/item/node/star.ts +32 -11
- package/src/stdlib/item/node/triangle.ts +32 -9
- package/src/stdlib/plugin/edgeBundling/index.ts +529 -0
- package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
- package/src/stdlib/plugin/fisheye/index.ts +3 -2
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/hull/bubbleset.ts +14 -14
- package/src/stdlib/plugin/hull/index.ts +4 -4
- package/src/stdlib/plugin/hull/util.ts +1 -1
- package/src/stdlib/plugin/index.ts +2 -0
- package/src/stdlib/plugin/legend/index.ts +11 -12
- package/src/stdlib/plugin/lodController/index.ts +603 -0
- package/src/stdlib/plugin/menu/index.ts +1 -1
- package/src/stdlib/plugin/minimap/index.ts +12 -14
- package/src/stdlib/plugin/snapline/index.ts +3 -3
- package/src/stdlib/plugin/toolbar/index.ts +29 -31
- package/src/stdlib/plugin/tooltip/index.ts +4 -4
- package/src/stdlib/plugin/{watermaker → watermarker}/index.ts +8 -8
- package/src/stdlib/selector/lasso.ts +3 -3
- package/src/stdlib/theme/dark.ts +31 -34
- package/src/stdlib/theme/light.ts +29 -29
- package/src/stdlib/themeSolver/spec.ts +5 -5
- package/src/stdlib/themeSolver/subject.ts +1 -1
- package/src/types/animate.ts +3 -3
- package/src/types/combo.ts +2 -2
- package/src/types/data.ts +5 -1
- package/src/types/edge.ts +2 -2
- package/src/types/graph.ts +144 -61
- package/src/types/hook.ts +37 -3
- package/src/types/index.ts +2 -1
- package/src/types/item.ts +23 -30
- package/src/types/layout.ts +21 -16
- package/src/types/node.ts +4 -33
- package/src/types/plugin.ts +3 -1
- package/src/types/spec.ts +6 -5
- package/src/types/theme.ts +8 -8
- package/src/types/view.ts +1 -1
- package/src/util/animate.ts +105 -79
- package/src/util/bbox.ts +26 -1
- package/src/util/canvas.ts +8 -0
- package/src/util/data.ts +26 -15
- package/src/util/dom.ts +6 -6
- package/src/util/extend.ts +1 -1
- package/src/util/item.ts +16 -2
- package/src/util/mapper.ts +1 -1
- package/src/util/math.ts +1 -1
- package/src/util/path.ts +73 -3
- package/src/util/polyline.ts +33 -26
- package/src/util/router.ts +28 -26
- package/src/util/shape.ts +96 -44
- package/src/util/shape3d.ts +16 -10
- package/src/util/zoom.ts +19 -25
- package/esm/runtime/controller/extension.d.ts +0 -9
- package/esm/runtime/controller/extension.js +0 -11
- package/esm/runtime/controller/extension.js.map +0 -1
- package/esm/stdlib/plugin/watermaker/index.js.map +0 -1
- package/lib/runtime/controller/extension.d.ts +0 -9
- package/lib/runtime/controller/extension.js +0 -15
- package/lib/runtime/controller/extension.js.map +0 -1
- package/lib/stdlib/plugin/watermaker/index.js.map +0 -1
- package/src/runtime/controller/extension.ts +0 -14
package/src/runtime/graph.ts
CHANGED
|
@@ -33,10 +33,19 @@ import type {
|
|
|
33
33
|
} from '../types';
|
|
34
34
|
import type { CameraAnimationOptions } from '../types/animate';
|
|
35
35
|
import type { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
|
|
36
|
-
import type {
|
|
36
|
+
import type {
|
|
37
|
+
ComboDisplayModel,
|
|
38
|
+
ComboModel,
|
|
39
|
+
ComboShapesEncode,
|
|
40
|
+
} from '../types/combo';
|
|
37
41
|
import type { Bounds, Padding, Point } from '../types/common';
|
|
38
42
|
import type { DataChangeType, DataConfig, GraphCore } from '../types/data';
|
|
39
|
-
import type {
|
|
43
|
+
import type {
|
|
44
|
+
EdgeDisplayModel,
|
|
45
|
+
EdgeModel,
|
|
46
|
+
EdgeModelData,
|
|
47
|
+
EdgeShapesEncode,
|
|
48
|
+
} from '../types/edge';
|
|
40
49
|
import type { StackType } from '../types/history';
|
|
41
50
|
import type { Hooks, ViewportChangeHookParams } from '../types/hook';
|
|
42
51
|
import type { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from '../types/item';
|
|
@@ -45,7 +54,12 @@ import type {
|
|
|
45
54
|
LayoutOptions,
|
|
46
55
|
StandardLayoutOptions,
|
|
47
56
|
} from '../types/layout';
|
|
48
|
-
import type {
|
|
57
|
+
import type {
|
|
58
|
+
NodeDisplayModel,
|
|
59
|
+
NodeModel,
|
|
60
|
+
NodeModelData,
|
|
61
|
+
NodeShapesEncode,
|
|
62
|
+
} from '../types/node';
|
|
49
63
|
import { Plugin as PluginBase } from '../types/plugin';
|
|
50
64
|
import type { RendererName } from '../types/render';
|
|
51
65
|
import { ComboMapper, EdgeMapper, NodeMapper } from '../types/spec';
|
|
@@ -59,34 +73,39 @@ import { changeRenderer, createCanvas } from '../util/canvas';
|
|
|
59
73
|
import { createDOM } from '../util/dom';
|
|
60
74
|
import { getLayoutBounds } from '../util/layout';
|
|
61
75
|
import { formatPadding } from '../util/shape';
|
|
76
|
+
import Node from '../item/node';
|
|
77
|
+
import { cloneJSON, isEmptyGraph } from '../util/data';
|
|
78
|
+
import { getCombinedCanvasesBounds } from '../util/bbox';
|
|
62
79
|
import {
|
|
63
80
|
DataController,
|
|
64
|
-
ExtensionController,
|
|
65
81
|
InteractionController,
|
|
66
82
|
ItemController,
|
|
67
83
|
LayoutController,
|
|
68
84
|
ThemeController,
|
|
69
85
|
ViewportController,
|
|
86
|
+
PluginController,
|
|
70
87
|
} from './controller';
|
|
71
|
-
import { PluginController } from './controller/plugin';
|
|
72
88
|
import Hook from './hooks';
|
|
73
|
-
import { isEmptyGraph } from '../util/data';
|
|
74
89
|
|
|
75
90
|
export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
76
91
|
extends EventEmitter
|
|
77
92
|
implements IGraph<B, T>
|
|
78
93
|
{
|
|
79
94
|
public hooks: Hooks;
|
|
80
|
-
// for nodes and edges, which will be separate into groups
|
|
95
|
+
// for nodes and edges excluding their labels, which will be separate into groups
|
|
81
96
|
public canvas: Canvas;
|
|
97
|
+
// for nodes' and edges' labels
|
|
98
|
+
public labelCanvas: Canvas;
|
|
82
99
|
// the container dom for the graph canvas
|
|
83
100
|
public container: HTMLElement;
|
|
84
101
|
// the tag to indicate whether the graph instance is destroyed
|
|
85
|
-
public destroyed: boolean;
|
|
102
|
+
public destroyed: boolean = false;
|
|
86
103
|
// the renderer type of current graph
|
|
87
104
|
public rendererType: RendererName;
|
|
88
105
|
// for transient shapes for interactions, e.g. transient node and related edges while draging, delegates
|
|
89
106
|
public transientCanvas: Canvas;
|
|
107
|
+
// for transient items' label shapes
|
|
108
|
+
public transientLabelCanvas: Canvas;
|
|
90
109
|
// for background shapes, e.g. grid, pipe indices
|
|
91
110
|
public backgroundCanvas: Canvas;
|
|
92
111
|
// the tag indicates all the three canvases are all ready
|
|
@@ -98,7 +117,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
98
117
|
private layoutController: LayoutController;
|
|
99
118
|
private viewportController: ViewportController;
|
|
100
119
|
private itemController: ItemController;
|
|
101
|
-
private extensionController: ExtensionController;
|
|
102
120
|
private themeController: ThemeController;
|
|
103
121
|
private pluginController: PluginController;
|
|
104
122
|
|
|
@@ -127,7 +145,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
127
145
|
canvases: {
|
|
128
146
|
background: this.backgroundCanvas,
|
|
129
147
|
main: this.canvas,
|
|
148
|
+
label: this.labelCanvas,
|
|
130
149
|
transient: this.transientCanvas,
|
|
150
|
+
transientLabel: this.transientLabelCanvas,
|
|
131
151
|
},
|
|
132
152
|
});
|
|
133
153
|
|
|
@@ -146,22 +166,13 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
146
166
|
this.interactionController = new InteractionController(this);
|
|
147
167
|
this.layoutController = new LayoutController(this);
|
|
148
168
|
this.themeController = new ThemeController(this);
|
|
149
|
-
this.itemController = new ItemController(this);
|
|
150
169
|
this.viewportController = new ViewportController(this);
|
|
151
|
-
this.
|
|
170
|
+
this.itemController = new ItemController(this);
|
|
152
171
|
this.pluginController = new PluginController(this);
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
private initCanvas() {
|
|
156
|
-
const {
|
|
157
|
-
renderer,
|
|
158
|
-
container,
|
|
159
|
-
canvas,
|
|
160
|
-
backgroundCanvas,
|
|
161
|
-
transientCanvas,
|
|
162
|
-
width,
|
|
163
|
-
height,
|
|
164
|
-
} = this.specification;
|
|
175
|
+
const { renderer, container, width, height } = this.specification;
|
|
165
176
|
|
|
166
177
|
let pixelRatio: number;
|
|
167
178
|
if (renderer && !isString(renderer)) {
|
|
@@ -174,13 +185,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
174
185
|
this.rendererType = renderer || 'canvas';
|
|
175
186
|
}
|
|
176
187
|
|
|
177
|
-
|
|
178
|
-
* These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
|
|
179
|
-
*/
|
|
180
|
-
if (canvas) {
|
|
181
|
-
this.canvas = canvas;
|
|
182
|
-
this.backgroundCanvas = backgroundCanvas;
|
|
183
|
-
this.transientCanvas = transientCanvas;
|
|
188
|
+
if (container) {
|
|
184
189
|
this.container = container as HTMLElement;
|
|
185
190
|
} else {
|
|
186
191
|
const containerDOM = isString(container)
|
|
@@ -194,60 +199,62 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
194
199
|
this.destroy();
|
|
195
200
|
return;
|
|
196
201
|
}
|
|
197
|
-
|
|
198
202
|
this.container = containerDOM;
|
|
199
|
-
const size = [width, height];
|
|
200
|
-
if (size[0] === undefined) {
|
|
201
|
-
size[0] = containerDOM.scrollWidth;
|
|
202
|
-
}
|
|
203
|
-
if (size[1] === undefined) {
|
|
204
|
-
size[1] = containerDOM.scrollHeight;
|
|
205
|
-
}
|
|
206
|
-
this.backgroundCanvas = createCanvas(
|
|
207
|
-
this.rendererType,
|
|
208
|
-
containerDOM,
|
|
209
|
-
size[0],
|
|
210
|
-
size[1],
|
|
211
|
-
pixelRatio,
|
|
212
|
-
);
|
|
213
|
-
this.canvas = createCanvas(
|
|
214
|
-
this.rendererType,
|
|
215
|
-
containerDOM,
|
|
216
|
-
size[0],
|
|
217
|
-
size[1],
|
|
218
|
-
pixelRatio,
|
|
219
|
-
);
|
|
220
|
-
this.transientCanvas = createCanvas(
|
|
221
|
-
this.rendererType,
|
|
222
|
-
containerDOM,
|
|
223
|
-
size[0],
|
|
224
|
-
size[1],
|
|
225
|
-
pixelRatio,
|
|
226
|
-
);
|
|
227
203
|
}
|
|
228
204
|
|
|
205
|
+
[
|
|
206
|
+
'backgroundCanvas',
|
|
207
|
+
'canvas',
|
|
208
|
+
'labelCanvas',
|
|
209
|
+
'transientCanvas',
|
|
210
|
+
'transientLabelCanvas',
|
|
211
|
+
].forEach((name) => {
|
|
212
|
+
this[name] =
|
|
213
|
+
this.specification[name] ||
|
|
214
|
+
createCanvas(
|
|
215
|
+
['labelCanvas', 'transientLabelCanvas'].includes(name)
|
|
216
|
+
? 'canvas'
|
|
217
|
+
: this.rendererType,
|
|
218
|
+
this.container,
|
|
219
|
+
width ?? this.container.scrollWidth,
|
|
220
|
+
height ?? this.container.scrollHeight,
|
|
221
|
+
pixelRatio,
|
|
222
|
+
undefined,
|
|
223
|
+
// enable dom interaction only for main canvas
|
|
224
|
+
name === 'canvas' ? [] : ['dom-interaction'],
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
229
228
|
Promise.all(
|
|
230
|
-
[
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
[
|
|
230
|
+
this.backgroundCanvas,
|
|
231
|
+
this.canvas,
|
|
232
|
+
this.labelCanvas,
|
|
233
|
+
this.transientCanvas,
|
|
234
|
+
this.transientLabelCanvas,
|
|
235
|
+
].map((canvas) => canvas.ready),
|
|
233
236
|
).then(() => {
|
|
234
|
-
[
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
237
|
+
[
|
|
238
|
+
this.backgroundCanvas,
|
|
239
|
+
this.canvas,
|
|
240
|
+
this.labelCanvas,
|
|
241
|
+
this.transientCanvas,
|
|
242
|
+
this.transientLabelCanvas,
|
|
243
|
+
].forEach((canvas, i) => {
|
|
244
|
+
const $domElement = canvas
|
|
245
|
+
.getContextService()
|
|
246
|
+
.getDomElement() as unknown as HTMLElement;
|
|
247
|
+
if ($domElement && $domElement.style) {
|
|
248
|
+
// Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
|
|
249
|
+
$domElement.style.position = 'absolute';
|
|
250
|
+
$domElement.style.outline = 'none';
|
|
251
|
+
$domElement.tabIndex = 1; // Enable keyboard events
|
|
252
|
+
// Transient canvas should let interactive events go through.
|
|
253
|
+
if (i !== 1) {
|
|
254
|
+
$domElement.style.pointerEvents = 'none';
|
|
248
255
|
}
|
|
249
|
-
}
|
|
250
|
-
);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
251
258
|
|
|
252
259
|
this.canvasReady = true;
|
|
253
260
|
});
|
|
@@ -287,8 +294,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
287
294
|
init: new Hook<{
|
|
288
295
|
canvases: {
|
|
289
296
|
background: Canvas;
|
|
297
|
+
label: Canvas;
|
|
290
298
|
main: Canvas;
|
|
291
299
|
transient: Canvas;
|
|
300
|
+
transientLabel: Canvas;
|
|
292
301
|
};
|
|
293
302
|
}>({ name: 'init' }),
|
|
294
303
|
datachange: new Hook<{ data: GraphData; type: DataChangeType }>({
|
|
@@ -306,6 +315,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
306
315
|
graphCore: GraphCore;
|
|
307
316
|
theme: ThemeSpecification;
|
|
308
317
|
transientCanvas: Canvas;
|
|
318
|
+
transientLabelCanvas: Canvas;
|
|
309
319
|
}>({
|
|
310
320
|
name: 'render',
|
|
311
321
|
}),
|
|
@@ -328,6 +338,27 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
328
338
|
}>({
|
|
329
339
|
name: 'itemstatechange',
|
|
330
340
|
}),
|
|
341
|
+
itemstateconfigchange: new Hook<{
|
|
342
|
+
itemType: ITEM_TYPE;
|
|
343
|
+
stateConfig:
|
|
344
|
+
| {
|
|
345
|
+
[stateName: string]:
|
|
346
|
+
| ((data: NodeModel) => NodeDisplayModel)
|
|
347
|
+
| NodeShapesEncode;
|
|
348
|
+
}
|
|
349
|
+
| {
|
|
350
|
+
[stateName: string]:
|
|
351
|
+
| ((data: EdgeModel) => EdgeDisplayModel)
|
|
352
|
+
| EdgeShapesEncode;
|
|
353
|
+
}
|
|
354
|
+
| {
|
|
355
|
+
[stateName: string]:
|
|
356
|
+
| ((data: ComboModel) => ComboDisplayModel)
|
|
357
|
+
| ComboShapesEncode;
|
|
358
|
+
};
|
|
359
|
+
}>({
|
|
360
|
+
name: 'itemstateconfigchange',
|
|
361
|
+
}),
|
|
331
362
|
itemvisibilitychange: new Hook<{ ids: ID[]; value: boolean }>({
|
|
332
363
|
name: 'itemvisibilitychange',
|
|
333
364
|
}),
|
|
@@ -396,11 +427,28 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
396
427
|
* Update the specs(configurations).
|
|
397
428
|
*/
|
|
398
429
|
public updateSpecification(spec: Specification<B, T>): Specification<B, T> {
|
|
430
|
+
const {
|
|
431
|
+
node,
|
|
432
|
+
edge,
|
|
433
|
+
combo,
|
|
434
|
+
theme,
|
|
435
|
+
nodeState,
|
|
436
|
+
edgeState,
|
|
437
|
+
comboState,
|
|
438
|
+
...others
|
|
439
|
+
} = spec;
|
|
440
|
+
if (node) this.updateMapper('node', node);
|
|
441
|
+
if (edge) this.updateMapper('edge', edge);
|
|
442
|
+
if (combo) this.updateMapper('combo', combo);
|
|
443
|
+
if (theme) this.updateTheme(theme);
|
|
444
|
+
if (nodeState) this.updateStateConfig('node', nodeState, 'replace');
|
|
445
|
+
if (edgeState) this.updateStateConfig('edge', edgeState, 'replace');
|
|
446
|
+
if (comboState) this.updateStateConfig('combo', comboState, 'replace');
|
|
447
|
+
|
|
399
448
|
const newSpec = Object.assign(
|
|
400
449
|
this.specification,
|
|
401
|
-
this.formatSpecification(
|
|
450
|
+
this.formatSpecification(others),
|
|
402
451
|
);
|
|
403
|
-
// TODO: update something
|
|
404
452
|
return newSpec;
|
|
405
453
|
}
|
|
406
454
|
/**
|
|
@@ -449,6 +497,47 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
449
497
|
});
|
|
450
498
|
}
|
|
451
499
|
|
|
500
|
+
/**
|
|
501
|
+
* Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
|
|
502
|
+
* @param {string} itemType - The type of item (node, edge, or combo).
|
|
503
|
+
* @param {object} stateConfig - The state configuration to update.
|
|
504
|
+
* @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
|
|
505
|
+
**/
|
|
506
|
+
public updateStateConfig(
|
|
507
|
+
itemType: ITEM_TYPE,
|
|
508
|
+
stateConfig:
|
|
509
|
+
| {
|
|
510
|
+
[stateName: string]:
|
|
511
|
+
| ((data: NodeModel) => NodeDisplayModel)
|
|
512
|
+
| NodeShapesEncode;
|
|
513
|
+
}
|
|
514
|
+
| {
|
|
515
|
+
[stateName: string]:
|
|
516
|
+
| ((data: EdgeModel) => EdgeDisplayModel)
|
|
517
|
+
| EdgeShapesEncode;
|
|
518
|
+
}
|
|
519
|
+
| {
|
|
520
|
+
[stateName: string]:
|
|
521
|
+
| ((data: ComboModel) => ComboDisplayModel)
|
|
522
|
+
| ComboShapesEncode;
|
|
523
|
+
},
|
|
524
|
+
updateType: 'mergeReplace' | 'replace' = 'mergeReplace',
|
|
525
|
+
) {
|
|
526
|
+
if (isEmpty(stateConfig)) return;
|
|
527
|
+
const stateField = `${itemType}State`;
|
|
528
|
+
if (updateType === 'mergeReplace') {
|
|
529
|
+
const config = {
|
|
530
|
+
...this.specification[stateField],
|
|
531
|
+
...stateConfig,
|
|
532
|
+
};
|
|
533
|
+
this.specification[itemType] = config;
|
|
534
|
+
this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
|
|
535
|
+
} else {
|
|
536
|
+
this.specification[itemType] = stateConfig;
|
|
537
|
+
this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
452
541
|
/**
|
|
453
542
|
* Get the copy of specs(configurations).
|
|
454
543
|
* @returns graph specs
|
|
@@ -473,6 +562,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
473
562
|
graphCore: this.dataController.graphCore,
|
|
474
563
|
theme: this.themeController.specification,
|
|
475
564
|
transientCanvas: this.transientCanvas,
|
|
565
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
476
566
|
tileOptimize: {
|
|
477
567
|
tileFirstRender,
|
|
478
568
|
tileFirstRenderSize,
|
|
@@ -518,9 +608,13 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
518
608
|
await emitRender();
|
|
519
609
|
} else {
|
|
520
610
|
await Promise.all(
|
|
521
|
-
[
|
|
522
|
-
|
|
523
|
-
|
|
611
|
+
[
|
|
612
|
+
this.backgroundCanvas,
|
|
613
|
+
this.canvas,
|
|
614
|
+
this.labelCanvas,
|
|
615
|
+
this.transientCanvas,
|
|
616
|
+
this.transientLabelCanvas,
|
|
617
|
+
].map((canvas) => canvas.ready),
|
|
524
618
|
);
|
|
525
619
|
await emitRender();
|
|
526
620
|
}
|
|
@@ -530,12 +624,14 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
530
624
|
* Change graph data.
|
|
531
625
|
* @param data new data
|
|
532
626
|
* @param type the way to change data, 'replace' means discard the old data and use the new one; 'mergeReplace' means merge the common part, remove (old - new), add (new - old)
|
|
627
|
+
* @param relayout whether relayout the nodes after data changing
|
|
533
628
|
* @returns
|
|
534
629
|
* @group Data
|
|
535
630
|
*/
|
|
536
631
|
public async changeData(
|
|
537
632
|
data: DataConfig,
|
|
538
633
|
type: 'replace' | 'mergeReplace' = 'mergeReplace',
|
|
634
|
+
relayout: boolean = true,
|
|
539
635
|
) {
|
|
540
636
|
const { tileFirstRender, tileFirstRenderSize } =
|
|
541
637
|
this.specification.optimize || {};
|
|
@@ -544,6 +640,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
544
640
|
graphCore: this.dataController.graphCore,
|
|
545
641
|
theme: this.themeController.specification,
|
|
546
642
|
transientCanvas: this.transientCanvas,
|
|
643
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
547
644
|
tileOptimize: {
|
|
548
645
|
tileFirstRender,
|
|
549
646
|
tileFirstRenderSize,
|
|
@@ -551,7 +648,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
551
648
|
});
|
|
552
649
|
this.emit('afterrender');
|
|
553
650
|
|
|
554
|
-
|
|
651
|
+
if (relayout) {
|
|
652
|
+
await this.layout();
|
|
653
|
+
}
|
|
555
654
|
}
|
|
556
655
|
|
|
557
656
|
/**
|
|
@@ -775,10 +874,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
775
874
|
halfExtents,
|
|
776
875
|
} = boundsType === 'render'
|
|
777
876
|
? // Get the bounds of the whole graph content.
|
|
778
|
-
this.canvas.
|
|
779
|
-
: // Get the
|
|
877
|
+
getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
|
|
878
|
+
: // Get the b ounds of the nodes positions while the graph content is not ready.
|
|
780
879
|
getLayoutBounds(this);
|
|
781
|
-
|
|
782
880
|
const origin = this.canvas.canvas2Viewport({
|
|
783
881
|
x: graphCenterX,
|
|
784
882
|
y: graphCenterY,
|
|
@@ -849,7 +947,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
849
947
|
} =
|
|
850
948
|
boundsType === 'render'
|
|
851
949
|
? // Get the bounds of the whole graph content.
|
|
852
|
-
this.canvas.
|
|
950
|
+
getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
|
|
853
951
|
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
854
952
|
getLayoutBounds(this);
|
|
855
953
|
await this.translateTo(
|
|
@@ -922,9 +1020,15 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
922
1020
|
this.emit('beforesetsize', { oldSize, size: size });
|
|
923
1021
|
this.specification.width = size[0];
|
|
924
1022
|
this.specification.height = size[1];
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1023
|
+
[
|
|
1024
|
+
this.canvas,
|
|
1025
|
+
this.labelCanvas,
|
|
1026
|
+
this.transientCanvas,
|
|
1027
|
+
this.transientLabelCanvas,
|
|
1028
|
+
this.backgroundCanvas,
|
|
1029
|
+
].forEach((canvas) => {
|
|
1030
|
+
canvas.resize(size[0], size[1]);
|
|
1031
|
+
});
|
|
928
1032
|
this.emit('aftersetsize', { oldSize, size: size });
|
|
929
1033
|
}
|
|
930
1034
|
|
|
@@ -1062,6 +1166,26 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1062
1166
|
): EdgeModel[] {
|
|
1063
1167
|
return this.dataController.findRelatedEdges(nodeId, direction);
|
|
1064
1168
|
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Get nearby edges from a start node using quad-tree collision detection.
|
|
1171
|
+
* @param nodeId id of the start node
|
|
1172
|
+
* @returns nearby edges' data array
|
|
1173
|
+
*/
|
|
1174
|
+
public getNearEdgesData(
|
|
1175
|
+
nodeId: ID,
|
|
1176
|
+
shouldBegin?: (edge: EdgeDisplayModel) => boolean,
|
|
1177
|
+
): EdgeModel[] {
|
|
1178
|
+
const transientItem = this.itemController.getTransientItem(
|
|
1179
|
+
nodeId,
|
|
1180
|
+
) as unknown as Node;
|
|
1181
|
+
const itemMap = this.itemController.getItemMap();
|
|
1182
|
+
return this.dataController.findNearEdges(
|
|
1183
|
+
nodeId,
|
|
1184
|
+
itemMap,
|
|
1185
|
+
transientItem,
|
|
1186
|
+
shouldBegin,
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1065
1189
|
/**
|
|
1066
1190
|
* Get one-hop node ids from a start node.
|
|
1067
1191
|
* @param nodeId id of the start node
|
|
@@ -1106,16 +1230,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1106
1230
|
return this.itemController.findDisplayModel(id);
|
|
1107
1231
|
}
|
|
1108
1232
|
|
|
1109
|
-
/**
|
|
1110
|
-
* Retrieve the nearby edges for a given node using quadtree collision detection.
|
|
1111
|
-
* @param nodeId node id
|
|
1112
|
-
* @group Data
|
|
1113
|
-
*/
|
|
1114
|
-
public getNearEdgesForNode(nodeId: ID): EdgeModel[] {
|
|
1115
|
-
const { graphCore } = this.dataController;
|
|
1116
|
-
return this.itemController.findNearEdgesByNode(nodeId, graphCore);
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
1233
|
/**
|
|
1120
1234
|
* Find items which has the state.
|
|
1121
1235
|
* @param itemType item type
|
|
@@ -1166,13 +1280,14 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1166
1280
|
|
|
1167
1281
|
const { graphCore } = this.dataController;
|
|
1168
1282
|
const { specification } = this.themeController;
|
|
1283
|
+
const modelArr = isArray(models) ? models : [models];
|
|
1169
1284
|
graphCore.once('changed', (event) => {
|
|
1170
1285
|
if (!event.changes.length) return;
|
|
1171
1286
|
const changes = event.changes;
|
|
1172
1287
|
const timingParameters = {
|
|
1173
1288
|
type: itemType,
|
|
1174
1289
|
action: 'add',
|
|
1175
|
-
models,
|
|
1290
|
+
models: modelArr,
|
|
1176
1291
|
apiName: 'addData',
|
|
1177
1292
|
changes,
|
|
1178
1293
|
};
|
|
@@ -1186,7 +1301,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1186
1301
|
this.emit('afteritemchange', timingParameters);
|
|
1187
1302
|
});
|
|
1188
1303
|
|
|
1189
|
-
const modelArr = isArray(models) ? models : [models];
|
|
1190
1304
|
const data = { nodes: [], edges: [], combos: [] };
|
|
1191
1305
|
data[`${itemType}s`] = modelArr;
|
|
1192
1306
|
this.hooks.datachange.emit({
|
|
@@ -1201,7 +1315,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1201
1315
|
}
|
|
1202
1316
|
/**
|
|
1203
1317
|
* Remove one or more node/edge/combo data from the graph.
|
|
1204
|
-
* @param
|
|
1318
|
+
* @param itemType the type the item(s) to be removed.
|
|
1319
|
+
* @param id the id or the ids' array of the items to be removed.
|
|
1205
1320
|
* @returns whether success
|
|
1206
1321
|
* @group Data
|
|
1207
1322
|
*/
|
|
@@ -1303,8 +1418,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1303
1418
|
}
|
|
1304
1419
|
/**
|
|
1305
1420
|
* Update one or more node/edge/combo data on the graph.
|
|
1306
|
-
* @param {ITEM_TYPE} itemType
|
|
1307
|
-
* @param models
|
|
1421
|
+
* @param {ITEM_TYPE} itemType the type the item(s) to be udated.
|
|
1422
|
+
* @param models update configs.
|
|
1308
1423
|
* @group Data
|
|
1309
1424
|
*/
|
|
1310
1425
|
public updateData(
|
|
@@ -1332,11 +1447,11 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1332
1447
|
const { graphCore } = this.dataController;
|
|
1333
1448
|
const { specification } = this.themeController;
|
|
1334
1449
|
graphCore.once('changed', (event) => {
|
|
1335
|
-
const changes = this.extendChanges(
|
|
1450
|
+
const changes = this.extendChanges(cloneJSON(event.changes));
|
|
1336
1451
|
const timingParameters = {
|
|
1337
1452
|
type: itemType,
|
|
1338
1453
|
action: 'update',
|
|
1339
|
-
models,
|
|
1454
|
+
models: modelArr,
|
|
1340
1455
|
apiName: 'updateData',
|
|
1341
1456
|
changes,
|
|
1342
1457
|
};
|
|
@@ -1364,7 +1479,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1364
1479
|
/**
|
|
1365
1480
|
* Update one or more nodes' positions,
|
|
1366
1481
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1367
|
-
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
1482
|
+
* @param models new configurations with x and y for every node, which has id field to indicate the specific item.
|
|
1483
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1484
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1485
|
+
* @param callback callback function after update nodes done.
|
|
1368
1486
|
* @group Data
|
|
1369
1487
|
*/
|
|
1370
1488
|
public updateNodePosition(
|
|
@@ -1379,7 +1497,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1379
1497
|
model: NodeModel | EdgeModel | ComboModel,
|
|
1380
1498
|
canceled?: boolean,
|
|
1381
1499
|
) => void,
|
|
1382
|
-
stack?: boolean,
|
|
1383
1500
|
) {
|
|
1384
1501
|
return this.updatePosition(
|
|
1385
1502
|
'node',
|
|
@@ -1387,7 +1504,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1387
1504
|
upsertAncestors,
|
|
1388
1505
|
disableAnimate,
|
|
1389
1506
|
callback,
|
|
1390
|
-
stack,
|
|
1391
1507
|
);
|
|
1392
1508
|
}
|
|
1393
1509
|
|
|
@@ -1395,7 +1511,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1395
1511
|
* Update one or more combos' positions,
|
|
1396
1512
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1397
1513
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1398
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1514
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1515
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1516
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1517
|
+
* @param callback callback function after update combos done.
|
|
1399
1518
|
* @group Data
|
|
1400
1519
|
*/
|
|
1401
1520
|
public updateComboPosition(
|
|
@@ -1407,7 +1526,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1407
1526
|
upsertAncestors?: boolean,
|
|
1408
1527
|
disableAnimate = false,
|
|
1409
1528
|
callback?: (model: NodeModel | EdgeModel | ComboModel) => void,
|
|
1410
|
-
stack?: boolean,
|
|
1411
1529
|
) {
|
|
1412
1530
|
return this.updatePosition(
|
|
1413
1531
|
'combo',
|
|
@@ -1415,7 +1533,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1415
1533
|
upsertAncestors,
|
|
1416
1534
|
disableAnimate,
|
|
1417
1535
|
callback,
|
|
1418
|
-
stack,
|
|
1419
1536
|
);
|
|
1420
1537
|
}
|
|
1421
1538
|
|
|
@@ -1446,7 +1563,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1446
1563
|
model: NodeModel | EdgeModel | ComboModel,
|
|
1447
1564
|
canceled?: boolean,
|
|
1448
1565
|
) => void,
|
|
1449
|
-
stack?: boolean,
|
|
1450
1566
|
) {
|
|
1451
1567
|
const modelArr = isArray(models) ? models : [models];
|
|
1452
1568
|
const { graphCore } = this.dataController;
|
|
@@ -1460,7 +1576,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1460
1576
|
type,
|
|
1461
1577
|
action: 'updatePosition',
|
|
1462
1578
|
upsertAncestors,
|
|
1463
|
-
models,
|
|
1579
|
+
models: modelArr,
|
|
1464
1580
|
apiName: 'updatePosition',
|
|
1465
1581
|
changes,
|
|
1466
1582
|
};
|
|
@@ -1484,7 +1600,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1484
1600
|
edges: [],
|
|
1485
1601
|
combos: type === 'combo' ? (modelArr as ComboUserModel[]) : [],
|
|
1486
1602
|
},
|
|
1487
|
-
type: '
|
|
1603
|
+
type: 'updatePosition',
|
|
1488
1604
|
});
|
|
1489
1605
|
const dataList = this.dataController.findData(
|
|
1490
1606
|
type,
|
|
@@ -1513,21 +1629,46 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1513
1629
|
* @returns
|
|
1514
1630
|
* @group Item
|
|
1515
1631
|
*/
|
|
1516
|
-
public showItem(
|
|
1632
|
+
public showItem(
|
|
1633
|
+
ids: ID | ID[],
|
|
1634
|
+
options?: {
|
|
1635
|
+
disableAnimate?: boolean;
|
|
1636
|
+
shapeIds?: string | string[];
|
|
1637
|
+
},
|
|
1638
|
+
) {
|
|
1639
|
+
const { disableAnimate = false, shapeIds } = options || {};
|
|
1517
1640
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1518
1641
|
if (isEmpty(idArr)) return;
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1642
|
+
|
|
1643
|
+
let changes;
|
|
1644
|
+
if (shapeIds?.length) {
|
|
1645
|
+
const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
|
|
1646
|
+
changes = {
|
|
1647
|
+
newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
|
|
1648
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1649
|
+
};
|
|
1650
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1651
|
+
ids: idArr as ID[],
|
|
1652
|
+
value: true,
|
|
1653
|
+
graphCore: this.dataController.graphCore,
|
|
1654
|
+
animate: !disableAnimate,
|
|
1655
|
+
shapeIds: shapeIdsArr,
|
|
1656
|
+
});
|
|
1657
|
+
} else {
|
|
1658
|
+
changes = {
|
|
1659
|
+
newValue: [{ ids: idArr, visible: true }],
|
|
1660
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1661
|
+
};
|
|
1662
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1663
|
+
ids: idArr as ID[],
|
|
1664
|
+
value: true,
|
|
1665
|
+
graphCore: this.dataController.graphCore,
|
|
1666
|
+
animate: !disableAnimate,
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1529
1670
|
this.emit('afteritemvisibilitychange', {
|
|
1530
|
-
ids,
|
|
1671
|
+
ids: idArr as ID[],
|
|
1531
1672
|
value: true,
|
|
1532
1673
|
animate: !disableAnimate,
|
|
1533
1674
|
action: 'updateVisibility',
|
|
@@ -1537,30 +1678,62 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1537
1678
|
}
|
|
1538
1679
|
/**
|
|
1539
1680
|
* Hide the item(s).
|
|
1540
|
-
* @param
|
|
1681
|
+
* @param id the id for the item to be hidden.
|
|
1682
|
+
* @param disableAnimate whether disable the hidden animations.
|
|
1683
|
+
* @param keepKeyShape whether keep the keyShape.
|
|
1684
|
+
* @param keepRelated whether keep the related nodes for edge.
|
|
1541
1685
|
* @returns
|
|
1542
1686
|
* @group Item
|
|
1543
1687
|
*/
|
|
1544
1688
|
public hideItem(
|
|
1545
1689
|
ids: ID | ID[],
|
|
1546
|
-
|
|
1547
|
-
|
|
1690
|
+
options?: {
|
|
1691
|
+
disableAnimate?: boolean;
|
|
1692
|
+
keepKeyShape?: boolean;
|
|
1693
|
+
keepRelated?: boolean;
|
|
1694
|
+
shapeIds?: string[];
|
|
1695
|
+
},
|
|
1548
1696
|
) {
|
|
1549
|
-
const
|
|
1697
|
+
const {
|
|
1698
|
+
disableAnimate = false,
|
|
1699
|
+
keepKeyShape = false,
|
|
1700
|
+
keepRelated = false,
|
|
1701
|
+
shapeIds,
|
|
1702
|
+
} = options || {};
|
|
1703
|
+
const idArr: ID[] = isArray(ids) ? ids : [ids];
|
|
1550
1704
|
if (isEmpty(idArr)) return;
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1705
|
+
|
|
1706
|
+
let changes;
|
|
1707
|
+
if (shapeIds?.length) {
|
|
1708
|
+
const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
|
|
1709
|
+
changes = {
|
|
1710
|
+
newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
|
|
1711
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1712
|
+
};
|
|
1713
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1714
|
+
ids: idArr,
|
|
1715
|
+
value: false,
|
|
1716
|
+
graphCore: this.dataController.graphCore,
|
|
1717
|
+
animate: !disableAnimate,
|
|
1718
|
+
shapeIds: shapeIdsArr,
|
|
1719
|
+
});
|
|
1720
|
+
} else {
|
|
1721
|
+
changes = {
|
|
1722
|
+
newValue: [{ ids: idArr, visible: false }],
|
|
1723
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1724
|
+
};
|
|
1725
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1726
|
+
ids: idArr,
|
|
1727
|
+
value: false,
|
|
1728
|
+
graphCore: this.dataController.graphCore,
|
|
1729
|
+
animate: !disableAnimate,
|
|
1730
|
+
keepKeyShape,
|
|
1731
|
+
keepRelated,
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1562
1735
|
this.emit('afteritemvisibilitychange', {
|
|
1563
|
-
ids,
|
|
1736
|
+
ids: idArr,
|
|
1564
1737
|
value: false,
|
|
1565
1738
|
animate: !disableAnimate,
|
|
1566
1739
|
action: 'updateVisibility',
|
|
@@ -1737,12 +1910,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1737
1910
|
return this.itemController.getItemVisible(id);
|
|
1738
1911
|
}
|
|
1739
1912
|
|
|
1913
|
+
/**
|
|
1914
|
+
* Get the visible shape ids in a node / edge / combo.
|
|
1915
|
+
* @param id the id for the node / edge / combo
|
|
1916
|
+
* @returns ids of the visible shapes
|
|
1917
|
+
*/
|
|
1918
|
+
public getItemVisibleShapeIds(id: ID) {
|
|
1919
|
+
return this.itemController.getItemVisibleShapeIds(id);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1740
1922
|
// ===== combo operations =====
|
|
1741
1923
|
|
|
1742
1924
|
/**
|
|
1743
1925
|
* Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
|
|
1744
|
-
* Different from addData with combo type, this API update the succeeds' combo tree
|
|
1745
|
-
* @param model combo user data
|
|
1926
|
+
* Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
|
|
1927
|
+
* @param model combo user data.
|
|
1928
|
+
* @param childrenIds the ids of the children nodes / combos to move into the new combo.
|
|
1746
1929
|
* @returns whether success
|
|
1747
1930
|
* @group Combo
|
|
1748
1931
|
*/
|
|
@@ -1790,7 +1973,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1790
1973
|
}
|
|
1791
1974
|
/**
|
|
1792
1975
|
* Collapse a combo.
|
|
1793
|
-
* @param comboId combo ids
|
|
1976
|
+
* @param comboId combo id or ids' array.
|
|
1794
1977
|
* @group Combo
|
|
1795
1978
|
*/
|
|
1796
1979
|
public collapseCombo(comboIds: ID | ID[]) {
|
|
@@ -1810,7 +1993,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1810
1993
|
}
|
|
1811
1994
|
/**
|
|
1812
1995
|
* Expand a combo.
|
|
1813
|
-
* @param
|
|
1996
|
+
* @param comboId combo id or ids' array.
|
|
1814
1997
|
* @group Combo
|
|
1815
1998
|
*/
|
|
1816
1999
|
public expandCombo(comboIds: ID | ID[]) {
|
|
@@ -1833,7 +2016,11 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1833
2016
|
* Move one or more combos a distance (dx, dy) relatively,
|
|
1834
2017
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1835
2018
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1836
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
2019
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
2020
|
+
* @param dx the distance alone x-axis to move the combo.
|
|
2021
|
+
* @param dy the distance alone y-axis to move the combo.
|
|
2022
|
+
* @param upsertAncestors whether update the ancestors in the combo tree.
|
|
2023
|
+
* @param callback callback function after move combo done.
|
|
1837
2024
|
* @group Combo
|
|
1838
2025
|
*/
|
|
1839
2026
|
public moveCombo(
|
|
@@ -1890,7 +2077,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1890
2077
|
/**
|
|
1891
2078
|
* Layout the graph (with current configurations if cfg is not assigned).
|
|
1892
2079
|
*/
|
|
1893
|
-
public async layout(
|
|
2080
|
+
public async layout(
|
|
2081
|
+
options?: Partial<LayoutOptions>,
|
|
2082
|
+
disableAnimate = false,
|
|
2083
|
+
) {
|
|
1894
2084
|
this.emit('beforelayout');
|
|
1895
2085
|
const { graphCore } = this.dataController;
|
|
1896
2086
|
const formattedOptions = {
|
|
@@ -1977,7 +2167,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1977
2167
|
*/
|
|
1978
2168
|
public setCursor(cursor: Cursor) {
|
|
1979
2169
|
this.canvas.setCursor(cursor);
|
|
2170
|
+
this.labelCanvas.setCursor(cursor);
|
|
1980
2171
|
this.transientCanvas.setCursor(cursor);
|
|
2172
|
+
this.transientLabelCanvas.setCursor(cursor);
|
|
1981
2173
|
}
|
|
1982
2174
|
|
|
1983
2175
|
/**
|
|
@@ -2153,12 +2345,15 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2153
2345
|
| PluginBase,
|
|
2154
2346
|
) {
|
|
2155
2347
|
const { plugins } = this.specification;
|
|
2156
|
-
const { key } = plugin
|
|
2348
|
+
const { key, type } = plugin as {
|
|
2349
|
+
key: string;
|
|
2350
|
+
type: string;
|
|
2351
|
+
[cfg: string]: unknown;
|
|
2352
|
+
};
|
|
2157
2353
|
if (!key) {
|
|
2158
2354
|
console.warn(
|
|
2159
|
-
|
|
2355
|
+
`The key for the plugin is not found. G6 will update the first plugin with type ${type}`,
|
|
2160
2356
|
);
|
|
2161
|
-
return;
|
|
2162
2357
|
}
|
|
2163
2358
|
if (!plugins) {
|
|
2164
2359
|
console.warn(
|
|
@@ -2167,12 +2362,21 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2167
2362
|
return;
|
|
2168
2363
|
}
|
|
2169
2364
|
const oldPlugin = plugins?.find((p) => {
|
|
2170
|
-
if (typeof p === 'string') return p === key;
|
|
2171
|
-
return
|
|
2365
|
+
if (typeof p === 'string') return p === key || p === type;
|
|
2366
|
+
return (
|
|
2367
|
+
p.key === key ||
|
|
2368
|
+
(
|
|
2369
|
+
p as {
|
|
2370
|
+
key: string;
|
|
2371
|
+
type: string;
|
|
2372
|
+
[cfg: string]: unknown;
|
|
2373
|
+
}
|
|
2374
|
+
).type === type
|
|
2375
|
+
);
|
|
2172
2376
|
});
|
|
2173
2377
|
if (!oldPlugin) {
|
|
2174
2378
|
console.warn(
|
|
2175
|
-
|
|
2379
|
+
`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`,
|
|
2176
2380
|
);
|
|
2177
2381
|
return;
|
|
2178
2382
|
}
|
|
@@ -2193,7 +2397,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2193
2397
|
/**
|
|
2194
2398
|
* Draw or update a G shape or group to the transient canvas.
|
|
2195
2399
|
* @param type shape type or item type
|
|
2196
|
-
* @param id new shape id or updated shape id for a
|
|
2400
|
+
* @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
|
|
2197
2401
|
* @returns upserted shape or group
|
|
2198
2402
|
* @group Interaction
|
|
2199
2403
|
*/
|
|
@@ -2236,19 +2440,23 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2236
2440
|
* @returns A Promise that resolves to the Data URL string.
|
|
2237
2441
|
*/
|
|
2238
2442
|
public async toDataURL(type?: DataURLType): Promise<string> {
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2443
|
+
const {
|
|
2444
|
+
backgroundCanvas,
|
|
2445
|
+
canvas,
|
|
2446
|
+
transientCanvas,
|
|
2447
|
+
labelCanvas,
|
|
2448
|
+
rendererType,
|
|
2449
|
+
} = this;
|
|
2243
2450
|
|
|
2244
2451
|
const pixelRatio =
|
|
2245
2452
|
typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
2246
|
-
const width = this.getSize()
|
|
2247
|
-
const height = this.getSize()[1];
|
|
2453
|
+
const [width, height] = this.getSize();
|
|
2248
2454
|
|
|
2249
2455
|
const vContainerDOM: HTMLElement = createDOM(
|
|
2250
2456
|
'<div id="virtual-image"></div>',
|
|
2251
2457
|
);
|
|
2458
|
+
|
|
2459
|
+
const camera = canvas.getCamera();
|
|
2252
2460
|
const vCanvas = createCanvas(
|
|
2253
2461
|
rendererType,
|
|
2254
2462
|
vContainerDOM,
|
|
@@ -2256,13 +2464,48 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2256
2464
|
height,
|
|
2257
2465
|
pixelRatio,
|
|
2258
2466
|
);
|
|
2467
|
+
await vCanvas.ready;
|
|
2468
|
+
|
|
2469
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
2470
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
2471
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
2472
|
+
const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
|
|
2473
|
+
|
|
2474
|
+
const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2475
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2476
|
+
labelClonedGroup.translate([
|
|
2477
|
+
currentViewportLTCanvas.x - originViewportLTCanvas.x,
|
|
2478
|
+
currentViewportLTCanvas.y - originViewportLTCanvas.y,
|
|
2479
|
+
]);
|
|
2480
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
2481
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
2482
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
2483
|
+
childGroup.children.forEach((shape) => {
|
|
2484
|
+
if (
|
|
2485
|
+
shape.getAttribute('data-is-label-background') &&
|
|
2486
|
+
shape.style.transform
|
|
2487
|
+
)
|
|
2488
|
+
shape.remove();
|
|
2489
|
+
});
|
|
2490
|
+
});
|
|
2491
|
+
|
|
2492
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
2493
|
+
vCanvas.appendChild(clonedGroup);
|
|
2494
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
2495
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
2496
|
+
|
|
2497
|
+
const vCamera = vCanvas.getCamera();
|
|
2498
|
+
vCamera.setZoom(camera.getZoom());
|
|
2499
|
+
vCamera.setPosition(camera.getPosition());
|
|
2500
|
+
vCamera.setFocalPoint(camera.getFocalPoint());
|
|
2501
|
+
|
|
2259
2502
|
const vCanvasContextService = vCanvas.getContextService();
|
|
2260
2503
|
let bgRect;
|
|
2261
2504
|
if (rendererType !== 'svg') {
|
|
2505
|
+
const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2262
2506
|
bgRect = new Rect({
|
|
2263
2507
|
style: {
|
|
2264
|
-
|
|
2265
|
-
y: 0,
|
|
2508
|
+
...backPositionCanvas,
|
|
2266
2509
|
z: -1,
|
|
2267
2510
|
width: vCanvasContextService.getDomElement().width,
|
|
2268
2511
|
height: vCanvasContextService.getDomElement().height,
|
|
@@ -2270,24 +2513,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2270
2513
|
fill: backgroundCanvas.getContextService().getDomElement().style[
|
|
2271
2514
|
'background-color'
|
|
2272
2515
|
],
|
|
2516
|
+
zIndex: -10,
|
|
2273
2517
|
},
|
|
2274
2518
|
});
|
|
2275
2519
|
vCanvas.appendChild(bgRect);
|
|
2276
2520
|
}
|
|
2277
|
-
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
2278
|
-
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
2279
|
-
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
2280
|
-
vCanvas.appendChild(backgroundClonedGroup);
|
|
2281
|
-
vCanvas.appendChild(clonedGroup);
|
|
2282
|
-
vCanvas.appendChild(transientClonedGroup);
|
|
2283
|
-
vCanvas.render();
|
|
2284
2521
|
|
|
2285
2522
|
if (!type) type = 'image/png';
|
|
2286
2523
|
let dataURL = '';
|
|
2287
|
-
|
|
2288
|
-
|
|
2524
|
+
return new Promise((resolve) => {
|
|
2525
|
+
setTimeout(() => {
|
|
2526
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
2527
|
+
dataURL = url;
|
|
2528
|
+
resolve(dataURL);
|
|
2529
|
+
});
|
|
2530
|
+
}, 50);
|
|
2289
2531
|
});
|
|
2290
|
-
return dataURL;
|
|
2291
2532
|
}
|
|
2292
2533
|
|
|
2293
2534
|
/**
|
|
@@ -2301,17 +2542,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2301
2542
|
type?: DataURLType,
|
|
2302
2543
|
imageConfig?: { padding?: number | number[] },
|
|
2303
2544
|
) {
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2545
|
+
const {
|
|
2546
|
+
backgroundCanvas,
|
|
2547
|
+
canvas,
|
|
2548
|
+
transientCanvas,
|
|
2549
|
+
labelCanvas,
|
|
2550
|
+
rendererType,
|
|
2551
|
+
} = this;
|
|
2552
|
+
const backgroundRoot = backgroundCanvas.getRoot();
|
|
2308
2553
|
const root = canvas.getRoot();
|
|
2309
2554
|
const transientRoot = transientCanvas.getRoot();
|
|
2310
|
-
const
|
|
2555
|
+
const labelRoot = labelCanvas.getRoot();
|
|
2311
2556
|
|
|
2312
|
-
const backgroundBBox = backgroundRoot.
|
|
2313
|
-
const BBox = root.
|
|
2314
|
-
const transientBBox = transientRoot.
|
|
2557
|
+
const backgroundBBox = backgroundRoot.getRenderBounds();
|
|
2558
|
+
const BBox = root.getRenderBounds();
|
|
2559
|
+
const transientBBox = transientRoot.getRenderBounds();
|
|
2560
|
+
const labelBBox = labelRoot.getRenderBounds();
|
|
2315
2561
|
|
|
2316
2562
|
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
2317
2563
|
if (!padding) {
|
|
@@ -2321,29 +2567,33 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2321
2567
|
}
|
|
2322
2568
|
|
|
2323
2569
|
const left =
|
|
2324
|
-
(
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2570
|
+
Math.min(
|
|
2571
|
+
backgroundBBox.min[0] || Infinity,
|
|
2572
|
+
BBox.min[0] || Infinity,
|
|
2573
|
+
transientBBox.min[0] || Infinity,
|
|
2574
|
+
labelBBox.min[0] || Infinity,
|
|
2575
|
+
) - padding[3];
|
|
2329
2576
|
const right =
|
|
2330
|
-
(
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2577
|
+
Math.max(
|
|
2578
|
+
backgroundBBox.max[0] || -Infinity,
|
|
2579
|
+
BBox.max[0] || -Infinity,
|
|
2580
|
+
transientBBox.max[0] || -Infinity,
|
|
2581
|
+
labelBBox.max[0] || -Infinity,
|
|
2582
|
+
) - padding[1];
|
|
2335
2583
|
const top =
|
|
2336
|
-
(
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2584
|
+
Math.min(
|
|
2585
|
+
backgroundBBox.min[1] || Infinity,
|
|
2586
|
+
BBox.min[1] || Infinity,
|
|
2587
|
+
transientBBox.min[1] || Infinity,
|
|
2588
|
+
labelBBox.min[1] || Infinity,
|
|
2589
|
+
) - padding[0];
|
|
2341
2590
|
const bottom =
|
|
2342
|
-
(
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2591
|
+
Math.max(
|
|
2592
|
+
backgroundBBox.max[1] || -Infinity,
|
|
2593
|
+
BBox.max[1] || -Infinity,
|
|
2594
|
+
transientBBox.max[1] || -Infinity,
|
|
2595
|
+
labelBBox.max[1] || -Infinity,
|
|
2596
|
+
) - padding[2];
|
|
2347
2597
|
|
|
2348
2598
|
const graphCenterX = (left + right) / 2;
|
|
2349
2599
|
const graphCenterY = (top + bottom) / 2;
|
|
@@ -2364,6 +2614,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2364
2614
|
vHeight,
|
|
2365
2615
|
pixelRatio,
|
|
2366
2616
|
);
|
|
2617
|
+
await vCanvas.ready;
|
|
2367
2618
|
const vCanvasContextService = vCanvas.getContextService();
|
|
2368
2619
|
if (rendererType !== 'svg') {
|
|
2369
2620
|
const bgRect = new Rect({
|
|
@@ -2384,6 +2635,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2384
2635
|
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
2385
2636
|
const clonedGroup = root.cloneNode(true);
|
|
2386
2637
|
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
2638
|
+
const labelClonedGroup = labelRoot.cloneNode(true);
|
|
2387
2639
|
const transPosition: [number, number] = [
|
|
2388
2640
|
-graphCenterX + halfX,
|
|
2389
2641
|
-graphCenterY + halfY,
|
|
@@ -2391,17 +2643,40 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2391
2643
|
backgroundClonedGroup.setPosition(transPosition);
|
|
2392
2644
|
clonedGroup.setPosition(transPosition);
|
|
2393
2645
|
transientClonedGroup.setPosition(transPosition);
|
|
2646
|
+
|
|
2647
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2648
|
+
const labelTransPosition: [number, number] = [
|
|
2649
|
+
transPosition[0] + currentViewportLTCanvas.x,
|
|
2650
|
+
transPosition[1] + currentViewportLTCanvas.y,
|
|
2651
|
+
];
|
|
2652
|
+
labelClonedGroup.setPosition(labelTransPosition);
|
|
2653
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
2654
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
2655
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
2656
|
+
childGroup.children.forEach((shape) => {
|
|
2657
|
+
if (
|
|
2658
|
+
shape.getAttribute('data-is-label-background') &&
|
|
2659
|
+
shape.style.transform
|
|
2660
|
+
)
|
|
2661
|
+
shape.remove();
|
|
2662
|
+
});
|
|
2663
|
+
});
|
|
2664
|
+
|
|
2394
2665
|
vCanvas.appendChild(backgroundClonedGroup);
|
|
2395
2666
|
vCanvas.appendChild(clonedGroup);
|
|
2667
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
2396
2668
|
vCanvas.appendChild(transientClonedGroup);
|
|
2397
|
-
vCanvas.render();
|
|
2398
2669
|
|
|
2399
2670
|
if (!type) type = 'image/png';
|
|
2400
2671
|
let dataURL = '';
|
|
2401
|
-
|
|
2402
|
-
|
|
2672
|
+
return new Promise((resolve) => {
|
|
2673
|
+
setTimeout(() => {
|
|
2674
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
2675
|
+
dataURL = url;
|
|
2676
|
+
resolve(dataURL);
|
|
2677
|
+
});
|
|
2678
|
+
}, 50);
|
|
2403
2679
|
});
|
|
2404
|
-
return dataURL;
|
|
2405
2680
|
}
|
|
2406
2681
|
|
|
2407
2682
|
/**
|
|
@@ -2544,7 +2819,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2544
2819
|
|
|
2545
2820
|
setTimeout(async () => {
|
|
2546
2821
|
await this.toFullDataURL(type, imageConfig).then((url) => {
|
|
2547
|
-
dataURL = url;
|
|
2822
|
+
dataURL = url as string;
|
|
2548
2823
|
});
|
|
2549
2824
|
if (callback) callback(dataURL);
|
|
2550
2825
|
}, 16);
|
|
@@ -2713,7 +2988,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2713
2988
|
* @returns
|
|
2714
2989
|
* @group Tree
|
|
2715
2990
|
*/
|
|
2716
|
-
public collapse(ids: ID | ID[], disableAnimate = false
|
|
2991
|
+
public collapse(ids: ID | ID[], disableAnimate = false) {
|
|
2717
2992
|
this.hooks.treecollapseexpand.emit({
|
|
2718
2993
|
ids: isArray(ids) ? ids : [ids],
|
|
2719
2994
|
action: 'collapse',
|
|
@@ -2729,7 +3004,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2729
3004
|
* @returns
|
|
2730
3005
|
* @group Tree
|
|
2731
3006
|
*/
|
|
2732
|
-
public expand(ids: ID | ID[], disableAnimate = false
|
|
3007
|
+
public expand(ids: ID | ID[], disableAnimate = false) {
|
|
2733
3008
|
this.hooks.treecollapseexpand.emit({
|
|
2734
3009
|
ids: isArray(ids) ? ids : [ids],
|
|
2735
3010
|
action: 'expand',
|
|
@@ -2744,17 +3019,25 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2744
3019
|
* @group Graph Instance
|
|
2745
3020
|
*/
|
|
2746
3021
|
public destroy(callback?: Function) {
|
|
2747
|
-
|
|
2748
|
-
|
|
3022
|
+
const camera = this.canvas.getCamera();
|
|
3023
|
+
const transientCamera = this.transientCanvas.getCamera();
|
|
3024
|
+
// @ts-ignore
|
|
3025
|
+
if (camera.landmarks?.length) {
|
|
3026
|
+
camera.cancelLandmarkAnimation();
|
|
3027
|
+
transientCamera.cancelLandmarkAnimation();
|
|
3028
|
+
this.emit('cancelviewportanimation');
|
|
3029
|
+
}
|
|
3030
|
+
|
|
2749
3031
|
this.canvas.destroy();
|
|
3032
|
+
this.labelCanvas.destroy();
|
|
2750
3033
|
this.backgroundCanvas.destroy();
|
|
2751
3034
|
this.transientCanvas.destroy();
|
|
3035
|
+
this.transientLabelCanvas.destroy();
|
|
2752
3036
|
|
|
2753
3037
|
// clear history stack
|
|
2754
3038
|
this.cleanHistory();
|
|
2755
3039
|
|
|
2756
3040
|
callback?.();
|
|
2757
|
-
// }, 500);
|
|
2758
3041
|
|
|
2759
3042
|
this.hooks.destroy.emit({});
|
|
2760
3043
|
|
|
@@ -2764,7 +3047,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2764
3047
|
// this.layoutController.destroy();
|
|
2765
3048
|
// this.themeController.destroy();
|
|
2766
3049
|
// this.itemController.destroy();
|
|
2767
|
-
// this.extensionController.destroy();
|
|
2768
3050
|
|
|
2769
3051
|
this.destroyed = true;
|
|
2770
3052
|
}
|