@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
|
@@ -14,6 +14,11 @@ import { getExtension } from './../../registry/get';
|
|
|
14
14
|
|
|
15
15
|
export interface BaseShapeStyleProps extends BaseStyleProps {}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* <zh/> 图形基类
|
|
19
|
+
*
|
|
20
|
+
* <en/> Base class for shapes
|
|
21
|
+
*/
|
|
17
22
|
export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends CustomElement<StyleProps> {
|
|
18
23
|
constructor(options: DisplayObjectConfig<StyleProps>) {
|
|
19
24
|
super(options);
|
|
@@ -23,34 +28,43 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
23
28
|
this.bindEvents();
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
/**
|
|
32
|
+
* <zh/> 解析后的属性
|
|
33
|
+
*
|
|
34
|
+
* <en/> parsed attributes
|
|
35
|
+
* @returns <zh/> 解析后的属性 | <en/> parsed attributes
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
26
38
|
protected get parsedAttributes() {
|
|
27
39
|
return this.attributes as Required<StyleProps>;
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
/**
|
|
31
|
-
* <zh
|
|
43
|
+
* <zh/> 图形实例映射表
|
|
32
44
|
*
|
|
33
|
-
* <en
|
|
45
|
+
* <en/> shape instance map
|
|
46
|
+
* @internal
|
|
34
47
|
*/
|
|
35
48
|
protected shapeMap: Record<string, DisplayObject> = {};
|
|
36
49
|
|
|
37
50
|
/**
|
|
38
|
-
* <zh
|
|
51
|
+
* <zh/> 动画实例映射表
|
|
39
52
|
*
|
|
40
|
-
* <en
|
|
53
|
+
* <en/> animation instance map
|
|
54
|
+
* @internal
|
|
41
55
|
*/
|
|
42
56
|
protected animateMap: Record<string, IAnimation> = {};
|
|
43
57
|
|
|
44
58
|
/**
|
|
45
|
-
* <zh
|
|
59
|
+
* <zh/> 创建、更新或删除图形
|
|
46
60
|
*
|
|
47
|
-
* <en
|
|
48
|
-
* @param className - <zh
|
|
49
|
-
* @param Ctor - <zh
|
|
50
|
-
* @param style - <zh
|
|
51
|
-
* @param container - <zh
|
|
52
|
-
* @param hooks - <zh
|
|
53
|
-
* @returns <zh
|
|
61
|
+
* <en/> create, update or remove shape
|
|
62
|
+
* @param className - <zh/> 图形名称 | <en/> shape name
|
|
63
|
+
* @param Ctor - <zh/> 图形类型 | <en/> shape type
|
|
64
|
+
* @param style - <zh/> 图形样式。若要删除图形,传入 false | <en/> shape style. Pass false to remove the shape
|
|
65
|
+
* @param container - <zh/> 容器 | <en/> container
|
|
66
|
+
* @param hooks - <zh/> 钩子函数 | <en/> hooks
|
|
67
|
+
* @returns <zh/> 图形实例 | <en/> shape instance
|
|
54
68
|
*/
|
|
55
69
|
protected upsert<T extends DisplayObject>(
|
|
56
70
|
className: string,
|
|
@@ -125,9 +139,9 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
125
139
|
}
|
|
126
140
|
|
|
127
141
|
/**
|
|
128
|
-
* <zh
|
|
142
|
+
* <zh/> 在初始化时会被自动调用
|
|
129
143
|
*
|
|
130
|
-
* <en
|
|
144
|
+
* <en/> will be called automatically when initializing
|
|
131
145
|
* @param attributes
|
|
132
146
|
* @param container
|
|
133
147
|
*/
|
|
@@ -155,6 +169,7 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
155
169
|
/**
|
|
156
170
|
* Get the prefix pairs for composite shapes used to handle animation
|
|
157
171
|
* @returns tuples array where each tuple contains a key corresponding to a method `get${key}Style` and its shape prefix
|
|
172
|
+
* @internal
|
|
158
173
|
*/
|
|
159
174
|
protected get compositeShapes(): [string, string][] {
|
|
160
175
|
return [
|
|
@@ -43,9 +43,9 @@ export abstract class Polygon<T extends PolygonStyleProps = PolygonStyleProps> e
|
|
|
43
43
|
|
|
44
44
|
protected abstract getPoints(attributes: Required<T>): Point[];
|
|
45
45
|
|
|
46
|
-
public getIntersectPoint(point: Point): Point {
|
|
46
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
47
47
|
const { points } = this.getShape<GPolygon>('key').attributes;
|
|
48
48
|
const center: Point = [+(this.attributes?.x || 0), +(this.attributes?.y || 0)];
|
|
49
|
-
return getPolygonIntersectPoint(point, center, points
|
|
49
|
+
return getPolygonIntersectPoint(point, center, points!, true, useExtendedLine).point;
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/exports.ts
CHANGED
|
@@ -27,7 +27,17 @@ export {
|
|
|
27
27
|
NodeEvent,
|
|
28
28
|
} from './constants';
|
|
29
29
|
export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
|
|
30
|
-
export {
|
|
30
|
+
export {
|
|
31
|
+
BaseEdge,
|
|
32
|
+
Cubic,
|
|
33
|
+
CubicHorizontal,
|
|
34
|
+
CubicRadial,
|
|
35
|
+
CubicVertical,
|
|
36
|
+
Line,
|
|
37
|
+
Polyline,
|
|
38
|
+
Quadratic,
|
|
39
|
+
} from './elements/edges';
|
|
40
|
+
export { effect } from './elements/effect';
|
|
31
41
|
export {
|
|
32
42
|
BaseNode,
|
|
33
43
|
Circle,
|
|
@@ -47,22 +57,23 @@ export {
|
|
|
47
57
|
BaseLayout,
|
|
48
58
|
CircularLayout,
|
|
49
59
|
ComboCombinedLayout,
|
|
60
|
+
compactBox as CompactBoxLayout,
|
|
50
61
|
ConcentricLayout,
|
|
51
62
|
D3ForceLayout,
|
|
52
63
|
DagreLayout,
|
|
64
|
+
dendrogram as DendrogramLayout,
|
|
53
65
|
ForceAtlas2Layout,
|
|
54
66
|
ForceLayout,
|
|
55
67
|
FruchtermanLayout,
|
|
56
68
|
GridLayout,
|
|
69
|
+
indented as IndentedLayout,
|
|
57
70
|
MDSLayout,
|
|
71
|
+
mindmap as MindmapLayout,
|
|
58
72
|
RadialLayout,
|
|
59
73
|
RandomLayout,
|
|
60
|
-
compactBox,
|
|
61
|
-
dendrogram,
|
|
62
|
-
indented,
|
|
63
|
-
mindmap,
|
|
64
74
|
} from './layouts';
|
|
65
75
|
export {
|
|
76
|
+
Background,
|
|
66
77
|
BasePlugin,
|
|
67
78
|
BubbleSets,
|
|
68
79
|
CameraSetting,
|
|
@@ -84,10 +95,11 @@ export {
|
|
|
84
95
|
export { getExtension, getExtensions } from './registry/get';
|
|
85
96
|
export { register } from './registry/register';
|
|
86
97
|
export { Graph } from './runtime/graph';
|
|
87
|
-
export { BaseTransform } from './transforms';
|
|
98
|
+
export { BaseTransform, PositionRadialLabels, ProcessParallelEdges } from './transforms';
|
|
88
99
|
export { isCollapsed } from './utils/collapsibility';
|
|
89
100
|
export { idOf } from './utils/id';
|
|
90
101
|
export { invokeLayoutMethod } from './utils/layout';
|
|
102
|
+
export { positionOf } from './utils/position';
|
|
91
103
|
export { omitStyleProps, subStyleProps } from './utils/prefix';
|
|
92
104
|
export { Shortcut } from './utils/shortcut';
|
|
93
105
|
export { parseSize } from './utils/size';
|
|
@@ -135,6 +147,7 @@ export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps }
|
|
|
135
147
|
export type {
|
|
136
148
|
BaseEdgeStyleProps,
|
|
137
149
|
CubicHorizontalStyleProps,
|
|
150
|
+
CubicRadialStyleProps,
|
|
138
151
|
CubicStyleProps,
|
|
139
152
|
CubicVerticalStyleProps,
|
|
140
153
|
LineStyleProps,
|
|
@@ -166,6 +179,7 @@ export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shape
|
|
|
166
179
|
export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
|
|
167
180
|
export type { CategoricalPalette } from './palettes/types';
|
|
168
181
|
export type {
|
|
182
|
+
BackgroundOptions,
|
|
169
183
|
BasePluginOptions,
|
|
170
184
|
BubbleSetsOptions,
|
|
171
185
|
CameraSettingOptions,
|
|
@@ -205,7 +219,7 @@ export type { CustomBehaviorOption } from './spec/behavior';
|
|
|
205
219
|
export type { AnimationStage } from './spec/element/animation';
|
|
206
220
|
export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
|
|
207
221
|
export type { CustomPluginOption } from './spec/plugin';
|
|
208
|
-
export type { BaseTransformOptions } from './transforms';
|
|
222
|
+
export type { BaseTransformOptions, PositionRadialLabelsOptions, ProcessParallelEdgesOptions } from './transforms';
|
|
209
223
|
export type { DrawData } from './transforms/types';
|
|
210
224
|
export type {
|
|
211
225
|
BaseElementStyleProps,
|
|
@@ -2,6 +2,11 @@ import type { RuntimeContext } from '../runtime/types';
|
|
|
2
2
|
import type { GraphData } from '../spec';
|
|
3
3
|
import type { BaseLayoutOptions } from './types';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* <zh/> 布局的基类
|
|
7
|
+
*
|
|
8
|
+
* <en/> Base class for layout
|
|
9
|
+
*/
|
|
5
10
|
export abstract class BaseLayout<O extends BaseLayoutOptions = any> {
|
|
6
11
|
public abstract id: string;
|
|
7
12
|
|
|
@@ -3,4 +3,9 @@ import type { CustomPluginOption } from '../spec/plugin';
|
|
|
3
3
|
|
|
4
4
|
export interface BasePluginOptions extends CustomPluginOption {}
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* <zh/> 插件的基类
|
|
8
|
+
*
|
|
9
|
+
* <en/> Base class for plugins
|
|
10
|
+
*/
|
|
6
11
|
export abstract class BasePlugin<T extends BasePluginOptions> extends BaseExtension<T> {}
|
package/src/plugins/grid-line.ts
CHANGED
package/src/plugins/legend.ts
CHANGED
|
@@ -13,15 +13,16 @@ import type { BasePluginOptions } from '../base-plugin';
|
|
|
13
13
|
import { BasePlugin } from '../base-plugin';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* <zh/>
|
|
16
|
+
* <zh/> 缩略图插件配置项
|
|
17
17
|
*
|
|
18
|
-
* <en/>
|
|
18
|
+
* <en/> Minimap plugin options
|
|
19
19
|
*/
|
|
20
20
|
export interface MinimapOptions extends BasePluginOptions {
|
|
21
21
|
/**
|
|
22
22
|
* <zh/> 宽度和高度
|
|
23
23
|
*
|
|
24
24
|
* <en/> Width and height
|
|
25
|
+
* @defaultValue [240, 160]
|
|
25
26
|
*/
|
|
26
27
|
size?: [number, number];
|
|
27
28
|
/**
|
|
@@ -94,6 +95,11 @@ export interface MinimapOptions extends BasePluginOptions {
|
|
|
94
95
|
renderer?: IRenderer;
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
/**
|
|
99
|
+
* <zh/> 缩略图插件
|
|
100
|
+
*
|
|
101
|
+
* <en/> Minimap plugin
|
|
102
|
+
*/
|
|
97
103
|
export class Minimap extends BasePlugin<MinimapOptions> {
|
|
98
104
|
static defaultOptions: Partial<MinimapOptions> = {
|
|
99
105
|
size: [240, 160],
|
|
@@ -8,6 +8,11 @@ import { divide } from '../../utils/vector';
|
|
|
8
8
|
import type { BasePluginOptions } from '../base-plugin';
|
|
9
9
|
import { BasePlugin } from '../base-plugin';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* <zh/> 对齐线插件配置项
|
|
13
|
+
*
|
|
14
|
+
* <en/> Snapline plugin options
|
|
15
|
+
*/
|
|
11
16
|
export interface SnaplineOptions extends BasePluginOptions {
|
|
12
17
|
/**
|
|
13
18
|
* <zh/> 对齐精度,即移动节点时与目标位置的距离小于 tolerance 时触发显示对齐线
|
|
@@ -79,6 +84,11 @@ type Metadata = {
|
|
|
79
84
|
horizontalMaxX: number | null;
|
|
80
85
|
};
|
|
81
86
|
|
|
87
|
+
/**
|
|
88
|
+
* <zh/> 对齐线插件
|
|
89
|
+
*
|
|
90
|
+
* <en/> Snapline plugin
|
|
91
|
+
*/
|
|
82
92
|
export class Snapline extends BasePlugin<SnaplineOptions> {
|
|
83
93
|
static defaultOptions: Partial<SnaplineOptions> = {
|
|
84
94
|
tolerance: 5,
|
package/src/plugins/timebar.ts
CHANGED
package/src/plugins/tooltip.ts
CHANGED
|
@@ -7,6 +7,11 @@ import { isToBeDestroyed } from '../utils/element';
|
|
|
7
7
|
import type { BasePluginOptions } from './base-plugin';
|
|
8
8
|
import { BasePlugin } from './base-plugin';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* <zh/> 提示框插件配置项
|
|
12
|
+
*
|
|
13
|
+
* <en/> Tooltip plugin options
|
|
14
|
+
*/
|
|
10
15
|
export interface TooltipOptions
|
|
11
16
|
extends BasePluginOptions,
|
|
12
17
|
Pick<TooltipStyleProps, 'position' | 'offset' | 'enterable' | 'style' | 'container' | 'title'> {
|
|
@@ -36,6 +41,11 @@ export interface TooltipOptions
|
|
|
36
41
|
enable?: boolean | ((event: IElementEvent) => boolean);
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
/**
|
|
45
|
+
* <zh/> 提示框插件
|
|
46
|
+
*
|
|
47
|
+
* <en/> Tooltip plugin
|
|
48
|
+
*/
|
|
39
49
|
export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
40
50
|
static defaultOptions: Partial<TooltipOptions> = {
|
|
41
51
|
trigger: 'hover',
|
|
@@ -151,8 +161,8 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
151
161
|
} = event;
|
|
152
162
|
// click the same item twice, tooltip will be hidden
|
|
153
163
|
if (this.currentTarget === id) {
|
|
154
|
-
this.currentTarget = null;
|
|
155
164
|
this.hide(event);
|
|
165
|
+
this.currentTarget = null;
|
|
156
166
|
} else {
|
|
157
167
|
this.currentTarget = id;
|
|
158
168
|
this.show(event);
|
|
@@ -294,7 +304,9 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
294
304
|
this.tooltipElement?.hide();
|
|
295
305
|
return;
|
|
296
306
|
}
|
|
297
|
-
if (!this.tooltipElement
|
|
307
|
+
if (!this.tooltipElement) return;
|
|
308
|
+
// No target node: tooltip has been hidden. No need for duplicated call.
|
|
309
|
+
if (!this.currentTarget) return;
|
|
298
310
|
const {
|
|
299
311
|
client: { x, y },
|
|
300
312
|
} = event;
|
|
@@ -336,6 +348,7 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
336
348
|
* <zh/> 销毁tooltip
|
|
337
349
|
*
|
|
338
350
|
* <en/> Destroy tooltip
|
|
351
|
+
* @internal
|
|
339
352
|
*/
|
|
340
353
|
public destroy(): void {
|
|
341
354
|
this.unbindEvents();
|
package/src/registry/build-in.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
CircleCombo,
|
|
33
33
|
Cubic,
|
|
34
34
|
CubicHorizontal,
|
|
35
|
+
CubicRadial,
|
|
35
36
|
CubicVertical,
|
|
36
37
|
Diamond,
|
|
37
38
|
Donut,
|
|
@@ -92,6 +93,7 @@ import {
|
|
|
92
93
|
CollapseExpandCombo,
|
|
93
94
|
CollapseExpandNode,
|
|
94
95
|
GetEdgeActualEnds,
|
|
96
|
+
PositionRadialLabels,
|
|
95
97
|
ProcessParallelEdges,
|
|
96
98
|
UpdateRelatedEdge,
|
|
97
99
|
} from '../transforms';
|
|
@@ -138,6 +140,7 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
138
140
|
polyline: Polyline,
|
|
139
141
|
quadratic: Quadratic,
|
|
140
142
|
'cubic-horizontal': CubicHorizontal,
|
|
143
|
+
'cubic-radial': CubicRadial,
|
|
141
144
|
'cubic-vertical': CubicVertical,
|
|
142
145
|
},
|
|
143
146
|
layout: {
|
|
@@ -207,6 +210,7 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
207
210
|
'collapse-expand-node': CollapseExpandNode,
|
|
208
211
|
'process-parallel-edges': ProcessParallelEdges,
|
|
209
212
|
'get-edge-actual-ends': GetEdgeActualEnds,
|
|
213
|
+
'position-radial-labels': PositionRadialLabels,
|
|
210
214
|
},
|
|
211
215
|
shape: {
|
|
212
216
|
circle: GCircle,
|
package/src/runtime/animation.ts
CHANGED
|
@@ -79,12 +79,14 @@ export class Animation {
|
|
|
79
79
|
* @param options - <zh/> 扩展选项 | <en/> Extend options
|
|
80
80
|
* @returns <zh/> 始态样式与终态样式 | <en/> Initial style and final style
|
|
81
81
|
*/
|
|
82
|
-
public inferStyle(
|
|
82
|
+
public inferStyle(
|
|
83
|
+
context: AnimationContext,
|
|
84
|
+
options?: ExtendOptions,
|
|
85
|
+
): [Record<string, unknown>, Record<string, unknown>] {
|
|
83
86
|
const { element, elementType, stage, originalStyle, modifiedStyle } = context;
|
|
84
87
|
|
|
85
|
-
const fromStyle = {
|
|
86
|
-
const toStyle = {
|
|
87
|
-
const getCacheOpacity = () => getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity');
|
|
88
|
+
const fromStyle: Record<string, unknown> = {};
|
|
89
|
+
const toStyle: Record<string, unknown> = {};
|
|
88
90
|
|
|
89
91
|
if (stage === 'enter') {
|
|
90
92
|
Object.assign(fromStyle, { opacity: 0 });
|
|
@@ -92,9 +94,9 @@ export class Animation {
|
|
|
92
94
|
Object.assign(toStyle, { opacity: 0 });
|
|
93
95
|
} else if (stage === 'show') {
|
|
94
96
|
Object.assign(fromStyle, { opacity: 0 });
|
|
95
|
-
Object.assign(toStyle, { opacity:
|
|
97
|
+
Object.assign(toStyle, { opacity: getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity') });
|
|
96
98
|
} else if (stage === 'hide') {
|
|
97
|
-
Object.assign(fromStyle, { opacity:
|
|
99
|
+
Object.assign(fromStyle, { opacity: getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity') });
|
|
98
100
|
Object.assign(toStyle, { opacity: 0 });
|
|
99
101
|
} else if (stage === 'collapse') {
|
|
100
102
|
const { collapse } = options || {};
|
|
@@ -109,10 +111,10 @@ export class Animation {
|
|
|
109
111
|
} else if (elementType === 'combo') {
|
|
110
112
|
if (element.id === target || descendants.includes(element.id)) {
|
|
111
113
|
const [x, y] = position;
|
|
112
|
-
Object.assign(toStyle, { x, y, childrenNode:
|
|
114
|
+
Object.assign(toStyle, { x, y, childrenNode: originalStyle.childrenNode });
|
|
113
115
|
}
|
|
114
116
|
} else if (elementType === 'edge') {
|
|
115
|
-
Object.assign(toStyle, { sourceNode:
|
|
117
|
+
Object.assign(toStyle, { sourceNode: modifiedStyle.sourceNode, targetNode: modifiedStyle.targetNode });
|
|
116
118
|
}
|
|
117
119
|
} else if (stage === 'expand') {
|
|
118
120
|
const { expand } = options || {};
|
|
@@ -129,16 +131,19 @@ export class Animation {
|
|
|
129
131
|
// Set the child elements of the expanded combo
|
|
130
132
|
if (element.id === target || descendants.includes(element.id)) {
|
|
131
133
|
const [x, y, z] = position;
|
|
132
|
-
Object.assign(fromStyle, { x, y, z, childrenNode:
|
|
134
|
+
Object.assign(fromStyle, { x, y, z, childrenNode: modifiedStyle.childrenNode });
|
|
133
135
|
}
|
|
134
136
|
} else if (elementType === 'edge') {
|
|
135
137
|
// 设置展开后的边的起点和终点
|
|
136
138
|
// Set the starting point and end point of the edge after expansion
|
|
137
|
-
Object.assign(fromStyle, { sourceNode:
|
|
139
|
+
Object.assign(fromStyle, { sourceNode: modifiedStyle.sourceNode, targetNode: modifiedStyle.targetNode });
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
|
|
141
|
-
return [
|
|
143
|
+
return [
|
|
144
|
+
Object.keys(fromStyle).length > 0 ? Object.assign({}, originalStyle, fromStyle) : originalStyle,
|
|
145
|
+
Object.keys(toStyle).length > 0 ? Object.assign({}, modifiedStyle, toStyle) : modifiedStyle,
|
|
146
|
+
];
|
|
142
147
|
}
|
|
143
148
|
|
|
144
149
|
public stop() {
|
package/src/runtime/data.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Graph as GraphLib } from '@antv/graphlib';
|
|
2
|
-
import {
|
|
2
|
+
import { isUndefined, uniq } from '@antv/util';
|
|
3
3
|
import { COMBO_KEY, ChangeType, TREE_KEY } from '../constants';
|
|
4
4
|
import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
|
|
5
5
|
import type {
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
} from '../types';
|
|
21
21
|
import type { EdgeDirection } from '../types/edge';
|
|
22
22
|
import type { ElementType } from '../types/element';
|
|
23
|
-
import { cloneElementData, mergeElementsData } from '../utils/data';
|
|
23
|
+
import { cloneElementData, isElementDataEqual, mergeElementsData } from '../utils/data';
|
|
24
24
|
import { arrayDiff } from '../utils/diff';
|
|
25
25
|
import { toG6Data, toGraphlibData } from '../utils/graphlib';
|
|
26
26
|
import { idOf, parentIdOf } from '../utils/id';
|
|
@@ -166,6 +166,10 @@ export class DataController {
|
|
|
166
166
|
}, [] as ComboData[]);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
public getRootsData(hierarchyKey: HierarchyKey = TREE_KEY) {
|
|
170
|
+
return this.model.getRoots(hierarchyKey).map(toG6Data);
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
public getAncestorsData(id: ID, hierarchyKey: HierarchyKey): NodeLikeData[] {
|
|
170
174
|
const { model } = this;
|
|
171
175
|
if (!model.hasNode(id) || !model.hasTreeStructure(hierarchyKey)) return [];
|
|
@@ -292,9 +296,9 @@ export class DataController {
|
|
|
292
296
|
const { nodes: modifiedNodes = [], edges: modifiedEdges = [], combos: modifiedCombos = [] } = data;
|
|
293
297
|
const { nodes: originalNodes, edges: originalEdges, combos: originalCombos } = this.getData();
|
|
294
298
|
|
|
295
|
-
const nodeDiff = arrayDiff(originalNodes, modifiedNodes, (node) => idOf(node));
|
|
296
|
-
const edgeDiff = arrayDiff(originalEdges, modifiedEdges, (edge) => idOf(edge));
|
|
297
|
-
const comboDiff = arrayDiff(originalCombos, modifiedCombos, (combo) => idOf(combo));
|
|
299
|
+
const nodeDiff = arrayDiff(originalNodes, modifiedNodes, (node) => idOf(node), isElementDataEqual);
|
|
300
|
+
const edgeDiff = arrayDiff(originalEdges, modifiedEdges, (edge) => idOf(edge), isElementDataEqual);
|
|
301
|
+
const comboDiff = arrayDiff(originalCombos, modifiedCombos, (combo) => idOf(combo), isElementDataEqual);
|
|
298
302
|
|
|
299
303
|
this.batch(() => {
|
|
300
304
|
this.addData({
|
|
@@ -381,13 +385,16 @@ export class DataController {
|
|
|
381
385
|
|
|
382
386
|
data.forEach((datum) => {
|
|
383
387
|
const id = idOf(datum);
|
|
388
|
+
const parent = parentIdOf(datum);
|
|
384
389
|
|
|
385
|
-
|
|
386
|
-
|
|
390
|
+
if (parent) {
|
|
391
|
+
if (!model.hasTreeStructure(COMBO_KEY)) model.attachTreeStructure(COMBO_KEY);
|
|
392
|
+
this.setParent(id, parentIdOf(datum), COMBO_KEY);
|
|
393
|
+
}
|
|
387
394
|
|
|
388
|
-
const children = (datum as NodeData).children;
|
|
389
|
-
if (children
|
|
390
|
-
model.attachTreeStructure(TREE_KEY);
|
|
395
|
+
const children = (datum as NodeData).children || [];
|
|
396
|
+
if (children.length) {
|
|
397
|
+
if (!model.hasTreeStructure(TREE_KEY)) model.attachTreeStructure(TREE_KEY);
|
|
391
398
|
const _children = children.filter((child) => model.hasNode(child));
|
|
392
399
|
_children.forEach((child) => this.setParent(child, id, TREE_KEY));
|
|
393
400
|
if (_children.length !== children.length) {
|
|
@@ -430,7 +437,7 @@ export class DataController {
|
|
|
430
437
|
nodes.forEach((modifiedNode) => {
|
|
431
438
|
const id = idOf(modifiedNode);
|
|
432
439
|
const originalNode = toG6Data(model.getNode(id));
|
|
433
|
-
if (
|
|
440
|
+
if (isElementDataEqual(originalNode, modifiedNode)) return;
|
|
434
441
|
|
|
435
442
|
const value = mergeElementsData(originalNode, modifiedNode);
|
|
436
443
|
this.pushChange({ value, original: originalNode, type: ChangeType.NodeUpdated });
|
|
@@ -476,7 +483,7 @@ export class DataController {
|
|
|
476
483
|
edges.forEach((modifiedEdge) => {
|
|
477
484
|
const id = idOf(modifiedEdge);
|
|
478
485
|
const originalEdge = toG6Data(model.getEdge(id));
|
|
479
|
-
if (
|
|
486
|
+
if (isElementDataEqual(originalEdge, modifiedEdge)) return;
|
|
480
487
|
|
|
481
488
|
if (modifiedEdge.source && originalEdge.source !== modifiedEdge.source) {
|
|
482
489
|
model.updateEdgeSource(id, modifiedEdge.source);
|
|
@@ -499,7 +506,7 @@ export class DataController {
|
|
|
499
506
|
combos.forEach((modifiedCombo) => {
|
|
500
507
|
const id = idOf(modifiedCombo);
|
|
501
508
|
const originalCombo = toG6Data(model.getNode(id)) as ComboData;
|
|
502
|
-
if (
|
|
509
|
+
if (isElementDataEqual(originalCombo, modifiedCombo)) return;
|
|
503
510
|
|
|
504
511
|
const value = mergeElementsData(originalCombo, modifiedCombo);
|
|
505
512
|
this.pushChange({ value, original: originalCombo, type: ChangeType.ComboUpdated });
|