@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/lib/runtime/graph.js
CHANGED
|
@@ -31,13 +31,15 @@ const canvas_1 = require("../util/canvas");
|
|
|
31
31
|
const dom_1 = require("../util/dom");
|
|
32
32
|
const layout_1 = require("../util/layout");
|
|
33
33
|
const shape_1 = require("../util/shape");
|
|
34
|
+
const data_1 = require("../util/data");
|
|
35
|
+
const bbox_1 = require("../util/bbox");
|
|
34
36
|
const controller_1 = require("./controller");
|
|
35
|
-
const plugin_1 = require("./controller/plugin");
|
|
36
37
|
const hooks_1 = __importDefault(require("./hooks"));
|
|
37
|
-
const data_1 = require("../util/data");
|
|
38
38
|
class Graph extends event_emitter_1.default {
|
|
39
39
|
constructor(spec) {
|
|
40
40
|
super();
|
|
41
|
+
// the tag to indicate whether the graph instance is destroyed
|
|
42
|
+
this.destroyed = false;
|
|
41
43
|
this.defaultSpecification = {
|
|
42
44
|
theme: {
|
|
43
45
|
type: 'spec',
|
|
@@ -68,7 +70,9 @@ class Graph extends event_emitter_1.default {
|
|
|
68
70
|
canvases: {
|
|
69
71
|
background: this.backgroundCanvas,
|
|
70
72
|
main: this.canvas,
|
|
73
|
+
label: this.labelCanvas,
|
|
71
74
|
transient: this.transientCanvas,
|
|
75
|
+
transientLabel: this.transientLabelCanvas,
|
|
72
76
|
},
|
|
73
77
|
});
|
|
74
78
|
const { data } = spec;
|
|
@@ -85,13 +89,12 @@ class Graph extends event_emitter_1.default {
|
|
|
85
89
|
this.interactionController = new controller_1.InteractionController(this);
|
|
86
90
|
this.layoutController = new controller_1.LayoutController(this);
|
|
87
91
|
this.themeController = new controller_1.ThemeController(this);
|
|
88
|
-
this.itemController = new controller_1.ItemController(this);
|
|
89
92
|
this.viewportController = new controller_1.ViewportController(this);
|
|
90
|
-
this.
|
|
91
|
-
this.pluginController = new
|
|
93
|
+
this.itemController = new controller_1.ItemController(this);
|
|
94
|
+
this.pluginController = new controller_1.PluginController(this);
|
|
92
95
|
}
|
|
93
96
|
initCanvas() {
|
|
94
|
-
const { renderer, container,
|
|
97
|
+
const { renderer, container, width, height } = this.specification;
|
|
95
98
|
let pixelRatio;
|
|
96
99
|
if (renderer && !(0, util_1.isString)(renderer)) {
|
|
97
100
|
// @ts-ignore
|
|
@@ -103,13 +106,7 @@ class Graph extends event_emitter_1.default {
|
|
|
103
106
|
// @ts-ignore
|
|
104
107
|
this.rendererType = renderer || 'canvas';
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
* These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
|
|
108
|
-
*/
|
|
109
|
-
if (canvas) {
|
|
110
|
-
this.canvas = canvas;
|
|
111
|
-
this.backgroundCanvas = backgroundCanvas;
|
|
112
|
-
this.transientCanvas = transientCanvas;
|
|
109
|
+
if (container) {
|
|
113
110
|
this.container = container;
|
|
114
111
|
}
|
|
115
112
|
else {
|
|
@@ -122,19 +119,36 @@ class Graph extends event_emitter_1.default {
|
|
|
122
119
|
return;
|
|
123
120
|
}
|
|
124
121
|
this.container = containerDOM;
|
|
125
|
-
const size = [width, height];
|
|
126
|
-
if (size[0] === undefined) {
|
|
127
|
-
size[0] = containerDOM.scrollWidth;
|
|
128
|
-
}
|
|
129
|
-
if (size[1] === undefined) {
|
|
130
|
-
size[1] = containerDOM.scrollHeight;
|
|
131
|
-
}
|
|
132
|
-
this.backgroundCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
133
|
-
this.canvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
134
|
-
this.transientCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
135
122
|
}
|
|
136
|
-
|
|
137
|
-
|
|
123
|
+
[
|
|
124
|
+
'backgroundCanvas',
|
|
125
|
+
'canvas',
|
|
126
|
+
'labelCanvas',
|
|
127
|
+
'transientCanvas',
|
|
128
|
+
'transientLabelCanvas',
|
|
129
|
+
].forEach((name) => {
|
|
130
|
+
this[name] =
|
|
131
|
+
this.specification[name] ||
|
|
132
|
+
(0, canvas_1.createCanvas)(['labelCanvas', 'transientLabelCanvas'].includes(name)
|
|
133
|
+
? 'canvas'
|
|
134
|
+
: this.rendererType, this.container, width !== null && width !== void 0 ? width : this.container.scrollWidth, height !== null && height !== void 0 ? height : this.container.scrollHeight, pixelRatio, undefined,
|
|
135
|
+
// enable dom interaction only for main canvas
|
|
136
|
+
name === 'canvas' ? [] : ['dom-interaction']);
|
|
137
|
+
});
|
|
138
|
+
Promise.all([
|
|
139
|
+
this.backgroundCanvas,
|
|
140
|
+
this.canvas,
|
|
141
|
+
this.labelCanvas,
|
|
142
|
+
this.transientCanvas,
|
|
143
|
+
this.transientLabelCanvas,
|
|
144
|
+
].map((canvas) => canvas.ready)).then(() => {
|
|
145
|
+
[
|
|
146
|
+
this.backgroundCanvas,
|
|
147
|
+
this.canvas,
|
|
148
|
+
this.labelCanvas,
|
|
149
|
+
this.transientCanvas,
|
|
150
|
+
this.transientLabelCanvas,
|
|
151
|
+
].forEach((canvas, i) => {
|
|
138
152
|
const $domElement = canvas
|
|
139
153
|
.getContextService()
|
|
140
154
|
.getDomElement();
|
|
@@ -196,6 +210,9 @@ class Graph extends event_emitter_1.default {
|
|
|
196
210
|
itemstatechange: new hooks_1.default({
|
|
197
211
|
name: 'itemstatechange',
|
|
198
212
|
}),
|
|
213
|
+
itemstateconfigchange: new hooks_1.default({
|
|
214
|
+
name: 'itemstateconfigchange',
|
|
215
|
+
}),
|
|
199
216
|
itemvisibilitychange: new hooks_1.default({
|
|
200
217
|
name: 'itemvisibilitychange',
|
|
201
218
|
}),
|
|
@@ -218,8 +235,22 @@ class Graph extends event_emitter_1.default {
|
|
|
218
235
|
* Update the specs(configurations).
|
|
219
236
|
*/
|
|
220
237
|
updateSpecification(spec) {
|
|
221
|
-
const
|
|
222
|
-
|
|
238
|
+
const { node, edge, combo, theme, nodeState, edgeState, comboState } = spec, others = __rest(spec, ["node", "edge", "combo", "theme", "nodeState", "edgeState", "comboState"]);
|
|
239
|
+
if (node)
|
|
240
|
+
this.updateMapper('node', node);
|
|
241
|
+
if (edge)
|
|
242
|
+
this.updateMapper('edge', edge);
|
|
243
|
+
if (combo)
|
|
244
|
+
this.updateMapper('combo', combo);
|
|
245
|
+
if (theme)
|
|
246
|
+
this.updateTheme(theme);
|
|
247
|
+
if (nodeState)
|
|
248
|
+
this.updateStateConfig('node', nodeState, 'replace');
|
|
249
|
+
if (edgeState)
|
|
250
|
+
this.updateStateConfig('edge', edgeState, 'replace');
|
|
251
|
+
if (comboState)
|
|
252
|
+
this.updateStateConfig('combo', comboState, 'replace');
|
|
253
|
+
const newSpec = Object.assign(this.specification, this.formatSpecification(others));
|
|
223
254
|
return newSpec;
|
|
224
255
|
}
|
|
225
256
|
/**
|
|
@@ -263,6 +294,26 @@ class Graph extends event_emitter_1.default {
|
|
|
263
294
|
mapper,
|
|
264
295
|
});
|
|
265
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
|
|
299
|
+
* @param {string} itemType - The type of item (node, edge, or combo).
|
|
300
|
+
* @param {object} stateConfig - The state configuration to update.
|
|
301
|
+
* @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
|
|
302
|
+
**/
|
|
303
|
+
updateStateConfig(itemType, stateConfig, updateType = 'mergeReplace') {
|
|
304
|
+
if ((0, util_1.isEmpty)(stateConfig))
|
|
305
|
+
return;
|
|
306
|
+
const stateField = `${itemType}State`;
|
|
307
|
+
if (updateType === 'mergeReplace') {
|
|
308
|
+
const config = Object.assign(Object.assign({}, this.specification[stateField]), stateConfig);
|
|
309
|
+
this.specification[itemType] = config;
|
|
310
|
+
this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
this.specification[itemType] = stateConfig;
|
|
314
|
+
this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
266
317
|
/**
|
|
267
318
|
* Get the copy of specs(configurations).
|
|
268
319
|
* @returns graph specs
|
|
@@ -286,6 +337,7 @@ class Graph extends event_emitter_1.default {
|
|
|
286
337
|
graphCore: this.dataController.graphCore,
|
|
287
338
|
theme: this.themeController.specification,
|
|
288
339
|
transientCanvas: this.transientCanvas,
|
|
340
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
289
341
|
tileOptimize: {
|
|
290
342
|
tileFirstRender,
|
|
291
343
|
tileFirstRenderSize,
|
|
@@ -326,7 +378,13 @@ class Graph extends event_emitter_1.default {
|
|
|
326
378
|
yield emitRender();
|
|
327
379
|
}
|
|
328
380
|
else {
|
|
329
|
-
yield Promise.all([
|
|
381
|
+
yield Promise.all([
|
|
382
|
+
this.backgroundCanvas,
|
|
383
|
+
this.canvas,
|
|
384
|
+
this.labelCanvas,
|
|
385
|
+
this.transientCanvas,
|
|
386
|
+
this.transientLabelCanvas,
|
|
387
|
+
].map((canvas) => canvas.ready));
|
|
330
388
|
yield emitRender();
|
|
331
389
|
}
|
|
332
390
|
});
|
|
@@ -335,10 +393,11 @@ class Graph extends event_emitter_1.default {
|
|
|
335
393
|
* Change graph data.
|
|
336
394
|
* @param data new data
|
|
337
395
|
* @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)
|
|
396
|
+
* @param relayout whether relayout the nodes after data changing
|
|
338
397
|
* @returns
|
|
339
398
|
* @group Data
|
|
340
399
|
*/
|
|
341
|
-
changeData(data, type = 'mergeReplace') {
|
|
400
|
+
changeData(data, type = 'mergeReplace', relayout = true) {
|
|
342
401
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
402
|
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
344
403
|
this.hooks.datachange.emit({ data, type });
|
|
@@ -346,13 +405,16 @@ class Graph extends event_emitter_1.default {
|
|
|
346
405
|
graphCore: this.dataController.graphCore,
|
|
347
406
|
theme: this.themeController.specification,
|
|
348
407
|
transientCanvas: this.transientCanvas,
|
|
408
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
349
409
|
tileOptimize: {
|
|
350
410
|
tileFirstRender,
|
|
351
411
|
tileFirstRenderSize,
|
|
352
412
|
},
|
|
353
413
|
});
|
|
354
414
|
this.emit('afterrender');
|
|
355
|
-
|
|
415
|
+
if (relayout) {
|
|
416
|
+
yield this.layout();
|
|
417
|
+
}
|
|
356
418
|
});
|
|
357
419
|
}
|
|
358
420
|
/**
|
|
@@ -505,8 +567,8 @@ class Graph extends event_emitter_1.default {
|
|
|
505
567
|
const { direction = 'both', ratioRule = 'min', boundsType = 'render', onlyOutOfViewport = false, onlyZoomAtLargerThanViewport = false, } = rules || {};
|
|
506
568
|
const { min, max, center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
|
|
507
569
|
? // Get the bounds of the whole graph content.
|
|
508
|
-
this.canvas.
|
|
509
|
-
: // Get the
|
|
570
|
+
(0, bbox_1.getCombinedCanvasesBounds)([this.canvas, this.labelCanvas])
|
|
571
|
+
: // Get the b ounds of the nodes positions while the graph content is not ready.
|
|
510
572
|
(0, layout_1.getLayoutBounds)(this);
|
|
511
573
|
const origin = this.canvas.canvas2Viewport({
|
|
512
574
|
x: graphCenterX,
|
|
@@ -566,7 +628,7 @@ class Graph extends event_emitter_1.default {
|
|
|
566
628
|
return __awaiter(this, void 0, void 0, function* () {
|
|
567
629
|
const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
|
|
568
630
|
? // Get the bounds of the whole graph content.
|
|
569
|
-
this.canvas.
|
|
631
|
+
(0, bbox_1.getCombinedCanvasesBounds)([this.canvas, this.labelCanvas])
|
|
570
632
|
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
571
633
|
(0, layout_1.getLayoutBounds)(this);
|
|
572
634
|
yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
|
|
@@ -629,9 +691,15 @@ class Graph extends event_emitter_1.default {
|
|
|
629
691
|
this.emit('beforesetsize', { oldSize, size: size });
|
|
630
692
|
this.specification.width = size[0];
|
|
631
693
|
this.specification.height = size[1];
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
694
|
+
[
|
|
695
|
+
this.canvas,
|
|
696
|
+
this.labelCanvas,
|
|
697
|
+
this.transientCanvas,
|
|
698
|
+
this.transientLabelCanvas,
|
|
699
|
+
this.backgroundCanvas,
|
|
700
|
+
].forEach((canvas) => {
|
|
701
|
+
canvas.resize(size[0], size[1]);
|
|
702
|
+
});
|
|
635
703
|
this.emit('aftersetsize', { oldSize, size: size });
|
|
636
704
|
}
|
|
637
705
|
getCanvasRange() {
|
|
@@ -760,6 +828,16 @@ class Graph extends event_emitter_1.default {
|
|
|
760
828
|
getRelatedEdgesData(nodeId, direction = 'both') {
|
|
761
829
|
return this.dataController.findRelatedEdges(nodeId, direction);
|
|
762
830
|
}
|
|
831
|
+
/**
|
|
832
|
+
* Get nearby edges from a start node using quad-tree collision detection.
|
|
833
|
+
* @param nodeId id of the start node
|
|
834
|
+
* @returns nearby edges' data array
|
|
835
|
+
*/
|
|
836
|
+
getNearEdgesData(nodeId, shouldBegin) {
|
|
837
|
+
const transientItem = this.itemController.getTransientItem(nodeId);
|
|
838
|
+
const itemMap = this.itemController.getItemMap();
|
|
839
|
+
return this.dataController.findNearEdges(nodeId, itemMap, transientItem, shouldBegin);
|
|
840
|
+
}
|
|
763
841
|
/**
|
|
764
842
|
* Get one-hop node ids from a start node.
|
|
765
843
|
* @param nodeId id of the start node
|
|
@@ -797,15 +875,6 @@ class Graph extends event_emitter_1.default {
|
|
|
797
875
|
getDisplayModel(id) {
|
|
798
876
|
return this.itemController.findDisplayModel(id);
|
|
799
877
|
}
|
|
800
|
-
/**
|
|
801
|
-
* Retrieve the nearby edges for a given node using quadtree collision detection.
|
|
802
|
-
* @param nodeId node id
|
|
803
|
-
* @group Data
|
|
804
|
-
*/
|
|
805
|
-
getNearEdgesForNode(nodeId) {
|
|
806
|
-
const { graphCore } = this.dataController;
|
|
807
|
-
return this.itemController.findNearEdgesByNode(nodeId, graphCore);
|
|
808
|
-
}
|
|
809
878
|
/**
|
|
810
879
|
* Find items which has the state.
|
|
811
880
|
* @param itemType item type
|
|
@@ -837,6 +906,7 @@ class Graph extends event_emitter_1.default {
|
|
|
837
906
|
// data controller and item controller subscribe additem in order
|
|
838
907
|
const { graphCore } = this.dataController;
|
|
839
908
|
const { specification } = this.themeController;
|
|
909
|
+
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
840
910
|
graphCore.once('changed', (event) => {
|
|
841
911
|
if (!event.changes.length)
|
|
842
912
|
return;
|
|
@@ -844,7 +914,7 @@ class Graph extends event_emitter_1.default {
|
|
|
844
914
|
const timingParameters = {
|
|
845
915
|
type: itemType,
|
|
846
916
|
action: 'add',
|
|
847
|
-
models,
|
|
917
|
+
models: modelArr,
|
|
848
918
|
apiName: 'addData',
|
|
849
919
|
changes,
|
|
850
920
|
};
|
|
@@ -857,7 +927,6 @@ class Graph extends event_emitter_1.default {
|
|
|
857
927
|
});
|
|
858
928
|
this.emit('afteritemchange', timingParameters);
|
|
859
929
|
});
|
|
860
|
-
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
861
930
|
const data = { nodes: [], edges: [], combos: [] };
|
|
862
931
|
data[`${itemType}s`] = modelArr;
|
|
863
932
|
this.hooks.datachange.emit({
|
|
@@ -869,7 +938,8 @@ class Graph extends event_emitter_1.default {
|
|
|
869
938
|
}
|
|
870
939
|
/**
|
|
871
940
|
* Remove one or more node/edge/combo data from the graph.
|
|
872
|
-
* @param
|
|
941
|
+
* @param itemType the type the item(s) to be removed.
|
|
942
|
+
* @param id the id or the ids' array of the items to be removed.
|
|
873
943
|
* @returns whether success
|
|
874
944
|
* @group Data
|
|
875
945
|
*/
|
|
@@ -963,8 +1033,8 @@ class Graph extends event_emitter_1.default {
|
|
|
963
1033
|
}
|
|
964
1034
|
/**
|
|
965
1035
|
* Update one or more node/edge/combo data on the graph.
|
|
966
|
-
* @param {ITEM_TYPE} itemType
|
|
967
|
-
* @param models
|
|
1036
|
+
* @param {ITEM_TYPE} itemType the type the item(s) to be udated.
|
|
1037
|
+
* @param models update configs.
|
|
968
1038
|
* @group Data
|
|
969
1039
|
*/
|
|
970
1040
|
updateData(itemType, models) {
|
|
@@ -974,11 +1044,11 @@ class Graph extends event_emitter_1.default {
|
|
|
974
1044
|
const { graphCore } = this.dataController;
|
|
975
1045
|
const { specification } = this.themeController;
|
|
976
1046
|
graphCore.once('changed', (event) => {
|
|
977
|
-
const changes = this.extendChanges((0,
|
|
1047
|
+
const changes = this.extendChanges((0, data_1.cloneJSON)(event.changes));
|
|
978
1048
|
const timingParameters = {
|
|
979
1049
|
type: itemType,
|
|
980
1050
|
action: 'update',
|
|
981
|
-
models,
|
|
1051
|
+
models: modelArr,
|
|
982
1052
|
apiName: 'updateData',
|
|
983
1053
|
changes,
|
|
984
1054
|
};
|
|
@@ -1001,21 +1071,27 @@ class Graph extends event_emitter_1.default {
|
|
|
1001
1071
|
/**
|
|
1002
1072
|
* Update one or more nodes' positions,
|
|
1003
1073
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1004
|
-
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
1074
|
+
* @param models new configurations with x and y for every node, which has id field to indicate the specific item.
|
|
1075
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1076
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1077
|
+
* @param callback callback function after update nodes done.
|
|
1005
1078
|
* @group Data
|
|
1006
1079
|
*/
|
|
1007
|
-
updateNodePosition(models, upsertAncestors, disableAnimate = false, callback
|
|
1008
|
-
return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback
|
|
1080
|
+
updateNodePosition(models, upsertAncestors, disableAnimate = false, callback) {
|
|
1081
|
+
return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback);
|
|
1009
1082
|
}
|
|
1010
1083
|
/**
|
|
1011
1084
|
* Update one or more combos' positions,
|
|
1012
1085
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1013
1086
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1014
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1087
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1088
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1089
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1090
|
+
* @param callback callback function after update combos done.
|
|
1015
1091
|
* @group Data
|
|
1016
1092
|
*/
|
|
1017
|
-
updateComboPosition(models, upsertAncestors, disableAnimate = false, callback
|
|
1018
|
-
return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback
|
|
1093
|
+
updateComboPosition(models, upsertAncestors, disableAnimate = false, callback) {
|
|
1094
|
+
return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback);
|
|
1019
1095
|
}
|
|
1020
1096
|
/**
|
|
1021
1097
|
* Get history plugin instance
|
|
@@ -1028,7 +1104,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1028
1104
|
}
|
|
1029
1105
|
return this.pluginController.getPlugin('history');
|
|
1030
1106
|
}
|
|
1031
|
-
updatePosition(type, models, upsertAncestors, disableAnimate = false, callback
|
|
1107
|
+
updatePosition(type, models, upsertAncestors, disableAnimate = false, callback) {
|
|
1032
1108
|
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
1033
1109
|
const { graphCore } = this.dataController;
|
|
1034
1110
|
const { specification } = this.themeController;
|
|
@@ -1040,7 +1116,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1040
1116
|
type,
|
|
1041
1117
|
action: 'updatePosition',
|
|
1042
1118
|
upsertAncestors,
|
|
1043
|
-
models,
|
|
1119
|
+
models: modelArr,
|
|
1044
1120
|
apiName: 'updatePosition',
|
|
1045
1121
|
changes,
|
|
1046
1122
|
};
|
|
@@ -1063,7 +1139,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1063
1139
|
edges: [],
|
|
1064
1140
|
combos: type === 'combo' ? modelArr : [],
|
|
1065
1141
|
},
|
|
1066
|
-
type: '
|
|
1142
|
+
type: 'updatePosition',
|
|
1067
1143
|
});
|
|
1068
1144
|
const dataList = this.dataController.findData(type, modelArr.map((model) => model.id));
|
|
1069
1145
|
return (0, util_1.isArray)(models) ? dataList : dataList[0];
|
|
@@ -1086,22 +1162,40 @@ class Graph extends event_emitter_1.default {
|
|
|
1086
1162
|
* @returns
|
|
1087
1163
|
* @group Item
|
|
1088
1164
|
*/
|
|
1089
|
-
showItem(ids,
|
|
1165
|
+
showItem(ids, options) {
|
|
1166
|
+
const { disableAnimate = false, shapeIds } = options || {};
|
|
1090
1167
|
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
1091
1168
|
if ((0, util_1.isEmpty)(idArr))
|
|
1092
1169
|
return;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1170
|
+
let changes;
|
|
1171
|
+
if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
|
|
1172
|
+
const shapeIdsArr = (0, util_1.isArray)(shapeIds) ? shapeIds : [shapeIds];
|
|
1173
|
+
changes = {
|
|
1174
|
+
newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
|
|
1175
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1176
|
+
};
|
|
1177
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1178
|
+
ids: idArr,
|
|
1179
|
+
value: true,
|
|
1180
|
+
graphCore: this.dataController.graphCore,
|
|
1181
|
+
animate: !disableAnimate,
|
|
1182
|
+
shapeIds: shapeIdsArr,
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
changes = {
|
|
1187
|
+
newValue: [{ ids: idArr, visible: true }],
|
|
1188
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1189
|
+
};
|
|
1190
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1191
|
+
ids: idArr,
|
|
1192
|
+
value: true,
|
|
1193
|
+
graphCore: this.dataController.graphCore,
|
|
1194
|
+
animate: !disableAnimate,
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1103
1197
|
this.emit('afteritemvisibilitychange', {
|
|
1104
|
-
ids,
|
|
1198
|
+
ids: idArr,
|
|
1105
1199
|
value: true,
|
|
1106
1200
|
animate: !disableAnimate,
|
|
1107
1201
|
action: 'updateVisibility',
|
|
@@ -1111,27 +1205,49 @@ class Graph extends event_emitter_1.default {
|
|
|
1111
1205
|
}
|
|
1112
1206
|
/**
|
|
1113
1207
|
* Hide the item(s).
|
|
1114
|
-
* @param
|
|
1208
|
+
* @param id the id for the item to be hidden.
|
|
1209
|
+
* @param disableAnimate whether disable the hidden animations.
|
|
1210
|
+
* @param keepKeyShape whether keep the keyShape.
|
|
1211
|
+
* @param keepRelated whether keep the related nodes for edge.
|
|
1115
1212
|
* @returns
|
|
1116
1213
|
* @group Item
|
|
1117
1214
|
*/
|
|
1118
|
-
hideItem(ids,
|
|
1215
|
+
hideItem(ids, options) {
|
|
1216
|
+
const { disableAnimate = false, keepKeyShape = false, keepRelated = false, shapeIds, } = options || {};
|
|
1119
1217
|
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
1120
1218
|
if ((0, util_1.isEmpty)(idArr))
|
|
1121
1219
|
return;
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1220
|
+
let changes;
|
|
1221
|
+
if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
|
|
1222
|
+
const shapeIdsArr = (0, util_1.isArray)(shapeIds) ? shapeIds : [shapeIds];
|
|
1223
|
+
changes = {
|
|
1224
|
+
newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
|
|
1225
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1226
|
+
};
|
|
1227
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1228
|
+
ids: idArr,
|
|
1229
|
+
value: false,
|
|
1230
|
+
graphCore: this.dataController.graphCore,
|
|
1231
|
+
animate: !disableAnimate,
|
|
1232
|
+
shapeIds: shapeIdsArr,
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
else {
|
|
1236
|
+
changes = {
|
|
1237
|
+
newValue: [{ ids: idArr, visible: false }],
|
|
1238
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1239
|
+
};
|
|
1240
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1241
|
+
ids: idArr,
|
|
1242
|
+
value: false,
|
|
1243
|
+
graphCore: this.dataController.graphCore,
|
|
1244
|
+
animate: !disableAnimate,
|
|
1245
|
+
keepKeyShape,
|
|
1246
|
+
keepRelated,
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1133
1249
|
this.emit('afteritemvisibilitychange', {
|
|
1134
|
-
ids,
|
|
1250
|
+
ids: idArr,
|
|
1135
1251
|
value: false,
|
|
1136
1252
|
animate: !disableAnimate,
|
|
1137
1253
|
action: 'updateVisibility',
|
|
@@ -1292,11 +1408,20 @@ class Graph extends event_emitter_1.default {
|
|
|
1292
1408
|
getItemVisible(id) {
|
|
1293
1409
|
return this.itemController.getItemVisible(id);
|
|
1294
1410
|
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Get the visible shape ids in a node / edge / combo.
|
|
1413
|
+
* @param id the id for the node / edge / combo
|
|
1414
|
+
* @returns ids of the visible shapes
|
|
1415
|
+
*/
|
|
1416
|
+
getItemVisibleShapeIds(id) {
|
|
1417
|
+
return this.itemController.getItemVisibleShapeIds(id);
|
|
1418
|
+
}
|
|
1295
1419
|
// ===== combo operations =====
|
|
1296
1420
|
/**
|
|
1297
1421
|
* 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.
|
|
1298
|
-
* Different from addData with combo type, this API update the succeeds' combo tree
|
|
1299
|
-
* @param model combo user data
|
|
1422
|
+
* Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
|
|
1423
|
+
* @param model combo user data.
|
|
1424
|
+
* @param childrenIds the ids of the children nodes / combos to move into the new combo.
|
|
1300
1425
|
* @returns whether success
|
|
1301
1426
|
* @group Combo
|
|
1302
1427
|
*/
|
|
@@ -1338,7 +1463,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1338
1463
|
}
|
|
1339
1464
|
/**
|
|
1340
1465
|
* Collapse a combo.
|
|
1341
|
-
* @param comboId combo ids
|
|
1466
|
+
* @param comboId combo id or ids' array.
|
|
1342
1467
|
* @group Combo
|
|
1343
1468
|
*/
|
|
1344
1469
|
collapseCombo(comboIds) {
|
|
@@ -1355,7 +1480,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1355
1480
|
}
|
|
1356
1481
|
/**
|
|
1357
1482
|
* Expand a combo.
|
|
1358
|
-
* @param
|
|
1483
|
+
* @param comboId combo id or ids' array.
|
|
1359
1484
|
* @group Combo
|
|
1360
1485
|
*/
|
|
1361
1486
|
expandCombo(comboIds) {
|
|
@@ -1374,7 +1499,11 @@ class Graph extends event_emitter_1.default {
|
|
|
1374
1499
|
* Move one or more combos a distance (dx, dy) relatively,
|
|
1375
1500
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1376
1501
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1377
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1502
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1503
|
+
* @param dx the distance alone x-axis to move the combo.
|
|
1504
|
+
* @param dy the distance alone y-axis to move the combo.
|
|
1505
|
+
* @param upsertAncestors whether update the ancestors in the combo tree.
|
|
1506
|
+
* @param callback callback function after move combo done.
|
|
1378
1507
|
* @group Combo
|
|
1379
1508
|
*/
|
|
1380
1509
|
moveCombo(ids, dx, dy, upsertAncestors, callback) {
|
|
@@ -1496,7 +1625,9 @@ class Graph extends event_emitter_1.default {
|
|
|
1496
1625
|
*/
|
|
1497
1626
|
setCursor(cursor) {
|
|
1498
1627
|
this.canvas.setCursor(cursor);
|
|
1628
|
+
this.labelCanvas.setCursor(cursor);
|
|
1499
1629
|
this.transientCanvas.setCursor(cursor);
|
|
1630
|
+
this.transientLabelCanvas.setCursor(cursor);
|
|
1500
1631
|
}
|
|
1501
1632
|
/**
|
|
1502
1633
|
* Add behavior(s) to mode(s).
|
|
@@ -1628,10 +1759,9 @@ class Graph extends event_emitter_1.default {
|
|
|
1628
1759
|
*/
|
|
1629
1760
|
updatePlugin(plugin) {
|
|
1630
1761
|
const { plugins } = this.specification;
|
|
1631
|
-
const { key } = plugin;
|
|
1762
|
+
const { key, type } = plugin;
|
|
1632
1763
|
if (!key) {
|
|
1633
|
-
console.warn(
|
|
1634
|
-
return;
|
|
1764
|
+
console.warn(`The key for the plugin is not found. G6 will update the first plugin with type ${type}`);
|
|
1635
1765
|
}
|
|
1636
1766
|
if (!plugins) {
|
|
1637
1767
|
console.warn('Update plugin failed, the plugin to be updated does not exist.');
|
|
@@ -1639,11 +1769,12 @@ class Graph extends event_emitter_1.default {
|
|
|
1639
1769
|
}
|
|
1640
1770
|
const oldPlugin = plugins === null || plugins === void 0 ? void 0 : plugins.find((p) => {
|
|
1641
1771
|
if (typeof p === 'string')
|
|
1642
|
-
return p === key;
|
|
1643
|
-
return p.key === key
|
|
1772
|
+
return p === key || p === type;
|
|
1773
|
+
return (p.key === key ||
|
|
1774
|
+
p.type === type);
|
|
1644
1775
|
});
|
|
1645
1776
|
if (!oldPlugin) {
|
|
1646
|
-
console.warn(
|
|
1777
|
+
console.warn(`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`);
|
|
1647
1778
|
return;
|
|
1648
1779
|
}
|
|
1649
1780
|
const idx = plugins.indexOf(oldPlugin);
|
|
@@ -1656,7 +1787,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1656
1787
|
/**
|
|
1657
1788
|
* Draw or update a G shape or group to the transient canvas.
|
|
1658
1789
|
* @param type shape type or item type
|
|
1659
|
-
* @param id new shape id or updated shape id for a
|
|
1790
|
+
* @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
|
|
1660
1791
|
* @returns upserted shape or group
|
|
1661
1792
|
* @group Interaction
|
|
1662
1793
|
*/
|
|
@@ -1679,45 +1810,62 @@ class Graph extends event_emitter_1.default {
|
|
|
1679
1810
|
*/
|
|
1680
1811
|
toDataURL(type) {
|
|
1681
1812
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1682
|
-
const backgroundCanvas = this
|
|
1683
|
-
const canvas = this.canvas;
|
|
1684
|
-
const transientCanvas = this.transientCanvas;
|
|
1685
|
-
const rendererType = this.rendererType;
|
|
1813
|
+
const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
|
|
1686
1814
|
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1687
|
-
const width = this.getSize()
|
|
1688
|
-
const height = this.getSize()[1];
|
|
1815
|
+
const [width, height] = this.getSize();
|
|
1689
1816
|
const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
|
|
1817
|
+
const camera = canvas.getCamera();
|
|
1690
1818
|
const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, width, height, pixelRatio);
|
|
1819
|
+
yield vCanvas.ready;
|
|
1820
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1821
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1822
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1823
|
+
const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
|
|
1824
|
+
const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1825
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1826
|
+
labelClonedGroup.translate([
|
|
1827
|
+
currentViewportLTCanvas.x - originViewportLTCanvas.x,
|
|
1828
|
+
currentViewportLTCanvas.y - originViewportLTCanvas.y,
|
|
1829
|
+
]);
|
|
1830
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
1831
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
1832
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
1833
|
+
childGroup.children.forEach((shape) => {
|
|
1834
|
+
if (shape.getAttribute('data-is-label-background') &&
|
|
1835
|
+
shape.style.transform)
|
|
1836
|
+
shape.remove();
|
|
1837
|
+
});
|
|
1838
|
+
});
|
|
1839
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1840
|
+
vCanvas.appendChild(clonedGroup);
|
|
1841
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
1842
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1843
|
+
const vCamera = vCanvas.getCamera();
|
|
1844
|
+
vCamera.setZoom(camera.getZoom());
|
|
1845
|
+
vCamera.setPosition(camera.getPosition());
|
|
1846
|
+
vCamera.setFocalPoint(camera.getFocalPoint());
|
|
1691
1847
|
const vCanvasContextService = vCanvas.getContextService();
|
|
1692
1848
|
let bgRect;
|
|
1693
1849
|
if (rendererType !== 'svg') {
|
|
1850
|
+
const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1694
1851
|
bgRect = new g_1.Rect({
|
|
1695
|
-
style: {
|
|
1696
|
-
x: 0,
|
|
1697
|
-
y: 0,
|
|
1698
|
-
z: -1,
|
|
1699
|
-
width: vCanvasContextService.getDomElement().width,
|
|
1700
|
-
height: vCanvasContextService.getDomElement().height,
|
|
1852
|
+
style: Object.assign(Object.assign({}, backPositionCanvas), { z: -1, width: vCanvasContextService.getDomElement().width, height: vCanvasContextService.getDomElement().height,
|
|
1701
1853
|
//@ts-ignore
|
|
1702
|
-
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1703
|
-
},
|
|
1854
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'], zIndex: -10 }),
|
|
1704
1855
|
});
|
|
1705
1856
|
vCanvas.appendChild(bgRect);
|
|
1706
1857
|
}
|
|
1707
|
-
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1708
|
-
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1709
|
-
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1710
|
-
vCanvas.appendChild(backgroundClonedGroup);
|
|
1711
|
-
vCanvas.appendChild(clonedGroup);
|
|
1712
|
-
vCanvas.appendChild(transientClonedGroup);
|
|
1713
|
-
vCanvas.render();
|
|
1714
1858
|
if (!type)
|
|
1715
1859
|
type = 'image/png';
|
|
1716
1860
|
let dataURL = '';
|
|
1717
|
-
|
|
1718
|
-
|
|
1861
|
+
return new Promise((resolve) => {
|
|
1862
|
+
setTimeout(() => {
|
|
1863
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1864
|
+
dataURL = url;
|
|
1865
|
+
resolve(dataURL);
|
|
1866
|
+
});
|
|
1867
|
+
}, 50);
|
|
1719
1868
|
});
|
|
1720
|
-
return dataURL;
|
|
1721
1869
|
});
|
|
1722
1870
|
}
|
|
1723
1871
|
/**
|
|
@@ -1729,16 +1877,15 @@ class Graph extends event_emitter_1.default {
|
|
|
1729
1877
|
*/
|
|
1730
1878
|
toFullDataURL(type, imageConfig) {
|
|
1731
1879
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1732
|
-
const backgroundCanvas = this
|
|
1733
|
-
const
|
|
1734
|
-
const transientCanvas = this.transientCanvas;
|
|
1735
|
-
const backgroundRoot = canvas.getRoot();
|
|
1880
|
+
const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
|
|
1881
|
+
const backgroundRoot = backgroundCanvas.getRoot();
|
|
1736
1882
|
const root = canvas.getRoot();
|
|
1737
1883
|
const transientRoot = transientCanvas.getRoot();
|
|
1738
|
-
const
|
|
1739
|
-
const backgroundBBox = backgroundRoot.
|
|
1740
|
-
const BBox = root.
|
|
1741
|
-
const transientBBox = transientRoot.
|
|
1884
|
+
const labelRoot = labelCanvas.getRoot();
|
|
1885
|
+
const backgroundBBox = backgroundRoot.getRenderBounds();
|
|
1886
|
+
const BBox = root.getRenderBounds();
|
|
1887
|
+
const transientBBox = transientRoot.getRenderBounds();
|
|
1888
|
+
const labelBBox = labelRoot.getRenderBounds();
|
|
1742
1889
|
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
1743
1890
|
if (!padding) {
|
|
1744
1891
|
padding = [0, 0, 0, 0];
|
|
@@ -1746,26 +1893,10 @@ class Graph extends event_emitter_1.default {
|
|
|
1746
1893
|
else if ((0, util_1.isNumber)(padding)) {
|
|
1747
1894
|
padding = [padding, padding, padding, padding];
|
|
1748
1895
|
}
|
|
1749
|
-
const left = (transientBBox.
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
: BBox.left) - padding[3];
|
|
1754
|
-
const right = (transientBBox.right
|
|
1755
|
-
? backgroundBBox.right
|
|
1756
|
-
? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
|
|
1757
|
-
: Math.max(BBox.right, transientBBox.right)
|
|
1758
|
-
: BBox.right) + padding[1];
|
|
1759
|
-
const top = (transientBBox.top
|
|
1760
|
-
? backgroundBBox.top
|
|
1761
|
-
? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
|
|
1762
|
-
: Math.min(BBox.top, transientBBox.top)
|
|
1763
|
-
: BBox.top) - padding[0];
|
|
1764
|
-
const bottom = (transientBBox.bottom
|
|
1765
|
-
? backgroundBBox.bottom
|
|
1766
|
-
? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
|
|
1767
|
-
: Math.max(BBox.bottom, transientBBox.bottom)
|
|
1768
|
-
: BBox.bottom) + padding[2];
|
|
1896
|
+
const left = Math.min(backgroundBBox.min[0] || Infinity, BBox.min[0] || Infinity, transientBBox.min[0] || Infinity, labelBBox.min[0] || Infinity) - padding[3];
|
|
1897
|
+
const right = Math.max(backgroundBBox.max[0] || -Infinity, BBox.max[0] || -Infinity, transientBBox.max[0] || -Infinity, labelBBox.max[0] || -Infinity) - padding[1];
|
|
1898
|
+
const top = Math.min(backgroundBBox.min[1] || Infinity, BBox.min[1] || Infinity, transientBBox.min[1] || Infinity, labelBBox.min[1] || Infinity) - padding[0];
|
|
1899
|
+
const bottom = Math.max(backgroundBBox.max[1] || -Infinity, BBox.max[1] || -Infinity, transientBBox.max[1] || -Infinity, labelBBox.max[1] || -Infinity) - padding[2];
|
|
1769
1900
|
const graphCenterX = (left + right) / 2;
|
|
1770
1901
|
const graphCenterY = (top + bottom) / 2;
|
|
1771
1902
|
const halfX = (right - left) / 2;
|
|
@@ -1775,6 +1906,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1775
1906
|
const vHeight = halfY * 2;
|
|
1776
1907
|
const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
|
|
1777
1908
|
const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
|
|
1909
|
+
yield vCanvas.ready;
|
|
1778
1910
|
const vCanvasContextService = vCanvas.getContextService();
|
|
1779
1911
|
if (rendererType !== 'svg') {
|
|
1780
1912
|
const bgRect = new g_1.Rect({
|
|
@@ -1793,6 +1925,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1793
1925
|
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
1794
1926
|
const clonedGroup = root.cloneNode(true);
|
|
1795
1927
|
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
1928
|
+
const labelClonedGroup = labelRoot.cloneNode(true);
|
|
1796
1929
|
const transPosition = [
|
|
1797
1930
|
-graphCenterX + halfX,
|
|
1798
1931
|
-graphCenterY + halfY,
|
|
@@ -1800,17 +1933,36 @@ class Graph extends event_emitter_1.default {
|
|
|
1800
1933
|
backgroundClonedGroup.setPosition(transPosition);
|
|
1801
1934
|
clonedGroup.setPosition(transPosition);
|
|
1802
1935
|
transientClonedGroup.setPosition(transPosition);
|
|
1936
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1937
|
+
const labelTransPosition = [
|
|
1938
|
+
transPosition[0] + currentViewportLTCanvas.x,
|
|
1939
|
+
transPosition[1] + currentViewportLTCanvas.y,
|
|
1940
|
+
];
|
|
1941
|
+
labelClonedGroup.setPosition(labelTransPosition);
|
|
1942
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
1943
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
1944
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
1945
|
+
childGroup.children.forEach((shape) => {
|
|
1946
|
+
if (shape.getAttribute('data-is-label-background') &&
|
|
1947
|
+
shape.style.transform)
|
|
1948
|
+
shape.remove();
|
|
1949
|
+
});
|
|
1950
|
+
});
|
|
1803
1951
|
vCanvas.appendChild(backgroundClonedGroup);
|
|
1804
1952
|
vCanvas.appendChild(clonedGroup);
|
|
1953
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
1805
1954
|
vCanvas.appendChild(transientClonedGroup);
|
|
1806
|
-
vCanvas.render();
|
|
1807
1955
|
if (!type)
|
|
1808
1956
|
type = 'image/png';
|
|
1809
1957
|
let dataURL = '';
|
|
1810
|
-
|
|
1811
|
-
|
|
1958
|
+
return new Promise((resolve) => {
|
|
1959
|
+
setTimeout(() => {
|
|
1960
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1961
|
+
dataURL = url;
|
|
1962
|
+
resolve(dataURL);
|
|
1963
|
+
});
|
|
1964
|
+
}, 50);
|
|
1812
1965
|
});
|
|
1813
|
-
return dataURL;
|
|
1814
1966
|
});
|
|
1815
1967
|
}
|
|
1816
1968
|
/**
|
|
@@ -2072,7 +2224,7 @@ class Graph extends event_emitter_1.default {
|
|
|
2072
2224
|
* @returns
|
|
2073
2225
|
* @group Tree
|
|
2074
2226
|
*/
|
|
2075
|
-
collapse(ids, disableAnimate = false
|
|
2227
|
+
collapse(ids, disableAnimate = false) {
|
|
2076
2228
|
this.hooks.treecollapseexpand.emit({
|
|
2077
2229
|
ids: (0, util_1.isArray)(ids) ? ids : [ids],
|
|
2078
2230
|
action: 'collapse',
|
|
@@ -2088,7 +2240,7 @@ class Graph extends event_emitter_1.default {
|
|
|
2088
2240
|
* @returns
|
|
2089
2241
|
* @group Tree
|
|
2090
2242
|
*/
|
|
2091
|
-
expand(ids, disableAnimate = false
|
|
2243
|
+
expand(ids, disableAnimate = false) {
|
|
2092
2244
|
this.hooks.treecollapseexpand.emit({
|
|
2093
2245
|
ids: (0, util_1.isArray)(ids) ? ids : [ids],
|
|
2094
2246
|
action: 'expand',
|
|
@@ -2102,15 +2254,23 @@ class Graph extends event_emitter_1.default {
|
|
|
2102
2254
|
* @group Graph Instance
|
|
2103
2255
|
*/
|
|
2104
2256
|
destroy(callback) {
|
|
2105
|
-
|
|
2106
|
-
|
|
2257
|
+
var _a;
|
|
2258
|
+
const camera = this.canvas.getCamera();
|
|
2259
|
+
const transientCamera = this.transientCanvas.getCamera();
|
|
2260
|
+
// @ts-ignore
|
|
2261
|
+
if ((_a = camera.landmarks) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2262
|
+
camera.cancelLandmarkAnimation();
|
|
2263
|
+
transientCamera.cancelLandmarkAnimation();
|
|
2264
|
+
this.emit('cancelviewportanimation');
|
|
2265
|
+
}
|
|
2107
2266
|
this.canvas.destroy();
|
|
2267
|
+
this.labelCanvas.destroy();
|
|
2108
2268
|
this.backgroundCanvas.destroy();
|
|
2109
2269
|
this.transientCanvas.destroy();
|
|
2270
|
+
this.transientLabelCanvas.destroy();
|
|
2110
2271
|
// clear history stack
|
|
2111
2272
|
this.cleanHistory();
|
|
2112
2273
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
2113
|
-
// }, 500);
|
|
2114
2274
|
this.hooks.destroy.emit({});
|
|
2115
2275
|
// TODO: destroy controllers and off the listeners
|
|
2116
2276
|
// this.dataController.destroy();
|
|
@@ -2118,7 +2278,6 @@ class Graph extends event_emitter_1.default {
|
|
|
2118
2278
|
// this.layoutController.destroy();
|
|
2119
2279
|
// this.themeController.destroy();
|
|
2120
2280
|
// this.itemController.destroy();
|
|
2121
|
-
// this.extensionController.destroy();
|
|
2122
2281
|
this.destroyed = true;
|
|
2123
2282
|
}
|
|
2124
2283
|
}
|