@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/lib/runtime/graph.js
CHANGED
|
@@ -25,15 +25,21 @@ const transform_1 = require("./transform");
|
|
|
25
25
|
const viewport_1 = require("./viewport");
|
|
26
26
|
class Graph extends event_emitter_1.default {
|
|
27
27
|
options;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
28
31
|
static defaultOptions = {
|
|
29
32
|
autoResize: false,
|
|
30
|
-
width: 800,
|
|
31
|
-
height: 600,
|
|
32
33
|
theme: 'light',
|
|
33
34
|
rotation: 0,
|
|
34
35
|
zoom: 1,
|
|
35
36
|
zoomRange: [0.01, 10],
|
|
36
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* <zh/> 当前图实例是否已经被销毁
|
|
40
|
+
*
|
|
41
|
+
* <en/> Whether the current graph instance has been destroyed
|
|
42
|
+
*/
|
|
37
43
|
destroyed = false;
|
|
38
44
|
// @ts-expect-error will be initialized in createRuntime
|
|
39
45
|
context = {
|
|
@@ -52,6 +58,7 @@ class Graph extends event_emitter_1.default {
|
|
|
52
58
|
*
|
|
53
59
|
* <en/> Get options
|
|
54
60
|
* @returns <zh/> 配置项 | <en/> options
|
|
61
|
+
* @apiCategory option
|
|
55
62
|
*/
|
|
56
63
|
getOptions() {
|
|
57
64
|
return this.options;
|
|
@@ -61,10 +68,11 @@ class Graph extends event_emitter_1.default {
|
|
|
61
68
|
*
|
|
62
69
|
* <en/> Set options
|
|
63
70
|
* @param options - <zh/> 配置项 | <en/> options
|
|
64
|
-
* @
|
|
71
|
+
* @remarks
|
|
65
72
|
* <zh/> 要更新 devicePixelRatio、container 属性请销毁后重新创建实例
|
|
66
73
|
*
|
|
67
74
|
* <en/> To update devicePixelRatio and container properties, please destroy and recreate the instance
|
|
75
|
+
* @apiCategory option
|
|
68
76
|
*/
|
|
69
77
|
setOptions(options) {
|
|
70
78
|
const { animation, background, behaviors, combo, container, data, edge, height, layout, node, padding, plugins, theme, transforms, width, zoom, zoomRange, } = options;
|
|
@@ -94,43 +102,124 @@ class Graph extends event_emitter_1.default {
|
|
|
94
102
|
this.options.zoomRange = zoomRange;
|
|
95
103
|
if ((0, util_1.isNumber)(zoom))
|
|
96
104
|
this.options.zoom = zoom;
|
|
97
|
-
if ((0, util_1.isNumber)(padding))
|
|
105
|
+
if ((0, util_1.isNumber)(padding) || (0, util_1.isArray)(padding))
|
|
98
106
|
this.options.padding = padding;
|
|
99
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* <zh/> 设置画布背景色
|
|
110
|
+
*
|
|
111
|
+
* <en/> Set canvas background color
|
|
112
|
+
* @param background - <zh/> 背景色 | <en/> background color
|
|
113
|
+
* @apiCategory canvas
|
|
114
|
+
*/
|
|
100
115
|
setBackground(background) {
|
|
101
116
|
this.options.background = background;
|
|
102
117
|
this.context.canvas?.setBackground(background);
|
|
103
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* <zh/> 获取画布背景色
|
|
121
|
+
*
|
|
122
|
+
* <en/> Get canvas background color
|
|
123
|
+
* @returns <zh/> 背景色 | <en/> background color
|
|
124
|
+
* @apiCategory canvas
|
|
125
|
+
*/
|
|
104
126
|
getBackground() {
|
|
105
127
|
return this.options.background;
|
|
106
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* <zh/> 获取当前图容器的大小
|
|
131
|
+
*
|
|
132
|
+
* <en/> Get the size of the current canvas container
|
|
133
|
+
* @returns <zh/> 画布尺寸 | <en/> canvas size
|
|
134
|
+
* @apiCategory canvas
|
|
135
|
+
*/
|
|
107
136
|
getSize() {
|
|
108
137
|
if (this.context.canvas)
|
|
109
138
|
return this.context.canvas.getSize();
|
|
110
139
|
return [this.options.width || 0, this.options.height || 0];
|
|
111
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* <zh/> 获取当前图容器的大小
|
|
143
|
+
*
|
|
144
|
+
* <en/> Get the size of the current canvas container
|
|
145
|
+
* @param width - <zh/> 画布宽度 | <en/> canvas width
|
|
146
|
+
* @param height - <zh/> 画布高度 | <en/> canvas height
|
|
147
|
+
* @apiCategory canvas
|
|
148
|
+
*/
|
|
112
149
|
setSize(width, height) {
|
|
113
150
|
this.options.width = width;
|
|
114
151
|
this.options.height = height;
|
|
115
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* <zh/> 获取当前图的缩放区间
|
|
155
|
+
*
|
|
156
|
+
* <en/> Get the zoom range of the current graph
|
|
157
|
+
* @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
|
|
158
|
+
* @apiCategory viewport
|
|
159
|
+
*/
|
|
116
160
|
setZoomRange(zoomRange) {
|
|
117
161
|
this.options.zoomRange = zoomRange;
|
|
118
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* <zh/> 获取当前图的缩放区间
|
|
165
|
+
*
|
|
166
|
+
* <en/> Get the zoom range of the current graph
|
|
167
|
+
* @returns <zh/> 缩放区间 | <en/> zoom range
|
|
168
|
+
* @apiCategory viewport
|
|
169
|
+
*/
|
|
119
170
|
getZoomRange() {
|
|
120
171
|
return this.options.zoomRange;
|
|
121
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* <zh/> 设置节点样式映射
|
|
175
|
+
*
|
|
176
|
+
* <en/> Set node mapper
|
|
177
|
+
* @param node - <zh/> 节点配置 | <en/> node configuration
|
|
178
|
+
* @apiCategory element
|
|
179
|
+
*/
|
|
122
180
|
setNode(node) {
|
|
123
181
|
this.options.node = node;
|
|
182
|
+
this.context.model.refreshData();
|
|
124
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* <zh/> 设置边样式映射
|
|
186
|
+
*
|
|
187
|
+
* <en/> Set edge mapper
|
|
188
|
+
* @param edge - <zh/> 边配置 | <en/> edge configuration
|
|
189
|
+
* @apiCategory element
|
|
190
|
+
*/
|
|
125
191
|
setEdge(edge) {
|
|
126
192
|
this.options.edge = edge;
|
|
193
|
+
this.context.model.refreshData();
|
|
127
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* <zh/> 设置组合样式映射
|
|
197
|
+
*
|
|
198
|
+
* <en/> Set combo mapper
|
|
199
|
+
* @param combo - <zh/> 组合配置 | <en/> combo configuration
|
|
200
|
+
* @apiCategory element
|
|
201
|
+
*/
|
|
128
202
|
setCombo(combo) {
|
|
129
203
|
this.options.combo = combo;
|
|
204
|
+
this.context.model.refreshData();
|
|
130
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* <zh/> 获取主题
|
|
208
|
+
*
|
|
209
|
+
* <en/> Get theme
|
|
210
|
+
* @returns <zh/> 主题配置 | <en/> theme configuration
|
|
211
|
+
* @apiCategory theme
|
|
212
|
+
*/
|
|
131
213
|
getTheme() {
|
|
132
214
|
return this.options.theme;
|
|
133
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* <zh/> 设置主题
|
|
218
|
+
*
|
|
219
|
+
* <en/> Set theme
|
|
220
|
+
* @param theme - <zh/> 主题配置 | <en/> theme configuration
|
|
221
|
+
* @apiCategory theme
|
|
222
|
+
*/
|
|
134
223
|
setTheme(theme) {
|
|
135
224
|
this.options.theme = (0, util_1.isFunction)(theme) ? theme(this.getTheme()) : theme;
|
|
136
225
|
const { background } = (0, registry_1.getExtension)('theme', this.options.theme) || {};
|
|
@@ -138,9 +227,23 @@ class Graph extends event_emitter_1.default {
|
|
|
138
227
|
this.setBackground(background);
|
|
139
228
|
}
|
|
140
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* <zh/> 设置布局
|
|
232
|
+
*
|
|
233
|
+
* <en/> Set layout
|
|
234
|
+
* @param layout - <zh/> 布局配置 | <en/> layout configuration
|
|
235
|
+
* @apiCategory layout
|
|
236
|
+
*/
|
|
141
237
|
setLayout(layout) {
|
|
142
238
|
this.options.layout = (0, util_1.isFunction)(layout) ? layout(this.getLayout()) : layout;
|
|
143
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* <zh/> 获取布局
|
|
242
|
+
*
|
|
243
|
+
* <en/> Get layout
|
|
244
|
+
* @returns <zh/> 布局配置 | <en/> layout configuration
|
|
245
|
+
* @apiCategory layout
|
|
246
|
+
*/
|
|
144
247
|
getLayout() {
|
|
145
248
|
return this.options.layout;
|
|
146
249
|
}
|
|
@@ -149,6 +252,7 @@ class Graph extends event_emitter_1.default {
|
|
|
149
252
|
*
|
|
150
253
|
* <en/> Set behaviors
|
|
151
254
|
* @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
|
|
255
|
+
* @apiCategory behavior
|
|
152
256
|
*/
|
|
153
257
|
setBehaviors(behaviors) {
|
|
154
258
|
this.options.behaviors = (0, util_1.isFunction)(behaviors) ? behaviors(this.getBehaviors()) : behaviors;
|
|
@@ -159,6 +263,7 @@ class Graph extends event_emitter_1.default {
|
|
|
159
263
|
*
|
|
160
264
|
* <en/> Update behavior
|
|
161
265
|
* @param behavior - <zh/> 交互配置 | <en/> behavior configuration
|
|
266
|
+
* @apiCategory behavior
|
|
162
267
|
*/
|
|
163
268
|
updateBehavior(behavior) {
|
|
164
269
|
this.setBehaviors((behaviors) => behaviors.map((_behavior) => {
|
|
@@ -173,6 +278,7 @@ class Graph extends event_emitter_1.default {
|
|
|
173
278
|
*
|
|
174
279
|
* <en/> Get behaviors
|
|
175
280
|
* @returns <zh/> 交互配置 | <en/> behavior configuration
|
|
281
|
+
* @apiCategory behavior
|
|
176
282
|
*/
|
|
177
283
|
getBehaviors() {
|
|
178
284
|
return this.options.behaviors || [];
|
|
@@ -182,6 +288,7 @@ class Graph extends event_emitter_1.default {
|
|
|
182
288
|
*
|
|
183
289
|
* <en/> Set plugins
|
|
184
290
|
* @param plugins - <zh/> 插件配置 | <en/> plugin configuration
|
|
291
|
+
* @apiCategory plugin
|
|
185
292
|
*/
|
|
186
293
|
setPlugins(plugins) {
|
|
187
294
|
this.options.plugins = (0, util_1.isFunction)(plugins) ? plugins(this.getPlugins()) : plugins;
|
|
@@ -192,6 +299,7 @@ class Graph extends event_emitter_1.default {
|
|
|
192
299
|
*
|
|
193
300
|
* <en/> Update plugin
|
|
194
301
|
* @param plugin - <zh/> 插件配置 | <en/> plugin configuration
|
|
302
|
+
* @apiCategory plugin
|
|
195
303
|
*/
|
|
196
304
|
updatePlugin(plugin) {
|
|
197
305
|
this.setPlugins((plugins) => plugins.map((_plugin) => {
|
|
@@ -206,6 +314,7 @@ class Graph extends event_emitter_1.default {
|
|
|
206
314
|
*
|
|
207
315
|
* <en/> Get plugins
|
|
208
316
|
* @returns <zh/> 插件配置 | <en/> plugin configuration
|
|
317
|
+
* @apiCategory plugin
|
|
209
318
|
*/
|
|
210
319
|
getPlugins() {
|
|
211
320
|
return this.options.plugins || [];
|
|
@@ -216,6 +325,7 @@ class Graph extends event_emitter_1.default {
|
|
|
216
325
|
* <en/> Get plugin instance
|
|
217
326
|
* @param key - <zh/> 插件 key | <en/> plugin key
|
|
218
327
|
* @returns <zh/> 插件实例 | <en/> plugin instance
|
|
328
|
+
* @apiCategory plugin
|
|
219
329
|
*/
|
|
220
330
|
getPluginInstance(key) {
|
|
221
331
|
return this.context.plugin.getPluginInstance(key);
|
|
@@ -225,6 +335,7 @@ class Graph extends event_emitter_1.default {
|
|
|
225
335
|
*
|
|
226
336
|
* <en/> Set data transforms
|
|
227
337
|
* @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
|
|
338
|
+
* @apiCategory transform
|
|
228
339
|
*/
|
|
229
340
|
setTransforms(transforms) {
|
|
230
341
|
this.options.transforms = (0, util_1.isFunction)(transforms) ? transforms(this.getTransforms()) : transforms;
|
|
@@ -235,6 +346,7 @@ class Graph extends event_emitter_1.default {
|
|
|
235
346
|
*
|
|
236
347
|
* <en/> Update data transform
|
|
237
348
|
* @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
|
|
349
|
+
* @apiCategory transform
|
|
238
350
|
*/
|
|
239
351
|
updateTransform(transform) {
|
|
240
352
|
this.setTransforms((transforms) => transforms.map((_transform) => {
|
|
@@ -249,10 +361,18 @@ class Graph extends event_emitter_1.default {
|
|
|
249
361
|
*
|
|
250
362
|
* <en/> Get data transforms
|
|
251
363
|
* @returns <zh/> 数据转换器实例 | <en/> data transform instance
|
|
364
|
+
* @apiCategory transform
|
|
252
365
|
*/
|
|
253
366
|
getTransforms() {
|
|
254
367
|
return this.options.transforms || [];
|
|
255
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* <zh/> 获取数据
|
|
371
|
+
*
|
|
372
|
+
* <en/> Get data
|
|
373
|
+
* @returns <zh/> 数据 | <en/> data
|
|
374
|
+
* @apiCategory data
|
|
375
|
+
*/
|
|
256
376
|
getData() {
|
|
257
377
|
return this.context.model.getData();
|
|
258
378
|
}
|
|
@@ -277,86 +397,205 @@ class Graph extends event_emitter_1.default {
|
|
|
277
397
|
return this.context.model.getComboData(id);
|
|
278
398
|
return this.context.model.getComboData([id])?.[0];
|
|
279
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* <zh/> 设置全量数据
|
|
402
|
+
*
|
|
403
|
+
* <en/> Set full data
|
|
404
|
+
* @param data - <zh/> 数据 | <en/> data
|
|
405
|
+
* @apiCategory data
|
|
406
|
+
*/
|
|
280
407
|
setData(data) {
|
|
281
408
|
this.context.model.setData((0, util_1.isFunction)(data) ? data(this.getData()) : data);
|
|
282
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* <zh/> 新增元素数据
|
|
412
|
+
*
|
|
413
|
+
* <en/> Add element data
|
|
414
|
+
* @param data - <zh/> 元素数据 | <en/> element data
|
|
415
|
+
* @apiCategory data
|
|
416
|
+
*/
|
|
283
417
|
addData(data) {
|
|
284
418
|
this.context.model.addData((0, util_1.isFunction)(data) ? data(this.getData()) : data);
|
|
285
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* <zh/> 新增节点数据
|
|
422
|
+
*
|
|
423
|
+
* <en/> Add node data
|
|
424
|
+
* @param data - <zh/> 节点数据 | <en/> node data
|
|
425
|
+
* @apiCategory data
|
|
426
|
+
*/
|
|
286
427
|
addNodeData(data) {
|
|
287
428
|
this.context.model.addNodeData((0, util_1.isFunction)(data) ? data(this.getNodeData()) : data);
|
|
288
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* <zh/> 新增边数据
|
|
432
|
+
*
|
|
433
|
+
* <en/> Add edge data
|
|
434
|
+
* @param data - <zh/> 边数据 | <en/> edge data
|
|
435
|
+
* @apiCategory data
|
|
436
|
+
*/
|
|
289
437
|
addEdgeData(data) {
|
|
290
438
|
this.context.model.addEdgeData((0, util_1.isFunction)(data) ? data(this.getEdgeData()) : data);
|
|
291
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* <zh/> 新增组合数据
|
|
442
|
+
*
|
|
443
|
+
* <en/> Add combo data
|
|
444
|
+
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
445
|
+
* @apiCategory data
|
|
446
|
+
*/
|
|
292
447
|
addComboData(data) {
|
|
293
448
|
this.context.model.addComboData((0, util_1.isFunction)(data) ? data(this.getComboData()) : data);
|
|
294
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* <zh/> 更新元素数据
|
|
452
|
+
*
|
|
453
|
+
* <en/> Update element data
|
|
454
|
+
* @param data - <zh/> 元素数据 | <en/> element data
|
|
455
|
+
* @apiCategory data
|
|
456
|
+
*/
|
|
295
457
|
updateData(data) {
|
|
296
458
|
this.context.model.updateData((0, util_1.isFunction)(data) ? data(this.getData()) : data);
|
|
297
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* <zh/> 更新节点数据
|
|
462
|
+
*
|
|
463
|
+
* <en/> Update node data
|
|
464
|
+
* @param data - <zh/> 节点数据 | <en/> node data
|
|
465
|
+
* @apiCategory data
|
|
466
|
+
*/
|
|
298
467
|
updateNodeData(data) {
|
|
299
468
|
this.context.model.updateNodeData((0, util_1.isFunction)(data) ? data(this.getNodeData()) : data);
|
|
300
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* <zh/> 更新边数据
|
|
472
|
+
*
|
|
473
|
+
* <en/> Update edge data
|
|
474
|
+
* @param data - <zh/> 边数据 | <en/> edge data
|
|
475
|
+
* @apiCategory data
|
|
476
|
+
*/
|
|
301
477
|
updateEdgeData(data) {
|
|
302
478
|
this.context.model.updateEdgeData((0, util_1.isFunction)(data) ? data(this.getEdgeData()) : data);
|
|
303
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* <zh/> 更新 组合数据
|
|
482
|
+
*
|
|
483
|
+
* <en/> Update combo data
|
|
484
|
+
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
485
|
+
* @apiCategory data
|
|
486
|
+
*/
|
|
304
487
|
updateComboData(data) {
|
|
305
488
|
this.context.model.updateComboData((0, util_1.isFunction)(data) ? data(this.getComboData()) : data);
|
|
306
489
|
}
|
|
307
|
-
|
|
308
|
-
|
|
490
|
+
/**
|
|
491
|
+
* <zh/> 删除多条元素数据
|
|
492
|
+
*
|
|
493
|
+
* <en/> Remove multiple element data
|
|
494
|
+
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
495
|
+
* @apiCategory data
|
|
496
|
+
*/
|
|
497
|
+
removeData(ids) {
|
|
498
|
+
this.context.model.removeData((0, util_1.isFunction)(ids) ? ids(this.getData()) : ids);
|
|
309
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* <zh/> 删除多条节点数据
|
|
502
|
+
*
|
|
503
|
+
* <en/> Remove multiple node data
|
|
504
|
+
* @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
|
|
505
|
+
* @apiCategory data
|
|
506
|
+
*/
|
|
310
507
|
removeNodeData(ids) {
|
|
311
508
|
this.context.model.removeNodeData((0, util_1.isFunction)(ids) ? ids(this.getNodeData()) : ids);
|
|
312
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* <zh/> 删除多条边数据
|
|
512
|
+
*
|
|
513
|
+
* <en/> Remove multiple edge data
|
|
514
|
+
* @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
|
|
515
|
+
* @apiCategory data
|
|
516
|
+
*/
|
|
313
517
|
removeEdgeData(ids) {
|
|
314
518
|
this.context.model.removeEdgeData((0, util_1.isFunction)(ids) ? ids(this.getEdgeData()) : ids);
|
|
315
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* <zh/> 删除多条组合数据
|
|
522
|
+
*
|
|
523
|
+
* <en/> Remove multiple combo data
|
|
524
|
+
* @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
|
|
525
|
+
* @apiCategory data
|
|
526
|
+
*/
|
|
316
527
|
removeComboData(ids) {
|
|
317
528
|
this.context.model.removeComboData((0, util_1.isFunction)(ids) ? ids(this.getComboData()) : ids);
|
|
318
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* <zh/> 获取元素类型
|
|
532
|
+
*
|
|
533
|
+
* <en/> Get element type
|
|
534
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
535
|
+
* @returns <zh/> 元素类型 | <en/> element type
|
|
536
|
+
* @apiCategory element
|
|
537
|
+
*/
|
|
319
538
|
getElementType(id) {
|
|
320
539
|
return this.context.model.getElementType(id);
|
|
321
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* <zh/> 获取节点或组合相关的边数据
|
|
543
|
+
*
|
|
544
|
+
* <en/> Get the edge data related to the node or combo
|
|
545
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
546
|
+
* @param direction - <zh/> 边的方向 | <en/> edge direction
|
|
547
|
+
* @returns <zh/> 边数据 | <en/> edge data
|
|
548
|
+
* @apiCategory data
|
|
549
|
+
*/
|
|
322
550
|
getRelatedEdgesData(id, direction = 'both') {
|
|
323
551
|
return this.context.model.getRelatedEdgesData(id, direction);
|
|
324
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* <zh/> 获取节点或组合的一跳邻居节点数据
|
|
555
|
+
*
|
|
556
|
+
* <en/> Get the one-hop neighbor node data of the node or combo
|
|
557
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
558
|
+
* @returns <zh/> 邻居节点数据 | <en/> neighbor node data
|
|
559
|
+
* @apiCategory data
|
|
560
|
+
*/
|
|
325
561
|
getNeighborNodesData(id) {
|
|
326
562
|
return this.context.model.getNeighborNodesData(id);
|
|
327
563
|
}
|
|
328
564
|
/**
|
|
329
|
-
* <zh/>
|
|
565
|
+
* <zh/> 获取节点或组合的祖先元素数据
|
|
330
566
|
*
|
|
331
567
|
* <en/> Get the ancestor element data of the node or combo
|
|
332
|
-
* @param id - <zh/>
|
|
333
|
-
* @param hierarchy - <zh/>
|
|
568
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
569
|
+
* @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
|
|
334
570
|
* @returns <zh/> 祖先元素数据 | <en/> ancestor element data
|
|
335
|
-
* @
|
|
571
|
+
* @remarks
|
|
336
572
|
* <zh/> 数组中的顺序是从父节点到祖先节点
|
|
337
573
|
*
|
|
338
574
|
* <en/> The order in the array is from the parent node to the ancestor node
|
|
575
|
+
* @apiCategory data
|
|
339
576
|
*/
|
|
340
577
|
getAncestorsData(id, hierarchy) {
|
|
341
578
|
return this.context.model.getAncestorsData(id, hierarchy);
|
|
342
579
|
}
|
|
343
580
|
/**
|
|
344
|
-
* <zh/>
|
|
581
|
+
* <zh/> 获取节点或组合的父元素数据
|
|
345
582
|
*
|
|
346
583
|
* <en/> Get the parent element data of the node or combo
|
|
347
|
-
* @param id - <zh/>
|
|
348
|
-
* @param hierarchy - <zh/>
|
|
584
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
585
|
+
* @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
|
|
349
586
|
* @returns <zh/> 父元素数据 | <en/> parent element data
|
|
587
|
+
* @apiCategory data
|
|
350
588
|
*/
|
|
351
589
|
getParentData(id, hierarchy) {
|
|
352
590
|
return this.context.model.getParentData(id, hierarchy);
|
|
353
591
|
}
|
|
354
592
|
/**
|
|
355
|
-
* <zh/>
|
|
593
|
+
* <zh/> 获取节点或组合的子元素数据
|
|
356
594
|
*
|
|
357
595
|
* <en/> Get the child element data of the node or combo
|
|
358
|
-
* @param id - <zh/>
|
|
596
|
+
* @param id - <zh/> 节点或组合ID | <en/> node or combo ID
|
|
359
597
|
* @returns <zh/> 子元素数据 | <en/> child element data
|
|
598
|
+
* @apiCategory data
|
|
360
599
|
*/
|
|
361
600
|
getChildrenData(id) {
|
|
362
601
|
return this.context.model.getChildrenData(id);
|
|
@@ -375,11 +614,12 @@ class Graph extends event_emitter_1.default {
|
|
|
375
614
|
}
|
|
376
615
|
else {
|
|
377
616
|
const $container = (0, util_1.isString)(container) ? document.getElementById(container) : container;
|
|
617
|
+
const containerSize = (0, dom_1.sizeOf)($container);
|
|
378
618
|
this.emit(constants_1.GraphEvent.BEFORE_CANVAS_INIT, { container: $container, width, height });
|
|
379
619
|
const canvas = new canvas_1.Canvas({
|
|
380
620
|
container: $container,
|
|
381
|
-
width,
|
|
382
|
-
height,
|
|
621
|
+
width: width || containerSize[0],
|
|
622
|
+
height: height || containerSize[1],
|
|
383
623
|
renderer,
|
|
384
624
|
});
|
|
385
625
|
this.context.canvas = canvas;
|
|
@@ -387,7 +627,7 @@ class Graph extends event_emitter_1.default {
|
|
|
387
627
|
this.emit(constants_1.GraphEvent.AFTER_CANVAS_INIT, { canvas });
|
|
388
628
|
}
|
|
389
629
|
}
|
|
390
|
-
|
|
630
|
+
initRuntime() {
|
|
391
631
|
this.context.options = this.options;
|
|
392
632
|
if (!this.context.batch)
|
|
393
633
|
this.context.batch = new batch_1.BatchController(this.context);
|
|
@@ -405,23 +645,27 @@ class Graph extends event_emitter_1.default {
|
|
|
405
645
|
this.context.behavior = new behavior_1.BehaviorController(this.context);
|
|
406
646
|
}
|
|
407
647
|
async prepare() {
|
|
648
|
+
// 等待同步任务执行完成,避免 render 后立即调用 destroy 导致的问题
|
|
649
|
+
// Wait for synchronous tasks to complete, to avoid problems caused by calling destroy immediately after render
|
|
650
|
+
await Promise.resolve();
|
|
408
651
|
if (this.destroyed)
|
|
409
652
|
throw new Error('Graph has been destroyed');
|
|
410
653
|
await this.initCanvas();
|
|
411
|
-
this.
|
|
654
|
+
this.initRuntime();
|
|
412
655
|
}
|
|
413
656
|
/**
|
|
414
657
|
* <zh/> 执行渲染
|
|
415
658
|
*
|
|
416
659
|
* <en/> Render
|
|
417
|
-
* @
|
|
660
|
+
* @remarks
|
|
418
661
|
* <zh/> 此过程会执行数据更新、绘制元素、执行布局
|
|
419
662
|
*
|
|
420
663
|
* <en/> This process will execute data update, element rendering, and layout execution
|
|
664
|
+
* @apiCategory render
|
|
421
665
|
*/
|
|
422
666
|
async render() {
|
|
423
|
-
(0, event_1.emit)(this, new event_1.GraphLifeCycleEvent(constants_1.GraphEvent.BEFORE_RENDER));
|
|
424
667
|
await this.prepare();
|
|
668
|
+
(0, event_1.emit)(this, new event_1.GraphLifeCycleEvent(constants_1.GraphEvent.BEFORE_RENDER));
|
|
425
669
|
await Promise.all([this.context.element?.draw(), this.context.layout?.layout()]);
|
|
426
670
|
await this.autoFit();
|
|
427
671
|
(0, event_1.emit)(this, new event_1.GraphLifeCycleEvent(constants_1.GraphEvent.AFTER_RENDER));
|
|
@@ -431,27 +675,52 @@ class Graph extends event_emitter_1.default {
|
|
|
431
675
|
*
|
|
432
676
|
* <en/> Draw elements
|
|
433
677
|
* @returns <zh/> 渲染结果 | <en/> draw result
|
|
678
|
+
* @apiCategory element
|
|
434
679
|
*/
|
|
435
680
|
async draw() {
|
|
436
681
|
await this.prepare();
|
|
437
682
|
return this.context.element.draw();
|
|
438
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* <zh/> 执行布局
|
|
686
|
+
*
|
|
687
|
+
* <en/> Execute layout
|
|
688
|
+
* @apiCategory layout
|
|
689
|
+
*/
|
|
439
690
|
layout() {
|
|
440
|
-
|
|
691
|
+
this.context.layout.layout();
|
|
441
692
|
}
|
|
693
|
+
/**
|
|
694
|
+
* <zh/> 停止布局
|
|
695
|
+
*
|
|
696
|
+
* <en/> Stop layout
|
|
697
|
+
* @remarks
|
|
698
|
+
* <zh/> 适用于带有迭代动画的布局,目前有 `force` 属于此类布局,即停止力导布局的迭代,一般用于布局迭代时间过长情况下的手动停止迭代动画,例如在点击画布/节点的监听中调用
|
|
699
|
+
*
|
|
700
|
+
* <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
|
|
701
|
+
* @apiCategory layout
|
|
702
|
+
*/
|
|
442
703
|
stopLayout() {
|
|
443
|
-
|
|
704
|
+
this.context.layout.stopLayout();
|
|
444
705
|
}
|
|
445
706
|
/**
|
|
446
707
|
* <zh/> 清空画布元素
|
|
447
708
|
*
|
|
448
709
|
* <en/> Clear canvas elements
|
|
710
|
+
* @apiCategory canvas
|
|
449
711
|
*/
|
|
450
712
|
async clear() {
|
|
451
713
|
this.context.model.setData({});
|
|
452
714
|
await this.draw();
|
|
453
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* <zh/> 销毁当前图实例
|
|
718
|
+
*
|
|
719
|
+
* <en/> Destroy the current graph instance
|
|
720
|
+
* @apiCategory instance
|
|
721
|
+
*/
|
|
454
722
|
destroy() {
|
|
723
|
+
(0, event_1.emit)(this, new event_1.GraphLifeCycleEvent(constants_1.GraphEvent.BEFORE_DESTROY));
|
|
455
724
|
const { layout, element, model, canvas, behavior, plugin } = this.context;
|
|
456
725
|
plugin?.destroy();
|
|
457
726
|
behavior?.destroy();
|
|
@@ -465,7 +734,15 @@ class Graph extends event_emitter_1.default {
|
|
|
465
734
|
this.off();
|
|
466
735
|
window.removeEventListener('resize', this.onResize);
|
|
467
736
|
this.destroyed = true;
|
|
737
|
+
(0, event_1.emit)(this, new event_1.GraphLifeCycleEvent(constants_1.GraphEvent.AFTER_DESTROY));
|
|
468
738
|
}
|
|
739
|
+
/**
|
|
740
|
+
* <zh/> 获取画布实例
|
|
741
|
+
*
|
|
742
|
+
* <en/> Get canvas instance
|
|
743
|
+
* @returns - <zh/> 画布实例 | <en/> canvas instance
|
|
744
|
+
* @apiCategory canvas
|
|
745
|
+
*/
|
|
469
746
|
getCanvas() {
|
|
470
747
|
return this.context.canvas;
|
|
471
748
|
}
|
|
@@ -483,6 +760,7 @@ class Graph extends event_emitter_1.default {
|
|
|
483
760
|
* <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
|
|
484
761
|
* @param options - <zh/> 适配配置 | <en/> fit options
|
|
485
762
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
763
|
+
* @apiCategory viewport
|
|
486
764
|
*/
|
|
487
765
|
async fitView(options, animation) {
|
|
488
766
|
await this.context.viewport?.fitView(options, animation);
|
|
@@ -492,6 +770,7 @@ class Graph extends event_emitter_1.default {
|
|
|
492
770
|
*
|
|
493
771
|
* <en/> Move the graph to the center of the viewport
|
|
494
772
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
773
|
+
* @apiCategory viewport
|
|
495
774
|
*/
|
|
496
775
|
async fitCenter(animation) {
|
|
497
776
|
await this.context.viewport?.fitCenter(animation);
|
|
@@ -514,6 +793,14 @@ class Graph extends event_emitter_1.default {
|
|
|
514
793
|
await this.fitCenter(animation);
|
|
515
794
|
}
|
|
516
795
|
}
|
|
796
|
+
/**
|
|
797
|
+
* <zh/> 移动图,使得元素对齐到视口中心
|
|
798
|
+
*
|
|
799
|
+
* <en/> Move the graph so that the element is aligned to the center of the viewport
|
|
800
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
801
|
+
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
802
|
+
* @apiCategory viewport
|
|
803
|
+
*/
|
|
517
804
|
async focusElement(id, animation) {
|
|
518
805
|
await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
|
|
519
806
|
}
|
|
@@ -524,13 +811,15 @@ class Graph extends event_emitter_1.default {
|
|
|
524
811
|
* @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
|
|
525
812
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
526
813
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
527
|
-
* @
|
|
814
|
+
* @remarks
|
|
528
815
|
* <zh/>
|
|
529
816
|
* - ratio > 1 放大
|
|
530
817
|
* - ratio < 1 缩小
|
|
818
|
+
*
|
|
531
819
|
* <en/>
|
|
532
820
|
* - ratio > 1 zoom in
|
|
533
821
|
* - ratio < 1 zoom out
|
|
822
|
+
* @apiCategory viewport
|
|
534
823
|
*/
|
|
535
824
|
async zoomBy(ratio, animation, origin) {
|
|
536
825
|
await this.context.viewport.transform({ mode: 'relative', scale: ratio, origin }, animation);
|
|
@@ -542,15 +831,17 @@ class Graph extends event_emitter_1.default {
|
|
|
542
831
|
* @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
|
|
543
832
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
544
833
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
545
|
-
* @
|
|
834
|
+
* @remarks
|
|
546
835
|
* <zh/>
|
|
547
836
|
* - zoom = 1 默认大小
|
|
548
837
|
* - zoom > 1 放大
|
|
549
838
|
* - zoom < 1 缩小
|
|
839
|
+
*
|
|
550
840
|
* <en/>
|
|
551
841
|
* - zoom = 1 default size
|
|
552
842
|
* - zoom > 1 zoom in
|
|
553
843
|
* - zoom < 1 zoom out
|
|
844
|
+
* @apiCategory viewport
|
|
554
845
|
*/
|
|
555
846
|
async zoomTo(zoom, animation, origin) {
|
|
556
847
|
this.context.viewport.transform({ mode: 'absolute', scale: zoom, origin }, animation);
|
|
@@ -560,6 +851,7 @@ class Graph extends event_emitter_1.default {
|
|
|
560
851
|
*
|
|
561
852
|
* <en/> Get the current zoom ratio
|
|
562
853
|
* @returns <zh/> 缩放比例 | <en/> zoom ratio
|
|
854
|
+
* @apiCategory viewport
|
|
563
855
|
*/
|
|
564
856
|
getZoom() {
|
|
565
857
|
return this.context.viewport.getZoom();
|
|
@@ -571,6 +863,7 @@ class Graph extends event_emitter_1.default {
|
|
|
571
863
|
* @param angle - <zh/> 旋转角度 | <en/> rotation angle
|
|
572
864
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
573
865
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
866
|
+
* @apiCategory viewport
|
|
574
867
|
*/
|
|
575
868
|
async rotateBy(angle, animation, origin) {
|
|
576
869
|
await this.context.viewport.transform({ mode: 'relative', rotate: angle, origin }, animation);
|
|
@@ -582,6 +875,7 @@ class Graph extends event_emitter_1.default {
|
|
|
582
875
|
* @param angle - <zh/> 目标角度 | <en/> target angle
|
|
583
876
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
584
877
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
878
|
+
* @apiCategory viewport
|
|
585
879
|
*/
|
|
586
880
|
async rotateTo(angle, animation, origin) {
|
|
587
881
|
await this.context.viewport.transform({ mode: 'absolute', rotate: angle, origin }, animation);
|
|
@@ -591,6 +885,7 @@ class Graph extends event_emitter_1.default {
|
|
|
591
885
|
*
|
|
592
886
|
* <en/> Get the current rotation angle
|
|
593
887
|
* @returns <zh/> 旋转角度 | <en/> rotation angle
|
|
888
|
+
* @apiCategory viewport
|
|
594
889
|
*/
|
|
595
890
|
getRotation() {
|
|
596
891
|
return this.context.viewport.getRotation();
|
|
@@ -601,6 +896,7 @@ class Graph extends event_emitter_1.default {
|
|
|
601
896
|
* <en/> Translate the graph by the specified distance
|
|
602
897
|
* @param offset - <zh/> 偏移量 | <en/> offset
|
|
603
898
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
899
|
+
* @apiCategory viewport
|
|
604
900
|
*/
|
|
605
901
|
async translateBy(offset, animation) {
|
|
606
902
|
await this.context.viewport.transform({ mode: 'relative', translate: offset }, animation);
|
|
@@ -611,7 +907,7 @@ class Graph extends event_emitter_1.default {
|
|
|
611
907
|
* <en/> Translate the graph to the specified position
|
|
612
908
|
* @param position - <zh/> 指定位置 | <en/> specified position
|
|
613
909
|
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
614
|
-
* @
|
|
910
|
+
* @apiCategory viewport
|
|
615
911
|
*/
|
|
616
912
|
async translateTo(position, animation) {
|
|
617
913
|
await this.context.viewport.transform({ mode: 'absolute', translate: position }, animation);
|
|
@@ -621,10 +917,11 @@ class Graph extends event_emitter_1.default {
|
|
|
621
917
|
*
|
|
622
918
|
* <en/> Get the position of the graph
|
|
623
919
|
* @returns <zh/> 图的位置 | <en/> position of the graph
|
|
624
|
-
* @
|
|
920
|
+
* @remarks
|
|
625
921
|
* <zh/> 默认状态下,图的位置为 [0, 0]
|
|
626
922
|
*
|
|
627
923
|
* <en/> By default, the position of the graph is [0, 0]
|
|
924
|
+
* @apiCategory viewport
|
|
628
925
|
*/
|
|
629
926
|
getPosition() {
|
|
630
927
|
return (0, vector_1.subtract)([0, 0], this.getCanvasByViewport([0, 0]));
|
|
@@ -643,9 +940,25 @@ class Graph extends event_emitter_1.default {
|
|
|
643
940
|
Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeTo(id, position));
|
|
644
941
|
await this.context.element.draw({ animation });
|
|
645
942
|
}
|
|
943
|
+
/**
|
|
944
|
+
* <zh/> 获取元素位置
|
|
945
|
+
*
|
|
946
|
+
* <en/> Get element position
|
|
947
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
948
|
+
* @returns <zh/> 元素位置 | <en/> element position
|
|
949
|
+
* @apiCategory element
|
|
950
|
+
*/
|
|
646
951
|
getElementPosition(id) {
|
|
647
952
|
return this.context.model.getElementPosition(id);
|
|
648
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* <zh/> 获取元素渲染样式
|
|
956
|
+
*
|
|
957
|
+
* <en/> Get element rendering style
|
|
958
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
959
|
+
* @returns <zh/> 元素渲染样式 | <en/> element rendering style
|
|
960
|
+
* @apiCategory element
|
|
961
|
+
*/
|
|
649
962
|
getElementRenderStyle(id) {
|
|
650
963
|
return (0, util_1.omit)(this.context.element.getElement(id).attributes, ['context']);
|
|
651
964
|
}
|
|
@@ -666,7 +979,8 @@ class Graph extends event_emitter_1.default {
|
|
|
666
979
|
*
|
|
667
980
|
* <en/> Show element
|
|
668
981
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
669
|
-
* @param animation - <zh/>
|
|
982
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
983
|
+
* @apiCategory element
|
|
670
984
|
*/
|
|
671
985
|
async showElement(id, animation) {
|
|
672
986
|
const ids = Array.isArray(id) ? id : [id];
|
|
@@ -677,7 +991,8 @@ class Graph extends event_emitter_1.default {
|
|
|
677
991
|
*
|
|
678
992
|
* <en/> Hide element
|
|
679
993
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
680
|
-
* @param animation - <zh/>
|
|
994
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
995
|
+
* @apiCategory element
|
|
681
996
|
*/
|
|
682
997
|
async hideElement(id, animation) {
|
|
683
998
|
const ids = Array.isArray(id) ? id : [id];
|
|
@@ -689,6 +1004,7 @@ class Graph extends event_emitter_1.default {
|
|
|
689
1004
|
* <en/> Get element visibility
|
|
690
1005
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
691
1006
|
* @returns <zh/> 元素可见性 | <en/> element visibility
|
|
1007
|
+
* @apiCategory element
|
|
692
1008
|
*/
|
|
693
1009
|
getElementVisibility(id) {
|
|
694
1010
|
const element = this.context.element.getElement(id);
|
|
@@ -710,6 +1026,7 @@ class Graph extends event_emitter_1.default {
|
|
|
710
1026
|
*
|
|
711
1027
|
* <en/> Bring the element to the front
|
|
712
1028
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1029
|
+
* @apiCategory element
|
|
713
1030
|
*/
|
|
714
1031
|
async frontElement(id) {
|
|
715
1032
|
const ids = Array.isArray(id) ? id : [id];
|
|
@@ -737,6 +1054,7 @@ class Graph extends event_emitter_1.default {
|
|
|
737
1054
|
* <en/> Get element z-index
|
|
738
1055
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
739
1056
|
* @returns <zh/> 元素层级 | <en/> element z-index
|
|
1057
|
+
* @apiCategory element
|
|
740
1058
|
*/
|
|
741
1059
|
getElementZIndex(id) {
|
|
742
1060
|
return (0, style_1.zIndexOf)(this.context.model.getElementsData([id])[0]);
|
|
@@ -764,18 +1082,43 @@ class Graph extends event_emitter_1.default {
|
|
|
764
1082
|
* <en/> Get element state
|
|
765
1083
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
766
1084
|
* @returns <zh/> 元素状态 | <en/> element state
|
|
1085
|
+
* @apiCategory element
|
|
767
1086
|
*/
|
|
768
1087
|
getElementState(id) {
|
|
769
1088
|
return this.context.model.getElementState(id);
|
|
770
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* <zh/> 获取元素自身以及子节点在世界坐标系下的渲染包围盒
|
|
1092
|
+
*
|
|
1093
|
+
* <en/> Get the rendering bounding box of the element itself and its child nodes in the world coordinate system
|
|
1094
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1095
|
+
* @returns <zh/> 渲染包围盒 | <en/> render bounding box
|
|
1096
|
+
* @apiCategory element
|
|
1097
|
+
*/
|
|
771
1098
|
getElementRenderBounds(id) {
|
|
772
1099
|
return this.context.element.getElement(id).getRenderBounds();
|
|
773
1100
|
}
|
|
774
|
-
|
|
1101
|
+
/**
|
|
1102
|
+
* <zh/> 收起 Combo
|
|
1103
|
+
*
|
|
1104
|
+
* <en/> Collapse Combo
|
|
1105
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1106
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1107
|
+
* @apiCategory element
|
|
1108
|
+
*/
|
|
1109
|
+
async collapseElement(id, animation = true) {
|
|
775
1110
|
this.setElementCollapsibility(id, true);
|
|
776
1111
|
await this.context.element.draw({ animation, stage: 'collapse' });
|
|
777
1112
|
}
|
|
778
|
-
|
|
1113
|
+
/**
|
|
1114
|
+
* <zh/> 展开 Combo
|
|
1115
|
+
*
|
|
1116
|
+
* <en/> Expand Combo
|
|
1117
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1118
|
+
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1119
|
+
* @apiCategory element
|
|
1120
|
+
*/
|
|
1121
|
+
async expandElement(id, animation = true) {
|
|
779
1122
|
this.setElementCollapsibility(id, false);
|
|
780
1123
|
await this.context.element.draw({ animation, stage: 'expand' });
|
|
781
1124
|
}
|
|
@@ -791,29 +1134,54 @@ class Graph extends event_emitter_1.default {
|
|
|
791
1134
|
*
|
|
792
1135
|
* <en/> Export canvas content as DataURL
|
|
793
1136
|
* @param options - <zh/> 导出配置 | <en/> export configuration
|
|
794
|
-
* @param mode
|
|
795
|
-
* <zh/> 导出模式
|
|
796
|
-
* - viewport: 导出视口内容
|
|
797
|
-
* - overall: 导出整个画布
|
|
798
|
-
*
|
|
799
|
-
* <en/> export mode
|
|
800
|
-
* - viewport: export the content of the viewport
|
|
801
|
-
* - overall: export the entire canvas
|
|
802
1137
|
* @returns <zh/> DataURL | <en/> DataURL
|
|
1138
|
+
* @apiCategory exportImage
|
|
803
1139
|
*/
|
|
804
1140
|
async toDataURL(options = {}) {
|
|
805
1141
|
return this.context.canvas.toDataURL(options);
|
|
806
1142
|
}
|
|
1143
|
+
/**
|
|
1144
|
+
* <zh/> 给定的视窗 DOM 坐标,转换为画布上的绘制坐标
|
|
1145
|
+
*
|
|
1146
|
+
* <en/> Convert the given viewport DOM coordinates to the drawing coordinates on the canvas
|
|
1147
|
+
* @param point - <zh/> 视窗坐标 | <en/> viewport coordinates
|
|
1148
|
+
* @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
|
|
1149
|
+
* @apiCategory viewport
|
|
1150
|
+
*/
|
|
807
1151
|
getCanvasByViewport(point) {
|
|
808
1152
|
return (0, point_1.parsePoint)(this.context.canvas.viewport2Canvas((0, point_1.toPointObject)(point)));
|
|
809
1153
|
}
|
|
1154
|
+
/**
|
|
1155
|
+
* <zh/> 给定画布上的绘制坐标,转换为视窗 DOM 的坐标
|
|
1156
|
+
*
|
|
1157
|
+
* <en/> Convert the given drawing coordinates on the canvas to the coordinates of the viewport DOM
|
|
1158
|
+
* @param point - <zh/> 画布坐标 | <en/> canvas coordinates
|
|
1159
|
+
* @returns <zh/> 视窗 DOM 的坐标 | <en/> coordinates of the viewport DOM
|
|
1160
|
+
* @apiCategory viewport
|
|
1161
|
+
*/
|
|
810
1162
|
getViewportByCanvas(point) {
|
|
811
1163
|
return (0, point_1.parsePoint)(this.context.canvas.canvas2Viewport((0, point_1.toPointObject)(point)));
|
|
812
1164
|
}
|
|
1165
|
+
/**
|
|
1166
|
+
* <zh/> 给定画布上的绘制坐标,转换为浏览器坐标
|
|
1167
|
+
*
|
|
1168
|
+
* <en/> Convert the given drawing coordinates on the canvas to browser coordinates
|
|
1169
|
+
* @param point - <zh/> 画布坐标 | <en/> canvas coordinates
|
|
1170
|
+
* @returns <zh/> 浏览器坐标 | <en/> browser coordinates
|
|
1171
|
+
* @apiCategory viewport
|
|
1172
|
+
*/
|
|
813
1173
|
getClientByCanvas(point) {
|
|
814
1174
|
const viewportPoint = this.context.canvas.canvas2Viewport((0, point_1.toPointObject)(point));
|
|
815
1175
|
return (0, point_1.parsePoint)(this.context.canvas.viewport2Canvas(viewportPoint));
|
|
816
1176
|
}
|
|
1177
|
+
/**
|
|
1178
|
+
* <zh/> 给定的浏览器坐标,转换为画布上的绘制坐标
|
|
1179
|
+
*
|
|
1180
|
+
* <en/> Convert the given browser coordinates to drawing coordinates on the canvas
|
|
1181
|
+
* @param point - <zh/> 浏览器坐标 | <en/> browser coordinates
|
|
1182
|
+
* @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
|
|
1183
|
+
* @apiCategory viewport
|
|
1184
|
+
*/
|
|
817
1185
|
getCanvasByClient(point) {
|
|
818
1186
|
const viewportPoint = this.context.canvas.client2Viewport((0, point_1.toPointObject)(point));
|
|
819
1187
|
return (0, point_1.parsePoint)(this.context.canvas.viewport2Canvas(viewportPoint));
|
|
@@ -823,10 +1191,18 @@ class Graph extends event_emitter_1.default {
|
|
|
823
1191
|
*
|
|
824
1192
|
* <en/> Get the canvas coordinates of the viewport center
|
|
825
1193
|
* @returns <zh/> 视口中心的画布坐标 | <en/> Canvas coordinates of the viewport center
|
|
1194
|
+
* @apiCategory viewport
|
|
826
1195
|
*/
|
|
827
1196
|
getViewportCenter() {
|
|
828
1197
|
return this.context.viewport.getViewportCenter();
|
|
829
1198
|
}
|
|
1199
|
+
/**
|
|
1200
|
+
* <zh/> 获取画布中心的画布坐标
|
|
1201
|
+
*
|
|
1202
|
+
* <en/> Get the canvas coordinates of the canvas center
|
|
1203
|
+
* @returns <zh/> 画布中心的画布坐标 | <en/> Canvas coordinates of the canvas center
|
|
1204
|
+
* @apiCategory viewport
|
|
1205
|
+
*/
|
|
830
1206
|
getCanvasCenter() {
|
|
831
1207
|
return this.context.viewport.getCanvasCenter();
|
|
832
1208
|
}
|
|
@@ -840,6 +1216,7 @@ class Graph extends event_emitter_1.default {
|
|
|
840
1216
|
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
841
1217
|
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
842
1218
|
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1219
|
+
* @apiCategory event
|
|
843
1220
|
*/
|
|
844
1221
|
on(eventName, callback) {
|
|
845
1222
|
return super.on(eventName, callback);
|
|
@@ -851,6 +1228,7 @@ class Graph extends event_emitter_1.default {
|
|
|
851
1228
|
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
852
1229
|
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
853
1230
|
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1231
|
+
* @apiCategory event
|
|
854
1232
|
*/
|
|
855
1233
|
once(eventName, callback) {
|
|
856
1234
|
return super.once(eventName, callback);
|