@antv/g6 5.0.0-beta.33 → 5.0.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g6.min.js +2 -2
- package/dist/lib/animations/types.d.ts +3 -4
- package/dist/lib/behaviors/base-behavior.d.ts +2 -1
- package/dist/lib/behaviors/brush-select.d.ts +33 -16
- package/dist/lib/behaviors/click-element.d.ts +28 -5
- package/dist/lib/behaviors/collapse-expand.d.ts +3 -2
- package/dist/lib/behaviors/create-edge.d.ts +1 -2
- package/dist/lib/behaviors/drag-canvas.d.ts +7 -0
- package/dist/lib/behaviors/drag-element-force.d.ts +1 -2
- package/dist/lib/behaviors/drag-element.d.ts +4 -5
- package/dist/lib/behaviors/index.d.ts +2 -0
- package/dist/lib/behaviors/lasso-select.d.ts +4 -4
- package/dist/lib/behaviors/scroll-canvas.d.ts +64 -0
- package/dist/lib/behaviors/types.d.ts +2 -1
- package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/dist/lib/constants/events/animation.d.ts +1 -4
- package/dist/lib/constants/events/graph.d.ts +5 -1
- package/dist/lib/elements/combos/base-combo.d.ts +1 -1
- package/dist/lib/elements/edges/base-edge.d.ts +0 -5
- package/dist/lib/elements/nodes/base-node.d.ts +3 -10
- package/dist/lib/elements/nodes/donut.d.ts +45 -0
- package/dist/lib/elements/nodes/html.d.ts +27 -0
- package/dist/lib/elements/nodes/index.d.ts +4 -0
- package/dist/lib/elements/shapes/badge.d.ts +1 -1
- package/dist/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
- package/dist/lib/elements/shapes/index.d.ts +2 -0
- package/dist/lib/exports.d.ts +15 -22
- package/dist/lib/plugins/bubble-sets.d.ts +45 -0
- package/dist/lib/plugins/camera-setting.d.ts +4 -2
- package/dist/lib/plugins/contextmenu.d.ts +1 -0
- package/dist/lib/plugins/grid-line.d.ts +51 -8
- package/dist/lib/plugins/hull/index.d.ts +44 -13
- package/dist/lib/plugins/index.d.ts +4 -0
- package/dist/lib/plugins/timebar.d.ts +225 -0
- package/dist/lib/plugins/tooltip.d.ts +2 -2
- package/dist/lib/registry/index.d.ts +1 -1
- package/dist/lib/runtime/data.d.ts +13 -7
- package/dist/lib/runtime/element.d.ts +6 -10
- package/dist/lib/runtime/graph.d.ts +532 -45
- package/dist/lib/runtime/types.d.ts +3 -3
- package/dist/lib/runtime/viewport.d.ts +3 -4
- package/dist/lib/spec/canvas.d.ts +6 -2
- package/dist/lib/spec/data.d.ts +74 -1
- package/dist/lib/spec/element/combo.d.ts +17 -6
- package/dist/lib/spec/element/edge.d.ts +14 -2
- package/dist/lib/spec/element/node.d.ts +19 -3
- package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +12 -4
- package/dist/lib/spec/index.d.ts +1 -1
- package/dist/lib/spec/theme.d.ts +1 -4
- package/dist/lib/spec/viewport.d.ts +1 -1
- package/dist/lib/themes/base.d.ts +1 -0
- package/dist/lib/themes/types.d.ts +0 -1
- package/dist/lib/transforms/process-parallel-edges.d.ts +2 -3
- package/dist/lib/transforms/types.d.ts +1 -1
- package/dist/lib/types/callable.d.ts +2 -2
- package/dist/lib/types/data.d.ts +3 -3
- package/dist/lib/types/id.d.ts +1 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/style.d.ts +1 -3
- package/dist/lib/types/viewport.d.ts +4 -4
- package/dist/lib/utils/animation.d.ts +6 -6
- package/dist/lib/utils/behaviors/brush.d.ts +1 -2
- package/dist/lib/utils/behaviors/lasso.d.ts +1 -2
- package/dist/lib/utils/behaviors/utils.d.ts +1 -1
- package/dist/lib/utils/data.d.ts +2 -2
- package/dist/lib/utils/edge.d.ts +1 -2
- package/dist/lib/utils/element.d.ts +1 -1
- package/dist/lib/utils/event/events.d.ts +1 -1
- package/dist/lib/utils/event/index.d.ts +1 -1
- package/dist/lib/utils/id.d.ts +2 -3
- package/dist/lib/utils/palette.d.ts +2 -3
- package/dist/lib/utils/relation.d.ts +3 -4
- package/dist/lib/utils/visibility.d.ts +1 -1
- package/esm/animations/types.d.ts +3 -4
- package/esm/behaviors/base-behavior.d.ts +2 -1
- package/esm/behaviors/brush-select.d.ts +33 -16
- package/esm/behaviors/brush-select.js +7 -2
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/click-element.d.ts +28 -5
- package/esm/behaviors/click-element.js +11 -0
- package/esm/behaviors/click-element.js.map +1 -1
- package/esm/behaviors/collapse-expand.d.ts +3 -2
- package/esm/behaviors/collapse-expand.js +2 -2
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.d.ts +1 -2
- package/esm/behaviors/create-edge.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +7 -0
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element-force.d.ts +1 -2
- package/esm/behaviors/drag-element-force.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +4 -5
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/focus-element.js.map +1 -1
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/behaviors/index.d.ts +2 -0
- package/esm/behaviors/index.js +1 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/lasso-select.d.ts +4 -4
- package/esm/behaviors/lasso-select.js +1 -1
- package/esm/behaviors/lasso-select.js.map +1 -1
- package/esm/behaviors/scroll-canvas.d.ts +64 -0
- package/esm/behaviors/scroll-canvas.js +80 -0
- package/esm/behaviors/scroll-canvas.js.map +1 -0
- package/esm/behaviors/types.d.ts +2 -1
- package/esm/behaviors/zoom-canvas.d.ts +1 -1
- package/esm/constants/events/animation.d.ts +1 -4
- package/esm/constants/events/animation.js +0 -4
- package/esm/constants/events/animation.js.map +1 -1
- package/esm/constants/events/graph.d.ts +5 -1
- package/esm/constants/events/graph.js +4 -0
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/elements/combos/base-combo.d.ts +1 -1
- package/esm/elements/edges/base-edge.d.ts +0 -5
- package/esm/elements/edges/base-edge.js +1 -2
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +3 -10
- package/esm/elements/nodes/base-node.js +2 -2
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/donut.d.ts +45 -0
- package/esm/elements/nodes/donut.js +81 -0
- package/esm/elements/nodes/donut.js.map +1 -0
- package/esm/elements/nodes/html.d.ts +27 -0
- package/esm/elements/nodes/html.js +209 -0
- package/esm/elements/nodes/html.js.map +1 -0
- package/esm/elements/nodes/index.d.ts +4 -0
- package/esm/elements/nodes/index.js +2 -0
- package/esm/elements/nodes/index.js.map +1 -1
- package/esm/elements/shapes/badge.d.ts +1 -1
- package/esm/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
- package/esm/{plugins/hull/shape.js → elements/shapes/contour.js} +12 -11
- package/esm/elements/shapes/contour.js.map +1 -0
- package/esm/elements/shapes/index.d.ts +2 -0
- package/esm/elements/shapes/index.js +1 -0
- package/esm/elements/shapes/index.js.map +1 -1
- package/esm/exports.d.ts +15 -22
- package/esm/exports.js +8 -18
- package/esm/exports.js.map +1 -1
- package/esm/plugins/bubble-sets.d.ts +45 -0
- package/esm/plugins/bubble-sets.js +212 -0
- package/esm/plugins/bubble-sets.js.map +1 -0
- package/esm/plugins/camera-setting.d.ts +4 -2
- package/esm/plugins/camera-setting.js.map +1 -1
- package/esm/plugins/contextmenu.d.ts +1 -0
- package/esm/plugins/contextmenu.js +1 -0
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +51 -8
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/history/utils.js +6 -2
- package/esm/plugins/history/utils.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +44 -13
- package/esm/plugins/hull/index.js +46 -16
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/index.d.ts +4 -0
- package/esm/plugins/index.js +2 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.js +4 -2
- package/esm/plugins/legend.js.map +1 -1
- package/esm/plugins/timebar.d.ts +225 -0
- package/esm/plugins/timebar.js +253 -0
- package/esm/plugins/timebar.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +2 -2
- package/esm/registry/build-in.js +15 -10
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/index.d.ts +1 -1
- package/esm/registry/index.js +1 -1
- package/esm/runtime/canvas.js +7 -4
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +13 -7
- package/esm/runtime/data.js +20 -3
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +6 -10
- package/esm/runtime/element.js +65 -46
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +532 -45
- package/esm/runtime/graph.js +418 -40
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +2 -2
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/types.d.ts +3 -3
- package/esm/runtime/viewport.d.ts +3 -4
- package/esm/runtime/viewport.js +2 -2
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/spec/canvas.d.ts +6 -2
- package/esm/spec/data.d.ts +74 -1
- package/esm/spec/element/combo.d.ts +17 -6
- package/esm/spec/element/edge.d.ts +14 -2
- package/esm/spec/element/node.d.ts +19 -3
- package/esm/spec/{spec.d.ts → graph.d.ts} +12 -4
- package/esm/spec/graph.js +2 -0
- package/esm/spec/graph.js.map +1 -0
- package/esm/spec/index.d.ts +1 -1
- package/esm/spec/theme.d.ts +1 -4
- package/esm/spec/viewport.d.ts +1 -1
- package/esm/themes/base.d.ts +1 -0
- package/esm/themes/base.js +11 -9
- package/esm/themes/base.js.map +1 -1
- package/esm/themes/types.d.ts +0 -1
- package/esm/transforms/process-parallel-edges.d.ts +2 -3
- package/esm/transforms/process-parallel-edges.js +2 -4
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/transforms/types.d.ts +1 -1
- package/esm/transforms/update-related-edge.js.map +1 -1
- package/esm/types/callable.d.ts +2 -2
- package/esm/types/data.d.ts +3 -3
- package/esm/types/id.d.ts +1 -0
- package/esm/types/id.js +2 -0
- package/esm/types/id.js.map +1 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/style.d.ts +1 -3
- package/esm/types/viewport.d.ts +4 -4
- package/esm/utils/animation.d.ts +6 -6
- package/esm/utils/animation.js +3 -3
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/behaviors/brush.d.ts +1 -2
- package/esm/utils/behaviors/brush.js.map +1 -1
- package/esm/utils/behaviors/lasso.d.ts +1 -2
- package/esm/utils/behaviors/lasso.js.map +1 -1
- package/esm/utils/behaviors/utils.d.ts +1 -1
- package/esm/utils/change.js +8 -1
- package/esm/utils/change.js.map +1 -1
- package/esm/utils/data.d.ts +2 -2
- package/esm/utils/data.js +2 -2
- package/esm/utils/edge.d.ts +1 -2
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/element.d.ts +1 -1
- package/esm/utils/element.js +2 -2
- package/esm/utils/event/events.d.ts +1 -1
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/event/index.d.ts +1 -1
- package/esm/utils/event/index.js +1 -1
- package/esm/utils/id.d.ts +2 -3
- package/esm/utils/id.js.map +1 -1
- package/esm/utils/palette.d.ts +2 -3
- package/esm/utils/palette.js +1 -1
- package/esm/utils/palette.js.map +1 -1
- package/esm/utils/relation.d.ts +3 -4
- package/esm/utils/relation.js +2 -2
- package/esm/utils/relation.js.map +1 -1
- package/esm/utils/style.js +3 -3
- package/esm/utils/style.js.map +1 -1
- package/esm/utils/visibility.d.ts +1 -1
- package/esm/utils/visibility.js +1 -1
- package/lib/animations/types.d.ts +3 -4
- package/lib/behaviors/base-behavior.d.ts +2 -1
- package/lib/behaviors/brush-select.d.ts +33 -16
- package/lib/behaviors/brush-select.js +7 -2
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/click-element.d.ts +28 -5
- package/lib/behaviors/click-element.js +11 -0
- package/lib/behaviors/click-element.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +3 -2
- package/lib/behaviors/collapse-expand.js +2 -2
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.d.ts +1 -2
- package/lib/behaviors/create-edge.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +7 -0
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element-force.d.ts +1 -2
- package/lib/behaviors/drag-element-force.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +4 -5
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/focus-element.js.map +1 -1
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/behaviors/index.d.ts +2 -0
- package/lib/behaviors/index.js +3 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/lasso-select.d.ts +4 -4
- package/lib/behaviors/lasso-select.js +1 -1
- package/lib/behaviors/lasso-select.js.map +1 -1
- package/lib/behaviors/scroll-canvas.d.ts +64 -0
- package/lib/behaviors/scroll-canvas.js +84 -0
- package/lib/behaviors/scroll-canvas.js.map +1 -0
- package/lib/behaviors/types.d.ts +2 -1
- package/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/lib/constants/events/animation.d.ts +1 -4
- package/lib/constants/events/animation.js +0 -4
- package/lib/constants/events/animation.js.map +1 -1
- package/lib/constants/events/graph.d.ts +5 -1
- package/lib/constants/events/graph.js +4 -0
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/elements/combos/base-combo.d.ts +1 -1
- package/lib/elements/edges/base-edge.d.ts +0 -5
- package/lib/elements/edges/base-edge.js +1 -2
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +3 -10
- package/lib/elements/nodes/base-node.js +2 -2
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/donut.d.ts +45 -0
- package/lib/elements/nodes/donut.js +85 -0
- package/lib/elements/nodes/donut.js.map +1 -0
- package/lib/elements/nodes/html.d.ts +27 -0
- package/lib/elements/nodes/html.js +213 -0
- package/lib/elements/nodes/html.js.map +1 -0
- package/lib/elements/nodes/index.d.ts +4 -0
- package/lib/elements/nodes/index.js +5 -1
- package/lib/elements/nodes/index.js.map +1 -1
- package/lib/elements/shapes/badge.d.ts +1 -1
- package/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
- package/lib/{plugins/hull/shape.js → elements/shapes/contour.js} +15 -14
- package/lib/elements/shapes/contour.js.map +1 -0
- package/lib/elements/shapes/index.d.ts +2 -0
- package/lib/elements/shapes/index.js +3 -1
- package/lib/elements/shapes/index.js.map +1 -1
- package/lib/exports.d.ts +15 -22
- package/lib/exports.js +50 -17
- package/lib/exports.js.map +1 -1
- package/lib/plugins/bubble-sets.d.ts +45 -0
- package/lib/plugins/bubble-sets.js +216 -0
- package/lib/plugins/bubble-sets.js.map +1 -0
- package/lib/plugins/camera-setting.d.ts +4 -2
- package/lib/plugins/camera-setting.js.map +1 -1
- package/lib/plugins/contextmenu.d.ts +1 -0
- package/lib/plugins/contextmenu.js +1 -0
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +51 -8
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/history/utils.js +6 -2
- package/lib/plugins/history/utils.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +44 -13
- package/lib/plugins/hull/index.js +46 -16
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/index.d.ts +4 -0
- package/lib/plugins/index.js +5 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.js +4 -2
- package/lib/plugins/legend.js.map +1 -1
- package/lib/plugins/timebar.d.ts +225 -0
- package/lib/plugins/timebar.js +257 -0
- package/lib/plugins/timebar.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +2 -2
- package/lib/registry/build-in.js +12 -7
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/index.d.ts +1 -1
- package/lib/registry/index.js +1 -1
- package/lib/runtime/canvas.js +7 -4
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +13 -7
- package/lib/runtime/data.js +20 -3
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +6 -10
- package/lib/runtime/element.js +64 -45
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +532 -45
- package/lib/runtime/graph.js +417 -39
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +2 -2
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/types.d.ts +3 -3
- package/lib/runtime/viewport.d.ts +3 -4
- package/lib/runtime/viewport.js +2 -2
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/spec/canvas.d.ts +6 -2
- package/lib/spec/data.d.ts +74 -1
- package/lib/spec/element/combo.d.ts +17 -6
- package/lib/spec/element/edge.d.ts +14 -2
- package/lib/spec/element/node.d.ts +19 -3
- package/{dist/lib/spec/spec.d.ts → lib/spec/graph.d.ts} +12 -4
- package/lib/spec/{spec.js → graph.js} +1 -1
- package/lib/spec/graph.js.map +1 -0
- package/lib/spec/index.d.ts +1 -1
- package/lib/spec/theme.d.ts +1 -4
- package/lib/spec/viewport.d.ts +1 -1
- package/lib/themes/base.d.ts +1 -0
- package/lib/themes/base.js +11 -9
- package/lib/themes/base.js.map +1 -1
- package/lib/themes/types.d.ts +0 -1
- package/lib/transforms/process-parallel-edges.d.ts +2 -3
- package/lib/transforms/process-parallel-edges.js +2 -4
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/transforms/types.d.ts +1 -1
- package/lib/transforms/update-related-edge.js.map +1 -1
- package/lib/types/callable.d.ts +2 -2
- package/lib/types/data.d.ts +3 -3
- package/lib/types/id.d.ts +1 -0
- package/lib/{spec/element/base.js → types/id.js} +1 -1
- package/lib/types/id.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/style.d.ts +1 -3
- package/lib/types/viewport.d.ts +4 -4
- package/lib/utils/animation.d.ts +6 -6
- package/lib/utils/animation.js +3 -3
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/behaviors/brush.d.ts +1 -2
- package/lib/utils/behaviors/brush.js.map +1 -1
- package/lib/utils/behaviors/lasso.d.ts +1 -2
- package/lib/utils/behaviors/lasso.js.map +1 -1
- package/lib/utils/behaviors/utils.d.ts +1 -1
- package/lib/utils/change.js +8 -1
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/data.d.ts +2 -2
- package/lib/utils/data.js +2 -2
- package/lib/utils/edge.d.ts +1 -2
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.d.ts +1 -1
- package/lib/utils/element.js +2 -2
- package/lib/utils/event/events.d.ts +1 -1
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/event/index.d.ts +1 -1
- package/lib/utils/event/index.js +1 -1
- package/lib/utils/id.d.ts +2 -3
- package/lib/utils/id.js.map +1 -1
- package/lib/utils/palette.d.ts +2 -3
- package/lib/utils/palette.js +1 -1
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/relation.d.ts +3 -4
- package/lib/utils/relation.js +2 -2
- package/lib/utils/relation.js.map +1 -1
- package/lib/utils/style.js +3 -3
- package/lib/utils/style.js.map +1 -1
- package/lib/utils/visibility.d.ts +1 -1
- package/lib/utils/visibility.js +1 -1
- package/package.json +2 -1
- package/src/animations/types.ts +3 -4
- package/src/behaviors/base-behavior.ts +1 -1
- package/src/behaviors/brush-select.ts +34 -16
- package/src/behaviors/click-element.ts +29 -7
- package/src/behaviors/collapse-expand.ts +5 -4
- package/src/behaviors/create-edge.ts +1 -2
- package/src/behaviors/drag-canvas.ts +7 -0
- package/src/behaviors/drag-element-force.ts +1 -2
- package/src/behaviors/drag-element.ts +3 -4
- package/src/behaviors/focus-element.ts +1 -2
- package/src/behaviors/hover-element.ts +1 -2
- package/src/behaviors/index.ts +2 -0
- package/src/behaviors/lasso-select.ts +3 -4
- package/src/behaviors/scroll-canvas.ts +143 -0
- package/src/behaviors/types.ts +2 -1
- package/src/behaviors/zoom-canvas.ts +1 -1
- package/src/constants/events/animation.ts +0 -4
- package/src/constants/events/graph.ts +4 -0
- package/src/elements/combos/base-combo.ts +1 -1
- package/src/elements/edges/base-edge.ts +1 -7
- package/src/elements/nodes/base-node.ts +6 -15
- package/src/elements/nodes/donut.ts +137 -0
- package/src/elements/nodes/html.ts +230 -0
- package/src/elements/nodes/index.ts +4 -0
- package/src/{plugins/hull/shape.ts → elements/shapes/contour.ts} +27 -34
- package/src/elements/shapes/index.ts +2 -0
- package/src/exports.ts +124 -25
- package/src/plugins/bubble-sets.ts +268 -0
- package/src/plugins/camera-setting.ts +4 -2
- package/src/plugins/contextmenu.ts +1 -0
- package/src/plugins/grid-line.ts +51 -8
- package/src/plugins/history/utils.ts +6 -2
- package/src/plugins/hull/index.ts +58 -22
- package/src/plugins/index.ts +4 -0
- package/src/plugins/legend.ts +6 -4
- package/src/plugins/timebar.ts +450 -0
- package/src/plugins/tooltip.ts +2 -2
- package/src/registry/build-in.ts +27 -8
- package/src/registry/index.ts +1 -1
- package/src/runtime/canvas.ts +7 -4
- package/src/runtime/data.ts +23 -4
- package/src/runtime/element.ts +67 -40
- package/src/runtime/graph.ts +554 -56
- package/src/runtime/layout.ts +4 -4
- package/src/runtime/types.ts +3 -3
- package/src/runtime/viewport.ts +3 -4
- package/src/spec/canvas.ts +6 -2
- package/src/spec/data.ts +74 -1
- package/src/spec/element/combo.ts +17 -6
- package/src/spec/element/edge.ts +14 -2
- package/src/spec/element/node.ts +19 -3
- package/src/spec/{spec.ts → graph.ts} +12 -4
- package/src/spec/index.ts +1 -1
- package/src/spec/theme.ts +1 -5
- package/src/spec/viewport.ts +1 -1
- package/src/themes/base.ts +12 -9
- package/src/themes/types.ts +0 -2
- package/src/transforms/arrange-draw-order.ts +1 -1
- package/src/transforms/process-parallel-edges.ts +5 -7
- package/src/transforms/types.ts +1 -1
- package/src/transforms/update-related-edge.ts +1 -2
- package/src/types/callable.ts +2 -2
- package/src/types/data.ts +3 -3
- package/src/types/id.ts +1 -0
- package/src/types/index.ts +1 -0
- package/src/types/style.ts +1 -3
- package/src/types/viewport.ts +4 -4
- package/src/utils/animation.ts +6 -6
- package/src/utils/behaviors/brush.ts +1 -2
- package/src/utils/behaviors/lasso.ts +1 -2
- package/src/utils/behaviors/utils.ts +1 -1
- package/src/utils/change.ts +7 -3
- package/src/utils/data.ts +2 -2
- package/src/utils/edge.ts +1 -1
- package/src/utils/element.ts +2 -2
- package/src/utils/event/events.ts +3 -1
- package/src/utils/event/index.ts +1 -1
- package/src/utils/id.ts +1 -2
- package/src/utils/palette.ts +2 -2
- package/src/utils/relation.ts +3 -4
- package/src/utils/style.ts +3 -3
- package/src/utils/visibility.ts +1 -1
- package/dist/lib/runtime/index.d.ts +0 -6
- package/dist/lib/spec/element/base.d.ts +0 -6
- package/esm/plugins/hull/shape.js.map +0 -1
- package/esm/runtime/index.d.ts +0 -6
- package/esm/runtime/index.js +0 -7
- package/esm/runtime/index.js.map +0 -1
- package/esm/spec/element/base.d.ts +0 -6
- package/esm/spec/element/base.js +0 -2
- package/esm/spec/element/base.js.map +0 -1
- package/esm/spec/spec.js +0 -2
- package/esm/spec/spec.js.map +0 -1
- package/lib/plugins/hull/shape.js.map +0 -1
- package/lib/runtime/index.d.ts +0 -6
- package/lib/runtime/index.js +0 -8
- package/lib/runtime/index.js.map +0 -1
- package/lib/spec/element/base.d.ts +0 -6
- package/lib/spec/element/base.js.map +0 -1
- package/lib/spec/spec.js.map +0 -1
- package/src/runtime/index.ts +0 -7
- package/src/spec/element/base.ts +0 -6
package/src/runtime/graph.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
2
|
import type { AABB, BaseStyleProps } from '@antv/g';
|
|
3
|
-
import
|
|
4
|
-
import { debounce, isEqual, isFunction, isNumber, isObject, isString, omit } from '@antv/util';
|
|
3
|
+
import { debounce, isArray, isEqual, isFunction, isNumber, isObject, isString, omit } from '@antv/util';
|
|
5
4
|
import { COMBO_KEY, GraphEvent } from '../constants';
|
|
6
5
|
import type { Plugin } from '../plugins/types';
|
|
7
6
|
import { getExtension } from '../registry';
|
|
@@ -11,8 +10,8 @@ import type {
|
|
|
11
10
|
ComboOptions,
|
|
12
11
|
EdgeData,
|
|
13
12
|
EdgeOptions,
|
|
14
|
-
G6Spec,
|
|
15
13
|
GraphData,
|
|
14
|
+
GraphOptions,
|
|
16
15
|
LayoutOptions,
|
|
17
16
|
NodeData,
|
|
18
17
|
NodeOptions,
|
|
@@ -30,6 +29,7 @@ import type {
|
|
|
30
29
|
ElementDatum,
|
|
31
30
|
ElementType,
|
|
32
31
|
FitViewOptions,
|
|
32
|
+
ID,
|
|
33
33
|
IEvent,
|
|
34
34
|
NodeLikeData,
|
|
35
35
|
PartialEdgeData,
|
|
@@ -61,18 +61,24 @@ import { RuntimeContext } from './types';
|
|
|
61
61
|
import { ViewportController } from './viewport';
|
|
62
62
|
|
|
63
63
|
export class Graph extends EventEmitter {
|
|
64
|
-
private options:
|
|
64
|
+
private options: GraphOptions;
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
static defaultOptions: GraphOptions = {
|
|
67
70
|
autoResize: false,
|
|
68
|
-
width: 800,
|
|
69
|
-
height: 600,
|
|
70
71
|
theme: 'light',
|
|
71
72
|
rotation: 0,
|
|
72
73
|
zoom: 1,
|
|
73
74
|
zoomRange: [0.01, 10],
|
|
74
75
|
};
|
|
75
76
|
|
|
77
|
+
/**
|
|
78
|
+
* <zh/> 当前图实例是否已经被销毁
|
|
79
|
+
*
|
|
80
|
+
* <en/> Whether the current graph instance has been destroyed
|
|
81
|
+
*/
|
|
76
82
|
public destroyed = false;
|
|
77
83
|
|
|
78
84
|
// @ts-expect-error will be initialized in createRuntime
|
|
@@ -80,7 +86,7 @@ export class Graph extends EventEmitter {
|
|
|
80
86
|
model: new DataController(),
|
|
81
87
|
};
|
|
82
88
|
|
|
83
|
-
constructor(options:
|
|
89
|
+
constructor(options: GraphOptions) {
|
|
84
90
|
super();
|
|
85
91
|
this.options = Object.assign({}, Graph.defaultOptions, options);
|
|
86
92
|
this.setOptions(this.options);
|
|
@@ -95,8 +101,9 @@ export class Graph extends EventEmitter {
|
|
|
95
101
|
*
|
|
96
102
|
* <en/> Get options
|
|
97
103
|
* @returns <zh/> 配置项 | <en/> options
|
|
104
|
+
* @apiCategory option
|
|
98
105
|
*/
|
|
99
|
-
public getOptions():
|
|
106
|
+
public getOptions(): GraphOptions {
|
|
100
107
|
return this.options;
|
|
101
108
|
}
|
|
102
109
|
|
|
@@ -105,12 +112,13 @@ export class Graph extends EventEmitter {
|
|
|
105
112
|
*
|
|
106
113
|
* <en/> Set options
|
|
107
114
|
* @param options - <zh/> 配置项 | <en/> options
|
|
108
|
-
* @
|
|
115
|
+
* @remarks
|
|
109
116
|
* <zh/> 要更新 devicePixelRatio、container 属性请销毁后重新创建实例
|
|
110
117
|
*
|
|
111
118
|
* <en/> To update devicePixelRatio and container properties, please destroy and recreate the instance
|
|
119
|
+
* @apiCategory option
|
|
112
120
|
*/
|
|
113
|
-
public setOptions(options:
|
|
121
|
+
public setOptions(options: GraphOptions): void {
|
|
114
122
|
const {
|
|
115
123
|
animation,
|
|
116
124
|
background,
|
|
@@ -146,52 +154,133 @@ export class Graph extends EventEmitter {
|
|
|
146
154
|
|
|
147
155
|
if (zoomRange) this.options.zoomRange = zoomRange;
|
|
148
156
|
if (isNumber(zoom)) this.options.zoom = zoom;
|
|
149
|
-
if (isNumber(padding)) this.options.padding = padding;
|
|
157
|
+
if (isNumber(padding) || isArray(padding)) this.options.padding = padding;
|
|
150
158
|
}
|
|
151
159
|
|
|
152
|
-
|
|
160
|
+
/**
|
|
161
|
+
* <zh/> 设置画布背景色
|
|
162
|
+
*
|
|
163
|
+
* <en/> Set canvas background color
|
|
164
|
+
* @param background - <zh/> 背景色 | <en/> background color
|
|
165
|
+
* @apiCategory canvas
|
|
166
|
+
*/
|
|
167
|
+
public setBackground(background: GraphOptions['background']): void {
|
|
153
168
|
this.options.background = background;
|
|
154
169
|
this.context.canvas?.setBackground(background);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
|
-
|
|
172
|
+
/**
|
|
173
|
+
* <zh/> 获取画布背景色
|
|
174
|
+
*
|
|
175
|
+
* <en/> Get canvas background color
|
|
176
|
+
* @returns <zh/> 背景色 | <en/> background color
|
|
177
|
+
* @apiCategory canvas
|
|
178
|
+
*/
|
|
179
|
+
public getBackground(): GraphOptions['background'] {
|
|
158
180
|
return this.options.background;
|
|
159
181
|
}
|
|
160
182
|
|
|
183
|
+
/**
|
|
184
|
+
* <zh/> 获取当前图容器的大小
|
|
185
|
+
*
|
|
186
|
+
* <en/> Get the size of the current canvas container
|
|
187
|
+
* @returns <zh/> 画布尺寸 | <en/> canvas size
|
|
188
|
+
* @apiCategory canvas
|
|
189
|
+
*/
|
|
161
190
|
public getSize(): [number, number] {
|
|
162
191
|
if (this.context.canvas) return this.context.canvas.getSize();
|
|
163
192
|
return [this.options.width || 0, this.options.height || 0];
|
|
164
193
|
}
|
|
165
194
|
|
|
195
|
+
/**
|
|
196
|
+
* <zh/> 获取当前图容器的大小
|
|
197
|
+
*
|
|
198
|
+
* <en/> Get the size of the current canvas container
|
|
199
|
+
* @param width - <zh/> 画布宽度 | <en/> canvas width
|
|
200
|
+
* @param height - <zh/> 画布高度 | <en/> canvas height
|
|
201
|
+
* @apiCategory canvas
|
|
202
|
+
*/
|
|
166
203
|
public setSize(width: number, height: number): void {
|
|
167
204
|
this.options.width = width;
|
|
168
205
|
this.options.height = height;
|
|
169
206
|
}
|
|
170
207
|
|
|
171
|
-
|
|
208
|
+
/**
|
|
209
|
+
* <zh/> 获取当前图的缩放区间
|
|
210
|
+
*
|
|
211
|
+
* <en/> Get the zoom range of the current graph
|
|
212
|
+
* @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
|
|
213
|
+
* @apiCategory viewport
|
|
214
|
+
*/
|
|
215
|
+
public setZoomRange(zoomRange: GraphOptions['zoomRange']): void {
|
|
172
216
|
this.options.zoomRange = zoomRange;
|
|
173
217
|
}
|
|
174
218
|
|
|
175
|
-
|
|
219
|
+
/**
|
|
220
|
+
* <zh/> 获取当前图的缩放区间
|
|
221
|
+
*
|
|
222
|
+
* <en/> Get the zoom range of the current graph
|
|
223
|
+
* @returns <zh/> 缩放区间 | <en/> zoom range
|
|
224
|
+
* @apiCategory viewport
|
|
225
|
+
*/
|
|
226
|
+
public getZoomRange(): GraphOptions['zoomRange'] {
|
|
176
227
|
return this.options.zoomRange;
|
|
177
228
|
}
|
|
178
229
|
|
|
230
|
+
/**
|
|
231
|
+
* <zh/> 设置节点样式映射
|
|
232
|
+
*
|
|
233
|
+
* <en/> Set node mapper
|
|
234
|
+
* @param node - <zh/> 节点配置 | <en/> node configuration
|
|
235
|
+
* @apiCategory element
|
|
236
|
+
*/
|
|
179
237
|
public setNode(node: NodeOptions): void {
|
|
180
238
|
this.options.node = node;
|
|
239
|
+
this.context.model.refreshData();
|
|
181
240
|
}
|
|
182
241
|
|
|
242
|
+
/**
|
|
243
|
+
* <zh/> 设置边样式映射
|
|
244
|
+
*
|
|
245
|
+
* <en/> Set edge mapper
|
|
246
|
+
* @param edge - <zh/> 边配置 | <en/> edge configuration
|
|
247
|
+
* @apiCategory element
|
|
248
|
+
*/
|
|
183
249
|
public setEdge(edge: EdgeOptions): void {
|
|
184
250
|
this.options.edge = edge;
|
|
251
|
+
this.context.model.refreshData();
|
|
185
252
|
}
|
|
186
253
|
|
|
254
|
+
/**
|
|
255
|
+
* <zh/> 设置组合样式映射
|
|
256
|
+
*
|
|
257
|
+
* <en/> Set combo mapper
|
|
258
|
+
* @param combo - <zh/> 组合配置 | <en/> combo configuration
|
|
259
|
+
* @apiCategory element
|
|
260
|
+
*/
|
|
187
261
|
public setCombo(combo: ComboOptions): void {
|
|
188
262
|
this.options.combo = combo;
|
|
263
|
+
this.context.model.refreshData();
|
|
189
264
|
}
|
|
190
265
|
|
|
266
|
+
/**
|
|
267
|
+
* <zh/> 获取主题
|
|
268
|
+
*
|
|
269
|
+
* <en/> Get theme
|
|
270
|
+
* @returns <zh/> 主题配置 | <en/> theme configuration
|
|
271
|
+
* @apiCategory theme
|
|
272
|
+
*/
|
|
191
273
|
public getTheme(): ThemeOptions {
|
|
192
274
|
return this.options.theme!;
|
|
193
275
|
}
|
|
194
276
|
|
|
277
|
+
/**
|
|
278
|
+
* <zh/> 设置主题
|
|
279
|
+
*
|
|
280
|
+
* <en/> Set theme
|
|
281
|
+
* @param theme - <zh/> 主题配置 | <en/> theme configuration
|
|
282
|
+
* @apiCategory theme
|
|
283
|
+
*/
|
|
195
284
|
public setTheme(theme: CallableValue<ThemeOptions>): void {
|
|
196
285
|
this.options.theme = isFunction(theme) ? theme(this.getTheme()) : theme;
|
|
197
286
|
|
|
@@ -201,10 +290,24 @@ export class Graph extends EventEmitter {
|
|
|
201
290
|
}
|
|
202
291
|
}
|
|
203
292
|
|
|
293
|
+
/**
|
|
294
|
+
* <zh/> 设置布局
|
|
295
|
+
*
|
|
296
|
+
* <en/> Set layout
|
|
297
|
+
* @param layout - <zh/> 布局配置 | <en/> layout configuration
|
|
298
|
+
* @apiCategory layout
|
|
299
|
+
*/
|
|
204
300
|
public setLayout(layout: CallableValue<LayoutOptions>): void {
|
|
205
301
|
this.options.layout = isFunction(layout) ? layout(this.getLayout()) : layout;
|
|
206
302
|
}
|
|
207
303
|
|
|
304
|
+
/**
|
|
305
|
+
* <zh/> 获取布局
|
|
306
|
+
*
|
|
307
|
+
* <en/> Get layout
|
|
308
|
+
* @returns <zh/> 布局配置 | <en/> layout configuration
|
|
309
|
+
* @apiCategory layout
|
|
310
|
+
*/
|
|
208
311
|
public getLayout(): LayoutOptions {
|
|
209
312
|
return this.options.layout!;
|
|
210
313
|
}
|
|
@@ -214,6 +317,7 @@ export class Graph extends EventEmitter {
|
|
|
214
317
|
*
|
|
215
318
|
* <en/> Set behaviors
|
|
216
319
|
* @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
|
|
320
|
+
* @apiCategory behavior
|
|
217
321
|
*/
|
|
218
322
|
public setBehaviors(behaviors: CallableValue<BehaviorOptions>): void {
|
|
219
323
|
this.options.behaviors = isFunction(behaviors) ? behaviors(this.getBehaviors()) : behaviors;
|
|
@@ -225,6 +329,7 @@ export class Graph extends EventEmitter {
|
|
|
225
329
|
*
|
|
226
330
|
* <en/> Update behavior
|
|
227
331
|
* @param behavior - <zh/> 交互配置 | <en/> behavior configuration
|
|
332
|
+
* @apiCategory behavior
|
|
228
333
|
*/
|
|
229
334
|
public updateBehavior(behavior: UpdateBehaviorOption): void {
|
|
230
335
|
this.setBehaviors((behaviors) =>
|
|
@@ -242,6 +347,7 @@ export class Graph extends EventEmitter {
|
|
|
242
347
|
*
|
|
243
348
|
* <en/> Get behaviors
|
|
244
349
|
* @returns <zh/> 交互配置 | <en/> behavior configuration
|
|
350
|
+
* @apiCategory behavior
|
|
245
351
|
*/
|
|
246
352
|
public getBehaviors(): BehaviorOptions {
|
|
247
353
|
return this.options.behaviors || [];
|
|
@@ -252,6 +358,7 @@ export class Graph extends EventEmitter {
|
|
|
252
358
|
*
|
|
253
359
|
* <en/> Set plugins
|
|
254
360
|
* @param plugins - <zh/> 插件配置 | <en/> plugin configuration
|
|
361
|
+
* @apiCategory plugin
|
|
255
362
|
*/
|
|
256
363
|
public setPlugins(plugins: CallableValue<PluginOptions>): void {
|
|
257
364
|
this.options.plugins = isFunction(plugins) ? plugins(this.getPlugins()) : plugins;
|
|
@@ -263,6 +370,7 @@ export class Graph extends EventEmitter {
|
|
|
263
370
|
*
|
|
264
371
|
* <en/> Update plugin
|
|
265
372
|
* @param plugin - <zh/> 插件配置 | <en/> plugin configuration
|
|
373
|
+
* @apiCategory plugin
|
|
266
374
|
*/
|
|
267
375
|
public updatePlugin(plugin: UpdatePluginOption): void {
|
|
268
376
|
this.setPlugins((plugins) =>
|
|
@@ -280,6 +388,7 @@ export class Graph extends EventEmitter {
|
|
|
280
388
|
*
|
|
281
389
|
* <en/> Get plugins
|
|
282
390
|
* @returns <zh/> 插件配置 | <en/> plugin configuration
|
|
391
|
+
* @apiCategory plugin
|
|
283
392
|
*/
|
|
284
393
|
public getPlugins(): PluginOptions {
|
|
285
394
|
return this.options.plugins || [];
|
|
@@ -291,6 +400,7 @@ export class Graph extends EventEmitter {
|
|
|
291
400
|
* <en/> Get plugin instance
|
|
292
401
|
* @param key - <zh/> 插件 key | <en/> plugin key
|
|
293
402
|
* @returns <zh/> 插件实例 | <en/> plugin instance
|
|
403
|
+
* @apiCategory plugin
|
|
294
404
|
*/
|
|
295
405
|
public getPluginInstance<T extends Plugin>(key: string) {
|
|
296
406
|
return this.context.plugin!.getPluginInstance(key) as unknown as T;
|
|
@@ -301,6 +411,7 @@ export class Graph extends EventEmitter {
|
|
|
301
411
|
*
|
|
302
412
|
* <en/> Set data transforms
|
|
303
413
|
* @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
|
|
414
|
+
* @apiCategory transform
|
|
304
415
|
*/
|
|
305
416
|
public setTransforms(transforms: CallableValue<TransformOptions>): void {
|
|
306
417
|
this.options.transforms = isFunction(transforms) ? transforms(this.getTransforms()) : transforms;
|
|
@@ -312,6 +423,7 @@ export class Graph extends EventEmitter {
|
|
|
312
423
|
*
|
|
313
424
|
* <en/> Update data transform
|
|
314
425
|
* @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
|
|
426
|
+
* @apiCategory transform
|
|
315
427
|
*/
|
|
316
428
|
public updateTransform(transform: UpdateTransformOption): void {
|
|
317
429
|
this.setTransforms((transforms) =>
|
|
@@ -329,17 +441,48 @@ export class Graph extends EventEmitter {
|
|
|
329
441
|
*
|
|
330
442
|
* <en/> Get data transforms
|
|
331
443
|
* @returns <zh/> 数据转换器实例 | <en/> data transform instance
|
|
444
|
+
* @apiCategory transform
|
|
332
445
|
*/
|
|
333
446
|
public getTransforms(): TransformOptions {
|
|
334
447
|
return this.options.transforms || [];
|
|
335
448
|
}
|
|
336
449
|
|
|
450
|
+
/**
|
|
451
|
+
* <zh/> 获取数据
|
|
452
|
+
*
|
|
453
|
+
* <en/> Get data
|
|
454
|
+
* @returns <zh/> 数据 | <en/> data
|
|
455
|
+
* @apiCategory data
|
|
456
|
+
*/
|
|
337
457
|
public getData(): GraphData {
|
|
338
458
|
return this.context.model.getData();
|
|
339
459
|
}
|
|
340
460
|
|
|
461
|
+
/**
|
|
462
|
+
* <zh/> 获取所有节点数据
|
|
463
|
+
*
|
|
464
|
+
* <en/> Get all node data
|
|
465
|
+
* @returns <zh/> 节点数据 | <en/> node data
|
|
466
|
+
* @apiCategory data
|
|
467
|
+
*/
|
|
341
468
|
public getNodeData(): NodeData[];
|
|
469
|
+
/**
|
|
470
|
+
* <zh/> 获取单个节点数据
|
|
471
|
+
*
|
|
472
|
+
* <en/> Get single node data
|
|
473
|
+
* @param id - <zh/> 节点 ID | <en/> node ID
|
|
474
|
+
* @returns <zh/> 节点数据 | <en/> node data
|
|
475
|
+
* @apiCategory data
|
|
476
|
+
*/
|
|
342
477
|
public getNodeData(id: ID): NodeData;
|
|
478
|
+
/**
|
|
479
|
+
* <zh/> 批量获取多个节点数据
|
|
480
|
+
*
|
|
481
|
+
* <en/> Get multiple node data in batch
|
|
482
|
+
* @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
|
|
483
|
+
* @returns <zh/> 节点数据 | <en/> node data
|
|
484
|
+
* @apiCategory data
|
|
485
|
+
*/
|
|
343
486
|
public getNodeData(ids: ID[]): NodeData[];
|
|
344
487
|
public getNodeData(id?: ID | ID[]): NodeData | NodeData[] {
|
|
345
488
|
if (id === undefined) return this.context.model.getNodeData();
|
|
@@ -347,8 +490,31 @@ export class Graph extends EventEmitter {
|
|
|
347
490
|
return this.context.model.getNodeData([id])?.[0];
|
|
348
491
|
}
|
|
349
492
|
|
|
493
|
+
/**
|
|
494
|
+
* <zh/> 获取所有边数据
|
|
495
|
+
*
|
|
496
|
+
* <en/> Get all edge data
|
|
497
|
+
* @returns <zh/> 边数据 | <en/> edge data
|
|
498
|
+
* @apiCategory data
|
|
499
|
+
*/
|
|
350
500
|
public getEdgeData(): EdgeData[];
|
|
501
|
+
/**
|
|
502
|
+
* <zh/> 获取单条边数据
|
|
503
|
+
*
|
|
504
|
+
* <en/> Get single edge data
|
|
505
|
+
* @param id - <zh/> 边 ID | <en/> edge ID
|
|
506
|
+
* @returns <zh/> 边数据 | <en/> edge data
|
|
507
|
+
* @apiCategory data
|
|
508
|
+
*/
|
|
351
509
|
public getEdgeData(id: ID): EdgeData;
|
|
510
|
+
/**
|
|
511
|
+
* <zh/> 批量获取多条边数据
|
|
512
|
+
*
|
|
513
|
+
* <en/> Get multiple edge data in batch
|
|
514
|
+
* @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
|
|
515
|
+
* @returns <zh/> 边数据 | <en/> edge data
|
|
516
|
+
* @apiCategory data
|
|
517
|
+
*/
|
|
352
518
|
public getEdgeData(ids: ID[]): EdgeData[];
|
|
353
519
|
public getEdgeData(id?: ID | ID[]): EdgeData | EdgeData[] {
|
|
354
520
|
if (id === undefined) return this.context.model.getEdgeData();
|
|
@@ -356,8 +522,31 @@ export class Graph extends EventEmitter {
|
|
|
356
522
|
return this.context.model.getEdgeData([id])?.[0];
|
|
357
523
|
}
|
|
358
524
|
|
|
525
|
+
/**
|
|
526
|
+
* <zh/> 获取所有组合数据
|
|
527
|
+
*
|
|
528
|
+
* <en/> Get all combo data
|
|
529
|
+
* @returns <zh/> 组合数据 | <en/> combo data
|
|
530
|
+
* @apiCategory data
|
|
531
|
+
*/
|
|
359
532
|
public getComboData(): ComboData[];
|
|
533
|
+
/**
|
|
534
|
+
* <zh/> 获取单个组合数据
|
|
535
|
+
*
|
|
536
|
+
* <en/> Get single combo data
|
|
537
|
+
* @param id - <zh/> 组合ID | <en/> combo ID
|
|
538
|
+
* @returns <zh/> 组合数据 | <en/> combo data
|
|
539
|
+
* @apiCategory data
|
|
540
|
+
*/
|
|
360
541
|
public getComboData(id: ID): ComboData;
|
|
542
|
+
/**
|
|
543
|
+
* <zh/> 批量获取多个组合数据
|
|
544
|
+
*
|
|
545
|
+
* <en/> Get multiple combo data in batch
|
|
546
|
+
* @param ids - <zh/> 组合ID 数组 | <en/> combo ID array
|
|
547
|
+
* @returns <zh/> 组合数据 | <en/> combo data
|
|
548
|
+
* @apiCategory data
|
|
549
|
+
*/
|
|
361
550
|
public getComboData(ids: ID[]): ComboData[];
|
|
362
551
|
public getComboData(id?: ID | ID[]): ComboData | ComboData[] {
|
|
363
552
|
if (id === undefined) return this.context.model.getComboData();
|
|
@@ -365,111 +554,254 @@ export class Graph extends EventEmitter {
|
|
|
365
554
|
return this.context.model.getComboData([id])?.[0];
|
|
366
555
|
}
|
|
367
556
|
|
|
557
|
+
/**
|
|
558
|
+
* <zh/> 设置全量数据
|
|
559
|
+
*
|
|
560
|
+
* <en/> Set full data
|
|
561
|
+
* @param data - <zh/> 数据 | <en/> data
|
|
562
|
+
* @apiCategory data
|
|
563
|
+
*/
|
|
368
564
|
public setData(data: CallableValue<GraphData>): void {
|
|
369
565
|
this.context.model.setData(isFunction(data) ? data(this.getData()) : data);
|
|
370
566
|
}
|
|
371
567
|
|
|
568
|
+
/**
|
|
569
|
+
* <zh/> 新增元素数据
|
|
570
|
+
*
|
|
571
|
+
* <en/> Add element data
|
|
572
|
+
* @param data - <zh/> 元素数据 | <en/> element data
|
|
573
|
+
* @apiCategory data
|
|
574
|
+
*/
|
|
372
575
|
public addData(data: CallableValue<GraphData>): void {
|
|
373
576
|
this.context.model.addData(isFunction(data) ? data(this.getData()) : data);
|
|
374
577
|
}
|
|
375
578
|
|
|
579
|
+
/**
|
|
580
|
+
* <zh/> 新增节点数据
|
|
581
|
+
*
|
|
582
|
+
* <en/> Add node data
|
|
583
|
+
* @param data - <zh/> 节点数据 | <en/> node data
|
|
584
|
+
* @apiCategory data
|
|
585
|
+
*/
|
|
376
586
|
public addNodeData(data: CallableValue<NodeData[]>): void {
|
|
377
587
|
this.context.model.addNodeData(isFunction(data) ? data(this.getNodeData()) : data);
|
|
378
588
|
}
|
|
379
589
|
|
|
590
|
+
/**
|
|
591
|
+
* <zh/> 新增边数据
|
|
592
|
+
*
|
|
593
|
+
* <en/> Add edge data
|
|
594
|
+
* @param data - <zh/> 边数据 | <en/> edge data
|
|
595
|
+
* @apiCategory data
|
|
596
|
+
*/
|
|
380
597
|
public addEdgeData(data: CallableValue<EdgeData[]>): void {
|
|
381
598
|
this.context.model.addEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
|
|
382
599
|
}
|
|
383
600
|
|
|
601
|
+
/**
|
|
602
|
+
* <zh/> 新增组合数据
|
|
603
|
+
*
|
|
604
|
+
* <en/> Add combo data
|
|
605
|
+
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
606
|
+
* @apiCategory data
|
|
607
|
+
*/
|
|
384
608
|
public addComboData(data: CallableValue<ComboData[]>): void {
|
|
385
609
|
this.context.model.addComboData(isFunction(data) ? data(this.getComboData()) : data);
|
|
386
610
|
}
|
|
387
611
|
|
|
612
|
+
/**
|
|
613
|
+
* <zh/> 更新元素数据
|
|
614
|
+
*
|
|
615
|
+
* <en/> Update element data
|
|
616
|
+
* @param data - <zh/> 元素数据 | <en/> element data
|
|
617
|
+
* @apiCategory data
|
|
618
|
+
*/
|
|
388
619
|
public updateData(data: CallableValue<PartialGraphData>): void {
|
|
389
620
|
this.context.model.updateData(isFunction(data) ? data(this.getData()) : data);
|
|
390
621
|
}
|
|
391
622
|
|
|
623
|
+
/**
|
|
624
|
+
* <zh/> 更新节点数据
|
|
625
|
+
*
|
|
626
|
+
* <en/> Update node data
|
|
627
|
+
* @param data - <zh/> 节点数据 | <en/> node data
|
|
628
|
+
* @apiCategory data
|
|
629
|
+
*/
|
|
392
630
|
public updateNodeData(data: CallableValue<PartialNodeLikeData<NodeData>[]>): void {
|
|
393
631
|
this.context.model.updateNodeData(isFunction(data) ? data(this.getNodeData()) : data);
|
|
394
632
|
}
|
|
395
633
|
|
|
634
|
+
/**
|
|
635
|
+
* <zh/> 更新边数据
|
|
636
|
+
*
|
|
637
|
+
* <en/> Update edge data
|
|
638
|
+
* @param data - <zh/> 边数据 | <en/> edge data
|
|
639
|
+
* @apiCategory data
|
|
640
|
+
*/
|
|
396
641
|
public updateEdgeData(data: CallableValue<PartialEdgeData<EdgeData>[]>): void {
|
|
397
642
|
this.context.model.updateEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
|
|
398
643
|
}
|
|
399
644
|
|
|
645
|
+
/**
|
|
646
|
+
* <zh/> 更新 组合数据
|
|
647
|
+
*
|
|
648
|
+
* <en/> Update combo data
|
|
649
|
+
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
650
|
+
* @apiCategory data
|
|
651
|
+
*/
|
|
400
652
|
public updateComboData(data: CallableValue<PartialNodeLikeData<ComboData>[]>): void {
|
|
401
653
|
this.context.model.updateComboData(isFunction(data) ? data(this.getComboData()) : data);
|
|
402
654
|
}
|
|
403
655
|
|
|
404
|
-
|
|
405
|
-
|
|
656
|
+
/**
|
|
657
|
+
* <zh/> 删除多条元素数据
|
|
658
|
+
*
|
|
659
|
+
* <en/> Remove multiple element data
|
|
660
|
+
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
661
|
+
* @apiCategory data
|
|
662
|
+
*/
|
|
663
|
+
public removeData(ids: DataID | ((data: GraphData) => DataID)): void {
|
|
664
|
+
this.context.model.removeData(isFunction(ids) ? ids(this.getData()) : ids);
|
|
406
665
|
}
|
|
407
666
|
|
|
667
|
+
/**
|
|
668
|
+
* <zh/> 删除多条节点数据
|
|
669
|
+
*
|
|
670
|
+
* <en/> Remove multiple node data
|
|
671
|
+
* @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
|
|
672
|
+
* @apiCategory data
|
|
673
|
+
*/
|
|
408
674
|
public removeNodeData(ids: ID[] | ((data: NodeData[]) => ID[])): void {
|
|
409
675
|
this.context.model.removeNodeData(isFunction(ids) ? ids(this.getNodeData()) : ids);
|
|
410
676
|
}
|
|
411
677
|
|
|
678
|
+
/**
|
|
679
|
+
* <zh/> 删除多条边数据
|
|
680
|
+
*
|
|
681
|
+
* <en/> Remove multiple edge data
|
|
682
|
+
* @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
|
|
683
|
+
* @apiCategory data
|
|
684
|
+
*/
|
|
412
685
|
public removeEdgeData(ids: ID[] | ((data: EdgeData[]) => ID[])): void {
|
|
413
686
|
this.context.model.removeEdgeData(isFunction(ids) ? ids(this.getEdgeData()) : ids);
|
|
414
687
|
}
|
|
415
688
|
|
|
689
|
+
/**
|
|
690
|
+
* <zh/> 删除多条组合数据
|
|
691
|
+
*
|
|
692
|
+
* <en/> Remove multiple combo data
|
|
693
|
+
* @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
|
|
694
|
+
* @apiCategory data
|
|
695
|
+
*/
|
|
416
696
|
public removeComboData(ids: ID[] | ((data: ComboData[]) => ID[])): void {
|
|
417
697
|
this.context.model.removeComboData(isFunction(ids) ? ids(this.getComboData()) : ids);
|
|
418
698
|
}
|
|
419
699
|
|
|
700
|
+
/**
|
|
701
|
+
* <zh/> 获取元素类型
|
|
702
|
+
*
|
|
703
|
+
* <en/> Get element type
|
|
704
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
705
|
+
* @returns <zh/> 元素类型 | <en/> element type
|
|
706
|
+
* @apiCategory element
|
|
707
|
+
*/
|
|
420
708
|
public getElementType(id: ID): ElementType {
|
|
421
709
|
return this.context.model.getElementType(id);
|
|
422
710
|
}
|
|
423
711
|
|
|
712
|
+
/**
|
|
713
|
+
* <zh/> 获取节点或组合相关的边数据
|
|
714
|
+
*
|
|
715
|
+
* <en/> Get the edge data related to the node or combo
|
|
716
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
717
|
+
* @param direction - <zh/> 边的方向 | <en/> edge direction
|
|
718
|
+
* @returns <zh/> 边数据 | <en/> edge data
|
|
719
|
+
* @apiCategory data
|
|
720
|
+
*/
|
|
424
721
|
public getRelatedEdgesData(id: ID, direction: EdgeDirection = 'both'): EdgeData[] {
|
|
425
722
|
return this.context.model.getRelatedEdgesData(id, direction);
|
|
426
723
|
}
|
|
427
724
|
|
|
725
|
+
/**
|
|
726
|
+
* <zh/> 获取节点或组合的一跳邻居节点数据
|
|
727
|
+
*
|
|
728
|
+
* <en/> Get the one-hop neighbor node data of the node or combo
|
|
729
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
730
|
+
* @returns <zh/> 邻居节点数据 | <en/> neighbor node data
|
|
731
|
+
* @apiCategory data
|
|
732
|
+
*/
|
|
428
733
|
public getNeighborNodesData(id: ID): NodeData[] {
|
|
429
734
|
return this.context.model.getNeighborNodesData(id);
|
|
430
735
|
}
|
|
431
736
|
|
|
432
737
|
/**
|
|
433
|
-
* <zh/>
|
|
738
|
+
* <zh/> 获取节点或组合的祖先元素数据
|
|
434
739
|
*
|
|
435
740
|
* <en/> Get the ancestor element data of the node or combo
|
|
436
|
-
* @param id - <zh/>
|
|
437
|
-
* @param hierarchy - <zh/>
|
|
741
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
742
|
+
* @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
|
|
438
743
|
* @returns <zh/> 祖先元素数据 | <en/> ancestor element data
|
|
439
|
-
* @
|
|
744
|
+
* @remarks
|
|
440
745
|
* <zh/> 数组中的顺序是从父节点到祖先节点
|
|
441
746
|
*
|
|
442
747
|
* <en/> The order in the array is from the parent node to the ancestor node
|
|
748
|
+
* @apiCategory data
|
|
443
749
|
*/
|
|
444
750
|
public getAncestorsData(id: ID, hierarchy: HierarchyKey): NodeLikeData[] {
|
|
445
751
|
return this.context.model.getAncestorsData(id, hierarchy);
|
|
446
752
|
}
|
|
447
753
|
|
|
448
754
|
/**
|
|
449
|
-
* <zh/>
|
|
755
|
+
* <zh/> 获取节点或组合的父元素数据
|
|
450
756
|
*
|
|
451
757
|
* <en/> Get the parent element data of the node or combo
|
|
452
|
-
* @param id - <zh/>
|
|
453
|
-
* @param hierarchy - <zh/>
|
|
758
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
759
|
+
* @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
|
|
454
760
|
* @returns <zh/> 父元素数据 | <en/> parent element data
|
|
761
|
+
* @apiCategory data
|
|
455
762
|
*/
|
|
456
763
|
public getParentData(id: ID, hierarchy: HierarchyKey): NodeLikeData | undefined {
|
|
457
764
|
return this.context.model.getParentData(id, hierarchy);
|
|
458
765
|
}
|
|
459
766
|
|
|
460
767
|
/**
|
|
461
|
-
* <zh/>
|
|
768
|
+
* <zh/> 获取节点或组合的子元素数据
|
|
462
769
|
*
|
|
463
770
|
* <en/> Get the child element data of the node or combo
|
|
464
|
-
* @param id - <zh/>
|
|
771
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
465
772
|
* @returns <zh/> 子元素数据 | <en/> child element data
|
|
773
|
+
* @apiCategory data
|
|
466
774
|
*/
|
|
467
775
|
public getChildrenData(id: ID): NodeLikeData[] {
|
|
468
776
|
return this.context.model.getChildrenData(id);
|
|
469
777
|
}
|
|
470
778
|
|
|
779
|
+
/**
|
|
780
|
+
* <zh/> 获取具体某一状态下的节点数据
|
|
781
|
+
*
|
|
782
|
+
* <en/> Get node data in a specific state
|
|
783
|
+
* @param state - <zh/> 状态 | <en/> state
|
|
784
|
+
* @returns <zh/> 节点数据 | <en/> node data
|
|
785
|
+
* @apiCategory data
|
|
786
|
+
*/
|
|
471
787
|
public getElementDataByState(elementType: 'node', state: State): NodeData[];
|
|
788
|
+
/**
|
|
789
|
+
* <zh/> 获取具体某一状态下的边数据
|
|
790
|
+
*
|
|
791
|
+
* <en/> Get edge data in a specific state
|
|
792
|
+
* @param state - <zh/> 状态 | <en/> state
|
|
793
|
+
* @returns <zh/> 边数据 | <en/> edge data
|
|
794
|
+
* @apiCategory data
|
|
795
|
+
*/
|
|
472
796
|
public getElementDataByState(elementType: 'edge', state: State): EdgeData[];
|
|
797
|
+
/**
|
|
798
|
+
* <zh/> 获取具体某一状态下的组合数据
|
|
799
|
+
*
|
|
800
|
+
* <en/> Get combo data in a specific state
|
|
801
|
+
* @param state - <zh/> 状态 | <en/> state
|
|
802
|
+
* @returns <zh/> 组合数据 | <en/> combo data
|
|
803
|
+
* @apiCategory data
|
|
804
|
+
*/
|
|
473
805
|
public getElementDataByState(elementType: 'combo', state: State): ComboData[];
|
|
474
806
|
public getElementDataByState(elementType: ElementType, state: State): ElementDatum[] {
|
|
475
807
|
return this.context.model.getElementDataByState(elementType, state);
|
|
@@ -486,13 +818,14 @@ export class Graph extends EventEmitter {
|
|
|
486
818
|
await container.init();
|
|
487
819
|
} else {
|
|
488
820
|
const $container = isString(container) ? document.getElementById(container!) : container;
|
|
821
|
+
const containerSize = sizeOf($container!);
|
|
489
822
|
|
|
490
823
|
this.emit(GraphEvent.BEFORE_CANVAS_INIT, { container: $container, width, height });
|
|
491
824
|
|
|
492
825
|
const canvas = new Canvas({
|
|
493
826
|
container: $container!,
|
|
494
|
-
width,
|
|
495
|
-
height,
|
|
827
|
+
width: width || containerSize[0],
|
|
828
|
+
height: height || containerSize[1],
|
|
496
829
|
renderer,
|
|
497
830
|
});
|
|
498
831
|
|
|
@@ -502,7 +835,7 @@ export class Graph extends EventEmitter {
|
|
|
502
835
|
}
|
|
503
836
|
}
|
|
504
837
|
|
|
505
|
-
private
|
|
838
|
+
private initRuntime() {
|
|
506
839
|
this.context.options = this.options;
|
|
507
840
|
if (!this.context.batch) this.context.batch = new BatchController(this.context);
|
|
508
841
|
if (!this.context.plugin) this.context.plugin = new PluginController(this.context);
|
|
@@ -514,24 +847,29 @@ export class Graph extends EventEmitter {
|
|
|
514
847
|
}
|
|
515
848
|
|
|
516
849
|
private async prepare(): Promise<void> {
|
|
850
|
+
// 等待同步任务执行完成,避免 render 后立即调用 destroy 导致的问题
|
|
851
|
+
// Wait for synchronous tasks to complete, to avoid problems caused by calling destroy immediately after render
|
|
852
|
+
await Promise.resolve();
|
|
853
|
+
|
|
517
854
|
if (this.destroyed) throw new Error('Graph has been destroyed');
|
|
518
855
|
|
|
519
856
|
await this.initCanvas();
|
|
520
|
-
this.
|
|
857
|
+
this.initRuntime();
|
|
521
858
|
}
|
|
522
859
|
|
|
523
860
|
/**
|
|
524
861
|
* <zh/> 执行渲染
|
|
525
862
|
*
|
|
526
863
|
* <en/> Render
|
|
527
|
-
* @
|
|
864
|
+
* @remarks
|
|
528
865
|
* <zh/> 此过程会执行数据更新、绘制元素、执行布局
|
|
529
866
|
*
|
|
530
867
|
* <en/> This process will execute data update, element rendering, and layout execution
|
|
868
|
+
* @apiCategory render
|
|
531
869
|
*/
|
|
532
870
|
public async render(): Promise<void> {
|
|
533
|
-
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_RENDER));
|
|
534
871
|
await this.prepare();
|
|
872
|
+
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_RENDER));
|
|
535
873
|
await Promise.all([this.context.element?.draw(), this.context.layout?.layout()]);
|
|
536
874
|
await this.autoFit();
|
|
537
875
|
emit(this, new GraphLifeCycleEvent(GraphEvent.AFTER_RENDER));
|
|
@@ -542,31 +880,57 @@ export class Graph extends EventEmitter {
|
|
|
542
880
|
*
|
|
543
881
|
* <en/> Draw elements
|
|
544
882
|
* @returns <zh/> 渲染结果 | <en/> draw result
|
|
883
|
+
* @apiCategory element
|
|
545
884
|
*/
|
|
546
885
|
public async draw(): Promise<void> {
|
|
547
886
|
await this.prepare();
|
|
548
887
|
return this.context.element!.draw();
|
|
549
888
|
}
|
|
550
889
|
|
|
551
|
-
|
|
552
|
-
|
|
890
|
+
/**
|
|
891
|
+
* <zh/> 执行布局
|
|
892
|
+
*
|
|
893
|
+
* <en/> Execute layout
|
|
894
|
+
* @apiCategory layout
|
|
895
|
+
*/
|
|
896
|
+
public layout() {
|
|
897
|
+
this.context.layout!.layout();
|
|
553
898
|
}
|
|
554
899
|
|
|
900
|
+
/**
|
|
901
|
+
* <zh/> 停止布局
|
|
902
|
+
*
|
|
903
|
+
* <en/> Stop layout
|
|
904
|
+
* @remarks
|
|
905
|
+
* <zh/> 适用于带有迭代动画的布局,目前有 `force` 属于此类布局,即停止力导布局的迭代,一般用于布局迭代时间过长情况下的手动停止迭代动画,例如在点击画布/节点的监听中调用
|
|
906
|
+
*
|
|
907
|
+
* <en/> Suitable for layouts with iterative animations. Currently, `force` belongs to this type of layout, that is, stop the iteration of the force-directed layout. It is generally used to manually stop the iteration animation when the layout iteration time is too long, such as calling in the click canvas/node listener
|
|
908
|
+
* @apiCategory layout
|
|
909
|
+
*/
|
|
555
910
|
public stopLayout() {
|
|
556
|
-
|
|
911
|
+
this.context.layout!.stopLayout();
|
|
557
912
|
}
|
|
558
913
|
|
|
559
914
|
/**
|
|
560
915
|
* <zh/> 清空画布元素
|
|
561
916
|
*
|
|
562
917
|
* <en/> Clear canvas elements
|
|
918
|
+
* @apiCategory canvas
|
|
563
919
|
*/
|
|
564
920
|
public async clear(): Promise<void> {
|
|
565
921
|
this.context.model.setData({});
|
|
566
922
|
await this.draw();
|
|
567
923
|
}
|
|
568
924
|
|
|
925
|
+
/**
|
|
926
|
+
* <zh/> 销毁当前图实例
|
|
927
|
+
*
|
|
928
|
+
* <en/> Destroy the current graph instance
|
|
929
|
+
* @apiCategory instance
|
|
930
|
+
*/
|
|
569
931
|
public destroy(): void {
|
|
932
|
+
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_DESTROY));
|
|
933
|
+
|
|
570
934
|
const { layout, element, model, canvas, behavior, plugin } = this.context;
|
|
571
935
|
plugin?.destroy();
|
|
572
936
|
behavior?.destroy();
|
|
@@ -582,13 +946,36 @@ export class Graph extends EventEmitter {
|
|
|
582
946
|
window.removeEventListener('resize', this.onResize);
|
|
583
947
|
|
|
584
948
|
this.destroyed = true;
|
|
949
|
+
|
|
950
|
+
emit(this, new GraphLifeCycleEvent(GraphEvent.AFTER_DESTROY));
|
|
585
951
|
}
|
|
586
952
|
|
|
953
|
+
/**
|
|
954
|
+
* <zh/> 获取画布实例
|
|
955
|
+
*
|
|
956
|
+
* <en/> Get canvas instance
|
|
957
|
+
* @returns - <zh/> 画布实例 | <en/> canvas instance
|
|
958
|
+
* @apiCategory canvas
|
|
959
|
+
*/
|
|
587
960
|
public getCanvas(): Canvas {
|
|
588
961
|
return this.context.canvas;
|
|
589
962
|
}
|
|
590
963
|
|
|
964
|
+
/**
|
|
965
|
+
* <zh/> 调整画布大小为图容器大小
|
|
966
|
+
*
|
|
967
|
+
* <en/> Resize the canvas to the size of the graph container
|
|
968
|
+
* @apiCategory viewport
|
|
969
|
+
*/
|
|
591
970
|
public resize(): void;
|
|
971
|
+
/**
|
|
972
|
+
* <zh/> 调整画布大小为指定宽高
|
|
973
|
+
*
|
|
974
|
+
* <en/> Resize the canvas to the specified width and height
|
|
975
|
+
* @param width - <zh/> 宽度 | <en/> width
|
|
976
|
+
* @param height - <zh/> 高度 | <en/> height
|
|
977
|
+
* @apiCategory viewport
|
|
978
|
+
*/
|
|
592
979
|
public resize(width: number, height: number): void;
|
|
593
980
|
public resize(width?: number, height?: number): void {
|
|
594
981
|
const size: Vector2 = !width || !height ? sizeOf(this.context.canvas!.getContainer()!) : [width, height];
|
|
@@ -604,6 +991,7 @@ export class Graph extends EventEmitter {
|
|
|
604
991
|
* <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
|
|
605
992
|
* @param options - <zh/> 适配配置 | <en/> fit options
|
|
606
993
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
994
|
+
* @apiCategory viewport
|
|
607
995
|
*/
|
|
608
996
|
public async fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
609
997
|
await this.context.viewport?.fitView(options, animation);
|
|
@@ -614,6 +1002,7 @@ export class Graph extends EventEmitter {
|
|
|
614
1002
|
*
|
|
615
1003
|
* <en/> Move the graph to the center of the viewport
|
|
616
1004
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1005
|
+
* @apiCategory viewport
|
|
617
1006
|
*/
|
|
618
1007
|
public async fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
619
1008
|
await this.context.viewport?.fitCenter(animation);
|
|
@@ -633,6 +1022,14 @@ export class Graph extends EventEmitter {
|
|
|
633
1022
|
}
|
|
634
1023
|
}
|
|
635
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* <zh/> 移动图,使得元素对齐到视口中心
|
|
1027
|
+
*
|
|
1028
|
+
* <en/> Move the graph so that the element is aligned to the center of the viewport
|
|
1029
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1030
|
+
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1031
|
+
* @apiCategory viewport
|
|
1032
|
+
*/
|
|
636
1033
|
public async focusElement(id: ID | ID[], animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
637
1034
|
await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
|
|
638
1035
|
}
|
|
@@ -644,13 +1041,15 @@ export class Graph extends EventEmitter {
|
|
|
644
1041
|
* @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
|
|
645
1042
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
646
1043
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
647
|
-
* @
|
|
1044
|
+
* @remarks
|
|
648
1045
|
* <zh/>
|
|
649
1046
|
* - ratio > 1 放大
|
|
650
1047
|
* - ratio < 1 缩小
|
|
1048
|
+
*
|
|
651
1049
|
* <en/>
|
|
652
1050
|
* - ratio > 1 zoom in
|
|
653
1051
|
* - ratio < 1 zoom out
|
|
1052
|
+
* @apiCategory viewport
|
|
654
1053
|
*/
|
|
655
1054
|
public async zoomBy(ratio: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
|
|
656
1055
|
await this.context.viewport!.transform({ mode: 'relative', scale: ratio, origin }, animation);
|
|
@@ -663,15 +1062,17 @@ export class Graph extends EventEmitter {
|
|
|
663
1062
|
* @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
|
|
664
1063
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
665
1064
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
666
|
-
* @
|
|
1065
|
+
* @remarks
|
|
667
1066
|
* <zh/>
|
|
668
1067
|
* - zoom = 1 默认大小
|
|
669
1068
|
* - zoom > 1 放大
|
|
670
1069
|
* - zoom < 1 缩小
|
|
1070
|
+
*
|
|
671
1071
|
* <en/>
|
|
672
1072
|
* - zoom = 1 default size
|
|
673
1073
|
* - zoom > 1 zoom in
|
|
674
1074
|
* - zoom < 1 zoom out
|
|
1075
|
+
* @apiCategory viewport
|
|
675
1076
|
*/
|
|
676
1077
|
public async zoomTo(zoom: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
|
|
677
1078
|
this.context.viewport!.transform({ mode: 'absolute', scale: zoom, origin }, animation);
|
|
@@ -682,6 +1083,7 @@ export class Graph extends EventEmitter {
|
|
|
682
1083
|
*
|
|
683
1084
|
* <en/> Get the current zoom ratio
|
|
684
1085
|
* @returns <zh/> 缩放比例 | <en/> zoom ratio
|
|
1086
|
+
* @apiCategory viewport
|
|
685
1087
|
*/
|
|
686
1088
|
public getZoom(): number {
|
|
687
1089
|
return this.context.viewport!.getZoom();
|
|
@@ -694,6 +1096,7 @@ export class Graph extends EventEmitter {
|
|
|
694
1096
|
* @param angle - <zh/> 旋转角度 | <en/> rotation angle
|
|
695
1097
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
696
1098
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
1099
|
+
* @apiCategory viewport
|
|
697
1100
|
*/
|
|
698
1101
|
public async rotateBy(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
|
|
699
1102
|
await this.context.viewport!.transform({ mode: 'relative', rotate: angle, origin }, animation);
|
|
@@ -706,6 +1109,7 @@ export class Graph extends EventEmitter {
|
|
|
706
1109
|
* @param angle - <zh/> 目标角度 | <en/> target angle
|
|
707
1110
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
708
1111
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
1112
|
+
* @apiCategory viewport
|
|
709
1113
|
*/
|
|
710
1114
|
public async rotateTo(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
|
|
711
1115
|
await this.context.viewport!.transform({ mode: 'absolute', rotate: angle, origin }, animation);
|
|
@@ -716,6 +1120,7 @@ export class Graph extends EventEmitter {
|
|
|
716
1120
|
*
|
|
717
1121
|
* <en/> Get the current rotation angle
|
|
718
1122
|
* @returns <zh/> 旋转角度 | <en/> rotation angle
|
|
1123
|
+
* @apiCategory viewport
|
|
719
1124
|
*/
|
|
720
1125
|
public getRotation(): number {
|
|
721
1126
|
return this.context.viewport!.getRotation();
|
|
@@ -727,6 +1132,7 @@ export class Graph extends EventEmitter {
|
|
|
727
1132
|
* <en/> Translate the graph by the specified distance
|
|
728
1133
|
* @param offset - <zh/> 偏移量 | <en/> offset
|
|
729
1134
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1135
|
+
* @apiCategory viewport
|
|
730
1136
|
*/
|
|
731
1137
|
public async translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
732
1138
|
await this.context.viewport!.transform({ mode: 'relative', translate: offset }, animation);
|
|
@@ -738,7 +1144,7 @@ export class Graph extends EventEmitter {
|
|
|
738
1144
|
* <en/> Translate the graph to the specified position
|
|
739
1145
|
* @param position - <zh/> 指定位置 | <en/> specified position
|
|
740
1146
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
741
|
-
* @
|
|
1147
|
+
* @apiCategory viewport
|
|
742
1148
|
*/
|
|
743
1149
|
public async translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
744
1150
|
await this.context.viewport!.transform({ mode: 'absolute', translate: position }, animation);
|
|
@@ -749,10 +1155,11 @@ export class Graph extends EventEmitter {
|
|
|
749
1155
|
*
|
|
750
1156
|
* <en/> Get the position of the graph
|
|
751
1157
|
* @returns <zh/> 图的位置 | <en/> position of the graph
|
|
752
|
-
* @
|
|
1158
|
+
* @remarks
|
|
753
1159
|
* <zh/> 默认状态下,图的位置为 [0, 0]
|
|
754
1160
|
*
|
|
755
1161
|
* <en/> By default, the position of the graph is [0, 0]
|
|
1162
|
+
* @apiCategory viewport
|
|
756
1163
|
*/
|
|
757
1164
|
public getPosition(): Point {
|
|
758
1165
|
return subtract([0, 0], this.getCanvasByViewport([0, 0]));
|
|
@@ -764,7 +1171,8 @@ export class Graph extends EventEmitter {
|
|
|
764
1171
|
* <en/> Translate the element by the specified distance
|
|
765
1172
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
766
1173
|
* @param offset - <zh/> 偏移量 | <en/> offset
|
|
767
|
-
* @param animation - <zh/>
|
|
1174
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1175
|
+
* @apiCategory element
|
|
768
1176
|
*/
|
|
769
1177
|
public async translateElementBy(id: ID, offset: Position, animation?: boolean): Promise<void>;
|
|
770
1178
|
/**
|
|
@@ -772,7 +1180,8 @@ export class Graph extends EventEmitter {
|
|
|
772
1180
|
*
|
|
773
1181
|
* <en/> Batch translate elements by the specified distance
|
|
774
1182
|
* @param offsets - <zh/> 偏移量配置 | <en/> offset configuration
|
|
775
|
-
* @param animation - <zh/>
|
|
1183
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1184
|
+
* @apiCategory element
|
|
776
1185
|
*/
|
|
777
1186
|
public async translateElementBy(offsets: Record<ID, Position>, animation?: boolean): Promise<void>;
|
|
778
1187
|
public async translateElementBy(
|
|
@@ -794,7 +1203,8 @@ export class Graph extends EventEmitter {
|
|
|
794
1203
|
* <en/> Translate the element to the specified position
|
|
795
1204
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
796
1205
|
* @param position - <zh/> 指定位置 | <en/> specified position
|
|
797
|
-
* @param animation - <zh/>
|
|
1206
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1207
|
+
* @apiCategory element
|
|
798
1208
|
*/
|
|
799
1209
|
public async translateElementTo(id: ID, position: Position, animation?: boolean): Promise<void>;
|
|
800
1210
|
/**
|
|
@@ -802,7 +1212,8 @@ export class Graph extends EventEmitter {
|
|
|
802
1212
|
*
|
|
803
1213
|
* <en/> Batch translate elements to the specified position
|
|
804
1214
|
* @param positions - <zh/> 位置配置 | <en/> position configuration
|
|
805
|
-
* @param animation - <zh/>
|
|
1215
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1216
|
+
* @apiCategory element
|
|
806
1217
|
*/
|
|
807
1218
|
public async translateElementTo(positions: Record<ID, Position>, animation?: boolean): Promise<void>;
|
|
808
1219
|
public async translateElementTo(
|
|
@@ -818,10 +1229,26 @@ export class Graph extends EventEmitter {
|
|
|
818
1229
|
await this.context.element!.draw({ animation });
|
|
819
1230
|
}
|
|
820
1231
|
|
|
1232
|
+
/**
|
|
1233
|
+
* <zh/> 获取元素位置
|
|
1234
|
+
*
|
|
1235
|
+
* <en/> Get element position
|
|
1236
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1237
|
+
* @returns <zh/> 元素位置 | <en/> element position
|
|
1238
|
+
* @apiCategory element
|
|
1239
|
+
*/
|
|
821
1240
|
public getElementPosition(id: ID): Position {
|
|
822
1241
|
return this.context.model.getElementPosition(id);
|
|
823
1242
|
}
|
|
824
1243
|
|
|
1244
|
+
/**
|
|
1245
|
+
* <zh/> 获取元素渲染样式
|
|
1246
|
+
*
|
|
1247
|
+
* <en/> Get element rendering style
|
|
1248
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1249
|
+
* @returns <zh/> 元素渲染样式 | <en/> element rendering style
|
|
1250
|
+
* @apiCategory element
|
|
1251
|
+
*/
|
|
825
1252
|
public getElementRenderStyle(id: ID) {
|
|
826
1253
|
return omit(this.context.element!.getElement(id)!.attributes, ['context']);
|
|
827
1254
|
}
|
|
@@ -833,6 +1260,7 @@ export class Graph extends EventEmitter {
|
|
|
833
1260
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
834
1261
|
* @param visibility - <zh/> 可见性 | <en/> visibility
|
|
835
1262
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1263
|
+
* @apiCategory element
|
|
836
1264
|
*/
|
|
837
1265
|
public async setElementVisibility(
|
|
838
1266
|
id: ID,
|
|
@@ -845,6 +1273,7 @@ export class Graph extends EventEmitter {
|
|
|
845
1273
|
* <en/> Batch set element visibility
|
|
846
1274
|
* @param visibility - <zh/> 可见性配置 | <en/> visibility configuration
|
|
847
1275
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1276
|
+
* @apiCategory element
|
|
848
1277
|
*/
|
|
849
1278
|
public async setElementVisibility(
|
|
850
1279
|
visibility: Record<ID, BaseStyleProps['visibility']>,
|
|
@@ -874,7 +1303,8 @@ export class Graph extends EventEmitter {
|
|
|
874
1303
|
*
|
|
875
1304
|
* <en/> Show element
|
|
876
1305
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
877
|
-
* @param animation - <zh/>
|
|
1306
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1307
|
+
* @apiCategory element
|
|
878
1308
|
*/
|
|
879
1309
|
public async showElement(id: ID | ID[], animation?: boolean): Promise<void> {
|
|
880
1310
|
const ids = Array.isArray(id) ? id : [id];
|
|
@@ -889,7 +1319,8 @@ export class Graph extends EventEmitter {
|
|
|
889
1319
|
*
|
|
890
1320
|
* <en/> Hide element
|
|
891
1321
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
892
|
-
* @param animation - <zh/>
|
|
1322
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1323
|
+
* @apiCategory element
|
|
893
1324
|
*/
|
|
894
1325
|
public async hideElement(id: ID | ID[], animation?: boolean): Promise<void> {
|
|
895
1326
|
const ids = Array.isArray(id) ? id : [id];
|
|
@@ -905,6 +1336,7 @@ export class Graph extends EventEmitter {
|
|
|
905
1336
|
* <en/> Get element visibility
|
|
906
1337
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
907
1338
|
* @returns <zh/> 元素可见性 | <en/> element visibility
|
|
1339
|
+
* @apiCategory element
|
|
908
1340
|
*/
|
|
909
1341
|
public getElementVisibility(id: ID): BaseStyleProps['visibility'] {
|
|
910
1342
|
const element = this.context.element!.getElement(id)!;
|
|
@@ -917,6 +1349,7 @@ export class Graph extends EventEmitter {
|
|
|
917
1349
|
* <en/> Set element z-index
|
|
918
1350
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
919
1351
|
* @param zIndex - <zh/> 层级 | <en/> z-index
|
|
1352
|
+
* @apiCategory element
|
|
920
1353
|
*/
|
|
921
1354
|
public async setElementZIndex(id: ID, zIndex: number): Promise<void>;
|
|
922
1355
|
/**
|
|
@@ -924,6 +1357,7 @@ export class Graph extends EventEmitter {
|
|
|
924
1357
|
*
|
|
925
1358
|
* <en/> Batch set element z-index
|
|
926
1359
|
* @param zIndex - <zh/> 层级配置 | <en/> z-index configuration
|
|
1360
|
+
* @apiCategory element
|
|
927
1361
|
*/
|
|
928
1362
|
public async setElementZIndex(zIndex: Record<ID, number>): Promise<void>;
|
|
929
1363
|
public async setElementZIndex(args1: ID | Record<ID, number>, args2?: number): Promise<void> {
|
|
@@ -945,6 +1379,7 @@ export class Graph extends EventEmitter {
|
|
|
945
1379
|
*
|
|
946
1380
|
* <en/> Bring the element to the front
|
|
947
1381
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1382
|
+
* @apiCategory element
|
|
948
1383
|
*/
|
|
949
1384
|
public async frontElement(id: ID | ID[]): Promise<void> {
|
|
950
1385
|
const ids = Array.isArray(id) ? id : [id];
|
|
@@ -975,6 +1410,7 @@ export class Graph extends EventEmitter {
|
|
|
975
1410
|
* <en/> Get element z-index
|
|
976
1411
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
977
1412
|
* @returns <zh/> 元素层级 | <en/> element z-index
|
|
1413
|
+
* @apiCategory element
|
|
978
1414
|
*/
|
|
979
1415
|
public getElementZIndex(id: ID): number {
|
|
980
1416
|
return zIndexOf(this.context.model.getElementsData([id])[0]);
|
|
@@ -987,6 +1423,7 @@ export class Graph extends EventEmitter {
|
|
|
987
1423
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
988
1424
|
* @param state - <zh/> 状态 | <en/> state
|
|
989
1425
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1426
|
+
* @apiCategory element
|
|
990
1427
|
*/
|
|
991
1428
|
public async setElementState(id: ID, state: State | State[], animation?: boolean): Promise<void>;
|
|
992
1429
|
/**
|
|
@@ -995,6 +1432,7 @@ export class Graph extends EventEmitter {
|
|
|
995
1432
|
* <en/> Batch set element state
|
|
996
1433
|
* @param state - <zh/> 状态配置 | <en/> state configuration
|
|
997
1434
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1435
|
+
* @apiCategory element
|
|
998
1436
|
*/
|
|
999
1437
|
public async setElementState(state: Record<ID, State | State[]>, animation?: boolean): Promise<void>;
|
|
1000
1438
|
public async setElementState(
|
|
@@ -1027,21 +1465,46 @@ export class Graph extends EventEmitter {
|
|
|
1027
1465
|
* <en/> Get element state
|
|
1028
1466
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1029
1467
|
* @returns <zh/> 元素状态 | <en/> element state
|
|
1468
|
+
* @apiCategory element
|
|
1030
1469
|
*/
|
|
1031
1470
|
public getElementState(id: ID): State[] {
|
|
1032
1471
|
return this.context.model.getElementState(id);
|
|
1033
1472
|
}
|
|
1034
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* <zh/> 获取元素自身以及子节点在世界坐标系下的渲染包围盒
|
|
1476
|
+
*
|
|
1477
|
+
* <en/> Get the rendering bounding box of the element itself and its child nodes in the world coordinate system
|
|
1478
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1479
|
+
* @returns <zh/> 渲染包围盒 | <en/> render bounding box
|
|
1480
|
+
* @apiCategory element
|
|
1481
|
+
*/
|
|
1035
1482
|
public getElementRenderBounds(id: ID): AABB {
|
|
1036
1483
|
return this.context.element!.getElement(id)!.getRenderBounds();
|
|
1037
1484
|
}
|
|
1038
1485
|
|
|
1039
|
-
|
|
1486
|
+
/**
|
|
1487
|
+
* <zh/> 收起 Combo
|
|
1488
|
+
*
|
|
1489
|
+
* <en/> Collapse Combo
|
|
1490
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1491
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1492
|
+
* @apiCategory element
|
|
1493
|
+
*/
|
|
1494
|
+
public async collapseElement(id: ID, animation: boolean = true): Promise<void> {
|
|
1040
1495
|
this.setElementCollapsibility(id, true);
|
|
1041
1496
|
await this.context.element!.draw({ animation, stage: 'collapse' });
|
|
1042
1497
|
}
|
|
1043
1498
|
|
|
1044
|
-
|
|
1499
|
+
/**
|
|
1500
|
+
* <zh/> 展开 Combo
|
|
1501
|
+
*
|
|
1502
|
+
* <en/> Expand Combo
|
|
1503
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1504
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1505
|
+
* @apiCategory element
|
|
1506
|
+
*/
|
|
1507
|
+
public async expandElement(id: ID, animation: boolean = true): Promise<void> {
|
|
1045
1508
|
this.setElementCollapsibility(id, false);
|
|
1046
1509
|
await this.context.element!.draw({ animation, stage: 'expand' });
|
|
1047
1510
|
}
|
|
@@ -1057,33 +1520,58 @@ export class Graph extends EventEmitter {
|
|
|
1057
1520
|
*
|
|
1058
1521
|
* <en/> Export canvas content as DataURL
|
|
1059
1522
|
* @param options - <zh/> 导出配置 | <en/> export configuration
|
|
1060
|
-
* @param mode
|
|
1061
|
-
* <zh/> 导出模式
|
|
1062
|
-
* - viewport: 导出视口内容
|
|
1063
|
-
* - overall: 导出整个画布
|
|
1064
|
-
*
|
|
1065
|
-
* <en/> export mode
|
|
1066
|
-
* - viewport: export the content of the viewport
|
|
1067
|
-
* - overall: export the entire canvas
|
|
1068
1523
|
* @returns <zh/> DataURL | <en/> DataURL
|
|
1524
|
+
* @apiCategory exportImage
|
|
1069
1525
|
*/
|
|
1070
1526
|
public async toDataURL(options: Partial<DataURLOptions> = {}): Promise<string> {
|
|
1071
1527
|
return this.context.canvas!.toDataURL(options);
|
|
1072
1528
|
}
|
|
1073
1529
|
|
|
1530
|
+
/**
|
|
1531
|
+
* <zh/> 给定的视窗 DOM 坐标,转换为画布上的绘制坐标
|
|
1532
|
+
*
|
|
1533
|
+
* <en/> Convert the given viewport DOM coordinates to the drawing coordinates on the canvas
|
|
1534
|
+
* @param point - <zh/> 视窗坐标 | <en/> viewport coordinates
|
|
1535
|
+
* @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
|
|
1536
|
+
* @apiCategory viewport
|
|
1537
|
+
*/
|
|
1074
1538
|
public getCanvasByViewport(point: Point): Point {
|
|
1075
1539
|
return parsePoint(this.context.canvas!.viewport2Canvas(toPointObject(point)));
|
|
1076
1540
|
}
|
|
1077
1541
|
|
|
1542
|
+
/**
|
|
1543
|
+
* <zh/> 给定画布上的绘制坐标,转换为视窗 DOM 的坐标
|
|
1544
|
+
*
|
|
1545
|
+
* <en/> Convert the given drawing coordinates on the canvas to the coordinates of the viewport DOM
|
|
1546
|
+
* @param point - <zh/> 画布坐标 | <en/> canvas coordinates
|
|
1547
|
+
* @returns <zh/> 视窗 DOM 的坐标 | <en/> coordinates of the viewport DOM
|
|
1548
|
+
* @apiCategory viewport
|
|
1549
|
+
*/
|
|
1078
1550
|
public getViewportByCanvas(point: Point): Point {
|
|
1079
1551
|
return parsePoint(this.context.canvas.canvas2Viewport(toPointObject(point)));
|
|
1080
1552
|
}
|
|
1081
1553
|
|
|
1554
|
+
/**
|
|
1555
|
+
* <zh/> 给定画布上的绘制坐标,转换为浏览器坐标
|
|
1556
|
+
*
|
|
1557
|
+
* <en/> Convert the given drawing coordinates on the canvas to browser coordinates
|
|
1558
|
+
* @param point - <zh/> 画布坐标 | <en/> canvas coordinates
|
|
1559
|
+
* @returns <zh/> 浏览器坐标 | <en/> browser coordinates
|
|
1560
|
+
* @apiCategory viewport
|
|
1561
|
+
*/
|
|
1082
1562
|
public getClientByCanvas(point: Point): Point {
|
|
1083
1563
|
const viewportPoint = this.context.canvas.canvas2Viewport(toPointObject(point));
|
|
1084
1564
|
return parsePoint(this.context.canvas.viewport2Canvas(viewportPoint));
|
|
1085
1565
|
}
|
|
1086
1566
|
|
|
1567
|
+
/**
|
|
1568
|
+
* <zh/> 给定的浏览器坐标,转换为画布上的绘制坐标
|
|
1569
|
+
*
|
|
1570
|
+
* <en/> Convert the given browser coordinates to drawing coordinates on the canvas
|
|
1571
|
+
* @param point - <zh/> 浏览器坐标 | <en/> browser coordinates
|
|
1572
|
+
* @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
|
|
1573
|
+
* @apiCategory viewport
|
|
1574
|
+
*/
|
|
1087
1575
|
public getCanvasByClient(point: Point): Point {
|
|
1088
1576
|
const viewportPoint = this.context.canvas.client2Viewport(toPointObject(point));
|
|
1089
1577
|
return parsePoint(this.context.canvas.viewport2Canvas(viewportPoint));
|
|
@@ -1094,11 +1582,19 @@ export class Graph extends EventEmitter {
|
|
|
1094
1582
|
*
|
|
1095
1583
|
* <en/> Get the canvas coordinates of the viewport center
|
|
1096
1584
|
* @returns <zh/> 视口中心的画布坐标 | <en/> Canvas coordinates of the viewport center
|
|
1585
|
+
* @apiCategory viewport
|
|
1097
1586
|
*/
|
|
1098
1587
|
public getViewportCenter(): Point {
|
|
1099
1588
|
return this.context.viewport!.getViewportCenter();
|
|
1100
1589
|
}
|
|
1101
1590
|
|
|
1591
|
+
/**
|
|
1592
|
+
* <zh/> 获取画布中心的画布坐标
|
|
1593
|
+
*
|
|
1594
|
+
* <en/> Get the canvas coordinates of the canvas center
|
|
1595
|
+
* @returns <zh/> 画布中心的画布坐标 | <en/> Canvas coordinates of the canvas center
|
|
1596
|
+
* @apiCategory viewport
|
|
1597
|
+
*/
|
|
1102
1598
|
public getCanvasCenter(): Point {
|
|
1103
1599
|
return this.context.viewport!.getCanvasCenter();
|
|
1104
1600
|
}
|
|
@@ -1114,6 +1610,7 @@ export class Graph extends EventEmitter {
|
|
|
1114
1610
|
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
1115
1611
|
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
1116
1612
|
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1613
|
+
* @apiCategory event
|
|
1117
1614
|
*/
|
|
1118
1615
|
public on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
|
|
1119
1616
|
return super.on(eventName, callback);
|
|
@@ -1126,6 +1623,7 @@ export class Graph extends EventEmitter {
|
|
|
1126
1623
|
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
1127
1624
|
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
1128
1625
|
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1626
|
+
* @apiCategory event
|
|
1129
1627
|
*/
|
|
1130
1628
|
public once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
|
|
1131
1629
|
return super.once(eventName, callback);
|