@antv/g6 5.0.19 → 5.0.21
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/base-behavior.d.ts +10 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +9 -0
- package/dist/lib/behaviors/hover-activate.d.ts +16 -2
- package/dist/lib/behaviors/scroll-canvas.d.ts +9 -0
- package/dist/lib/elements/combos/circle.d.ts +1 -1
- package/dist/lib/elements/edges/cubic-radial.d.ts +24 -0
- package/dist/lib/elements/edges/index.d.ts +2 -0
- package/dist/lib/elements/edges/line.d.ts +0 -2
- package/dist/lib/elements/nodes/base-node.d.ts +2 -1
- package/dist/lib/elements/nodes/circle.d.ts +1 -1
- package/dist/lib/elements/nodes/ellipse.d.ts +1 -1
- package/dist/lib/elements/shapes/base-shape.d.ts +29 -14
- package/dist/lib/elements/shapes/polygon.d.ts +1 -1
- package/dist/lib/exports.d.ts +9 -7
- package/dist/lib/layouts/base-layout.d.ts +5 -0
- package/dist/lib/plugins/background/index.d.ts +1 -0
- package/dist/lib/plugins/base-plugin.d.ts +5 -0
- package/dist/lib/plugins/bubble-sets.d.ts +1 -0
- package/dist/lib/plugins/contextmenu/index.d.ts +1 -0
- package/dist/lib/plugins/grid-line.d.ts +1 -0
- package/dist/lib/plugins/history/index.d.ts +1 -0
- package/dist/lib/plugins/hull/index.d.ts +1 -0
- package/dist/lib/plugins/legend.d.ts +1 -0
- package/dist/lib/plugins/minimap/index.d.ts +8 -2
- package/dist/lib/plugins/snapline/index.d.ts +10 -0
- package/dist/lib/plugins/timebar.d.ts +1 -0
- package/dist/lib/plugins/toolbar/index.d.ts +1 -0
- package/dist/lib/plugins/tooltip.d.ts +11 -0
- package/dist/lib/plugins/watermark/index.d.ts +1 -0
- package/dist/lib/runtime/data.d.ts +1 -0
- package/dist/lib/runtime/element.d.ts +1 -0
- package/dist/lib/runtime/graph.d.ts +2 -0
- package/dist/lib/runtime/layout.d.ts +1 -0
- package/dist/lib/transforms/base-transform.d.ts +6 -0
- package/dist/lib/transforms/index.d.ts +3 -0
- package/dist/lib/transforms/position-radial-labels.d.ts +27 -0
- package/dist/lib/transforms/process-parallel-edges.d.ts +7 -9
- package/dist/lib/transforms/utils.d.ts +5 -5
- package/dist/lib/types/element.d.ts +2 -1
- package/dist/lib/utils/bbox.d.ts +12 -3
- package/dist/lib/utils/data.d.ts +14 -0
- package/dist/lib/utils/diff.d.ts +2 -1
- package/dist/lib/utils/padding.d.ts +4 -4
- package/dist/lib/utils/point.d.ts +17 -5
- package/dist/lib/utils/position.d.ts +8 -0
- package/dist/lib/utils/prefix.d.ts +1 -1
- package/dist/lib/utils/relation.d.ts +6 -4
- package/dist/lib/utils/router/orth.d.ts +1 -1
- package/dist/lib/utils/size.d.ts +3 -1
- package/dist/lib/utils/transform.d.ts +5 -5
- package/dist/lib/utils/vector.d.ts +8 -0
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/base-behavior.d.ts +10 -0
- package/esm/behaviors/base-behavior.js +5 -0
- package/esm/behaviors/base-behavior.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +9 -0
- package/esm/behaviors/drag-canvas.js +28 -3
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/hover-activate.d.ts +16 -2
- package/esm/behaviors/hover-activate.js +17 -7
- package/esm/behaviors/hover-activate.js.map +1 -1
- package/esm/behaviors/scroll-canvas.d.ts +9 -0
- package/esm/behaviors/scroll-canvas.js +31 -4
- package/esm/behaviors/scroll-canvas.js.map +1 -1
- package/esm/elements/combos/base-combo.js +2 -2
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/combos/circle.d.ts +1 -1
- package/esm/elements/combos/circle.js +2 -2
- package/esm/elements/combos/circle.js.map +1 -1
- package/esm/elements/edges/cubic-radial.d.ts +24 -0
- package/esm/elements/edges/cubic-radial.js +52 -0
- package/esm/elements/edges/cubic-radial.js.map +1 -0
- package/esm/elements/edges/index.d.ts +2 -0
- package/esm/elements/edges/index.js +1 -0
- package/esm/elements/edges/index.js.map +1 -1
- package/esm/elements/edges/line.d.ts +0 -2
- package/esm/elements/edges/line.js +0 -2
- package/esm/elements/edges/line.js.map +1 -1
- package/esm/elements/edges/polyline.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +2 -1
- package/esm/elements/nodes/base-node.js +3 -2
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/circle.d.ts +1 -1
- package/esm/elements/nodes/circle.js +2 -2
- package/esm/elements/nodes/circle.js.map +1 -1
- package/esm/elements/nodes/ellipse.d.ts +1 -1
- package/esm/elements/nodes/ellipse.js +2 -2
- package/esm/elements/nodes/ellipse.js.map +1 -1
- package/esm/elements/nodes/html.js +4 -1
- package/esm/elements/nodes/html.js.map +1 -1
- package/esm/elements/shapes/base-shape.d.ts +29 -14
- package/esm/elements/shapes/base-shape.js +27 -12
- package/esm/elements/shapes/base-shape.js.map +1 -1
- package/esm/elements/shapes/polygon.d.ts +1 -1
- package/esm/elements/shapes/polygon.js +2 -2
- package/esm/elements/shapes/polygon.js.map +1 -1
- package/esm/exports.d.ts +9 -7
- package/esm/exports.js +6 -4
- package/esm/exports.js.map +1 -1
- package/esm/layouts/base-layout.d.ts +5 -0
- package/esm/layouts/base-layout.js +5 -0
- package/esm/layouts/base-layout.js.map +1 -1
- package/esm/plugins/background/index.d.ts +1 -0
- package/esm/plugins/background/index.js +1 -0
- package/esm/plugins/background/index.js.map +1 -1
- package/esm/plugins/base-plugin.d.ts +5 -0
- package/esm/plugins/base-plugin.js +5 -0
- package/esm/plugins/base-plugin.js.map +1 -1
- package/esm/plugins/bubble-sets.d.ts +1 -0
- package/esm/plugins/bubble-sets.js +1 -0
- package/esm/plugins/bubble-sets.js.map +1 -1
- package/esm/plugins/contextmenu/index.d.ts +1 -0
- package/esm/plugins/contextmenu/index.js +1 -0
- package/esm/plugins/contextmenu/index.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +1 -0
- package/esm/plugins/grid-line.js +1 -0
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/history/index.d.ts +1 -0
- package/esm/plugins/history/index.js +1 -0
- package/esm/plugins/history/index.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +1 -0
- package/esm/plugins/hull/index.js +1 -0
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +1 -0
- package/esm/plugins/legend.js +1 -0
- package/esm/plugins/legend.js.map +1 -1
- package/esm/plugins/minimap/index.d.ts +8 -2
- package/esm/plugins/minimap/index.js +5 -0
- package/esm/plugins/minimap/index.js.map +1 -1
- package/esm/plugins/snapline/index.d.ts +10 -0
- package/esm/plugins/snapline/index.js +5 -0
- package/esm/plugins/snapline/index.js.map +1 -1
- package/esm/plugins/timebar.d.ts +1 -0
- package/esm/plugins/timebar.js +1 -0
- package/esm/plugins/timebar.js.map +1 -1
- package/esm/plugins/toolbar/index.d.ts +1 -0
- package/esm/plugins/toolbar/index.js +1 -0
- package/esm/plugins/toolbar/index.js.map +1 -1
- package/esm/plugins/tooltip.d.ts +11 -0
- package/esm/plugins/tooltip.js +11 -2
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/plugins/watermark/index.d.ts +1 -0
- package/esm/plugins/watermark/index.js +1 -0
- package/esm/plugins/watermark/index.js.map +1 -1
- package/esm/registry/build-in.js +4 -2
- package/esm/registry/build-in.js.map +1 -1
- package/esm/runtime/animation.js +12 -10
- package/esm/runtime/animation.js.map +1 -1
- package/esm/runtime/data.d.ts +1 -0
- package/esm/runtime/data.js +21 -13
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +1 -0
- package/esm/runtime/element.js +21 -11
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +2 -0
- package/esm/runtime/graph.js +42 -22
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.d.ts +1 -0
- package/esm/runtime/layout.js +5 -0
- package/esm/runtime/layout.js.map +1 -1
- package/esm/transforms/base-transform.d.ts +6 -0
- package/esm/transforms/base-transform.js +6 -0
- package/esm/transforms/base-transform.js.map +1 -1
- package/esm/transforms/collapse-expand-combo.js +3 -0
- package/esm/transforms/collapse-expand-combo.js.map +1 -1
- package/esm/transforms/collapse-expand-node.js +2 -0
- package/esm/transforms/collapse-expand-node.js.map +1 -1
- package/esm/transforms/index.d.ts +3 -0
- package/esm/transforms/index.js +1 -0
- package/esm/transforms/index.js.map +1 -1
- package/esm/transforms/position-radial-labels.d.ts +27 -0
- package/esm/transforms/position-radial-labels.js +50 -0
- package/esm/transforms/position-radial-labels.js.map +1 -0
- package/esm/transforms/process-parallel-edges.d.ts +7 -9
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/transforms/utils.d.ts +5 -5
- package/esm/transforms/utils.js +5 -5
- package/esm/types/element.d.ts +2 -1
- package/esm/utils/bbox.d.ts +12 -3
- package/esm/utils/bbox.js +16 -4
- package/esm/utils/bbox.js.map +1 -1
- package/esm/utils/data.d.ts +14 -0
- package/esm/utils/data.js +39 -0
- package/esm/utils/data.js.map +1 -1
- package/esm/utils/diff.d.ts +2 -1
- package/esm/utils/diff.js +3 -2
- package/esm/utils/diff.js.map +1 -1
- package/esm/utils/edge.js +4 -4
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/padding.d.ts +4 -4
- package/esm/utils/padding.js +4 -4
- package/esm/utils/point.d.ts +17 -5
- package/esm/utils/point.js +27 -8
- package/esm/utils/point.js.map +1 -1
- package/esm/utils/position.d.ts +8 -0
- package/esm/utils/position.js +11 -0
- package/esm/utils/position.js.map +1 -1
- package/esm/utils/prefix.d.ts +1 -1
- package/esm/utils/prefix.js +1 -1
- package/esm/utils/relation.d.ts +6 -4
- package/esm/utils/relation.js +10 -8
- package/esm/utils/relation.js.map +1 -1
- package/esm/utils/router/orth.d.ts +1 -1
- package/esm/utils/router/orth.js +27 -11
- package/esm/utils/router/orth.js.map +1 -1
- package/esm/utils/size.d.ts +3 -1
- package/esm/utils/size.js +3 -1
- package/esm/utils/size.js.map +1 -1
- package/esm/utils/transform.d.ts +5 -5
- package/esm/utils/transform.js +5 -5
- package/esm/utils/vector.d.ts +8 -0
- package/esm/utils/vector.js +13 -0
- package/esm/utils/vector.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/base-behavior.d.ts +10 -0
- package/lib/behaviors/base-behavior.js +5 -0
- package/lib/behaviors/base-behavior.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +9 -0
- package/lib/behaviors/drag-canvas.js +27 -2
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/hover-activate.d.ts +16 -2
- package/lib/behaviors/hover-activate.js +17 -7
- package/lib/behaviors/hover-activate.js.map +1 -1
- package/lib/behaviors/scroll-canvas.d.ts +9 -0
- package/lib/behaviors/scroll-canvas.js +31 -4
- package/lib/behaviors/scroll-canvas.js.map +1 -1
- package/lib/elements/combos/base-combo.js +1 -1
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/combos/circle.d.ts +1 -1
- package/lib/elements/combos/circle.js +2 -2
- package/lib/elements/combos/circle.js.map +1 -1
- package/lib/elements/edges/cubic-radial.d.ts +24 -0
- package/lib/elements/edges/cubic-radial.js +56 -0
- package/lib/elements/edges/cubic-radial.js.map +1 -0
- package/lib/elements/edges/index.d.ts +2 -0
- package/lib/elements/edges/index.js +3 -1
- package/lib/elements/edges/index.js.map +1 -1
- package/lib/elements/edges/line.d.ts +0 -2
- package/lib/elements/edges/line.js +0 -2
- package/lib/elements/edges/line.js.map +1 -1
- package/lib/elements/edges/polyline.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +2 -1
- package/lib/elements/nodes/base-node.js +3 -2
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/circle.d.ts +1 -1
- package/lib/elements/nodes/circle.js +2 -2
- package/lib/elements/nodes/circle.js.map +1 -1
- package/lib/elements/nodes/ellipse.d.ts +1 -1
- package/lib/elements/nodes/ellipse.js +2 -2
- package/lib/elements/nodes/ellipse.js.map +1 -1
- package/lib/elements/nodes/html.js +3 -0
- package/lib/elements/nodes/html.js.map +1 -1
- package/lib/elements/shapes/base-shape.d.ts +29 -14
- package/lib/elements/shapes/base-shape.js +27 -12
- package/lib/elements/shapes/base-shape.js.map +1 -1
- package/lib/elements/shapes/polygon.d.ts +1 -1
- package/lib/elements/shapes/polygon.js +2 -2
- package/lib/elements/shapes/polygon.js.map +1 -1
- package/lib/exports.d.ts +9 -7
- package/lib/exports.js +15 -6
- package/lib/exports.js.map +1 -1
- package/lib/layouts/base-layout.d.ts +5 -0
- package/lib/layouts/base-layout.js +5 -0
- package/lib/layouts/base-layout.js.map +1 -1
- package/lib/plugins/background/index.d.ts +1 -0
- package/lib/plugins/background/index.js +1 -0
- package/lib/plugins/background/index.js.map +1 -1
- package/lib/plugins/base-plugin.d.ts +5 -0
- package/lib/plugins/base-plugin.js +5 -0
- package/lib/plugins/base-plugin.js.map +1 -1
- package/lib/plugins/bubble-sets.d.ts +1 -0
- package/lib/plugins/bubble-sets.js +1 -0
- package/lib/plugins/bubble-sets.js.map +1 -1
- package/lib/plugins/contextmenu/index.d.ts +1 -0
- package/lib/plugins/contextmenu/index.js +1 -0
- package/lib/plugins/contextmenu/index.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +1 -0
- package/lib/plugins/grid-line.js +1 -0
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/history/index.d.ts +1 -0
- package/lib/plugins/history/index.js +1 -0
- package/lib/plugins/history/index.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +1 -0
- package/lib/plugins/hull/index.js +1 -0
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +1 -0
- package/lib/plugins/legend.js +1 -0
- package/lib/plugins/legend.js.map +1 -1
- package/lib/plugins/minimap/index.d.ts +8 -2
- package/lib/plugins/minimap/index.js +5 -0
- package/lib/plugins/minimap/index.js.map +1 -1
- package/lib/plugins/snapline/index.d.ts +10 -0
- package/lib/plugins/snapline/index.js +5 -0
- package/lib/plugins/snapline/index.js.map +1 -1
- package/lib/plugins/timebar.d.ts +1 -0
- package/lib/plugins/timebar.js +1 -0
- package/lib/plugins/timebar.js.map +1 -1
- package/lib/plugins/toolbar/index.d.ts +1 -0
- package/lib/plugins/toolbar/index.js +1 -0
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/tooltip.d.ts +11 -0
- package/lib/plugins/tooltip.js +11 -2
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/plugins/watermark/index.d.ts +1 -0
- package/lib/plugins/watermark/index.js +1 -0
- package/lib/plugins/watermark/index.js.map +1 -1
- package/lib/registry/build-in.js +2 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/runtime/animation.js +12 -10
- package/lib/runtime/animation.js.map +1 -1
- package/lib/runtime/data.d.ts +1 -0
- package/lib/runtime/data.js +19 -11
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +1 -0
- package/lib/runtime/element.js +21 -11
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +2 -0
- package/lib/runtime/graph.js +42 -22
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.d.ts +1 -0
- package/lib/runtime/layout.js +5 -0
- package/lib/runtime/layout.js.map +1 -1
- package/lib/transforms/base-transform.d.ts +6 -0
- package/lib/transforms/base-transform.js +6 -0
- package/lib/transforms/base-transform.js.map +1 -1
- package/lib/transforms/collapse-expand-combo.js +3 -0
- package/lib/transforms/collapse-expand-combo.js.map +1 -1
- package/lib/transforms/collapse-expand-node.js +2 -0
- package/lib/transforms/collapse-expand-node.js.map +1 -1
- package/lib/transforms/index.d.ts +3 -0
- package/lib/transforms/index.js +3 -1
- package/lib/transforms/index.js.map +1 -1
- package/lib/transforms/position-radial-labels.d.ts +27 -0
- package/lib/transforms/position-radial-labels.js +54 -0
- package/lib/transforms/position-radial-labels.js.map +1 -0
- package/lib/transforms/process-parallel-edges.d.ts +7 -9
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/transforms/utils.d.ts +5 -5
- package/lib/transforms/utils.js +5 -5
- package/lib/types/element.d.ts +2 -1
- package/lib/utils/bbox.d.ts +12 -3
- package/lib/utils/bbox.js +19 -6
- package/lib/utils/bbox.js.map +1 -1
- package/lib/utils/data.d.ts +14 -0
- package/lib/utils/data.js +40 -0
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/diff.d.ts +2 -1
- package/lib/utils/diff.js +3 -2
- package/lib/utils/diff.js.map +1 -1
- package/lib/utils/edge.js +3 -3
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/padding.d.ts +4 -4
- package/lib/utils/padding.js +4 -4
- package/lib/utils/point.d.ts +17 -5
- package/lib/utils/point.js +28 -8
- package/lib/utils/point.js.map +1 -1
- package/lib/utils/position.d.ts +8 -0
- package/lib/utils/position.js +12 -0
- package/lib/utils/position.js.map +1 -1
- package/lib/utils/prefix.d.ts +1 -1
- package/lib/utils/prefix.js +1 -1
- package/lib/utils/relation.d.ts +6 -4
- package/lib/utils/relation.js +10 -8
- package/lib/utils/relation.js.map +1 -1
- package/lib/utils/router/orth.d.ts +1 -1
- package/lib/utils/router/orth.js +25 -9
- package/lib/utils/router/orth.js.map +1 -1
- package/lib/utils/size.d.ts +3 -1
- package/lib/utils/size.js +3 -1
- package/lib/utils/size.js.map +1 -1
- package/lib/utils/transform.d.ts +5 -5
- package/lib/utils/transform.js +5 -5
- package/lib/utils/vector.d.ts +8 -0
- package/lib/utils/vector.js +14 -0
- package/lib/utils/vector.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +10 -10
- package/src/behaviors/base-behavior.ts +10 -0
- package/src/behaviors/drag-canvas.ts +42 -3
- package/src/behaviors/hover-activate.ts +39 -9
- package/src/behaviors/scroll-canvas.ts +45 -4
- package/src/elements/combos/base-combo.ts +2 -2
- package/src/elements/combos/circle.ts +2 -2
- package/src/elements/edges/cubic-radial.ts +77 -0
- package/src/elements/edges/index.ts +2 -0
- package/src/elements/edges/line.ts +0 -2
- package/src/elements/edges/polyline.ts +2 -0
- package/src/elements/nodes/base-node.ts +3 -2
- package/src/elements/nodes/circle.ts +2 -2
- package/src/elements/nodes/ellipse.ts +2 -2
- package/src/elements/nodes/html.ts +4 -1
- package/src/elements/shapes/base-shape.ts +29 -14
- package/src/elements/shapes/polygon.ts +2 -2
- package/src/exports.ts +21 -7
- package/src/layouts/base-layout.ts +5 -0
- package/src/plugins/background/index.ts +1 -0
- package/src/plugins/base-plugin.ts +5 -0
- package/src/plugins/bubble-sets.ts +1 -0
- package/src/plugins/contextmenu/index.ts +1 -0
- package/src/plugins/grid-line.ts +1 -0
- package/src/plugins/history/index.ts +1 -0
- package/src/plugins/hull/index.ts +1 -0
- package/src/plugins/legend.ts +1 -0
- package/src/plugins/minimap/index.ts +8 -2
- package/src/plugins/snapline/index.ts +10 -0
- package/src/plugins/timebar.ts +1 -0
- package/src/plugins/toolbar/index.ts +1 -0
- package/src/plugins/tooltip.ts +15 -2
- package/src/plugins/watermark/index.ts +1 -0
- package/src/registry/build-in.ts +4 -0
- package/src/runtime/animation.ts +16 -11
- package/src/runtime/data.ts +20 -13
- package/src/runtime/element.ts +23 -11
- package/src/runtime/graph.ts +51 -22
- package/src/runtime/layout.ts +7 -0
- package/src/transforms/base-transform.ts +7 -0
- package/src/transforms/collapse-expand-combo.ts +2 -0
- package/src/transforms/collapse-expand-node.ts +3 -0
- package/src/transforms/index.ts +3 -0
- package/src/transforms/position-radial-labels.ts +76 -0
- package/src/transforms/process-parallel-edges.ts +7 -9
- package/src/transforms/utils.ts +5 -5
- package/src/types/element.ts +2 -1
- package/src/utils/bbox.ts +17 -4
- package/src/utils/data.ts +49 -0
- package/src/utils/diff.ts +8 -2
- package/src/utils/edge.ts +4 -4
- package/src/utils/padding.ts +4 -4
- package/src/utils/point.ts +27 -7
- package/src/utils/position.ts +12 -0
- package/src/utils/prefix.ts +1 -1
- package/src/utils/relation.ts +22 -9
- package/src/utils/router/orth.ts +29 -11
- package/src/utils/size.ts +3 -1
- package/src/utils/transform.ts +5 -5
- package/src/utils/vector.ts +13 -0
- package/src/version.ts +1 -1
package/lib/utils/transform.js
CHANGED
|
@@ -27,11 +27,11 @@ function replaceTranslateInTransform(x, y, z, transform) {
|
|
|
27
27
|
* <zh/> 重新分配绘制任务
|
|
28
28
|
*
|
|
29
29
|
* <en/> Reassign drawing tasks
|
|
30
|
-
* @param input - <zh
|
|
31
|
-
* @param type - <zh
|
|
32
|
-
* @param elementType - <zh
|
|
33
|
-
* @param datum - <zh
|
|
34
|
-
* @param merge - <zh
|
|
30
|
+
* @param input - <zh/>绘制数据 | <en/>DrawData
|
|
31
|
+
* @param type - <zh/>类型 | <en/>type
|
|
32
|
+
* @param elementType - <zh/>元素类型 | <en/>element type
|
|
33
|
+
* @param datum - <zh/>数据 | <en/>data
|
|
34
|
+
* @param merge - <zh/>是否合并 | <en/>whether to merge
|
|
35
35
|
*/
|
|
36
36
|
const reassignTo = (input, type, elementType, datum, merge = false) => {
|
|
37
37
|
const id = (0, id_1.idOf)(datum);
|
package/lib/utils/vector.d.ts
CHANGED
|
@@ -141,3 +141,11 @@ export declare function toVector2(a: Vector2 | Vector3): Vector2;
|
|
|
141
141
|
* @returns - <zh/> 三维向量 | <en/> Three-dimensional vector
|
|
142
142
|
*/
|
|
143
143
|
export declare function toVector3(a: Vector2 | Vector3): Vector3;
|
|
144
|
+
/**
|
|
145
|
+
* <zh/> 计算向量与 x 轴正方向的夹角(弧度制)
|
|
146
|
+
*
|
|
147
|
+
* <en/> The angle between the vector and the positive direction of the x-axis (radians)
|
|
148
|
+
* @param a - <zh/> 向量 | <en/> The vector
|
|
149
|
+
* @returns <zh/> 弧度值 | <en/> The angle in radians
|
|
150
|
+
*/
|
|
151
|
+
export declare function rad(a: Vector2 | Vector3): number;
|
package/lib/utils/vector.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.perpendicular = perpendicular;
|
|
|
16
16
|
exports.mod = mod;
|
|
17
17
|
exports.toVector2 = toVector2;
|
|
18
18
|
exports.toVector3 = toVector3;
|
|
19
|
+
exports.rad = rad;
|
|
19
20
|
const is_1 = require("./is");
|
|
20
21
|
const VECTOR_ZERO = [0, 0, 0];
|
|
21
22
|
/**
|
|
@@ -206,4 +207,17 @@ function toVector2(a) {
|
|
|
206
207
|
function toVector3(a) {
|
|
207
208
|
return (0, is_1.isVector2)(a) ? [a[0], a[1], 0] : a;
|
|
208
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* <zh/> 计算向量与 x 轴正方向的夹角(弧度制)
|
|
212
|
+
*
|
|
213
|
+
* <en/> The angle between the vector and the positive direction of the x-axis (radians)
|
|
214
|
+
* @param a - <zh/> 向量 | <en/> The vector
|
|
215
|
+
* @returns <zh/> 弧度值 | <en/> The angle in radians
|
|
216
|
+
*/
|
|
217
|
+
function rad(a) {
|
|
218
|
+
const [x, y] = a;
|
|
219
|
+
if (!x && !y)
|
|
220
|
+
return 0;
|
|
221
|
+
return Math.atan2(y, x);
|
|
222
|
+
}
|
|
209
223
|
//# sourceMappingURL=vector.js.map
|
package/lib/utils/vector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.js","sourceRoot":"src/","sources":["utils/vector.ts"],"names":[],"mappings":";;AAaA,kBAEC;AAUD,4BAEC;AAUD,4BAGC;AAUD,wBAGC;AAUD,kBAEC;AAUD,sBAIC;AAUD,sBAEC;AAUD,4BAEC;AAUD,8CAEC;AASD,8BAGC;AAWD,sBAWC;AAUD,kCAEC;AAUD,sCAEC;AAUD,kBAEC;AASD,8BAEC;AASD,8BAEC;
|
|
1
|
+
{"version":3,"file":"vector.js","sourceRoot":"src/","sources":["utils/vector.ts"],"names":[],"mappings":";;AAaA,kBAEC;AAUD,4BAEC;AAUD,4BAGC;AAUD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AE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,GAAG,CAAC,CAAoB;IACtC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACvB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.0.
|
|
1
|
+
export declare const version = "5.0.21";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g6",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.21",
|
|
4
4
|
"description": "A Graph Visualization Framework in JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"README"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@antv/component": "^2.0.
|
|
35
|
+
"@antv/component": "^2.0.4",
|
|
36
36
|
"@antv/event-emitter": "^0.1.3",
|
|
37
|
-
"@antv/g": "^6.0.
|
|
38
|
-
"@antv/g-canvas": "^2.0.
|
|
39
|
-
"@antv/g-plugin-dragndrop": "^2.0.
|
|
37
|
+
"@antv/g": "^6.0.13",
|
|
38
|
+
"@antv/g-canvas": "^2.0.12",
|
|
39
|
+
"@antv/g-plugin-dragndrop": "^2.0.9",
|
|
40
40
|
"@antv/graphlib": "^2.0.3",
|
|
41
|
-
"@antv/hierarchy": "^0.6.
|
|
42
|
-
"@antv/layout": "
|
|
43
|
-
"@antv/util": "^3.3.
|
|
41
|
+
"@antv/hierarchy": "^0.6.13",
|
|
42
|
+
"@antv/layout": "1.2.14-beta.6",
|
|
43
|
+
"@antv/util": "^3.3.8",
|
|
44
44
|
"bubblesets-js": "^2.3.3",
|
|
45
45
|
"hull.js": "^1.0.6"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@antv/g-svg": "^2.0.
|
|
49
|
-
"@antv/g-webgl": "^2.0.
|
|
48
|
+
"@antv/g-svg": "^2.0.11",
|
|
49
|
+
"@antv/g-webgl": "^2.0.16",
|
|
50
50
|
"@antv/layout-gpu": "^1.1.6",
|
|
51
51
|
"@antv/layout-wasm": "^1.4.1",
|
|
52
52
|
"@types/hull.js": "^1.0.4",
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { BaseExtension } from '../registry/extension';
|
|
2
2
|
import type { CustomBehaviorOption } from '../spec/behavior';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* <zh/> 交互通用配置项
|
|
6
|
+
*
|
|
7
|
+
* <en/> Base options for behaviors
|
|
8
|
+
*/
|
|
4
9
|
export interface BaseBehaviorOptions extends CustomBehaviorOption {}
|
|
5
10
|
|
|
11
|
+
/**
|
|
12
|
+
* <zh/> 交互的基类
|
|
13
|
+
*
|
|
14
|
+
* <en/> Base class for behaviors
|
|
15
|
+
*/
|
|
6
16
|
export abstract class BaseBehavior<T extends BaseBehaviorOptions = BaseBehaviorOptions> extends BaseExtension<T> {}
|
|
@@ -3,9 +3,11 @@ import { debounce, isObject } from '@antv/util';
|
|
|
3
3
|
import { CommonEvent } from '../constants';
|
|
4
4
|
import type { RuntimeContext } from '../runtime/types';
|
|
5
5
|
import type { IKeyboardEvent, IPointerEvent, Vector2, ViewportAnimationEffectTiming } from '../types';
|
|
6
|
+
import { getExpandedBBox, getPointBBox, isPointInBBox } from '../utils/bbox';
|
|
7
|
+
import { parsePadding } from '../utils/padding';
|
|
6
8
|
import type { ShortcutKey } from '../utils/shortcut';
|
|
7
9
|
import { Shortcut } from '../utils/shortcut';
|
|
8
|
-
import { multiply } from '../utils/vector';
|
|
10
|
+
import { multiply, subtract } from '../utils/vector';
|
|
9
11
|
import type { BaseBehaviorOptions } from './base-behavior';
|
|
10
12
|
import { BaseBehavior } from './base-behavior';
|
|
11
13
|
|
|
@@ -41,6 +43,13 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
|
|
|
41
43
|
* @defaultValue `'both'`
|
|
42
44
|
*/
|
|
43
45
|
direction?: 'x' | 'y' | 'both';
|
|
46
|
+
/**
|
|
47
|
+
* <zh/> 可拖拽的视口范围,默认最多可拖拽一屏。可以分别设置上、右、下、左四个方向的范围,每个方向的范围在 [0, Infinity] 之间
|
|
48
|
+
*
|
|
49
|
+
* <en/> The draggable viewport range allows you to drag up to one screen by default. You can set the range for each direction (top, right, bottom, left) individually, with each direction's range between [0, Infinity]
|
|
50
|
+
* @defaultValue 1
|
|
51
|
+
*/
|
|
52
|
+
range?: number | number[];
|
|
44
53
|
/**
|
|
45
54
|
* <zh/> 触发拖拽的方式,默认使用指针按下拖拽
|
|
46
55
|
*
|
|
@@ -80,6 +89,7 @@ export class DragCanvas extends BaseBehavior<DragCanvasOptions> {
|
|
|
80
89
|
},
|
|
81
90
|
sensitivity: 10,
|
|
82
91
|
direction: 'both',
|
|
92
|
+
range: 1,
|
|
83
93
|
};
|
|
84
94
|
|
|
85
95
|
private shortcut: Shortcut;
|
|
@@ -169,16 +179,45 @@ export class DragCanvas extends BaseBehavior<DragCanvasOptions> {
|
|
|
169
179
|
* @internal
|
|
170
180
|
*/
|
|
171
181
|
protected async translate(offset: Vector2, animation?: ViewportAnimationEffectTiming) {
|
|
172
|
-
|
|
182
|
+
offset = this.clampByDirection(offset);
|
|
183
|
+
offset = this.clampByRange(offset);
|
|
173
184
|
|
|
185
|
+
await this.context.graph.translateBy(offset, animation);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private clampByDirection([dx, dy]: Vector2): Vector2 {
|
|
174
189
|
const { direction } = this.options;
|
|
175
190
|
if (direction === 'x') {
|
|
176
191
|
dy = 0;
|
|
177
192
|
} else if (direction === 'y') {
|
|
178
193
|
dx = 0;
|
|
179
194
|
}
|
|
195
|
+
return [dx, dy];
|
|
196
|
+
}
|
|
180
197
|
|
|
181
|
-
|
|
198
|
+
private clampByRange([dx, dy]: Vector2): Vector2 {
|
|
199
|
+
const { viewport, canvas } = this.context;
|
|
200
|
+
|
|
201
|
+
const [canvasWidth, canvasHeight] = canvas.getSize();
|
|
202
|
+
const [top, right, bottom, left] = parsePadding(this.options.range);
|
|
203
|
+
const range = [canvasHeight * top, canvasWidth * right, canvasHeight * bottom, canvasWidth * left];
|
|
204
|
+
const draggableArea = getExpandedBBox(getPointBBox(viewport!.getCanvasCenter()), range);
|
|
205
|
+
|
|
206
|
+
const nextViewportCenter = subtract(viewport!.getViewportCenter(), [dx, dy, 0]);
|
|
207
|
+
if (!isPointInBBox(nextViewportCenter, draggableArea)) {
|
|
208
|
+
const {
|
|
209
|
+
min: [minX, minY],
|
|
210
|
+
max: [maxX, maxY],
|
|
211
|
+
} = draggableArea;
|
|
212
|
+
|
|
213
|
+
if ((nextViewportCenter[0] < minX && dx > 0) || (nextViewportCenter[0] > maxX && dx < 0)) {
|
|
214
|
+
dx = 0;
|
|
215
|
+
}
|
|
216
|
+
if ((nextViewportCenter[1] < minY && dy > 0) || (nextViewportCenter[1] > maxY && dy < 0)) {
|
|
217
|
+
dy = 0;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return [dx, dy];
|
|
182
221
|
}
|
|
183
222
|
|
|
184
223
|
private validate(event: IPointerEvent | IKeyboardEvent) {
|
|
@@ -2,7 +2,7 @@ import { isFunction } from '@antv/util';
|
|
|
2
2
|
import { CommonEvent } from '../constants';
|
|
3
3
|
import { ELEMENT_TYPES } from '../constants/element';
|
|
4
4
|
import type { RuntimeContext } from '../runtime/types';
|
|
5
|
-
import type { Element, ElementType, ID, IDragEvent, IPointerEvent, State } from '../types';
|
|
5
|
+
import type { EdgeDirection, Element, ElementType, ID, IDragEvent, IPointerEvent, State } from '../types';
|
|
6
6
|
import { idsOf } from '../utils/id';
|
|
7
7
|
import { getElementNthDegreeIds } from '../utils/relation';
|
|
8
8
|
import type { BaseBehaviorOptions } from './base-behavior';
|
|
@@ -38,7 +38,20 @@ export interface HoverActivateOptions extends BaseBehaviorOptions {
|
|
|
38
38
|
* - `1` means the current node and its directly adjacent nodes and edges are activated, etc
|
|
39
39
|
* @defaultValue 0
|
|
40
40
|
*/
|
|
41
|
-
degree?: number;
|
|
41
|
+
degree?: number | ((event: IPointerEvent) => number);
|
|
42
|
+
/**
|
|
43
|
+
* <zh/> 指定边的方向
|
|
44
|
+
* - `'both'`: 表示激活当前节点的所有关系
|
|
45
|
+
* - `'in'`: 表示激活当前节点的入边和入节点
|
|
46
|
+
* - `'out'`: 表示激活当前节点的出边和出节点
|
|
47
|
+
*
|
|
48
|
+
* <en/> Specify the direction of the edge
|
|
49
|
+
* - `'both'`: Activate all relationships of the current node
|
|
50
|
+
* - `'in'`: Activate the incoming edges and nodes of the current node
|
|
51
|
+
* - `'out'`: Activate the outgoing edges and nodes of the current node
|
|
52
|
+
* @defaultValue 'both'
|
|
53
|
+
*/
|
|
54
|
+
direction?: EdgeDirection;
|
|
42
55
|
/**
|
|
43
56
|
* <zh/> 激活元素的状态,默认为 `active`
|
|
44
57
|
*
|
|
@@ -80,6 +93,7 @@ export class HoverActivate extends BaseBehavior<HoverActivateOptions> {
|
|
|
80
93
|
animation: false,
|
|
81
94
|
enable: true,
|
|
82
95
|
degree: 0,
|
|
96
|
+
direction: 'both',
|
|
83
97
|
state: 'active',
|
|
84
98
|
inactiveState: undefined,
|
|
85
99
|
};
|
|
@@ -119,16 +133,29 @@ export class HoverActivate extends BaseBehavior<HoverActivateOptions> {
|
|
|
119
133
|
else onHoverEnd?.(event);
|
|
120
134
|
};
|
|
121
135
|
|
|
136
|
+
protected getActiveIds(event: IPointerEvent<Element>) {
|
|
137
|
+
const { graph } = this.context;
|
|
138
|
+
const { degree, direction } = this.options;
|
|
139
|
+
const { targetType, target } = event;
|
|
140
|
+
|
|
141
|
+
return degree
|
|
142
|
+
? getElementNthDegreeIds(
|
|
143
|
+
graph,
|
|
144
|
+
targetType as ElementType,
|
|
145
|
+
target.id,
|
|
146
|
+
typeof degree === 'function' ? degree(event) : degree,
|
|
147
|
+
direction,
|
|
148
|
+
)
|
|
149
|
+
: [target.id];
|
|
150
|
+
}
|
|
151
|
+
|
|
122
152
|
private updateElementsState = (event: IPointerEvent<Element>, add: boolean) => {
|
|
123
153
|
if (!this.options.state && !this.options.inactiveState) return;
|
|
124
154
|
|
|
125
155
|
const { graph } = this.context;
|
|
126
|
-
const { state,
|
|
127
|
-
const { targetType, target } = event;
|
|
156
|
+
const { state, animation, inactiveState } = this.options;
|
|
128
157
|
|
|
129
|
-
const activeIds =
|
|
130
|
-
? getElementNthDegreeIds(graph, targetType as ElementType, target.id, degree)
|
|
131
|
-
: [target.id];
|
|
158
|
+
const activeIds = this.getActiveIds(event);
|
|
132
159
|
|
|
133
160
|
const states: Record<ID, State[]> = {};
|
|
134
161
|
|
|
@@ -148,8 +175,11 @@ export class HoverActivate extends BaseBehavior<HoverActivateOptions> {
|
|
|
148
175
|
const states: Record<ID, State[]> = {};
|
|
149
176
|
ids.forEach((id) => {
|
|
150
177
|
const currentState = graph.getElementState(id);
|
|
151
|
-
|
|
152
|
-
|
|
178
|
+
if (add) {
|
|
179
|
+
states[id] = currentState.includes(state) ? currentState : [...currentState, state];
|
|
180
|
+
} else {
|
|
181
|
+
states[id] = currentState.filter((s) => s !== state);
|
|
182
|
+
}
|
|
153
183
|
});
|
|
154
184
|
return states;
|
|
155
185
|
};
|
|
@@ -2,7 +2,10 @@ import { isFunction, isObject } from '@antv/util';
|
|
|
2
2
|
import { CommonEvent } from '../constants';
|
|
3
3
|
import type { RuntimeContext } from '../runtime/types';
|
|
4
4
|
import type { IKeyboardEvent, Point } from '../types';
|
|
5
|
+
import { getExpandedBBox, getPointBBox, isPointInBBox } from '../utils/bbox';
|
|
6
|
+
import { parsePadding } from '../utils/padding';
|
|
5
7
|
import { Shortcut, ShortcutKey } from '../utils/shortcut';
|
|
8
|
+
import { multiply, subtract } from '../utils/vector';
|
|
6
9
|
import type { BaseBehaviorOptions } from './base-behavior';
|
|
7
10
|
import { BaseBehavior } from './base-behavior';
|
|
8
11
|
|
|
@@ -42,6 +45,13 @@ export interface ScrollCanvasOptions extends BaseBehaviorOptions {
|
|
|
42
45
|
* - `'y'`: only allow vertical scrolling
|
|
43
46
|
*/
|
|
44
47
|
direction?: 'x' | 'y';
|
|
48
|
+
/**
|
|
49
|
+
* <zh/> 可滚动的视口范围,默认最多可滚动一屏。可以分别设置上、右、下、左四个方向的范围,每个方向的范围在 [0, Infinity] 之间
|
|
50
|
+
*
|
|
51
|
+
* <en/> The scrollable viewport range allows you to scroll up to one screen by default. You can set the range for each direction (top, right, bottom, left) individually, with each direction's range between [0, Infinity]
|
|
52
|
+
* @defaultValue 1
|
|
53
|
+
*/
|
|
54
|
+
range?: number | number[];
|
|
45
55
|
/**
|
|
46
56
|
* <zh/> 滚动灵敏度
|
|
47
57
|
*
|
|
@@ -74,6 +84,7 @@ export class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
|
|
|
74
84
|
enable: true,
|
|
75
85
|
sensitivity: 1,
|
|
76
86
|
preventDefault: true,
|
|
87
|
+
range: 0.5,
|
|
77
88
|
};
|
|
78
89
|
|
|
79
90
|
private shortcut: Shortcut;
|
|
@@ -130,18 +141,48 @@ export class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
|
|
|
130
141
|
await this.scroll([-diffX, -diffY], event);
|
|
131
142
|
};
|
|
132
143
|
|
|
133
|
-
private formatDisplacement(
|
|
134
|
-
const {
|
|
144
|
+
private formatDisplacement(d: Point) {
|
|
145
|
+
const { sensitivity } = this.options;
|
|
135
146
|
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
d = multiply(d, sensitivity);
|
|
148
|
+
d = this.clampByDirection(d);
|
|
149
|
+
d = this.clampByRange(d);
|
|
138
150
|
|
|
151
|
+
return d;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private clampByDirection([dx, dy]: Point) {
|
|
155
|
+
const { direction } = this.options;
|
|
139
156
|
if (direction === 'x') {
|
|
140
157
|
dy = 0;
|
|
141
158
|
} else if (direction === 'y') {
|
|
142
159
|
dx = 0;
|
|
143
160
|
}
|
|
161
|
+
return [dx, dy] as Point;
|
|
162
|
+
}
|
|
144
163
|
|
|
164
|
+
private clampByRange([dx, dy]: Point) {
|
|
165
|
+
const { viewport, canvas } = this.context;
|
|
166
|
+
|
|
167
|
+
const [canvasWidth, canvasHeight] = canvas.getSize();
|
|
168
|
+
const [top, right, bottom, left] = parsePadding(this.options.range);
|
|
169
|
+
const range = [canvasHeight * top, canvasWidth * right, canvasHeight * bottom, canvasWidth * left];
|
|
170
|
+
const scrollableArea = getExpandedBBox(getPointBBox(viewport!.getCanvasCenter()), range);
|
|
171
|
+
|
|
172
|
+
const nextViewportCenter = subtract(viewport!.getViewportCenter(), [dx, dy, 0]);
|
|
173
|
+
if (!isPointInBBox(nextViewportCenter, scrollableArea)) {
|
|
174
|
+
const {
|
|
175
|
+
min: [minX, minY],
|
|
176
|
+
max: [maxX, maxY],
|
|
177
|
+
} = scrollableArea;
|
|
178
|
+
|
|
179
|
+
if ((nextViewportCenter[0] < minX && dx > 0) || (nextViewportCenter[0] > maxX && dx < 0)) {
|
|
180
|
+
dx = 0;
|
|
181
|
+
}
|
|
182
|
+
if ((nextViewportCenter[1] < minY && dy > 0) || (nextViewportCenter[1] > maxY && dy < 0)) {
|
|
183
|
+
dy = 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
145
186
|
return [dx, dy] as Point;
|
|
146
187
|
}
|
|
147
188
|
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
import { getBBoxHeight, getBBoxWidth, getCombinedBBox, getExpandedBBox } from '../../utils/bbox';
|
|
16
16
|
import { idOf } from '../../utils/id';
|
|
17
17
|
import { parsePadding } from '../../utils/padding';
|
|
18
|
-
import { getXYByPlacement, positionOf } from '../../utils/position';
|
|
18
|
+
import { getXYByPlacement, hasPosition, positionOf } from '../../utils/position';
|
|
19
19
|
import { subStyleProps } from '../../utils/prefix';
|
|
20
20
|
import { parseSize } from '../../utils/size';
|
|
21
21
|
import { mergeOptions } from '../../utils/style';
|
|
@@ -210,7 +210,7 @@ export abstract class BaseCombo<S extends BaseComboStyleProps = BaseComboStylePr
|
|
|
210
210
|
const { model } = context!;
|
|
211
211
|
const descendants = model.getDescendantsData(this.id).filter((datum) => !model.isCombo(idOf(datum)));
|
|
212
212
|
|
|
213
|
-
if (descendants.length > 0) {
|
|
213
|
+
if (descendants.length > 0 && descendants.some(hasPosition)) {
|
|
214
214
|
// combo 被收起,返回平均中心位置 / combo is collapsed, return the average center position
|
|
215
215
|
const totalPosition = descendants.reduce((acc, datum) => add(acc, positionOf(datum)), [0, 0, 0] as Point);
|
|
216
216
|
return divide(totalPosition, descendants.length);
|
|
@@ -54,8 +54,8 @@ export class CircleCombo extends BaseCombo<CircleComboStyleProps> {
|
|
|
54
54
|
return [expandedR * 2, expandedR * 2, 0];
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
public getIntersectPoint(point: Point): Point {
|
|
57
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
58
58
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
59
|
-
return getEllipseIntersectPoint(point, keyShapeBounds);
|
|
59
|
+
return getEllipseIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
|
+
import type { NodeData } from '../../spec';
|
|
3
|
+
import type { Point } from '../../types';
|
|
4
|
+
import { positionOf } from '../../utils/position';
|
|
5
|
+
import { mergeOptions } from '../../utils/style';
|
|
6
|
+
import { distance, rad, subtract } from '../../utils/vector';
|
|
7
|
+
import type { CubicStyleProps } from './cubic';
|
|
8
|
+
import { Cubic } from './cubic';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* <zh/> 径向贝塞尔曲线样式配置项
|
|
12
|
+
*
|
|
13
|
+
* <en/> Radial cubic style props
|
|
14
|
+
*/
|
|
15
|
+
export interface CubicRadialStyleProps extends CubicStyleProps {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* <zh/> 径向贝塞尔曲线
|
|
19
|
+
*
|
|
20
|
+
* <en/> Radial cubic edge
|
|
21
|
+
*/
|
|
22
|
+
export class CubicRadial extends Cubic {
|
|
23
|
+
static defaultStyleProps: Partial<CubicStyleProps> = {
|
|
24
|
+
curvePosition: 0.5,
|
|
25
|
+
curveOffset: 20,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
constructor(options: DisplayObjectConfig<CubicStyleProps>) {
|
|
29
|
+
super(mergeOptions({ style: CubicRadial.defaultStyleProps }, options));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private get ref(): NodeData {
|
|
33
|
+
return this.context.model.getRootsData()[0];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected getEndpoints(attributes: Required<CubicStyleProps>): [Point, Point] {
|
|
37
|
+
if (this.sourceNode.id === this.ref.id) {
|
|
38
|
+
return super.getEndpoints(attributes);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const refPoint = positionOf(this.ref);
|
|
42
|
+
const sourcePoint = this.sourceNode.getIntersectPoint(refPoint, true);
|
|
43
|
+
const targetPoint = this.targetNode.getIntersectPoint(refPoint);
|
|
44
|
+
|
|
45
|
+
return [sourcePoint, targetPoint];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private toRadialCoordinate(p: Point) {
|
|
49
|
+
const refPoint = positionOf(this.ref);
|
|
50
|
+
const r = distance(p, refPoint);
|
|
51
|
+
const radian = rad(subtract(p, refPoint));
|
|
52
|
+
return [r, radian];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected getControlPoints(
|
|
56
|
+
sourcePoint: Point,
|
|
57
|
+
targetPoint: Point,
|
|
58
|
+
curvePosition: [number, number],
|
|
59
|
+
curveOffset: [number, number],
|
|
60
|
+
): [Point, Point] {
|
|
61
|
+
const [r1, rad1] = this.toRadialCoordinate(sourcePoint);
|
|
62
|
+
const [r2] = this.toRadialCoordinate(targetPoint);
|
|
63
|
+
|
|
64
|
+
const rDist = r2 - r1;
|
|
65
|
+
|
|
66
|
+
return [
|
|
67
|
+
[
|
|
68
|
+
sourcePoint[0] + (rDist * curvePosition[0] + curveOffset[0]) * Math.cos(rad1),
|
|
69
|
+
sourcePoint[1] + (rDist * curvePosition[0] + curveOffset[0]) * Math.sin(rad1),
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
targetPoint[0] - (rDist * curvePosition[1] - curveOffset[0]) * Math.cos(rad1),
|
|
73
|
+
targetPoint[1] - (rDist * curvePosition[1] - curveOffset[0]) * Math.sin(rad1),
|
|
74
|
+
],
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { BaseEdge } from './base-edge';
|
|
2
2
|
export { Cubic } from './cubic';
|
|
3
3
|
export { CubicHorizontal } from './cubic-horizontal';
|
|
4
|
+
export { CubicRadial } from './cubic-radial';
|
|
4
5
|
export { CubicVertical } from './cubic-vertical';
|
|
5
6
|
export { Line } from './line';
|
|
6
7
|
export { Polyline } from './polyline';
|
|
@@ -9,6 +10,7 @@ export { Quadratic } from './quadratic';
|
|
|
9
10
|
export type { BaseEdgeStyleProps } from './base-edge';
|
|
10
11
|
export type { CubicStyleProps } from './cubic';
|
|
11
12
|
export type { CubicHorizontalStyleProps } from './cubic-horizontal';
|
|
13
|
+
export type { CubicRadialStyleProps } from './cubic-radial';
|
|
12
14
|
export type { CubicVerticalStyleProps } from './cubic-vertical';
|
|
13
15
|
export type { LineStyleProps } from './line';
|
|
14
16
|
export type { PolylineStyleProps } from './polyline';
|
|
@@ -17,8 +17,6 @@ type ParsedLineStyleProps = Required<LineStyleProps>;
|
|
|
17
17
|
* <zh/> 直线
|
|
18
18
|
*
|
|
19
19
|
* <en/> Line
|
|
20
|
-
* @remarks
|
|
21
|
-
* <img width="300" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*YbpvTa4liAEAAAAAAAAAAAAADmJ7AQ/original" />
|
|
22
20
|
*/
|
|
23
21
|
export class Line extends BaseEdge {
|
|
24
22
|
static defaultStyleProps: Partial<LineStyleProps> = {};
|
|
@@ -69,6 +69,7 @@ export class Polyline extends BaseEdge {
|
|
|
69
69
|
if (router.type === 'shortest-path') {
|
|
70
70
|
const nodes = this.context.element!.getNodes();
|
|
71
71
|
controlPoints = aStarSearch(sourceNode, targetNode, nodes, router);
|
|
72
|
+
|
|
72
73
|
if (!controlPoints.length) {
|
|
73
74
|
controlPoints = orth(sourcePoint, targetPoint, sourceNode, targetNode, attributes.controlPoints, {
|
|
74
75
|
padding: router.offset,
|
|
@@ -91,6 +92,7 @@ export class Polyline extends BaseEdge {
|
|
|
91
92
|
|
|
92
93
|
protected getKeyPath(attributes: ParsedPolylineStyleProps): PathArray {
|
|
93
94
|
const points = this.getPoints(attributes);
|
|
95
|
+
|
|
94
96
|
return getPolylinePath(points, attributes.radius);
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -354,11 +354,12 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
354
354
|
/**
|
|
355
355
|
* Get the point on the outer contour of the node that is the intersection with a line starting in the center the ending in the point `p`.
|
|
356
356
|
* @param point - The point to intersect with the node.
|
|
357
|
+
* @param useExtendedLine - Whether to use the extended line.
|
|
357
358
|
* @returns The intersection point.
|
|
358
359
|
*/
|
|
359
|
-
public getIntersectPoint(point: Point): Point {
|
|
360
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
360
361
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
361
|
-
return getRectIntersectPoint(point, keyShapeBounds);
|
|
362
|
+
return getRectIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
362
363
|
}
|
|
363
364
|
|
|
364
365
|
protected drawHaloShape(attributes: Required<S>, container: Group): void {
|
|
@@ -45,8 +45,8 @@ export class Circle extends BaseNode {
|
|
|
45
45
|
return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
public getIntersectPoint(point: Point): Point {
|
|
48
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
49
49
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
50
|
-
return getEllipseIntersectPoint(point, keyShapeBounds);
|
|
50
|
+
return getEllipseIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -51,8 +51,8 @@ export class Ellipse extends BaseNode {
|
|
|
51
51
|
return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
public getIntersectPoint(point: Point): Point {
|
|
54
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
55
55
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
56
|
-
return getEllipseIntersectPoint(point, keyShapeBounds);
|
|
56
|
+
return getEllipseIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Rect,
|
|
11
11
|
} from '@antv/g';
|
|
12
12
|
import { Renderer } from '@antv/g-canvas';
|
|
13
|
-
import { isNil, isUndefined, pick } from '@antv/util';
|
|
13
|
+
import { isNil, isUndefined, pick, set } from '@antv/util';
|
|
14
14
|
import { CommonEvent } from '../../constants';
|
|
15
15
|
import type { BaseNodeStyleProps } from './base-node';
|
|
16
16
|
import { BaseNode } from './base-node';
|
|
@@ -136,6 +136,9 @@ export class HTML extends BaseNode<HTMLStyleProps> {
|
|
|
136
136
|
|
|
137
137
|
normalizedEvents.forEach((normalizedEvent) => {
|
|
138
138
|
const event = this.bootstrapEvent(this.rootPointerEvent, normalizedEvent, iCanvas, nativeEvent);
|
|
139
|
+
// 当点击到 html 元素时,避免触发 pointerupoutside 事件
|
|
140
|
+
// When clicking on the html element, avoid triggering the pointerupoutside event
|
|
141
|
+
set(canvas.context.eventService, 'mappingTable.pointerupoutside', []);
|
|
139
142
|
canvas.context.eventService.mapEvent(event);
|
|
140
143
|
});
|
|
141
144
|
};
|