@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/esm/runtime/graph.js
CHANGED
|
@@ -25,13 +25,15 @@ import { changeRenderer, createCanvas } from '../util/canvas';
|
|
|
25
25
|
import { createDOM } from '../util/dom';
|
|
26
26
|
import { getLayoutBounds } from '../util/layout';
|
|
27
27
|
import { formatPadding } from '../util/shape';
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
28
|
+
import { cloneJSON, isEmptyGraph } from '../util/data';
|
|
29
|
+
import { getCombinedCanvasesBounds } from '../util/bbox';
|
|
30
|
+
import { DataController, InteractionController, ItemController, LayoutController, ThemeController, ViewportController, PluginController, } from './controller';
|
|
30
31
|
import Hook from './hooks';
|
|
31
|
-
import { isEmptyGraph } from '../util/data';
|
|
32
32
|
export class Graph extends EventEmitter {
|
|
33
33
|
constructor(spec) {
|
|
34
34
|
super();
|
|
35
|
+
// the tag to indicate whether the graph instance is destroyed
|
|
36
|
+
this.destroyed = false;
|
|
35
37
|
this.defaultSpecification = {
|
|
36
38
|
theme: {
|
|
37
39
|
type: 'spec',
|
|
@@ -62,7 +64,9 @@ export class Graph extends EventEmitter {
|
|
|
62
64
|
canvases: {
|
|
63
65
|
background: this.backgroundCanvas,
|
|
64
66
|
main: this.canvas,
|
|
67
|
+
label: this.labelCanvas,
|
|
65
68
|
transient: this.transientCanvas,
|
|
69
|
+
transientLabel: this.transientLabelCanvas,
|
|
66
70
|
},
|
|
67
71
|
});
|
|
68
72
|
const { data } = spec;
|
|
@@ -79,13 +83,12 @@ export class Graph extends EventEmitter {
|
|
|
79
83
|
this.interactionController = new InteractionController(this);
|
|
80
84
|
this.layoutController = new LayoutController(this);
|
|
81
85
|
this.themeController = new ThemeController(this);
|
|
82
|
-
this.itemController = new ItemController(this);
|
|
83
86
|
this.viewportController = new ViewportController(this);
|
|
84
|
-
this.
|
|
87
|
+
this.itemController = new ItemController(this);
|
|
85
88
|
this.pluginController = new PluginController(this);
|
|
86
89
|
}
|
|
87
90
|
initCanvas() {
|
|
88
|
-
const { renderer, container,
|
|
91
|
+
const { renderer, container, width, height } = this.specification;
|
|
89
92
|
let pixelRatio;
|
|
90
93
|
if (renderer && !isString(renderer)) {
|
|
91
94
|
// @ts-ignore
|
|
@@ -97,13 +100,7 @@ export class Graph extends EventEmitter {
|
|
|
97
100
|
// @ts-ignore
|
|
98
101
|
this.rendererType = renderer || 'canvas';
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
* These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
|
|
102
|
-
*/
|
|
103
|
-
if (canvas) {
|
|
104
|
-
this.canvas = canvas;
|
|
105
|
-
this.backgroundCanvas = backgroundCanvas;
|
|
106
|
-
this.transientCanvas = transientCanvas;
|
|
103
|
+
if (container) {
|
|
107
104
|
this.container = container;
|
|
108
105
|
}
|
|
109
106
|
else {
|
|
@@ -116,19 +113,36 @@ export class Graph extends EventEmitter {
|
|
|
116
113
|
return;
|
|
117
114
|
}
|
|
118
115
|
this.container = containerDOM;
|
|
119
|
-
const size = [width, height];
|
|
120
|
-
if (size[0] === undefined) {
|
|
121
|
-
size[0] = containerDOM.scrollWidth;
|
|
122
|
-
}
|
|
123
|
-
if (size[1] === undefined) {
|
|
124
|
-
size[1] = containerDOM.scrollHeight;
|
|
125
|
-
}
|
|
126
|
-
this.backgroundCanvas = createCanvas(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
127
|
-
this.canvas = createCanvas(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
128
|
-
this.transientCanvas = createCanvas(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
129
116
|
}
|
|
130
|
-
|
|
131
|
-
|
|
117
|
+
[
|
|
118
|
+
'backgroundCanvas',
|
|
119
|
+
'canvas',
|
|
120
|
+
'labelCanvas',
|
|
121
|
+
'transientCanvas',
|
|
122
|
+
'transientLabelCanvas',
|
|
123
|
+
].forEach((name) => {
|
|
124
|
+
this[name] =
|
|
125
|
+
this.specification[name] ||
|
|
126
|
+
createCanvas(['labelCanvas', 'transientLabelCanvas'].includes(name)
|
|
127
|
+
? 'canvas'
|
|
128
|
+
: this.rendererType, this.container, width !== null && width !== void 0 ? width : this.container.scrollWidth, height !== null && height !== void 0 ? height : this.container.scrollHeight, pixelRatio, undefined,
|
|
129
|
+
// enable dom interaction only for main canvas
|
|
130
|
+
name === 'canvas' ? [] : ['dom-interaction']);
|
|
131
|
+
});
|
|
132
|
+
Promise.all([
|
|
133
|
+
this.backgroundCanvas,
|
|
134
|
+
this.canvas,
|
|
135
|
+
this.labelCanvas,
|
|
136
|
+
this.transientCanvas,
|
|
137
|
+
this.transientLabelCanvas,
|
|
138
|
+
].map((canvas) => canvas.ready)).then(() => {
|
|
139
|
+
[
|
|
140
|
+
this.backgroundCanvas,
|
|
141
|
+
this.canvas,
|
|
142
|
+
this.labelCanvas,
|
|
143
|
+
this.transientCanvas,
|
|
144
|
+
this.transientLabelCanvas,
|
|
145
|
+
].forEach((canvas, i) => {
|
|
132
146
|
const $domElement = canvas
|
|
133
147
|
.getContextService()
|
|
134
148
|
.getDomElement();
|
|
@@ -190,6 +204,9 @@ export class Graph extends EventEmitter {
|
|
|
190
204
|
itemstatechange: new Hook({
|
|
191
205
|
name: 'itemstatechange',
|
|
192
206
|
}),
|
|
207
|
+
itemstateconfigchange: new Hook({
|
|
208
|
+
name: 'itemstateconfigchange',
|
|
209
|
+
}),
|
|
193
210
|
itemvisibilitychange: new Hook({
|
|
194
211
|
name: 'itemvisibilitychange',
|
|
195
212
|
}),
|
|
@@ -212,8 +229,22 @@ export class Graph extends EventEmitter {
|
|
|
212
229
|
* Update the specs(configurations).
|
|
213
230
|
*/
|
|
214
231
|
updateSpecification(spec) {
|
|
215
|
-
const
|
|
216
|
-
|
|
232
|
+
const { node, edge, combo, theme, nodeState, edgeState, comboState } = spec, others = __rest(spec, ["node", "edge", "combo", "theme", "nodeState", "edgeState", "comboState"]);
|
|
233
|
+
if (node)
|
|
234
|
+
this.updateMapper('node', node);
|
|
235
|
+
if (edge)
|
|
236
|
+
this.updateMapper('edge', edge);
|
|
237
|
+
if (combo)
|
|
238
|
+
this.updateMapper('combo', combo);
|
|
239
|
+
if (theme)
|
|
240
|
+
this.updateTheme(theme);
|
|
241
|
+
if (nodeState)
|
|
242
|
+
this.updateStateConfig('node', nodeState, 'replace');
|
|
243
|
+
if (edgeState)
|
|
244
|
+
this.updateStateConfig('edge', edgeState, 'replace');
|
|
245
|
+
if (comboState)
|
|
246
|
+
this.updateStateConfig('combo', comboState, 'replace');
|
|
247
|
+
const newSpec = Object.assign(this.specification, this.formatSpecification(others));
|
|
217
248
|
return newSpec;
|
|
218
249
|
}
|
|
219
250
|
/**
|
|
@@ -257,6 +288,26 @@ export class Graph extends EventEmitter {
|
|
|
257
288
|
mapper,
|
|
258
289
|
});
|
|
259
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
|
|
293
|
+
* @param {string} itemType - The type of item (node, edge, or combo).
|
|
294
|
+
* @param {object} stateConfig - The state configuration to update.
|
|
295
|
+
* @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
|
|
296
|
+
**/
|
|
297
|
+
updateStateConfig(itemType, stateConfig, updateType = 'mergeReplace') {
|
|
298
|
+
if (isEmpty(stateConfig))
|
|
299
|
+
return;
|
|
300
|
+
const stateField = `${itemType}State`;
|
|
301
|
+
if (updateType === 'mergeReplace') {
|
|
302
|
+
const config = Object.assign(Object.assign({}, this.specification[stateField]), stateConfig);
|
|
303
|
+
this.specification[itemType] = config;
|
|
304
|
+
this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.specification[itemType] = stateConfig;
|
|
308
|
+
this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
260
311
|
/**
|
|
261
312
|
* Get the copy of specs(configurations).
|
|
262
313
|
* @returns graph specs
|
|
@@ -280,6 +331,7 @@ export class Graph extends EventEmitter {
|
|
|
280
331
|
graphCore: this.dataController.graphCore,
|
|
281
332
|
theme: this.themeController.specification,
|
|
282
333
|
transientCanvas: this.transientCanvas,
|
|
334
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
283
335
|
tileOptimize: {
|
|
284
336
|
tileFirstRender,
|
|
285
337
|
tileFirstRenderSize,
|
|
@@ -320,7 +372,13 @@ export class Graph extends EventEmitter {
|
|
|
320
372
|
yield emitRender();
|
|
321
373
|
}
|
|
322
374
|
else {
|
|
323
|
-
yield Promise.all([
|
|
375
|
+
yield Promise.all([
|
|
376
|
+
this.backgroundCanvas,
|
|
377
|
+
this.canvas,
|
|
378
|
+
this.labelCanvas,
|
|
379
|
+
this.transientCanvas,
|
|
380
|
+
this.transientLabelCanvas,
|
|
381
|
+
].map((canvas) => canvas.ready));
|
|
324
382
|
yield emitRender();
|
|
325
383
|
}
|
|
326
384
|
});
|
|
@@ -329,10 +387,11 @@ export class Graph extends EventEmitter {
|
|
|
329
387
|
* Change graph data.
|
|
330
388
|
* @param data new data
|
|
331
389
|
* @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)
|
|
390
|
+
* @param relayout whether relayout the nodes after data changing
|
|
332
391
|
* @returns
|
|
333
392
|
* @group Data
|
|
334
393
|
*/
|
|
335
|
-
changeData(data, type = 'mergeReplace') {
|
|
394
|
+
changeData(data, type = 'mergeReplace', relayout = true) {
|
|
336
395
|
return __awaiter(this, void 0, void 0, function* () {
|
|
337
396
|
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
338
397
|
this.hooks.datachange.emit({ data, type });
|
|
@@ -340,13 +399,16 @@ export class Graph extends EventEmitter {
|
|
|
340
399
|
graphCore: this.dataController.graphCore,
|
|
341
400
|
theme: this.themeController.specification,
|
|
342
401
|
transientCanvas: this.transientCanvas,
|
|
402
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
343
403
|
tileOptimize: {
|
|
344
404
|
tileFirstRender,
|
|
345
405
|
tileFirstRenderSize,
|
|
346
406
|
},
|
|
347
407
|
});
|
|
348
408
|
this.emit('afterrender');
|
|
349
|
-
|
|
409
|
+
if (relayout) {
|
|
410
|
+
yield this.layout();
|
|
411
|
+
}
|
|
350
412
|
});
|
|
351
413
|
}
|
|
352
414
|
/**
|
|
@@ -499,8 +561,8 @@ export class Graph extends EventEmitter {
|
|
|
499
561
|
const { direction = 'both', ratioRule = 'min', boundsType = 'render', onlyOutOfViewport = false, onlyZoomAtLargerThanViewport = false, } = rules || {};
|
|
500
562
|
const { min, max, center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
|
|
501
563
|
? // Get the bounds of the whole graph content.
|
|
502
|
-
this.canvas.
|
|
503
|
-
: // Get the
|
|
564
|
+
getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
|
|
565
|
+
: // Get the b ounds of the nodes positions while the graph content is not ready.
|
|
504
566
|
getLayoutBounds(this);
|
|
505
567
|
const origin = this.canvas.canvas2Viewport({
|
|
506
568
|
x: graphCenterX,
|
|
@@ -560,7 +622,7 @@ export class Graph extends EventEmitter {
|
|
|
560
622
|
return __awaiter(this, void 0, void 0, function* () {
|
|
561
623
|
const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
|
|
562
624
|
? // Get the bounds of the whole graph content.
|
|
563
|
-
this.canvas.
|
|
625
|
+
getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
|
|
564
626
|
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
565
627
|
getLayoutBounds(this);
|
|
566
628
|
yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
|
|
@@ -623,9 +685,15 @@ export class Graph extends EventEmitter {
|
|
|
623
685
|
this.emit('beforesetsize', { oldSize, size: size });
|
|
624
686
|
this.specification.width = size[0];
|
|
625
687
|
this.specification.height = size[1];
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
688
|
+
[
|
|
689
|
+
this.canvas,
|
|
690
|
+
this.labelCanvas,
|
|
691
|
+
this.transientCanvas,
|
|
692
|
+
this.transientLabelCanvas,
|
|
693
|
+
this.backgroundCanvas,
|
|
694
|
+
].forEach((canvas) => {
|
|
695
|
+
canvas.resize(size[0], size[1]);
|
|
696
|
+
});
|
|
629
697
|
this.emit('aftersetsize', { oldSize, size: size });
|
|
630
698
|
}
|
|
631
699
|
getCanvasRange() {
|
|
@@ -754,6 +822,16 @@ export class Graph extends EventEmitter {
|
|
|
754
822
|
getRelatedEdgesData(nodeId, direction = 'both') {
|
|
755
823
|
return this.dataController.findRelatedEdges(nodeId, direction);
|
|
756
824
|
}
|
|
825
|
+
/**
|
|
826
|
+
* Get nearby edges from a start node using quad-tree collision detection.
|
|
827
|
+
* @param nodeId id of the start node
|
|
828
|
+
* @returns nearby edges' data array
|
|
829
|
+
*/
|
|
830
|
+
getNearEdgesData(nodeId, shouldBegin) {
|
|
831
|
+
const transientItem = this.itemController.getTransientItem(nodeId);
|
|
832
|
+
const itemMap = this.itemController.getItemMap();
|
|
833
|
+
return this.dataController.findNearEdges(nodeId, itemMap, transientItem, shouldBegin);
|
|
834
|
+
}
|
|
757
835
|
/**
|
|
758
836
|
* Get one-hop node ids from a start node.
|
|
759
837
|
* @param nodeId id of the start node
|
|
@@ -791,15 +869,6 @@ export class Graph extends EventEmitter {
|
|
|
791
869
|
getDisplayModel(id) {
|
|
792
870
|
return this.itemController.findDisplayModel(id);
|
|
793
871
|
}
|
|
794
|
-
/**
|
|
795
|
-
* Retrieve the nearby edges for a given node using quadtree collision detection.
|
|
796
|
-
* @param nodeId node id
|
|
797
|
-
* @group Data
|
|
798
|
-
*/
|
|
799
|
-
getNearEdgesForNode(nodeId) {
|
|
800
|
-
const { graphCore } = this.dataController;
|
|
801
|
-
return this.itemController.findNearEdgesByNode(nodeId, graphCore);
|
|
802
|
-
}
|
|
803
872
|
/**
|
|
804
873
|
* Find items which has the state.
|
|
805
874
|
* @param itemType item type
|
|
@@ -831,6 +900,7 @@ export class Graph extends EventEmitter {
|
|
|
831
900
|
// data controller and item controller subscribe additem in order
|
|
832
901
|
const { graphCore } = this.dataController;
|
|
833
902
|
const { specification } = this.themeController;
|
|
903
|
+
const modelArr = isArray(models) ? models : [models];
|
|
834
904
|
graphCore.once('changed', (event) => {
|
|
835
905
|
if (!event.changes.length)
|
|
836
906
|
return;
|
|
@@ -838,7 +908,7 @@ export class Graph extends EventEmitter {
|
|
|
838
908
|
const timingParameters = {
|
|
839
909
|
type: itemType,
|
|
840
910
|
action: 'add',
|
|
841
|
-
models,
|
|
911
|
+
models: modelArr,
|
|
842
912
|
apiName: 'addData',
|
|
843
913
|
changes,
|
|
844
914
|
};
|
|
@@ -851,7 +921,6 @@ export class Graph extends EventEmitter {
|
|
|
851
921
|
});
|
|
852
922
|
this.emit('afteritemchange', timingParameters);
|
|
853
923
|
});
|
|
854
|
-
const modelArr = isArray(models) ? models : [models];
|
|
855
924
|
const data = { nodes: [], edges: [], combos: [] };
|
|
856
925
|
data[`${itemType}s`] = modelArr;
|
|
857
926
|
this.hooks.datachange.emit({
|
|
@@ -863,7 +932,8 @@ export class Graph extends EventEmitter {
|
|
|
863
932
|
}
|
|
864
933
|
/**
|
|
865
934
|
* Remove one or more node/edge/combo data from the graph.
|
|
866
|
-
* @param
|
|
935
|
+
* @param itemType the type the item(s) to be removed.
|
|
936
|
+
* @param id the id or the ids' array of the items to be removed.
|
|
867
937
|
* @returns whether success
|
|
868
938
|
* @group Data
|
|
869
939
|
*/
|
|
@@ -957,8 +1027,8 @@ export class Graph extends EventEmitter {
|
|
|
957
1027
|
}
|
|
958
1028
|
/**
|
|
959
1029
|
* Update one or more node/edge/combo data on the graph.
|
|
960
|
-
* @param {ITEM_TYPE} itemType
|
|
961
|
-
* @param models
|
|
1030
|
+
* @param {ITEM_TYPE} itemType the type the item(s) to be udated.
|
|
1031
|
+
* @param models update configs.
|
|
962
1032
|
* @group Data
|
|
963
1033
|
*/
|
|
964
1034
|
updateData(itemType, models) {
|
|
@@ -968,11 +1038,11 @@ export class Graph extends EventEmitter {
|
|
|
968
1038
|
const { graphCore } = this.dataController;
|
|
969
1039
|
const { specification } = this.themeController;
|
|
970
1040
|
graphCore.once('changed', (event) => {
|
|
971
|
-
const changes = this.extendChanges(
|
|
1041
|
+
const changes = this.extendChanges(cloneJSON(event.changes));
|
|
972
1042
|
const timingParameters = {
|
|
973
1043
|
type: itemType,
|
|
974
1044
|
action: 'update',
|
|
975
|
-
models,
|
|
1045
|
+
models: modelArr,
|
|
976
1046
|
apiName: 'updateData',
|
|
977
1047
|
changes,
|
|
978
1048
|
};
|
|
@@ -995,21 +1065,27 @@ export class Graph extends EventEmitter {
|
|
|
995
1065
|
/**
|
|
996
1066
|
* Update one or more nodes' positions,
|
|
997
1067
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
998
|
-
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
1068
|
+
* @param models new configurations with x and y for every node, which has id field to indicate the specific item.
|
|
1069
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1070
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1071
|
+
* @param callback callback function after update nodes done.
|
|
999
1072
|
* @group Data
|
|
1000
1073
|
*/
|
|
1001
|
-
updateNodePosition(models, upsertAncestors, disableAnimate = false, callback
|
|
1002
|
-
return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback
|
|
1074
|
+
updateNodePosition(models, upsertAncestors, disableAnimate = false, callback) {
|
|
1075
|
+
return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback);
|
|
1003
1076
|
}
|
|
1004
1077
|
/**
|
|
1005
1078
|
* Update one or more combos' positions,
|
|
1006
1079
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1007
1080
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1008
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1081
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1082
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1083
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1084
|
+
* @param callback callback function after update combos done.
|
|
1009
1085
|
* @group Data
|
|
1010
1086
|
*/
|
|
1011
|
-
updateComboPosition(models, upsertAncestors, disableAnimate = false, callback
|
|
1012
|
-
return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback
|
|
1087
|
+
updateComboPosition(models, upsertAncestors, disableAnimate = false, callback) {
|
|
1088
|
+
return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback);
|
|
1013
1089
|
}
|
|
1014
1090
|
/**
|
|
1015
1091
|
* Get history plugin instance
|
|
@@ -1022,7 +1098,7 @@ export class Graph extends EventEmitter {
|
|
|
1022
1098
|
}
|
|
1023
1099
|
return this.pluginController.getPlugin('history');
|
|
1024
1100
|
}
|
|
1025
|
-
updatePosition(type, models, upsertAncestors, disableAnimate = false, callback
|
|
1101
|
+
updatePosition(type, models, upsertAncestors, disableAnimate = false, callback) {
|
|
1026
1102
|
const modelArr = isArray(models) ? models : [models];
|
|
1027
1103
|
const { graphCore } = this.dataController;
|
|
1028
1104
|
const { specification } = this.themeController;
|
|
@@ -1034,7 +1110,7 @@ export class Graph extends EventEmitter {
|
|
|
1034
1110
|
type,
|
|
1035
1111
|
action: 'updatePosition',
|
|
1036
1112
|
upsertAncestors,
|
|
1037
|
-
models,
|
|
1113
|
+
models: modelArr,
|
|
1038
1114
|
apiName: 'updatePosition',
|
|
1039
1115
|
changes,
|
|
1040
1116
|
};
|
|
@@ -1057,7 +1133,7 @@ export class Graph extends EventEmitter {
|
|
|
1057
1133
|
edges: [],
|
|
1058
1134
|
combos: type === 'combo' ? modelArr : [],
|
|
1059
1135
|
},
|
|
1060
|
-
type: '
|
|
1136
|
+
type: 'updatePosition',
|
|
1061
1137
|
});
|
|
1062
1138
|
const dataList = this.dataController.findData(type, modelArr.map((model) => model.id));
|
|
1063
1139
|
return isArray(models) ? dataList : dataList[0];
|
|
@@ -1080,22 +1156,40 @@ export class Graph extends EventEmitter {
|
|
|
1080
1156
|
* @returns
|
|
1081
1157
|
* @group Item
|
|
1082
1158
|
*/
|
|
1083
|
-
showItem(ids,
|
|
1159
|
+
showItem(ids, options) {
|
|
1160
|
+
const { disableAnimate = false, shapeIds } = options || {};
|
|
1084
1161
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1085
1162
|
if (isEmpty(idArr))
|
|
1086
1163
|
return;
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1164
|
+
let changes;
|
|
1165
|
+
if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
|
|
1166
|
+
const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
|
|
1167
|
+
changes = {
|
|
1168
|
+
newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
|
|
1169
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1170
|
+
};
|
|
1171
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1172
|
+
ids: idArr,
|
|
1173
|
+
value: true,
|
|
1174
|
+
graphCore: this.dataController.graphCore,
|
|
1175
|
+
animate: !disableAnimate,
|
|
1176
|
+
shapeIds: shapeIdsArr,
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
changes = {
|
|
1181
|
+
newValue: [{ ids: idArr, visible: true }],
|
|
1182
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1183
|
+
};
|
|
1184
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1185
|
+
ids: idArr,
|
|
1186
|
+
value: true,
|
|
1187
|
+
graphCore: this.dataController.graphCore,
|
|
1188
|
+
animate: !disableAnimate,
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1097
1191
|
this.emit('afteritemvisibilitychange', {
|
|
1098
|
-
ids,
|
|
1192
|
+
ids: idArr,
|
|
1099
1193
|
value: true,
|
|
1100
1194
|
animate: !disableAnimate,
|
|
1101
1195
|
action: 'updateVisibility',
|
|
@@ -1105,27 +1199,49 @@ export class Graph extends EventEmitter {
|
|
|
1105
1199
|
}
|
|
1106
1200
|
/**
|
|
1107
1201
|
* Hide the item(s).
|
|
1108
|
-
* @param
|
|
1202
|
+
* @param id the id for the item to be hidden.
|
|
1203
|
+
* @param disableAnimate whether disable the hidden animations.
|
|
1204
|
+
* @param keepKeyShape whether keep the keyShape.
|
|
1205
|
+
* @param keepRelated whether keep the related nodes for edge.
|
|
1109
1206
|
* @returns
|
|
1110
1207
|
* @group Item
|
|
1111
1208
|
*/
|
|
1112
|
-
hideItem(ids,
|
|
1209
|
+
hideItem(ids, options) {
|
|
1210
|
+
const { disableAnimate = false, keepKeyShape = false, keepRelated = false, shapeIds, } = options || {};
|
|
1113
1211
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1114
1212
|
if (isEmpty(idArr))
|
|
1115
1213
|
return;
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1214
|
+
let changes;
|
|
1215
|
+
if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
|
|
1216
|
+
const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
|
|
1217
|
+
changes = {
|
|
1218
|
+
newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
|
|
1219
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1220
|
+
};
|
|
1221
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1222
|
+
ids: idArr,
|
|
1223
|
+
value: false,
|
|
1224
|
+
graphCore: this.dataController.graphCore,
|
|
1225
|
+
animate: !disableAnimate,
|
|
1226
|
+
shapeIds: shapeIdsArr,
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
else {
|
|
1230
|
+
changes = {
|
|
1231
|
+
newValue: [{ ids: idArr, visible: false }],
|
|
1232
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1233
|
+
};
|
|
1234
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1235
|
+
ids: idArr,
|
|
1236
|
+
value: false,
|
|
1237
|
+
graphCore: this.dataController.graphCore,
|
|
1238
|
+
animate: !disableAnimate,
|
|
1239
|
+
keepKeyShape,
|
|
1240
|
+
keepRelated,
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1127
1243
|
this.emit('afteritemvisibilitychange', {
|
|
1128
|
-
ids,
|
|
1244
|
+
ids: idArr,
|
|
1129
1245
|
value: false,
|
|
1130
1246
|
animate: !disableAnimate,
|
|
1131
1247
|
action: 'updateVisibility',
|
|
@@ -1286,11 +1402,20 @@ export class Graph extends EventEmitter {
|
|
|
1286
1402
|
getItemVisible(id) {
|
|
1287
1403
|
return this.itemController.getItemVisible(id);
|
|
1288
1404
|
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Get the visible shape ids in a node / edge / combo.
|
|
1407
|
+
* @param id the id for the node / edge / combo
|
|
1408
|
+
* @returns ids of the visible shapes
|
|
1409
|
+
*/
|
|
1410
|
+
getItemVisibleShapeIds(id) {
|
|
1411
|
+
return this.itemController.getItemVisibleShapeIds(id);
|
|
1412
|
+
}
|
|
1289
1413
|
// ===== combo operations =====
|
|
1290
1414
|
/**
|
|
1291
1415
|
* 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.
|
|
1292
|
-
* Different from addData with combo type, this API update the succeeds' combo tree
|
|
1293
|
-
* @param model combo user data
|
|
1416
|
+
* Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
|
|
1417
|
+
* @param model combo user data.
|
|
1418
|
+
* @param childrenIds the ids of the children nodes / combos to move into the new combo.
|
|
1294
1419
|
* @returns whether success
|
|
1295
1420
|
* @group Combo
|
|
1296
1421
|
*/
|
|
@@ -1332,7 +1457,7 @@ export class Graph extends EventEmitter {
|
|
|
1332
1457
|
}
|
|
1333
1458
|
/**
|
|
1334
1459
|
* Collapse a combo.
|
|
1335
|
-
* @param comboId combo ids
|
|
1460
|
+
* @param comboId combo id or ids' array.
|
|
1336
1461
|
* @group Combo
|
|
1337
1462
|
*/
|
|
1338
1463
|
collapseCombo(comboIds) {
|
|
@@ -1349,7 +1474,7 @@ export class Graph extends EventEmitter {
|
|
|
1349
1474
|
}
|
|
1350
1475
|
/**
|
|
1351
1476
|
* Expand a combo.
|
|
1352
|
-
* @param
|
|
1477
|
+
* @param comboId combo id or ids' array.
|
|
1353
1478
|
* @group Combo
|
|
1354
1479
|
*/
|
|
1355
1480
|
expandCombo(comboIds) {
|
|
@@ -1368,7 +1493,11 @@ export class Graph extends EventEmitter {
|
|
|
1368
1493
|
* Move one or more combos a distance (dx, dy) relatively,
|
|
1369
1494
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1370
1495
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1371
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1496
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1497
|
+
* @param dx the distance alone x-axis to move the combo.
|
|
1498
|
+
* @param dy the distance alone y-axis to move the combo.
|
|
1499
|
+
* @param upsertAncestors whether update the ancestors in the combo tree.
|
|
1500
|
+
* @param callback callback function after move combo done.
|
|
1372
1501
|
* @group Combo
|
|
1373
1502
|
*/
|
|
1374
1503
|
moveCombo(ids, dx, dy, upsertAncestors, callback) {
|
|
@@ -1490,7 +1619,9 @@ export class Graph extends EventEmitter {
|
|
|
1490
1619
|
*/
|
|
1491
1620
|
setCursor(cursor) {
|
|
1492
1621
|
this.canvas.setCursor(cursor);
|
|
1622
|
+
this.labelCanvas.setCursor(cursor);
|
|
1493
1623
|
this.transientCanvas.setCursor(cursor);
|
|
1624
|
+
this.transientLabelCanvas.setCursor(cursor);
|
|
1494
1625
|
}
|
|
1495
1626
|
/**
|
|
1496
1627
|
* Add behavior(s) to mode(s).
|
|
@@ -1622,10 +1753,9 @@ export class Graph extends EventEmitter {
|
|
|
1622
1753
|
*/
|
|
1623
1754
|
updatePlugin(plugin) {
|
|
1624
1755
|
const { plugins } = this.specification;
|
|
1625
|
-
const { key } = plugin;
|
|
1756
|
+
const { key, type } = plugin;
|
|
1626
1757
|
if (!key) {
|
|
1627
|
-
console.warn(
|
|
1628
|
-
return;
|
|
1758
|
+
console.warn(`The key for the plugin is not found. G6 will update the first plugin with type ${type}`);
|
|
1629
1759
|
}
|
|
1630
1760
|
if (!plugins) {
|
|
1631
1761
|
console.warn('Update plugin failed, the plugin to be updated does not exist.');
|
|
@@ -1633,11 +1763,12 @@ export class Graph extends EventEmitter {
|
|
|
1633
1763
|
}
|
|
1634
1764
|
const oldPlugin = plugins === null || plugins === void 0 ? void 0 : plugins.find((p) => {
|
|
1635
1765
|
if (typeof p === 'string')
|
|
1636
|
-
return p === key;
|
|
1637
|
-
return p.key === key
|
|
1766
|
+
return p === key || p === type;
|
|
1767
|
+
return (p.key === key ||
|
|
1768
|
+
p.type === type);
|
|
1638
1769
|
});
|
|
1639
1770
|
if (!oldPlugin) {
|
|
1640
|
-
console.warn(
|
|
1771
|
+
console.warn(`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`);
|
|
1641
1772
|
return;
|
|
1642
1773
|
}
|
|
1643
1774
|
const idx = plugins.indexOf(oldPlugin);
|
|
@@ -1650,7 +1781,7 @@ export class Graph extends EventEmitter {
|
|
|
1650
1781
|
/**
|
|
1651
1782
|
* Draw or update a G shape or group to the transient canvas.
|
|
1652
1783
|
* @param type shape type or item type
|
|
1653
|
-
* @param id new shape id or updated shape id for a
|
|
1784
|
+
* @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
|
|
1654
1785
|
* @returns upserted shape or group
|
|
1655
1786
|
* @group Interaction
|
|
1656
1787
|
*/
|
|
@@ -1673,45 +1804,62 @@ export class Graph extends EventEmitter {
|
|
|
1673
1804
|
*/
|
|
1674
1805
|
toDataURL(type) {
|
|
1675
1806
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1676
|
-
const backgroundCanvas = this
|
|
1677
|
-
const canvas = this.canvas;
|
|
1678
|
-
const transientCanvas = this.transientCanvas;
|
|
1679
|
-
const rendererType = this.rendererType;
|
|
1807
|
+
const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
|
|
1680
1808
|
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1681
|
-
const width = this.getSize()
|
|
1682
|
-
const height = this.getSize()[1];
|
|
1809
|
+
const [width, height] = this.getSize();
|
|
1683
1810
|
const vContainerDOM = createDOM('<div id="virtual-image"></div>');
|
|
1811
|
+
const camera = canvas.getCamera();
|
|
1684
1812
|
const vCanvas = createCanvas(rendererType, vContainerDOM, width, height, pixelRatio);
|
|
1813
|
+
yield vCanvas.ready;
|
|
1814
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1815
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1816
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1817
|
+
const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
|
|
1818
|
+
const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1819
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1820
|
+
labelClonedGroup.translate([
|
|
1821
|
+
currentViewportLTCanvas.x - originViewportLTCanvas.x,
|
|
1822
|
+
currentViewportLTCanvas.y - originViewportLTCanvas.y,
|
|
1823
|
+
]);
|
|
1824
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
1825
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
1826
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
1827
|
+
childGroup.children.forEach((shape) => {
|
|
1828
|
+
if (shape.getAttribute('data-is-label-background') &&
|
|
1829
|
+
shape.style.transform)
|
|
1830
|
+
shape.remove();
|
|
1831
|
+
});
|
|
1832
|
+
});
|
|
1833
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1834
|
+
vCanvas.appendChild(clonedGroup);
|
|
1835
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
1836
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1837
|
+
const vCamera = vCanvas.getCamera();
|
|
1838
|
+
vCamera.setZoom(camera.getZoom());
|
|
1839
|
+
vCamera.setPosition(camera.getPosition());
|
|
1840
|
+
vCamera.setFocalPoint(camera.getFocalPoint());
|
|
1685
1841
|
const vCanvasContextService = vCanvas.getContextService();
|
|
1686
1842
|
let bgRect;
|
|
1687
1843
|
if (rendererType !== 'svg') {
|
|
1844
|
+
const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1688
1845
|
bgRect = new Rect({
|
|
1689
|
-
style: {
|
|
1690
|
-
x: 0,
|
|
1691
|
-
y: 0,
|
|
1692
|
-
z: -1,
|
|
1693
|
-
width: vCanvasContextService.getDomElement().width,
|
|
1694
|
-
height: vCanvasContextService.getDomElement().height,
|
|
1846
|
+
style: Object.assign(Object.assign({}, backPositionCanvas), { z: -1, width: vCanvasContextService.getDomElement().width, height: vCanvasContextService.getDomElement().height,
|
|
1695
1847
|
//@ts-ignore
|
|
1696
|
-
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1697
|
-
},
|
|
1848
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'], zIndex: -10 }),
|
|
1698
1849
|
});
|
|
1699
1850
|
vCanvas.appendChild(bgRect);
|
|
1700
1851
|
}
|
|
1701
|
-
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1702
|
-
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1703
|
-
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1704
|
-
vCanvas.appendChild(backgroundClonedGroup);
|
|
1705
|
-
vCanvas.appendChild(clonedGroup);
|
|
1706
|
-
vCanvas.appendChild(transientClonedGroup);
|
|
1707
|
-
vCanvas.render();
|
|
1708
1852
|
if (!type)
|
|
1709
1853
|
type = 'image/png';
|
|
1710
1854
|
let dataURL = '';
|
|
1711
|
-
|
|
1712
|
-
|
|
1855
|
+
return new Promise((resolve) => {
|
|
1856
|
+
setTimeout(() => {
|
|
1857
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1858
|
+
dataURL = url;
|
|
1859
|
+
resolve(dataURL);
|
|
1860
|
+
});
|
|
1861
|
+
}, 50);
|
|
1713
1862
|
});
|
|
1714
|
-
return dataURL;
|
|
1715
1863
|
});
|
|
1716
1864
|
}
|
|
1717
1865
|
/**
|
|
@@ -1723,16 +1871,15 @@ export class Graph extends EventEmitter {
|
|
|
1723
1871
|
*/
|
|
1724
1872
|
toFullDataURL(type, imageConfig) {
|
|
1725
1873
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1726
|
-
const backgroundCanvas = this
|
|
1727
|
-
const
|
|
1728
|
-
const transientCanvas = this.transientCanvas;
|
|
1729
|
-
const backgroundRoot = canvas.getRoot();
|
|
1874
|
+
const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
|
|
1875
|
+
const backgroundRoot = backgroundCanvas.getRoot();
|
|
1730
1876
|
const root = canvas.getRoot();
|
|
1731
1877
|
const transientRoot = transientCanvas.getRoot();
|
|
1732
|
-
const
|
|
1733
|
-
const backgroundBBox = backgroundRoot.
|
|
1734
|
-
const BBox = root.
|
|
1735
|
-
const transientBBox = transientRoot.
|
|
1878
|
+
const labelRoot = labelCanvas.getRoot();
|
|
1879
|
+
const backgroundBBox = backgroundRoot.getRenderBounds();
|
|
1880
|
+
const BBox = root.getRenderBounds();
|
|
1881
|
+
const transientBBox = transientRoot.getRenderBounds();
|
|
1882
|
+
const labelBBox = labelRoot.getRenderBounds();
|
|
1736
1883
|
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
1737
1884
|
if (!padding) {
|
|
1738
1885
|
padding = [0, 0, 0, 0];
|
|
@@ -1740,26 +1887,10 @@ export class Graph extends EventEmitter {
|
|
|
1740
1887
|
else if (isNumber(padding)) {
|
|
1741
1888
|
padding = [padding, padding, padding, padding];
|
|
1742
1889
|
}
|
|
1743
|
-
const left = (transientBBox.
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
: BBox.left) - padding[3];
|
|
1748
|
-
const right = (transientBBox.right
|
|
1749
|
-
? backgroundBBox.right
|
|
1750
|
-
? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
|
|
1751
|
-
: Math.max(BBox.right, transientBBox.right)
|
|
1752
|
-
: BBox.right) + padding[1];
|
|
1753
|
-
const top = (transientBBox.top
|
|
1754
|
-
? backgroundBBox.top
|
|
1755
|
-
? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
|
|
1756
|
-
: Math.min(BBox.top, transientBBox.top)
|
|
1757
|
-
: BBox.top) - padding[0];
|
|
1758
|
-
const bottom = (transientBBox.bottom
|
|
1759
|
-
? backgroundBBox.bottom
|
|
1760
|
-
? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
|
|
1761
|
-
: Math.max(BBox.bottom, transientBBox.bottom)
|
|
1762
|
-
: BBox.bottom) + padding[2];
|
|
1890
|
+
const left = Math.min(backgroundBBox.min[0] || Infinity, BBox.min[0] || Infinity, transientBBox.min[0] || Infinity, labelBBox.min[0] || Infinity) - padding[3];
|
|
1891
|
+
const right = Math.max(backgroundBBox.max[0] || -Infinity, BBox.max[0] || -Infinity, transientBBox.max[0] || -Infinity, labelBBox.max[0] || -Infinity) - padding[1];
|
|
1892
|
+
const top = Math.min(backgroundBBox.min[1] || Infinity, BBox.min[1] || Infinity, transientBBox.min[1] || Infinity, labelBBox.min[1] || Infinity) - padding[0];
|
|
1893
|
+
const bottom = Math.max(backgroundBBox.max[1] || -Infinity, BBox.max[1] || -Infinity, transientBBox.max[1] || -Infinity, labelBBox.max[1] || -Infinity) - padding[2];
|
|
1763
1894
|
const graphCenterX = (left + right) / 2;
|
|
1764
1895
|
const graphCenterY = (top + bottom) / 2;
|
|
1765
1896
|
const halfX = (right - left) / 2;
|
|
@@ -1769,6 +1900,7 @@ export class Graph extends EventEmitter {
|
|
|
1769
1900
|
const vHeight = halfY * 2;
|
|
1770
1901
|
const vContainerDOM = createDOM('<div id="virtual-image"></div>');
|
|
1771
1902
|
const vCanvas = createCanvas(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
|
|
1903
|
+
yield vCanvas.ready;
|
|
1772
1904
|
const vCanvasContextService = vCanvas.getContextService();
|
|
1773
1905
|
if (rendererType !== 'svg') {
|
|
1774
1906
|
const bgRect = new Rect({
|
|
@@ -1787,6 +1919,7 @@ export class Graph extends EventEmitter {
|
|
|
1787
1919
|
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
1788
1920
|
const clonedGroup = root.cloneNode(true);
|
|
1789
1921
|
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
1922
|
+
const labelClonedGroup = labelRoot.cloneNode(true);
|
|
1790
1923
|
const transPosition = [
|
|
1791
1924
|
-graphCenterX + halfX,
|
|
1792
1925
|
-graphCenterY + halfY,
|
|
@@ -1794,17 +1927,36 @@ export class Graph extends EventEmitter {
|
|
|
1794
1927
|
backgroundClonedGroup.setPosition(transPosition);
|
|
1795
1928
|
clonedGroup.setPosition(transPosition);
|
|
1796
1929
|
transientClonedGroup.setPosition(transPosition);
|
|
1930
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1931
|
+
const labelTransPosition = [
|
|
1932
|
+
transPosition[0] + currentViewportLTCanvas.x,
|
|
1933
|
+
transPosition[1] + currentViewportLTCanvas.y,
|
|
1934
|
+
];
|
|
1935
|
+
labelClonedGroup.setPosition(labelTransPosition);
|
|
1936
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
1937
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
1938
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
1939
|
+
childGroup.children.forEach((shape) => {
|
|
1940
|
+
if (shape.getAttribute('data-is-label-background') &&
|
|
1941
|
+
shape.style.transform)
|
|
1942
|
+
shape.remove();
|
|
1943
|
+
});
|
|
1944
|
+
});
|
|
1797
1945
|
vCanvas.appendChild(backgroundClonedGroup);
|
|
1798
1946
|
vCanvas.appendChild(clonedGroup);
|
|
1947
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
1799
1948
|
vCanvas.appendChild(transientClonedGroup);
|
|
1800
|
-
vCanvas.render();
|
|
1801
1949
|
if (!type)
|
|
1802
1950
|
type = 'image/png';
|
|
1803
1951
|
let dataURL = '';
|
|
1804
|
-
|
|
1805
|
-
|
|
1952
|
+
return new Promise((resolve) => {
|
|
1953
|
+
setTimeout(() => {
|
|
1954
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1955
|
+
dataURL = url;
|
|
1956
|
+
resolve(dataURL);
|
|
1957
|
+
});
|
|
1958
|
+
}, 50);
|
|
1806
1959
|
});
|
|
1807
|
-
return dataURL;
|
|
1808
1960
|
});
|
|
1809
1961
|
}
|
|
1810
1962
|
/**
|
|
@@ -2066,7 +2218,7 @@ export class Graph extends EventEmitter {
|
|
|
2066
2218
|
* @returns
|
|
2067
2219
|
* @group Tree
|
|
2068
2220
|
*/
|
|
2069
|
-
collapse(ids, disableAnimate = false
|
|
2221
|
+
collapse(ids, disableAnimate = false) {
|
|
2070
2222
|
this.hooks.treecollapseexpand.emit({
|
|
2071
2223
|
ids: isArray(ids) ? ids : [ids],
|
|
2072
2224
|
action: 'collapse',
|
|
@@ -2082,7 +2234,7 @@ export class Graph extends EventEmitter {
|
|
|
2082
2234
|
* @returns
|
|
2083
2235
|
* @group Tree
|
|
2084
2236
|
*/
|
|
2085
|
-
expand(ids, disableAnimate = false
|
|
2237
|
+
expand(ids, disableAnimate = false) {
|
|
2086
2238
|
this.hooks.treecollapseexpand.emit({
|
|
2087
2239
|
ids: isArray(ids) ? ids : [ids],
|
|
2088
2240
|
action: 'expand',
|
|
@@ -2096,15 +2248,23 @@ export class Graph extends EventEmitter {
|
|
|
2096
2248
|
* @group Graph Instance
|
|
2097
2249
|
*/
|
|
2098
2250
|
destroy(callback) {
|
|
2099
|
-
|
|
2100
|
-
|
|
2251
|
+
var _a;
|
|
2252
|
+
const camera = this.canvas.getCamera();
|
|
2253
|
+
const transientCamera = this.transientCanvas.getCamera();
|
|
2254
|
+
// @ts-ignore
|
|
2255
|
+
if ((_a = camera.landmarks) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2256
|
+
camera.cancelLandmarkAnimation();
|
|
2257
|
+
transientCamera.cancelLandmarkAnimation();
|
|
2258
|
+
this.emit('cancelviewportanimation');
|
|
2259
|
+
}
|
|
2101
2260
|
this.canvas.destroy();
|
|
2261
|
+
this.labelCanvas.destroy();
|
|
2102
2262
|
this.backgroundCanvas.destroy();
|
|
2103
2263
|
this.transientCanvas.destroy();
|
|
2264
|
+
this.transientLabelCanvas.destroy();
|
|
2104
2265
|
// clear history stack
|
|
2105
2266
|
this.cleanHistory();
|
|
2106
2267
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
2107
|
-
// }, 500);
|
|
2108
2268
|
this.hooks.destroy.emit({});
|
|
2109
2269
|
// TODO: destroy controllers and off the listeners
|
|
2110
2270
|
// this.dataController.destroy();
|
|
@@ -2112,7 +2272,6 @@ export class Graph extends EventEmitter {
|
|
|
2112
2272
|
// this.layoutController.destroy();
|
|
2113
2273
|
// this.themeController.destroy();
|
|
2114
2274
|
// this.itemController.destroy();
|
|
2115
|
-
// this.extensionController.destroy();
|
|
2116
2275
|
this.destroyed = true;
|
|
2117
2276
|
}
|
|
2118
2277
|
}
|