@antv/g6 5.0.0-beta.31 → 5.0.0-beta.33
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/behaviors/brush-select.d.ts +104 -0
- package/dist/lib/behaviors/click-element.d.ts +77 -0
- package/dist/lib/behaviors/collapse-expand.d.ts +4 -5
- package/dist/lib/behaviors/create-edge.d.ts +55 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +6 -6
- package/dist/lib/behaviors/drag-element-force.d.ts +14 -0
- package/dist/lib/behaviors/drag-element.d.ts +17 -14
- package/dist/lib/behaviors/focus-element.d.ts +4 -3
- package/dist/lib/behaviors/hover-element.d.ts +4 -5
- package/dist/lib/behaviors/index.d.ts +10 -0
- package/dist/lib/behaviors/lasso-select.d.ts +20 -0
- package/dist/lib/behaviors/types.d.ts +1 -0
- package/dist/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/dist/lib/constants/change.d.ts +1 -1
- package/dist/lib/constants/events/graph.d.ts +9 -15
- package/dist/lib/constants/index.d.ts +1 -0
- package/dist/lib/constants/registry.d.ts +22 -0
- package/dist/lib/elements/combos/base-combo.d.ts +64 -6
- package/dist/lib/elements/combos/circle.d.ts +8 -12
- package/dist/lib/elements/combos/rect.d.ts +5 -9
- package/dist/lib/elements/edges/base-edge.d.ts +85 -10
- package/dist/lib/elements/edges/cubic-horizontal.d.ts +2 -2
- package/dist/lib/elements/edges/cubic-vertical.d.ts +2 -2
- package/dist/lib/elements/edges/cubic.d.ts +2 -2
- package/dist/lib/elements/edges/polyline.d.ts +2 -2
- package/dist/lib/elements/edges/quadratic.d.ts +2 -2
- package/dist/lib/elements/nodes/base-node.d.ts +125 -13
- package/dist/lib/elements/nodes/circle.d.ts +5 -8
- package/dist/lib/elements/nodes/diamond.d.ts +2 -4
- package/dist/lib/elements/nodes/ellipse.d.ts +5 -8
- package/dist/lib/elements/nodes/hexagon.d.ts +6 -9
- package/dist/lib/elements/nodes/image.d.ts +9 -11
- package/dist/lib/elements/nodes/polygon.d.ts +9 -8
- package/dist/lib/elements/nodes/rect.d.ts +2 -3
- package/dist/lib/elements/nodes/star.d.ts +7 -10
- package/dist/lib/elements/nodes/triangle.d.ts +7 -10
- package/dist/lib/exports.d.ts +18 -14
- package/dist/lib/layouts/index.d.ts +1 -1
- package/dist/lib/layouts/types.d.ts +6 -6
- package/dist/lib/palettes/index.d.ts +1 -0
- package/dist/lib/plugins/camera-setting.d.ts +95 -0
- package/dist/lib/plugins/contextmenu.d.ts +8 -5
- package/dist/lib/plugins/history/events.d.ts +21 -0
- package/dist/lib/plugins/history/index.d.ts +82 -0
- package/dist/lib/plugins/history/utils.d.ts +31 -0
- package/dist/lib/plugins/hull/index.d.ts +59 -0
- package/dist/lib/plugins/hull/shape.d.ts +49 -0
- package/dist/lib/plugins/hull/util.d.ts +12 -0
- package/dist/lib/plugins/index.d.ts +8 -0
- package/dist/lib/plugins/legend.d.ts +49 -0
- package/dist/lib/plugins/tooltip.d.ts +12 -10
- package/dist/lib/registry/extension/index.d.ts +3 -3
- package/dist/lib/registry/index.d.ts +6 -4
- package/dist/lib/registry/types.d.ts +4 -6
- package/dist/lib/runtime/batch.d.ts +11 -0
- package/dist/lib/runtime/behavior.d.ts +1 -1
- package/dist/lib/runtime/canvas.d.ts +15 -4
- package/dist/lib/runtime/data.d.ts +4 -4
- package/dist/lib/runtime/element.d.ts +6 -23
- package/dist/lib/runtime/graph.d.ts +71 -6
- package/dist/lib/runtime/layout.d.ts +5 -11
- package/dist/lib/runtime/plugin.d.ts +2 -1
- package/dist/lib/runtime/transform.d.ts +11 -0
- package/dist/lib/runtime/types.d.ts +14 -0
- package/dist/lib/spec/index.d.ts +1 -0
- package/dist/lib/spec/spec.d.ts +7 -0
- package/dist/lib/spec/transform.d.ts +12 -0
- package/dist/lib/transforms/arrange-draw-order.d.ts +10 -0
- package/dist/lib/transforms/base-transform.d.ts +7 -0
- package/dist/lib/transforms/collapse-expand-combo.d.ts +10 -0
- package/dist/lib/transforms/index.d.ts +6 -0
- package/dist/lib/transforms/process-parallel-edges.d.ts +84 -0
- package/dist/lib/transforms/types.d.ts +20 -0
- package/dist/lib/transforms/update-related-edge.d.ts +9 -0
- package/dist/lib/types/canvas.d.ts +1 -1
- package/dist/lib/types/change.d.ts +27 -10
- package/dist/lib/types/element.d.ts +6 -140
- package/dist/lib/types/event.d.ts +42 -7
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/node.d.ts +3 -3
- package/dist/lib/types/point.d.ts +1 -0
- package/dist/lib/utils/animation.d.ts +1 -1
- package/dist/lib/utils/bbox.d.ts +1 -1
- package/dist/lib/utils/behaviors/brush.d.ts +19 -0
- package/dist/lib/utils/behaviors/lasso.d.ts +13 -0
- package/dist/lib/utils/behaviors/utils.d.ts +21 -0
- package/dist/lib/utils/change.d.ts +9 -1
- package/dist/lib/utils/combo.d.ts +5 -4
- package/dist/lib/utils/edge.d.ts +11 -0
- package/dist/lib/utils/element.d.ts +19 -11
- package/dist/lib/utils/event/events.d.ts +9 -14
- package/dist/lib/utils/extension.d.ts +1 -1
- package/dist/lib/utils/id.d.ts +3 -8
- package/dist/lib/utils/line.d.ts +21 -0
- package/dist/lib/utils/path.d.ts +35 -0
- package/dist/lib/utils/point.d.ts +74 -20
- package/dist/lib/utils/polygon.d.ts +17 -0
- package/dist/lib/utils/position.d.ts +14 -1
- package/dist/lib/utils/prefix.d.ts +1 -1
- package/dist/lib/utils/shortcut.d.ts +11 -0
- package/dist/lib/utils/vector.d.ts +3 -2
- package/esm/behaviors/brush-select.d.ts +104 -0
- package/esm/behaviors/brush-select.js +199 -0
- package/esm/behaviors/brush-select.js.map +1 -0
- package/esm/behaviors/click-element.d.ts +77 -0
- package/esm/behaviors/click-element.js +108 -0
- package/esm/behaviors/click-element.js.map +1 -0
- package/esm/behaviors/collapse-expand.d.ts +4 -5
- package/esm/behaviors/collapse-expand.js +8 -4
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.d.ts +55 -0
- package/esm/behaviors/create-edge.js +141 -0
- package/esm/behaviors/create-edge.js.map +1 -0
- package/esm/behaviors/drag-canvas.d.ts +6 -6
- package/esm/behaviors/drag-canvas.js +15 -7
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element-force.d.ts +14 -0
- package/esm/behaviors/drag-element-force.js +55 -0
- package/esm/behaviors/drag-element-force.js.map +1 -0
- package/esm/behaviors/drag-element.d.ts +17 -14
- package/esm/behaviors/drag-element.js +17 -9
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/focus-element.d.ts +4 -3
- package/esm/behaviors/focus-element.js.map +1 -1
- package/esm/behaviors/hover-element.d.ts +4 -5
- package/esm/behaviors/hover-element.js +2 -2
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/behaviors/index.d.ts +10 -0
- package/esm/behaviors/index.js +5 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/lasso-select.d.ts +20 -0
- package/esm/behaviors/lasso-select.js +79 -0
- package/esm/behaviors/lasso-select.js.map +1 -0
- package/esm/behaviors/types.d.ts +1 -0
- package/esm/behaviors/zoom-canvas.d.ts +7 -6
- package/esm/behaviors/zoom-canvas.js +6 -2
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/constants/change.d.ts +1 -1
- package/esm/constants/change.js +12 -12
- package/esm/constants/change.js.map +1 -1
- package/esm/constants/events/graph.d.ts +9 -15
- package/esm/constants/events/graph.js +8 -16
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +1 -0
- package/esm/constants/index.js.map +1 -1
- package/esm/constants/registry.d.ts +22 -0
- package/esm/constants/registry.js +24 -0
- package/esm/constants/registry.js.map +1 -0
- package/esm/elements/combos/base-combo.d.ts +64 -6
- package/esm/elements/combos/base-combo.js +21 -0
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/combos/circle.d.ts +8 -12
- package/esm/elements/combos/circle.js.map +1 -1
- package/esm/elements/combos/rect.d.ts +5 -9
- package/esm/elements/combos/rect.js.map +1 -1
- package/esm/elements/edges/base-edge.d.ts +85 -10
- package/esm/elements/edges/base-edge.js +21 -0
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/edges/cubic-horizontal.d.ts +2 -2
- package/esm/elements/edges/cubic-vertical.d.ts +2 -2
- package/esm/elements/edges/cubic.d.ts +2 -2
- package/esm/elements/edges/polyline.d.ts +2 -2
- package/esm/elements/edges/quadratic.d.ts +2 -2
- package/esm/elements/nodes/base-node.d.ts +125 -13
- package/esm/elements/nodes/base-node.js +25 -1
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/circle.d.ts +5 -8
- package/esm/elements/nodes/circle.js.map +1 -1
- package/esm/elements/nodes/diamond.d.ts +2 -4
- package/esm/elements/nodes/diamond.js +2 -2
- package/esm/elements/nodes/diamond.js.map +1 -1
- package/esm/elements/nodes/ellipse.d.ts +5 -8
- package/esm/elements/nodes/ellipse.js +1 -1
- package/esm/elements/nodes/ellipse.js.map +1 -1
- package/esm/elements/nodes/hexagon.d.ts +6 -9
- package/esm/elements/nodes/hexagon.js.map +1 -1
- package/esm/elements/nodes/image.d.ts +9 -11
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/elements/nodes/polygon.d.ts +9 -8
- package/esm/elements/nodes/polygon.js +4 -1
- package/esm/elements/nodes/polygon.js.map +1 -1
- package/esm/elements/nodes/rect.d.ts +2 -3
- package/esm/elements/nodes/rect.js.map +1 -1
- package/esm/elements/nodes/star.d.ts +7 -10
- package/esm/elements/nodes/star.js.map +1 -1
- package/esm/elements/nodes/triangle.d.ts +7 -10
- package/esm/elements/nodes/triangle.js.map +1 -1
- package/esm/exports.d.ts +18 -14
- package/esm/exports.js +8 -6
- package/esm/exports.js.map +1 -1
- package/esm/layouts/index.d.ts +1 -1
- package/esm/layouts/index.js +1 -1
- package/esm/layouts/index.js.map +1 -1
- package/esm/layouts/types.d.ts +6 -6
- package/esm/palettes/index.d.ts +1 -0
- package/esm/palettes/index.js +12 -0
- package/esm/palettes/index.js.map +1 -1
- package/esm/plugins/camera-setting.d.ts +95 -0
- package/esm/plugins/camera-setting.js +65 -0
- package/esm/plugins/camera-setting.js.map +1 -0
- package/esm/plugins/contextmenu.d.ts +8 -5
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/history/events.d.ts +21 -0
- package/esm/plugins/history/events.js +16 -0
- package/esm/plugins/history/events.js.map +1 -0
- package/esm/plugins/history/index.d.ts +82 -0
- package/esm/plugins/history/index.js +168 -0
- package/esm/plugins/history/index.js.map +1 -0
- package/esm/plugins/history/utils.d.ts +31 -0
- package/esm/plugins/history/utils.js +79 -0
- package/esm/plugins/history/utils.js.map +1 -0
- package/esm/plugins/hull/index.d.ts +59 -0
- package/esm/plugins/hull/index.js +107 -0
- package/esm/plugins/hull/index.js.map +1 -0
- package/esm/plugins/hull/shape.d.ts +49 -0
- package/esm/plugins/hull/shape.js +35 -0
- package/esm/plugins/hull/shape.js.map +1 -0
- package/esm/plugins/hull/util.d.ts +12 -0
- package/esm/plugins/hull/util.js +203 -0
- package/esm/plugins/hull/util.js.map +1 -0
- package/esm/plugins/index.d.ts +8 -0
- package/esm/plugins/index.js +4 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +49 -0
- package/esm/plugins/legend.js +267 -0
- package/esm/plugins/legend.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +12 -10
- package/esm/plugins/tooltip.js +0 -1
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/preset.js +2 -5
- package/esm/preset.js.map +1 -1
- package/esm/registry/build-in.js +21 -4
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/index.d.ts +3 -3
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/registry/index.d.ts +6 -4
- package/esm/registry/index.js +1 -0
- package/esm/registry/index.js.map +1 -1
- package/esm/registry/types.d.ts +4 -6
- package/esm/runtime/batch.d.ts +11 -0
- package/esm/runtime/batch.js +31 -0
- package/esm/runtime/batch.js.map +1 -0
- package/esm/runtime/behavior.d.ts +1 -1
- package/esm/runtime/behavior.js +3 -2
- package/esm/runtime/behavior.js.map +1 -1
- package/esm/runtime/canvas.d.ts +15 -4
- package/esm/runtime/canvas.js +103 -41
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +4 -4
- package/esm/runtime/data.js +23 -25
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +6 -23
- package/esm/runtime/element.js +48 -150
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +71 -6
- package/esm/runtime/graph.js +105 -10
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.d.ts +5 -11
- package/esm/runtime/layout.js +29 -75
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plugin.d.ts +2 -1
- package/esm/runtime/plugin.js +3 -0
- package/esm/runtime/plugin.js.map +1 -1
- package/esm/runtime/transform.d.ts +11 -0
- package/esm/runtime/transform.js +20 -0
- package/esm/runtime/transform.js.map +1 -0
- package/esm/runtime/types.d.ts +14 -0
- package/esm/spec/index.d.ts +1 -0
- package/esm/spec/spec.d.ts +7 -0
- package/esm/spec/transform.d.ts +12 -0
- package/esm/spec/transform.js +2 -0
- package/esm/spec/transform.js.map +1 -0
- package/esm/themes/base.js +9 -1
- package/esm/themes/base.js.map +1 -1
- package/esm/transforms/arrange-draw-order.d.ts +10 -0
- package/esm/transforms/arrange-draw-order.js +27 -0
- package/esm/transforms/arrange-draw-order.js.map +1 -0
- package/esm/transforms/base-transform.d.ts +7 -0
- package/esm/transforms/base-transform.js +7 -0
- package/esm/transforms/base-transform.js.map +1 -0
- package/esm/transforms/collapse-expand-combo.d.ts +10 -0
- package/esm/transforms/collapse-expand-combo.js +82 -0
- package/esm/transforms/collapse-expand-combo.js.map +1 -0
- package/esm/transforms/index.d.ts +6 -0
- package/esm/transforms/index.js +6 -0
- package/esm/transforms/index.js.map +1 -0
- package/esm/transforms/process-parallel-edges.d.ts +84 -0
- package/esm/transforms/process-parallel-edges.js +215 -0
- package/esm/transforms/process-parallel-edges.js.map +1 -0
- package/esm/transforms/types.d.ts +20 -0
- package/esm/transforms/types.js +11 -0
- package/esm/transforms/types.js.map +1 -0
- package/esm/transforms/update-related-edge.d.ts +9 -0
- package/esm/transforms/update-related-edge.js +20 -0
- package/esm/transforms/update-related-edge.js.map +1 -0
- package/esm/types/canvas.d.ts +1 -1
- package/esm/types/change.d.ts +27 -10
- package/esm/types/element.d.ts +6 -140
- package/esm/types/event.d.ts +42 -7
- package/esm/types/index.d.ts +0 -1
- package/esm/types/node.d.ts +3 -3
- package/esm/types/point.d.ts +1 -0
- package/esm/utils/animation.d.ts +1 -1
- package/esm/utils/animation.js +6 -0
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/bbox.d.ts +1 -1
- package/esm/utils/behaviors/brush.d.ts +19 -0
- package/esm/utils/behaviors/brush.js +25 -0
- package/esm/utils/behaviors/brush.js.map +1 -0
- package/esm/utils/behaviors/lasso.d.ts +13 -0
- package/esm/utils/behaviors/lasso.js +112 -0
- package/esm/utils/behaviors/lasso.js.map +1 -0
- package/esm/utils/behaviors/utils.d.ts +21 -0
- package/esm/utils/behaviors/utils.js +42 -0
- package/esm/utils/behaviors/utils.js.map +1 -0
- package/esm/utils/change.d.ts +9 -1
- package/esm/utils/change.js +28 -0
- package/esm/utils/change.js.map +1 -1
- package/esm/utils/combo.d.ts +5 -4
- package/esm/utils/combo.js.map +1 -1
- package/esm/utils/edge.d.ts +11 -0
- package/esm/utils/edge.js +1 -1
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/element.d.ts +19 -11
- package/esm/utils/element.js +19 -9
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/event/events.d.ts +9 -14
- package/esm/utils/event/events.js +3 -8
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/extension.d.ts +1 -1
- package/esm/utils/extension.js.map +1 -1
- package/esm/utils/id.d.ts +3 -8
- package/esm/utils/id.js +8 -2
- package/esm/utils/id.js.map +1 -1
- package/esm/utils/line.d.ts +21 -0
- package/esm/utils/line.js +41 -0
- package/esm/utils/line.js.map +1 -0
- package/esm/utils/path.d.ts +35 -0
- package/esm/utils/path.js +143 -0
- package/esm/utils/path.js.map +1 -0
- package/esm/utils/point.d.ts +74 -20
- package/esm/utils/point.js +168 -44
- package/esm/utils/point.js.map +1 -1
- package/esm/utils/polygon.d.ts +17 -0
- package/esm/utils/polygon.js +62 -0
- package/esm/utils/polygon.js.map +1 -0
- package/esm/utils/position.d.ts +14 -1
- package/esm/utils/position.js +16 -0
- package/esm/utils/position.js.map +1 -1
- package/esm/utils/prefix.d.ts +1 -1
- package/esm/utils/prefix.js.map +1 -1
- package/esm/utils/shortcut.d.ts +11 -0
- package/esm/utils/shortcut.js +37 -5
- package/esm/utils/shortcut.js.map +1 -1
- package/esm/utils/style.js.map +1 -1
- package/esm/utils/vector.d.ts +3 -2
- package/esm/utils/vector.js +10 -3
- package/esm/utils/vector.js.map +1 -1
- package/lib/behaviors/brush-select.d.ts +104 -0
- package/lib/behaviors/brush-select.js +203 -0
- package/lib/behaviors/brush-select.js.map +1 -0
- package/lib/behaviors/click-element.d.ts +77 -0
- package/lib/behaviors/click-element.js +112 -0
- package/lib/behaviors/click-element.js.map +1 -0
- package/lib/behaviors/collapse-expand.d.ts +4 -5
- package/lib/behaviors/collapse-expand.js +8 -4
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.d.ts +55 -0
- package/lib/behaviors/create-edge.js +145 -0
- package/lib/behaviors/create-edge.js.map +1 -0
- package/lib/behaviors/drag-canvas.d.ts +6 -6
- package/lib/behaviors/drag-canvas.js +15 -7
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element-force.d.ts +14 -0
- package/lib/behaviors/drag-element-force.js +59 -0
- package/lib/behaviors/drag-element-force.js.map +1 -0
- package/lib/behaviors/drag-element.d.ts +17 -14
- package/lib/behaviors/drag-element.js +17 -9
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/focus-element.d.ts +4 -3
- package/lib/behaviors/focus-element.js.map +1 -1
- package/lib/behaviors/hover-element.d.ts +4 -5
- package/lib/behaviors/hover-element.js +1 -1
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/behaviors/index.d.ts +10 -0
- package/lib/behaviors/index.js +11 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/lasso-select.d.ts +20 -0
- package/lib/behaviors/lasso-select.js +83 -0
- package/lib/behaviors/lasso-select.js.map +1 -0
- package/lib/behaviors/types.d.ts +1 -0
- package/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/lib/behaviors/zoom-canvas.js +6 -2
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/constants/change.d.ts +1 -1
- package/lib/constants/change.js +13 -13
- package/lib/constants/change.js.map +1 -1
- package/lib/constants/events/graph.d.ts +9 -15
- package/lib/constants/events/graph.js +9 -17
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/constants/index.js.map +1 -1
- package/lib/constants/registry.d.ts +22 -0
- package/lib/constants/registry.js +27 -0
- package/lib/constants/registry.js.map +1 -0
- package/lib/elements/combos/base-combo.d.ts +64 -6
- package/lib/elements/combos/base-combo.js +21 -0
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/combos/circle.d.ts +8 -12
- package/lib/elements/combos/circle.js.map +1 -1
- package/lib/elements/combos/rect.d.ts +5 -9
- package/lib/elements/combos/rect.js.map +1 -1
- package/lib/elements/edges/base-edge.d.ts +85 -10
- package/lib/elements/edges/base-edge.js +21 -0
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/edges/cubic-horizontal.d.ts +2 -2
- package/lib/elements/edges/cubic-vertical.d.ts +2 -2
- package/lib/elements/edges/cubic.d.ts +2 -2
- package/lib/elements/edges/polyline.d.ts +2 -2
- package/lib/elements/edges/quadratic.d.ts +2 -2
- package/lib/elements/nodes/base-node.d.ts +125 -13
- package/lib/elements/nodes/base-node.js +25 -1
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/circle.d.ts +5 -8
- package/lib/elements/nodes/circle.js.map +1 -1
- package/lib/elements/nodes/diamond.d.ts +2 -4
- package/lib/elements/nodes/diamond.js +2 -2
- package/lib/elements/nodes/diamond.js.map +1 -1
- package/lib/elements/nodes/ellipse.d.ts +5 -8
- package/lib/elements/nodes/ellipse.js +1 -1
- package/lib/elements/nodes/ellipse.js.map +1 -1
- package/lib/elements/nodes/hexagon.d.ts +6 -9
- package/lib/elements/nodes/hexagon.js.map +1 -1
- package/lib/elements/nodes/image.d.ts +9 -11
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/elements/nodes/polygon.d.ts +9 -8
- package/lib/elements/nodes/polygon.js +4 -1
- package/lib/elements/nodes/polygon.js.map +1 -1
- package/lib/elements/nodes/rect.d.ts +2 -3
- package/lib/elements/nodes/rect.js.map +1 -1
- package/lib/elements/nodes/star.d.ts +7 -10
- package/lib/elements/nodes/star.js.map +1 -1
- package/lib/elements/nodes/triangle.d.ts +7 -10
- package/lib/elements/nodes/triangle.js.map +1 -1
- package/lib/exports.d.ts +18 -14
- package/lib/exports.js +26 -1
- package/lib/exports.js.map +1 -1
- package/lib/layouts/index.d.ts +1 -1
- package/lib/layouts/index.js +2 -1
- package/lib/layouts/index.js.map +1 -1
- package/lib/layouts/types.d.ts +6 -6
- package/lib/palettes/index.d.ts +1 -0
- package/lib/palettes/index.js +13 -1
- package/lib/palettes/index.js.map +1 -1
- package/lib/plugins/camera-setting.d.ts +95 -0
- package/lib/plugins/camera-setting.js +69 -0
- package/lib/plugins/camera-setting.js.map +1 -0
- package/lib/plugins/contextmenu.d.ts +8 -5
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/history/events.d.ts +21 -0
- package/lib/plugins/history/events.js +19 -0
- package/lib/plugins/history/events.js.map +1 -0
- package/lib/plugins/history/index.d.ts +82 -0
- package/lib/plugins/history/index.js +175 -0
- package/lib/plugins/history/index.js.map +1 -0
- package/lib/plugins/history/utils.d.ts +31 -0
- package/lib/plugins/history/utils.js +84 -0
- package/lib/plugins/history/utils.js.map +1 -0
- package/lib/plugins/hull/index.d.ts +59 -0
- package/lib/plugins/hull/index.js +114 -0
- package/lib/plugins/hull/index.js.map +1 -0
- package/lib/plugins/hull/shape.d.ts +49 -0
- package/lib/plugins/hull/shape.js +39 -0
- package/lib/plugins/hull/shape.js.map +1 -0
- package/lib/plugins/hull/util.d.ts +12 -0
- package/lib/plugins/hull/util.js +207 -0
- package/lib/plugins/hull/util.js.map +1 -0
- package/lib/plugins/index.d.ts +8 -0
- package/lib/plugins/index.js +9 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +49 -0
- package/lib/plugins/legend.js +271 -0
- package/lib/plugins/legend.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +12 -10
- package/lib/plugins/tooltip.js +0 -1
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/preset.js +2 -5
- package/lib/preset.js.map +1 -1
- package/lib/registry/build-in.js +17 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/index.d.ts +3 -3
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/registry/index.d.ts +6 -4
- package/lib/registry/index.js +1 -0
- package/lib/registry/index.js.map +1 -1
- package/lib/registry/types.d.ts +4 -6
- package/lib/runtime/batch.d.ts +11 -0
- package/lib/runtime/batch.js +35 -0
- package/lib/runtime/batch.js.map +1 -0
- package/lib/runtime/behavior.d.ts +1 -1
- package/lib/runtime/behavior.js +3 -2
- package/lib/runtime/behavior.js.map +1 -1
- package/lib/runtime/canvas.d.ts +15 -4
- package/lib/runtime/canvas.js +101 -39
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +4 -4
- package/lib/runtime/data.js +22 -24
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +6 -23
- package/lib/runtime/element.js +47 -149
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +71 -6
- package/lib/runtime/graph.js +104 -9
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.d.ts +5 -11
- package/lib/runtime/layout.js +27 -73
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plugin.d.ts +2 -1
- package/lib/runtime/plugin.js +3 -0
- package/lib/runtime/plugin.js.map +1 -1
- package/lib/runtime/transform.d.ts +11 -0
- package/lib/runtime/transform.js +24 -0
- package/lib/runtime/transform.js.map +1 -0
- package/lib/runtime/types.d.ts +14 -0
- package/lib/spec/index.d.ts +1 -0
- package/lib/spec/spec.d.ts +7 -0
- package/lib/spec/transform.d.ts +12 -0
- package/lib/{types/behavior.js → spec/transform.js} +1 -1
- package/lib/spec/transform.js.map +1 -0
- package/lib/themes/base.js +9 -1
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/arrange-draw-order.d.ts +10 -0
- package/lib/transforms/arrange-draw-order.js +31 -0
- package/lib/transforms/arrange-draw-order.js.map +1 -0
- package/lib/transforms/base-transform.d.ts +7 -0
- package/lib/transforms/base-transform.js +11 -0
- package/lib/transforms/base-transform.js.map +1 -0
- package/lib/transforms/collapse-expand-combo.d.ts +10 -0
- package/lib/transforms/collapse-expand-combo.js +86 -0
- package/lib/transforms/collapse-expand-combo.js.map +1 -0
- package/lib/transforms/index.d.ts +6 -0
- package/lib/transforms/index.js +14 -0
- package/lib/transforms/index.js.map +1 -0
- package/lib/transforms/process-parallel-edges.d.ts +84 -0
- package/lib/transforms/process-parallel-edges.js +222 -0
- package/lib/transforms/process-parallel-edges.js.map +1 -0
- package/lib/transforms/types.d.ts +20 -0
- package/lib/transforms/types.js +15 -0
- package/lib/transforms/types.js.map +1 -0
- package/lib/transforms/update-related-edge.d.ts +9 -0
- package/lib/transforms/update-related-edge.js +24 -0
- package/lib/transforms/update-related-edge.js.map +1 -0
- package/lib/types/canvas.d.ts +1 -1
- package/lib/types/change.d.ts +27 -10
- package/lib/types/element.d.ts +6 -140
- package/lib/types/event.d.ts +42 -7
- package/lib/types/index.d.ts +0 -1
- package/lib/types/node.d.ts +3 -3
- package/lib/types/point.d.ts +1 -0
- package/lib/utils/animation.d.ts +1 -1
- package/lib/utils/animation.js +6 -0
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/bbox.d.ts +1 -1
- package/lib/utils/behaviors/brush.d.ts +19 -0
- package/lib/utils/behaviors/brush.js +30 -0
- package/lib/utils/behaviors/brush.js.map +1 -0
- package/lib/utils/behaviors/lasso.d.ts +13 -0
- package/lib/utils/behaviors/lasso.js +116 -0
- package/lib/utils/behaviors/lasso.js.map +1 -0
- package/lib/utils/behaviors/utils.d.ts +21 -0
- package/lib/utils/behaviors/utils.js +47 -0
- package/lib/utils/behaviors/utils.js.map +1 -0
- package/lib/utils/change.d.ts +9 -1
- package/lib/utils/change.js +30 -1
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/combo.d.ts +5 -4
- package/lib/utils/combo.js.map +1 -1
- package/lib/utils/edge.d.ts +11 -0
- package/lib/utils/edge.js +2 -1
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.d.ts +19 -11
- package/lib/utils/element.js +21 -10
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/event/events.d.ts +9 -14
- package/lib/utils/event/events.js +4 -10
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/extension.d.ts +1 -1
- package/lib/utils/extension.js.map +1 -1
- package/lib/utils/id.d.ts +3 -8
- package/lib/utils/id.js +10 -4
- package/lib/utils/id.js.map +1 -1
- package/lib/utils/line.d.ts +21 -0
- package/lib/utils/line.js +46 -0
- package/lib/utils/line.js.map +1 -0
- package/lib/utils/path.d.ts +35 -0
- package/lib/utils/path.js +150 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/utils/point.d.ts +74 -20
- package/lib/utils/point.js +178 -48
- package/lib/utils/point.js.map +1 -1
- package/lib/utils/polygon.d.ts +17 -0
- package/lib/utils/polygon.js +66 -0
- package/lib/utils/polygon.js.map +1 -0
- package/lib/utils/position.d.ts +14 -1
- package/lib/utils/position.js +18 -1
- package/lib/utils/position.js.map +1 -1
- package/lib/utils/prefix.d.ts +1 -1
- package/lib/utils/prefix.js.map +1 -1
- package/lib/utils/shortcut.d.ts +11 -0
- package/lib/utils/shortcut.js +36 -4
- package/lib/utils/shortcut.js.map +1 -1
- package/lib/utils/style.js.map +1 -1
- package/lib/utils/vector.d.ts +3 -2
- package/lib/utils/vector.js +10 -3
- package/lib/utils/vector.js.map +1 -1
- package/package.json +6 -7
- package/src/behaviors/brush-select.ts +306 -0
- package/src/behaviors/click-element.ts +182 -0
- package/src/behaviors/collapse-expand.ts +13 -11
- package/src/behaviors/create-edge.ts +206 -0
- package/src/behaviors/drag-canvas.ts +22 -14
- package/src/behaviors/drag-element-force.ts +70 -0
- package/src/behaviors/drag-element.ts +32 -25
- package/src/behaviors/focus-element.ts +7 -6
- package/src/behaviors/hover-element.ts +16 -13
- package/src/behaviors/index.ts +10 -0
- package/src/behaviors/lasso-select.ts +103 -0
- package/src/behaviors/types.ts +2 -0
- package/src/behaviors/zoom-canvas.ts +14 -9
- package/src/constants/change.ts +1 -1
- package/src/constants/events/graph.ts +8 -16
- package/src/constants/index.ts +1 -0
- package/src/constants/registry.ts +22 -0
- package/src/elements/combos/base-combo.ts +83 -10
- package/src/elements/combos/circle.ts +8 -11
- package/src/elements/combos/rect.ts +5 -8
- package/src/elements/edges/base-edge.ts +95 -14
- package/src/elements/edges/cubic-horizontal.ts +2 -2
- package/src/elements/edges/cubic-vertical.ts +2 -2
- package/src/elements/edges/cubic.ts +2 -2
- package/src/elements/edges/polyline.ts +2 -2
- package/src/elements/edges/quadratic.ts +2 -2
- package/src/elements/nodes/base-node.ts +140 -20
- package/src/elements/nodes/circle.ts +5 -7
- package/src/elements/nodes/diamond.ts +4 -6
- package/src/elements/nodes/ellipse.ts +6 -8
- package/src/elements/nodes/hexagon.ts +7 -9
- package/src/elements/nodes/image.ts +12 -13
- package/src/elements/nodes/polygon.ts +17 -11
- package/src/elements/nodes/rect.ts +3 -4
- package/src/elements/nodes/star.ts +9 -11
- package/src/elements/nodes/triangle.ts +7 -9
- package/src/exports.ts +57 -12
- package/src/layouts/index.ts +1 -0
- package/src/layouts/types.ts +7 -5
- package/src/palettes/index.ts +13 -0
- package/src/plugins/camera-setting.ts +153 -0
- package/src/plugins/contextmenu.ts +10 -7
- package/src/plugins/history/events.ts +25 -0
- package/src/plugins/history/index.ts +222 -0
- package/src/plugins/history/utils.ts +98 -0
- package/src/plugins/hull/index.ts +149 -0
- package/src/plugins/hull/shape.ts +96 -0
- package/src/plugins/hull/util.ts +222 -0
- package/src/plugins/index.ts +8 -0
- package/src/plugins/legend.ts +321 -0
- package/src/plugins/tooltip.ts +16 -15
- package/src/preset.ts +2 -6
- package/src/registry/build-in.ts +33 -3
- package/src/registry/extension/index.ts +5 -5
- package/src/registry/index.ts +11 -4
- package/src/registry/types.ts +2 -7
- package/src/runtime/batch.ts +38 -0
- package/src/runtime/behavior.ts +4 -3
- package/src/runtime/canvas.ts +130 -52
- package/src/runtime/data.ts +31 -36
- package/src/runtime/element.ts +78 -185
- package/src/runtime/graph.ts +121 -15
- package/src/runtime/layout.ts +48 -79
- package/src/runtime/plugin.ts +5 -1
- package/src/runtime/transform.ts +27 -0
- package/src/runtime/types.ts +14 -0
- package/src/spec/index.ts +1 -0
- package/src/spec/spec.ts +7 -0
- package/src/spec/transform.ts +15 -0
- package/src/themes/base.ts +9 -1
- package/src/transforms/arrange-draw-order.ts +36 -0
- package/src/transforms/base-transform.ts +11 -0
- package/src/transforms/collapse-expand-combo.ts +87 -0
- package/src/transforms/index.ts +7 -0
- package/src/transforms/process-parallel-edges.ts +286 -0
- package/src/transforms/types.ts +23 -0
- package/src/transforms/update-related-edge.ts +28 -0
- package/src/types/canvas.ts +1 -1
- package/src/types/change.ts +28 -10
- package/src/types/element.ts +6 -147
- package/src/types/event.ts +62 -7
- package/src/types/index.ts +0 -1
- package/src/types/node.ts +3 -3
- package/src/types/point.ts +1 -0
- package/src/utils/animation.ts +6 -0
- package/src/utils/bbox.ts +1 -1
- package/src/utils/behaviors/brush.ts +29 -0
- package/src/utils/behaviors/lasso.ts +127 -0
- package/src/utils/behaviors/utils.ts +47 -0
- package/src/utils/change.ts +42 -1
- package/src/utils/combo.ts +6 -5
- package/src/utils/edge.ts +6 -1
- package/src/utils/element.ts +22 -11
- package/src/utils/event/events.ts +18 -18
- package/src/utils/extension.ts +1 -1
- package/src/utils/id.ts +11 -2
- package/src/utils/line.ts +50 -0
- package/src/utils/path.ts +153 -0
- package/src/utils/point.ts +190 -51
- package/src/utils/polygon.ts +72 -0
- package/src/utils/position.ts +18 -1
- package/src/utils/prefix.ts +1 -1
- package/src/utils/shortcut.ts +41 -5
- package/src/utils/style.ts +1 -1
- package/src/utils/vector.ts +10 -3
- package/dist/lib/types/behavior.d.ts +0 -5
- package/esm/elements/types.d.ts +0 -0
- package/esm/elements/types.js +0 -15
- package/esm/elements/types.js.map +0 -1
- package/esm/types/behavior.d.ts +0 -5
- package/esm/types/behavior.js +0 -2
- package/esm/types/behavior.js.map +0 -1
- package/lib/elements/types.d.ts +0 -0
- package/lib/elements/types.js +0 -15
- package/lib/elements/types.js.map +0 -1
- package/lib/types/behavior.d.ts +0 -5
- package/lib/types/behavior.js.map +0 -1
- package/src/elements/types.ts +0 -21
- package/src/types/behavior.ts +0 -6
package/src/runtime/behavior.ts
CHANGED
|
@@ -11,7 +11,7 @@ export class BehaviorController extends ExtensionController<BaseBehavior<CustomB
|
|
|
11
11
|
/** <zh/> 当前事件的目标 | <en/> The current event target */
|
|
12
12
|
private currentTarget: Target | null = null;
|
|
13
13
|
|
|
14
|
-
public category
|
|
14
|
+
public category = 'behavior' as const;
|
|
15
15
|
|
|
16
16
|
constructor(context: RuntimeContext) {
|
|
17
17
|
super(context);
|
|
@@ -59,12 +59,13 @@ export class BehaviorController extends ExtensionController<BaseBehavior<CustomB
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
private forwardCanvasEvents = (event: FederatedPointerEvent | FederatedWheelEvent) => {
|
|
62
|
-
const target =
|
|
62
|
+
const { target: originalTarget } = event;
|
|
63
|
+
const target = eventTargetOf(originalTarget as DisplayObject);
|
|
63
64
|
if (!target) return;
|
|
64
65
|
const { graph, canvas } = this.context;
|
|
65
66
|
const { type: targetType, element: targetElement } = target;
|
|
66
67
|
const { type, detail, button } = event;
|
|
67
|
-
const stdEvent = { ...event, target: targetElement, targetType };
|
|
68
|
+
const stdEvent = { ...event, target: targetElement, targetType, originalTarget };
|
|
68
69
|
|
|
69
70
|
if (type === CanvasEvent.POINTER_MOVE) {
|
|
70
71
|
if (this.currentTarget !== targetElement) {
|
package/src/runtime/canvas.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Cursor,
|
|
3
|
-
DataURLOptions,
|
|
4
3
|
DisplayObject,
|
|
5
4
|
CanvasConfig as GCanvasConfig,
|
|
5
|
+
DataURLOptions as GDataURLOptions,
|
|
6
|
+
IAnimation,
|
|
6
7
|
IRenderer,
|
|
7
8
|
PointLike,
|
|
8
9
|
} from '@antv/g';
|
|
9
|
-
import { Canvas as GCanvas } from '@antv/g';
|
|
10
|
+
import { CanvasEvent, Canvas as GCanvas } from '@antv/g';
|
|
10
11
|
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
11
12
|
import { Plugin as DragNDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
12
13
|
import { createDOM, isFunction, isString } from '@antv/util';
|
|
13
14
|
import type { CanvasOptions } from '../spec/canvas';
|
|
14
15
|
import type { CanvasLayer } from '../types/canvas';
|
|
15
|
-
import { getCombinedBBox } from '../utils/bbox';
|
|
16
|
+
import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
|
|
16
17
|
|
|
17
18
|
export interface CanvasConfig
|
|
18
19
|
extends Pick<GCanvasConfig, 'container' | 'devicePixelRatio' | 'width' | 'height' | 'cursor'> {
|
|
@@ -20,6 +21,19 @@ export interface CanvasConfig
|
|
|
20
21
|
background?: string;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
export interface DataURLOptions extends GDataURLOptions {
|
|
25
|
+
/**
|
|
26
|
+
* <zh/> 导出模式
|
|
27
|
+
* - viewport: 导出视口内容
|
|
28
|
+
* - overall: 导出整个画布
|
|
29
|
+
*
|
|
30
|
+
* <en/> export mode
|
|
31
|
+
* - viewport: export the content of the viewport
|
|
32
|
+
* - overall: export the entire canvas
|
|
33
|
+
*/
|
|
34
|
+
mode?: 'viewport' | 'overall';
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
/**
|
|
24
38
|
* @deprecated this canvas will be replace by layered canvas
|
|
25
39
|
*/
|
|
@@ -30,14 +44,12 @@ export class Canvas {
|
|
|
30
44
|
public main!: GCanvas;
|
|
31
45
|
public label!: GCanvas;
|
|
32
46
|
public transient!: GCanvas;
|
|
33
|
-
public transientLabel!: GCanvas;
|
|
34
47
|
|
|
35
48
|
public get canvas() {
|
|
36
49
|
return {
|
|
37
50
|
main: this.main,
|
|
38
51
|
label: this.label,
|
|
39
52
|
transient: this.transient,
|
|
40
|
-
transientLabel: this.transientLabel,
|
|
41
53
|
background: this.background,
|
|
42
54
|
};
|
|
43
55
|
}
|
|
@@ -48,21 +60,23 @@ export class Canvas {
|
|
|
48
60
|
|
|
49
61
|
public renderers!: Record<CanvasLayer, IRenderer>;
|
|
50
62
|
|
|
63
|
+
private initialized = false;
|
|
64
|
+
|
|
51
65
|
constructor(config: CanvasConfig) {
|
|
52
66
|
this.config = config;
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
public async init() {
|
|
56
|
-
|
|
70
|
+
if (this.initialized) return;
|
|
57
71
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const names: CanvasLayer[] = ['main', 'label', 'transient', 'transientLabel', 'background'];
|
|
72
|
+
const { renderer: getRenderer, background, ...restConfig } = this.config;
|
|
73
|
+
const names: CanvasLayer[] = ['main', 'label', 'transient', 'background'];
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
const { renderers, canvas } = names.reduce(
|
|
76
|
+
(acc, name) => {
|
|
77
|
+
const renderer = isFunction(getRenderer) ? getRenderer?.(name) : new CanvasRenderer();
|
|
65
78
|
|
|
79
|
+
if (name === 'main') {
|
|
66
80
|
renderer.registerPlugin(
|
|
67
81
|
new DragNDropPlugin({
|
|
68
82
|
isDocumentDraggable: true,
|
|
@@ -71,45 +85,45 @@ export class Canvas {
|
|
|
71
85
|
dragstartTimeThreshold: 100,
|
|
72
86
|
}),
|
|
73
87
|
);
|
|
88
|
+
} else {
|
|
89
|
+
renderer.unregisterPlugin(renderer.getPlugin('dom-interaction'));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const canvas = new GCanvas({
|
|
93
|
+
renderer,
|
|
94
|
+
supportsMutipleCanvasesInOneContainer: true,
|
|
95
|
+
...restConfig,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
acc.renderers[name] = renderer;
|
|
99
|
+
acc.canvas[name] = canvas;
|
|
100
|
+
this[name] = canvas;
|
|
101
|
+
|
|
102
|
+
return acc;
|
|
103
|
+
},
|
|
104
|
+
{ renderers: {}, canvas: {} } as {
|
|
105
|
+
renderers: Record<CanvasLayer, IRenderer>;
|
|
106
|
+
canvas: Record<CanvasLayer, GCanvas>;
|
|
107
|
+
},
|
|
108
|
+
);
|
|
74
109
|
|
|
75
|
-
|
|
76
|
-
renderer.unregisterPlugin(renderer.getPlugin('dom-interaction'));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const canvas = new GCanvas({
|
|
80
|
-
renderer,
|
|
81
|
-
supportsMutipleCanvasesInOneContainer: true,
|
|
82
|
-
...restConfig,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
acc.renderers[name] = renderer;
|
|
86
|
-
acc.canvas[name] = canvas;
|
|
87
|
-
this[name] = canvas;
|
|
88
|
-
|
|
89
|
-
return acc;
|
|
90
|
-
},
|
|
91
|
-
{ renderers: {}, canvas: {} } as {
|
|
92
|
-
renderers: Record<CanvasLayer, IRenderer>;
|
|
93
|
-
canvas: Record<CanvasLayer, GCanvas>;
|
|
94
|
-
},
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
this.renderers = renderers;
|
|
110
|
+
this.renderers = renderers;
|
|
98
111
|
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
Object.entries(canvas).forEach(([name, canvas]) => {
|
|
113
|
+
const domElement = canvas.getContextService().getDomElement() as unknown as HTMLElement;
|
|
101
114
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
domElement.style.position = 'absolute';
|
|
116
|
+
domElement.style.outline = 'none';
|
|
117
|
+
domElement.tabIndex = 1;
|
|
105
118
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
119
|
+
if (name !== 'main') domElement.style.pointerEvents = 'none';
|
|
120
|
+
});
|
|
109
121
|
|
|
110
122
|
this.setBackground();
|
|
111
123
|
|
|
112
|
-
|
|
124
|
+
await Promise.all(Object.values(this.canvas).map((canvas) => canvas.ready));
|
|
125
|
+
|
|
126
|
+
this.initialized = true;
|
|
113
127
|
}
|
|
114
128
|
|
|
115
129
|
public getRendererType(layer: CanvasLayer = 'main') {
|
|
@@ -172,7 +186,7 @@ export class Canvas {
|
|
|
172
186
|
Object.values(this.canvas)
|
|
173
187
|
.map((canvas) => canvas.document.documentElement)
|
|
174
188
|
.filter((el) => el.childNodes.length > 0)
|
|
175
|
-
.map((el) => el.
|
|
189
|
+
.map((el) => el.getRenderBounds()),
|
|
176
190
|
);
|
|
177
191
|
}
|
|
178
192
|
|
|
@@ -210,14 +224,28 @@ export class Canvas {
|
|
|
210
224
|
|
|
211
225
|
public async toDataURL(options: Partial<DataURLOptions> = {}) {
|
|
212
226
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
213
|
-
const {
|
|
227
|
+
const { mode = 'viewport', ...restOptions } = options;
|
|
228
|
+
|
|
229
|
+
let startX = 0;
|
|
230
|
+
let startY = 0;
|
|
231
|
+
let width = 0;
|
|
232
|
+
let height = 0;
|
|
233
|
+
|
|
234
|
+
if (mode === 'viewport') {
|
|
235
|
+
[width, height] = [this.config.width || 0, this.config.height || 0];
|
|
236
|
+
} else if (mode === 'overall') {
|
|
237
|
+
const bounds = this.getBounds();
|
|
238
|
+
const size = getBBoxSize(bounds);
|
|
239
|
+
[startX, startY] = bounds.min;
|
|
240
|
+
[width, height] = size;
|
|
241
|
+
}
|
|
214
242
|
|
|
215
243
|
const container: HTMLElement = createDOM('<div id="virtual-image"></div>');
|
|
216
244
|
|
|
217
245
|
const offscreenCanvas = new GCanvas({
|
|
218
246
|
width,
|
|
219
247
|
height,
|
|
220
|
-
renderer:
|
|
248
|
+
renderer: new CanvasRenderer(),
|
|
221
249
|
devicePixelRatio,
|
|
222
250
|
container,
|
|
223
251
|
background: this.background.getConfig().background,
|
|
@@ -243,13 +271,26 @@ export class Canvas {
|
|
|
243
271
|
|
|
244
272
|
const camera = this.main.getCamera();
|
|
245
273
|
const offscreenCamera = offscreenCanvas.getCamera();
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
274
|
+
|
|
275
|
+
if (mode === 'viewport') {
|
|
276
|
+
offscreenCamera.setZoom(camera.getZoom());
|
|
277
|
+
offscreenCamera.setPosition(camera.getPosition());
|
|
278
|
+
offscreenCamera.setFocalPoint(camera.getFocalPoint());
|
|
279
|
+
} else if (mode === 'overall') {
|
|
280
|
+
const [x, y, z] = offscreenCamera.getPosition();
|
|
281
|
+
const [fx, fy, fz] = offscreenCamera.getFocalPoint();
|
|
282
|
+
offscreenCamera.setPosition([x + startX, y + startY, z]);
|
|
283
|
+
offscreenCamera.setFocalPoint([fx + startX, fy + startY, fz]);
|
|
284
|
+
}
|
|
249
285
|
|
|
250
286
|
const contextService = offscreenCanvas.getContextService();
|
|
251
287
|
|
|
252
|
-
return
|
|
288
|
+
return new Promise<string>((resolve) => {
|
|
289
|
+
offscreenCanvas.on(CanvasEvent.AFTER_RENDER, async () => {
|
|
290
|
+
const url = await contextService.toDataURL(restOptions);
|
|
291
|
+
resolve(url);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
253
294
|
}
|
|
254
295
|
|
|
255
296
|
public destroy() {
|
|
@@ -263,9 +304,46 @@ export class Canvas {
|
|
|
263
304
|
camera.cancelLandmarkAnimation();
|
|
264
305
|
}
|
|
265
306
|
|
|
266
|
-
canvas
|
|
307
|
+
destroyCanvas(canvas);
|
|
267
308
|
// @ts-expect-error force delete
|
|
268
309
|
this[name] = undefined;
|
|
269
310
|
});
|
|
270
311
|
}
|
|
271
312
|
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* <zh/> G Canvas destroy 未处理动画对象,导致内存泄漏
|
|
316
|
+
*
|
|
317
|
+
* <en/> G Canvas destroy does not handle animation objects, causing memory leaks
|
|
318
|
+
* @param canvas GCanvas
|
|
319
|
+
* @description
|
|
320
|
+
* <zh/> 这些操作都应该在 G 中完成,这里只是一个临时的解决方案
|
|
321
|
+
* 此操作大概能在测试环节降低 10~20% 的内存占用(从 2800MB 降低到 2200MB)
|
|
322
|
+
*
|
|
323
|
+
* <en/> These operations should be completed in G, this is just a temporary solution
|
|
324
|
+
* This operation can reduce memory usage by 10-20% in the test environment (from 2800MB to 2200MB)
|
|
325
|
+
*/
|
|
326
|
+
function destroyCanvas(canvas: GCanvas) {
|
|
327
|
+
canvas.destroy();
|
|
328
|
+
|
|
329
|
+
// 移除相机事件 / Remove camera events
|
|
330
|
+
const camera = canvas.getCamera();
|
|
331
|
+
camera.eventEmitter.removeAllListeners();
|
|
332
|
+
|
|
333
|
+
canvas.document.timeline.destroy();
|
|
334
|
+
// @ts-expect-error private property
|
|
335
|
+
const { animationsWithPromises } = canvas.document.timeline;
|
|
336
|
+
// 释放 target 对象图形 / Release target object graphics
|
|
337
|
+
animationsWithPromises.forEach((animation: IAnimation) => {
|
|
338
|
+
if (animation.effect.target) animation.effect.target = null;
|
|
339
|
+
// @ts-expect-error private property
|
|
340
|
+
if (animation.effect.computedTiming) animation.effect.computedTiming = null;
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// @ts-expect-error private property
|
|
344
|
+
canvas.document.timeline.animationsWithPromises = [];
|
|
345
|
+
// @ts-expect-error private property
|
|
346
|
+
canvas.document.timeline.rafCallbacks = [];
|
|
347
|
+
// @ts-expect-error private property
|
|
348
|
+
canvas.document.timeline = null;
|
|
349
|
+
}
|
package/src/runtime/data.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Graph as GraphLib, ID } from '@antv/graphlib';
|
|
2
2
|
import { isEqual, isUndefined } from '@antv/util';
|
|
3
|
-
import { COMBO_KEY,
|
|
3
|
+
import { COMBO_KEY, ChangeType, TREE_KEY } from '../constants';
|
|
4
4
|
import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
|
|
5
5
|
import type {
|
|
6
6
|
DataAdded,
|
|
@@ -75,11 +75,7 @@ export class DataController {
|
|
|
75
75
|
if (this.isTraceless) return;
|
|
76
76
|
const { type } = change;
|
|
77
77
|
|
|
78
|
-
if (
|
|
79
|
-
type === ChangeTypeEnum.NodeUpdated ||
|
|
80
|
-
type === ChangeTypeEnum.EdgeUpdated ||
|
|
81
|
-
type === ChangeTypeEnum.ComboUpdated
|
|
82
|
-
) {
|
|
78
|
+
if (type === ChangeType.NodeUpdated || type === ChangeType.EdgeUpdated || type === ChangeType.ComboUpdated) {
|
|
83
79
|
const { value, original } = change;
|
|
84
80
|
this.changes.push({ value: cloneElementData(value), original: cloneElementData(original), type } as DataUpdated);
|
|
85
81
|
} else {
|
|
@@ -94,9 +90,11 @@ export class DataController {
|
|
|
94
90
|
* @returns <zh/> 数据变更 | <en/> data changes
|
|
95
91
|
*/
|
|
96
92
|
public getChanges(): DataChange[] {
|
|
97
|
-
|
|
93
|
+
return this.changes;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public clearChanges() {
|
|
98
97
|
this.changes = [];
|
|
99
|
-
return changes;
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
public batch(callback: () => void) {
|
|
@@ -157,8 +155,8 @@ export class DataController {
|
|
|
157
155
|
const data = toG6Data(combo);
|
|
158
156
|
if (!this.isCombo(idOf(data))) return acc;
|
|
159
157
|
|
|
160
|
-
if (ids === undefined) acc.push(data);
|
|
161
|
-
else ids.includes(idOf(data)) && acc.push(data);
|
|
158
|
+
if (ids === undefined) acc.push(data as ComboData);
|
|
159
|
+
else ids.includes(idOf(data)) && acc.push(data as ComboData);
|
|
162
160
|
return acc;
|
|
163
161
|
}, [] as ComboData[]);
|
|
164
162
|
}
|
|
@@ -183,10 +181,7 @@ export class DataController {
|
|
|
183
181
|
return data;
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
public getParentData(
|
|
187
|
-
id: ID,
|
|
188
|
-
hierarchy: HierarchyKey | undefined = this.inferStructureKey(id),
|
|
189
|
-
): NodeLikeData | undefined {
|
|
184
|
+
public getParentData(id: ID, hierarchy: HierarchyKey): NodeLikeData | undefined {
|
|
190
185
|
const { model } = this;
|
|
191
186
|
if (!hierarchy) {
|
|
192
187
|
console.error('The hierarchy structure key is not specified');
|
|
@@ -204,10 +199,6 @@ export class DataController {
|
|
|
204
199
|
return model.getChildren(id, structureKey).map(toG6Data);
|
|
205
200
|
}
|
|
206
201
|
|
|
207
|
-
private inferStructureKey(id: ID) {
|
|
208
|
-
if (this.isCombo(id)) return COMBO_KEY;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
202
|
/**
|
|
212
203
|
* <zh/> 获取指定类型元素的数据
|
|
213
204
|
*
|
|
@@ -326,7 +317,7 @@ export class DataController {
|
|
|
326
317
|
if (!nodes.length) return;
|
|
327
318
|
this.model.addNodes(
|
|
328
319
|
nodes.map((node) => {
|
|
329
|
-
this.pushChange({ value: node, type:
|
|
320
|
+
this.pushChange({ value: node, type: ChangeType.NodeAdded });
|
|
330
321
|
return toGraphlibData(node);
|
|
331
322
|
}),
|
|
332
323
|
);
|
|
@@ -337,7 +328,7 @@ export class DataController {
|
|
|
337
328
|
if (!edges.length) return;
|
|
338
329
|
this.model.addEdges(
|
|
339
330
|
edges.map((edge) => {
|
|
340
|
-
this.pushChange({ value: edge, type:
|
|
331
|
+
this.pushChange({ value: edge, type: ChangeType.EdgeAdded });
|
|
341
332
|
return toGraphlibData(edge);
|
|
342
333
|
}),
|
|
343
334
|
);
|
|
@@ -354,7 +345,7 @@ export class DataController {
|
|
|
354
345
|
model.addNodes(
|
|
355
346
|
combos.map((combo) => {
|
|
356
347
|
this.comboIds.add(idOf(combo));
|
|
357
|
-
this.pushChange({ value: combo, type:
|
|
348
|
+
this.pushChange({ value: combo, type: ChangeType.ComboAdded });
|
|
358
349
|
return toGraphlibData(combo);
|
|
359
350
|
}),
|
|
360
351
|
);
|
|
@@ -416,7 +407,7 @@ export class DataController {
|
|
|
416
407
|
if (isEqual(originalNode, modifiedNode)) return;
|
|
417
408
|
|
|
418
409
|
const value = mergeElementsData(originalNode, modifiedNode);
|
|
419
|
-
this.pushChange({ value, original: originalNode, type:
|
|
410
|
+
this.pushChange({ value, original: originalNode, type: ChangeType.NodeUpdated });
|
|
420
411
|
model.mergeNodeData(id, value);
|
|
421
412
|
modifiedNodes.push(value);
|
|
422
413
|
});
|
|
@@ -450,8 +441,8 @@ export class DataController {
|
|
|
450
441
|
model.updateEdgeTarget(id, modifiedEdge.target);
|
|
451
442
|
}
|
|
452
443
|
const updatedData = mergeElementsData(originalEdge, modifiedEdge);
|
|
444
|
+
this.pushChange({ value: updatedData, original: originalEdge, type: ChangeType.EdgeUpdated });
|
|
453
445
|
model.mergeEdgeData(id, updatedData);
|
|
454
|
-
this.pushChange({ value: updatedData, original: originalEdge, type: ChangeTypeEnum.EdgeUpdated });
|
|
455
446
|
});
|
|
456
447
|
});
|
|
457
448
|
}
|
|
@@ -463,11 +454,11 @@ export class DataController {
|
|
|
463
454
|
const modifiedCombos: ComboData[] = [];
|
|
464
455
|
combos.forEach((modifiedCombo) => {
|
|
465
456
|
const id = idOf(modifiedCombo);
|
|
466
|
-
const originalCombo = toG6Data(model.getNode(id));
|
|
457
|
+
const originalCombo = toG6Data(model.getNode(id)) as ComboData;
|
|
467
458
|
if (isEqual(originalCombo, modifiedCombo)) return;
|
|
468
459
|
|
|
469
460
|
const value = mergeElementsData(originalCombo, modifiedCombo);
|
|
470
|
-
this.pushChange({ value, original: originalCombo, type:
|
|
461
|
+
this.pushChange({ value, original: originalCombo, type: ChangeType.ComboUpdated });
|
|
471
462
|
model.mergeNodeData(id, value);
|
|
472
463
|
modifiedCombos.push(value);
|
|
473
464
|
});
|
|
@@ -517,12 +508,12 @@ export class DataController {
|
|
|
517
508
|
*/
|
|
518
509
|
public refreshComboData(id: ID) {
|
|
519
510
|
const combo = this.getComboData([id])[0];
|
|
520
|
-
const ancestors = this.getAncestorsData(id, COMBO_KEY);
|
|
511
|
+
const ancestors = this.getAncestorsData(id, COMBO_KEY) as ComboData[];
|
|
521
512
|
|
|
522
|
-
if (combo) this.pushChange({ value: combo, original: combo, type:
|
|
513
|
+
if (combo) this.pushChange({ value: combo, original: combo, type: ChangeType.ComboUpdated });
|
|
523
514
|
|
|
524
515
|
ancestors.forEach((value) => {
|
|
525
|
-
this.pushChange({ value: value, original: value, type:
|
|
516
|
+
this.pushChange({ value: value, original: value, type: ChangeType.ComboUpdated });
|
|
526
517
|
});
|
|
527
518
|
}
|
|
528
519
|
|
|
@@ -564,7 +555,7 @@ export class DataController {
|
|
|
564
555
|
if ([dx, dy, dz].some(isNaN) || [dx, dy, dz].every((o) => o === 0)) return;
|
|
565
556
|
const combo = this.getComboData([id])[0];
|
|
566
557
|
if (!combo) return;
|
|
567
|
-
dfs(
|
|
558
|
+
dfs<NodeLikeData>(
|
|
568
559
|
combo,
|
|
569
560
|
(succeed) => {
|
|
570
561
|
const succeedID = idOf(succeed);
|
|
@@ -574,9 +565,11 @@ export class DataController {
|
|
|
574
565
|
});
|
|
575
566
|
this.pushChange({
|
|
576
567
|
value,
|
|
568
|
+
// @ts-ignore
|
|
577
569
|
original: succeed,
|
|
578
|
-
type: this.isCombo(succeedID) ?
|
|
570
|
+
type: this.isCombo(succeedID) ? ChangeType.ComboUpdated : ChangeType.NodeUpdated,
|
|
579
571
|
});
|
|
572
|
+
|
|
580
573
|
this.model.mergeNodeData(succeedID, value);
|
|
581
574
|
},
|
|
582
575
|
(node) => this.getChildrenData(idOf(node)),
|
|
@@ -595,7 +588,7 @@ export class DataController {
|
|
|
595
588
|
const dy = ty - comboY;
|
|
596
589
|
const dz = tz - comboZ;
|
|
597
590
|
|
|
598
|
-
dfs(
|
|
591
|
+
dfs<NodeLikeData>(
|
|
599
592
|
combo,
|
|
600
593
|
(succeed) => {
|
|
601
594
|
const succeedId = idOf(succeed);
|
|
@@ -605,8 +598,9 @@ export class DataController {
|
|
|
605
598
|
});
|
|
606
599
|
this.pushChange({
|
|
607
600
|
value,
|
|
601
|
+
// @ts-ignore
|
|
608
602
|
original: succeed,
|
|
609
|
-
type: this.isCombo(succeedId) ?
|
|
603
|
+
type: this.isCombo(succeedId) ? ChangeType.ComboUpdated : ChangeType.NodeUpdated,
|
|
610
604
|
});
|
|
611
605
|
this.model.mergeNodeData(succeedId, value);
|
|
612
606
|
},
|
|
@@ -636,7 +630,7 @@ export class DataController {
|
|
|
636
630
|
this.removeEdgeData(this.getRelatedEdgesData(id).map(idOf));
|
|
637
631
|
// TODO 树图情况下移除子节点
|
|
638
632
|
|
|
639
|
-
this.pushChange({ value: this.getNodeData([id])[0], type:
|
|
633
|
+
this.pushChange({ value: this.getNodeData([id])[0], type: ChangeType.NodeRemoved });
|
|
640
634
|
this.removeNodeLikeHierarchy(id);
|
|
641
635
|
});
|
|
642
636
|
this.model.removeNodes(ids);
|
|
@@ -645,7 +639,7 @@ export class DataController {
|
|
|
645
639
|
|
|
646
640
|
public removeEdgeData(ids: ID[] = []) {
|
|
647
641
|
if (!ids.length) return;
|
|
648
|
-
ids.forEach((id) => this.pushChange({ value: this.getEdgeData([id])[0], type:
|
|
642
|
+
ids.forEach((id) => this.pushChange({ value: this.getEdgeData([id])[0], type: ChangeType.EdgeRemoved }));
|
|
649
643
|
this.model.removeEdges(ids);
|
|
650
644
|
}
|
|
651
645
|
|
|
@@ -653,7 +647,7 @@ export class DataController {
|
|
|
653
647
|
if (!ids.length) return;
|
|
654
648
|
this.batch(() => {
|
|
655
649
|
ids.forEach((id) => {
|
|
656
|
-
this.pushChange({ value: this.getComboData([id])[0], type:
|
|
650
|
+
this.pushChange({ value: this.getComboData([id])[0], type: ChangeType.ComboRemoved });
|
|
657
651
|
this.removeNodeLikeHierarchy(id);
|
|
658
652
|
this.comboIds.delete(id);
|
|
659
653
|
});
|
|
@@ -688,8 +682,9 @@ export class DataController {
|
|
|
688
682
|
});
|
|
689
683
|
this.pushChange({
|
|
690
684
|
value,
|
|
685
|
+
// @ts-ignore
|
|
691
686
|
original: childData,
|
|
692
|
-
type: this.isCombo(childId) ?
|
|
687
|
+
type: this.isCombo(childId) ? ChangeType.ComboUpdated : ChangeType.NodeUpdated,
|
|
693
688
|
});
|
|
694
689
|
this.model.mergeNodeData(idOf(childData), value);
|
|
695
690
|
});
|