@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/graph.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
|
-
import type { AABB, BaseStyleProps
|
|
2
|
+
import type { AABB, BaseStyleProps } from '@antv/g';
|
|
3
3
|
import type { ID } from '@antv/graphlib';
|
|
4
4
|
import { debounce, isEqual, isFunction, isNumber, isObject, isString, omit } from '@antv/util';
|
|
5
5
|
import { COMBO_KEY, GraphEvent } from '../constants';
|
|
6
|
+
import type { Plugin } from '../plugins/types';
|
|
6
7
|
import { getExtension } from '../registry';
|
|
7
8
|
import type {
|
|
8
9
|
BehaviorOptions,
|
|
@@ -17,9 +18,11 @@ import type {
|
|
|
17
18
|
NodeOptions,
|
|
18
19
|
PluginOptions,
|
|
19
20
|
ThemeOptions,
|
|
21
|
+
TransformOptions,
|
|
20
22
|
} from '../spec';
|
|
21
|
-
import { UpdateBehaviorOption } from '../spec/behavior';
|
|
22
|
-
import { UpdatePluginOption } from '../spec/plugin';
|
|
23
|
+
import type { UpdateBehaviorOption } from '../spec/behavior';
|
|
24
|
+
import type { UpdatePluginOption } from '../spec/plugin';
|
|
25
|
+
import type { UpdateTransformOption } from '../spec/transform';
|
|
23
26
|
import type {
|
|
24
27
|
CallableValue,
|
|
25
28
|
DataID,
|
|
@@ -27,6 +30,7 @@ import type {
|
|
|
27
30
|
ElementDatum,
|
|
28
31
|
ElementType,
|
|
29
32
|
FitViewOptions,
|
|
33
|
+
IEvent,
|
|
30
34
|
NodeLikeData,
|
|
31
35
|
PartialEdgeData,
|
|
32
36
|
PartialGraphData,
|
|
@@ -38,18 +42,21 @@ import type {
|
|
|
38
42
|
ViewportAnimationEffectTiming,
|
|
39
43
|
} from '../types';
|
|
40
44
|
import { sizeOf } from '../utils/dom';
|
|
41
|
-
import {
|
|
45
|
+
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
42
46
|
import { idOf } from '../utils/id';
|
|
43
47
|
import { parsePoint, toPointObject } from '../utils/point';
|
|
44
48
|
import { zIndexOf } from '../utils/style';
|
|
45
49
|
import { subtract } from '../utils/vector';
|
|
50
|
+
import { BatchController } from './batch';
|
|
46
51
|
import { BehaviorController } from './behavior';
|
|
52
|
+
import type { DataURLOptions } from './canvas';
|
|
47
53
|
import { Canvas } from './canvas';
|
|
48
54
|
import type { HierarchyKey } from './data';
|
|
49
55
|
import { DataController } from './data';
|
|
50
56
|
import { ElementController } from './element';
|
|
51
57
|
import { LayoutController } from './layout';
|
|
52
58
|
import { PluginController } from './plugin';
|
|
59
|
+
import { TransformController } from './transform';
|
|
53
60
|
import { RuntimeContext } from './types';
|
|
54
61
|
import { ViewportController } from './viewport';
|
|
55
62
|
|
|
@@ -116,11 +123,12 @@ export class Graph extends EventEmitter {
|
|
|
116
123
|
layout,
|
|
117
124
|
node,
|
|
118
125
|
padding,
|
|
119
|
-
theme,
|
|
120
126
|
plugins,
|
|
127
|
+
theme,
|
|
128
|
+
transforms,
|
|
121
129
|
width,
|
|
122
|
-
zoomRange,
|
|
123
130
|
zoom,
|
|
131
|
+
zoomRange,
|
|
124
132
|
} = options;
|
|
125
133
|
|
|
126
134
|
if (background) this.setBackground(background);
|
|
@@ -132,6 +140,7 @@ export class Graph extends EventEmitter {
|
|
|
132
140
|
if (node) this.setNode(node);
|
|
133
141
|
if (theme) this.setTheme(theme);
|
|
134
142
|
if (plugins) this.setPlugins(plugins);
|
|
143
|
+
if (transforms) this.setTransforms(transforms);
|
|
135
144
|
if (isNumber(width) || isNumber(height))
|
|
136
145
|
this.setSize(width ?? this.options.width ?? 0, height ?? this.options.height ?? 0);
|
|
137
146
|
|
|
@@ -276,6 +285,55 @@ export class Graph extends EventEmitter {
|
|
|
276
285
|
return this.options.plugins || [];
|
|
277
286
|
}
|
|
278
287
|
|
|
288
|
+
/**
|
|
289
|
+
* <zh/> 获取插件实例
|
|
290
|
+
*
|
|
291
|
+
* <en/> Get plugin instance
|
|
292
|
+
* @param key - <zh/> 插件 key | <en/> plugin key
|
|
293
|
+
* @returns <zh/> 插件实例 | <en/> plugin instance
|
|
294
|
+
*/
|
|
295
|
+
public getPluginInstance<T extends Plugin>(key: string) {
|
|
296
|
+
return this.context.plugin!.getPluginInstance(key) as unknown as T;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* <zh/> 设置数据转换器
|
|
301
|
+
*
|
|
302
|
+
* <en/> Set data transforms
|
|
303
|
+
* @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
|
|
304
|
+
*/
|
|
305
|
+
public setTransforms(transforms: CallableValue<TransformOptions>): void {
|
|
306
|
+
this.options.transforms = isFunction(transforms) ? transforms(this.getTransforms()) : transforms;
|
|
307
|
+
this.context.transform?.setTransforms(this.options.transforms);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* <zh/> 更新数据转换器
|
|
312
|
+
*
|
|
313
|
+
* <en/> Update data transform
|
|
314
|
+
* @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
|
|
315
|
+
*/
|
|
316
|
+
public updateTransform(transform: UpdateTransformOption): void {
|
|
317
|
+
this.setTransforms((transforms) =>
|
|
318
|
+
transforms.map((_transform) => {
|
|
319
|
+
if (isObject(_transform) && _transform.key === transform.key) {
|
|
320
|
+
return { ..._transform, ...transform };
|
|
321
|
+
}
|
|
322
|
+
return _transform;
|
|
323
|
+
}),
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* <zh/> 获取数据转换器
|
|
329
|
+
*
|
|
330
|
+
* <en/> Get data transforms
|
|
331
|
+
* @returns <zh/> 数据转换器实例 | <en/> data transform instance
|
|
332
|
+
*/
|
|
333
|
+
public getTransforms(): TransformOptions {
|
|
334
|
+
return this.options.transforms || [];
|
|
335
|
+
}
|
|
336
|
+
|
|
279
337
|
public getData(): GraphData {
|
|
280
338
|
return this.context.model.getData();
|
|
281
339
|
}
|
|
@@ -417,32 +475,39 @@ export class Graph extends EventEmitter {
|
|
|
417
475
|
return this.context.model.getElementDataByState(elementType, state);
|
|
418
476
|
}
|
|
419
477
|
|
|
420
|
-
private
|
|
421
|
-
if (this.context.canvas) return this.context.canvas;
|
|
478
|
+
private async initCanvas() {
|
|
479
|
+
if (this.context.canvas) return await this.context.canvas.init();
|
|
422
480
|
|
|
423
481
|
const { container = 'container', width, height, renderer, background } = this.options;
|
|
424
482
|
|
|
425
483
|
if (container instanceof Canvas) {
|
|
426
484
|
this.context.canvas = container;
|
|
427
485
|
container.setBackground(background);
|
|
486
|
+
await container.init();
|
|
428
487
|
} else {
|
|
429
488
|
const $container = isString(container) ? document.getElementById(container!) : container;
|
|
430
489
|
|
|
431
|
-
this.
|
|
490
|
+
this.emit(GraphEvent.BEFORE_CANVAS_INIT, { container: $container, width, height });
|
|
491
|
+
|
|
492
|
+
const canvas = new Canvas({
|
|
432
493
|
container: $container!,
|
|
433
494
|
width,
|
|
434
495
|
height,
|
|
435
496
|
renderer,
|
|
436
497
|
});
|
|
437
|
-
}
|
|
438
498
|
|
|
439
|
-
|
|
499
|
+
this.context.canvas = canvas;
|
|
500
|
+
await canvas.init();
|
|
501
|
+
this.emit(GraphEvent.AFTER_CANVAS_INIT, { canvas });
|
|
502
|
+
}
|
|
440
503
|
}
|
|
441
504
|
|
|
442
505
|
private createRuntime() {
|
|
443
506
|
this.context.options = this.options;
|
|
507
|
+
if (!this.context.batch) this.context.batch = new BatchController(this.context);
|
|
444
508
|
if (!this.context.plugin) this.context.plugin = new PluginController(this.context);
|
|
445
509
|
if (!this.context.viewport) this.context.viewport = new ViewportController(this.context);
|
|
510
|
+
if (!this.context.transform) this.context.transform = new TransformController(this.context);
|
|
446
511
|
if (!this.context.element) this.context.element = new ElementController(this.context);
|
|
447
512
|
if (!this.context.layout) this.context.layout = new LayoutController(this.context);
|
|
448
513
|
if (!this.context.behavior) this.context.behavior = new BehaviorController(this.context);
|
|
@@ -451,7 +516,7 @@ export class Graph extends EventEmitter {
|
|
|
451
516
|
private async prepare(): Promise<void> {
|
|
452
517
|
if (this.destroyed) throw new Error('Graph has been destroyed');
|
|
453
518
|
|
|
454
|
-
await this.
|
|
519
|
+
await this.initCanvas();
|
|
455
520
|
this.createRuntime();
|
|
456
521
|
}
|
|
457
522
|
|
|
@@ -941,17 +1006,19 @@ export class Graph extends EventEmitter {
|
|
|
941
1006
|
? [args1, (args2 as boolean) ?? true]
|
|
942
1007
|
: [{ [args1]: args2 as State | State[] }, args3];
|
|
943
1008
|
|
|
944
|
-
|
|
1009
|
+
const parseState = (state: State | State[]) => {
|
|
1010
|
+
if (!state) return [];
|
|
1011
|
+
return Array.isArray(state) ? state : [state];
|
|
1012
|
+
};
|
|
945
1013
|
|
|
946
1014
|
const dataToUpdate: Required<PartialGraphData> = { nodes: [], edges: [], combos: [] };
|
|
947
1015
|
Object.entries(config).forEach(([id, value]) => {
|
|
948
1016
|
const elementType = this.getElementType(id);
|
|
949
|
-
dataToUpdate[`${elementType}s`].push({ id, style: { states:
|
|
1017
|
+
dataToUpdate[`${elementType}s`].push({ id, style: { states: parseState(value) } });
|
|
950
1018
|
});
|
|
951
1019
|
this.updateData(dataToUpdate);
|
|
952
1020
|
|
|
953
1021
|
await this.context.element!.draw({ animation });
|
|
954
|
-
emit(this, new ElementStateChangeEvent(GraphEvent.AFTER_ELEMENT_STATE_CHANGE, config));
|
|
955
1022
|
}
|
|
956
1023
|
|
|
957
1024
|
/**
|
|
@@ -985,6 +1052,21 @@ export class Graph extends EventEmitter {
|
|
|
985
1052
|
else if (elementType === 'combo') this.updateComboData([{ id, style: { collapsed } }]);
|
|
986
1053
|
}
|
|
987
1054
|
|
|
1055
|
+
/**
|
|
1056
|
+
* <zh/> 导出画布内容为 DataURL
|
|
1057
|
+
*
|
|
1058
|
+
* <en/> Export canvas content as DataURL
|
|
1059
|
+
* @param options - <zh/> 导出配置 | <en/> export configuration
|
|
1060
|
+
* @param mode
|
|
1061
|
+
* <zh/> 导出模式
|
|
1062
|
+
* - viewport: 导出视口内容
|
|
1063
|
+
* - overall: 导出整个画布
|
|
1064
|
+
*
|
|
1065
|
+
* <en/> export mode
|
|
1066
|
+
* - viewport: export the content of the viewport
|
|
1067
|
+
* - overall: export the entire canvas
|
|
1068
|
+
* @returns <zh/> DataURL | <en/> DataURL
|
|
1069
|
+
*/
|
|
988
1070
|
public async toDataURL(options: Partial<DataURLOptions> = {}): Promise<string> {
|
|
989
1071
|
return this.context.canvas!.toDataURL(options);
|
|
990
1072
|
}
|
|
@@ -1024,4 +1106,28 @@ export class Graph extends EventEmitter {
|
|
|
1024
1106
|
private onResize = debounce(() => {
|
|
1025
1107
|
this.resize();
|
|
1026
1108
|
}, 300);
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* <zh/> 监听事件
|
|
1112
|
+
*
|
|
1113
|
+
* <en/> Listen to events
|
|
1114
|
+
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
1115
|
+
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
1116
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1117
|
+
*/
|
|
1118
|
+
public on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
|
|
1119
|
+
return super.on(eventName, callback);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* <zh/> 一次性监听事件
|
|
1124
|
+
*
|
|
1125
|
+
* <en/> Listen to events once
|
|
1126
|
+
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
1127
|
+
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
1128
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1129
|
+
*/
|
|
1130
|
+
public once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
|
|
1131
|
+
return super.once(eventName, callback);
|
|
1132
|
+
}
|
|
1027
1133
|
}
|
package/src/runtime/layout.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import type { IAnimation } from '@antv/g';
|
|
2
2
|
import type { Edge as GraphlibEdge, Node as GraphlibNode } from '@antv/graphlib';
|
|
3
3
|
import { Graph as Graphlib } from '@antv/graphlib';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Layout, LayoutMapping } from '@antv/layout';
|
|
5
5
|
import { Supervisor, isLayoutWithIterations } from '@antv/layout';
|
|
6
|
-
import {
|
|
6
|
+
import { deepMix } from '@antv/util';
|
|
7
7
|
import { COMBO_KEY, GraphEvent, TREE_KEY } from '../constants';
|
|
8
|
-
import type { BaseLayoutOptions } from '../layouts/types';
|
|
9
8
|
import { getExtension } from '../registry';
|
|
10
9
|
import type { EdgeData, NodeData } from '../spec';
|
|
11
10
|
import type { STDLayoutOptions } from '../spec/layout';
|
|
12
|
-
import type {
|
|
11
|
+
import type { Combo, Node, PartialGraphData, TreeData } from '../types';
|
|
13
12
|
import { getAnimation } from '../utils/animation';
|
|
14
13
|
import { isVisible } from '../utils/element';
|
|
15
14
|
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
16
15
|
import { createTreeStructure } from '../utils/graphlib';
|
|
17
|
-
import { isComboLayout,
|
|
16
|
+
import { isComboLayout, isTreeLayout } from '../utils/layout';
|
|
18
17
|
import { parsePoint } from '../utils/point';
|
|
19
18
|
import { parseSize } from '../utils/size';
|
|
20
19
|
import { dfs } from '../utils/traverse';
|
|
21
|
-
import { add } from '../utils/vector';
|
|
22
20
|
import type { RuntimeContext } from './types';
|
|
23
21
|
|
|
24
22
|
type LayoutGraphlibModel = Graphlib<Required<NodeData>['style'], Required<EdgeData>['style']>;
|
|
@@ -34,6 +32,8 @@ export class LayoutController {
|
|
|
34
32
|
|
|
35
33
|
private instance?: Layout<unknown>;
|
|
36
34
|
|
|
35
|
+
private instances: Layout<unknown>[] = [];
|
|
36
|
+
|
|
37
37
|
private animationResult?: IAnimation | null;
|
|
38
38
|
|
|
39
39
|
private get presetOptions() {
|
|
@@ -51,45 +51,11 @@ export class LayoutController {
|
|
|
51
51
|
this.context = context;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @param options - <zh/> 预设布局配置项 | <en/> Preset layout options
|
|
60
|
-
* @returns <zh/> 布局结果 | <en/> Layout result
|
|
61
|
-
*/
|
|
62
|
-
private async presetLayout(model: LayoutGraphlibModel, options?: BaseLayoutOptions) {
|
|
63
|
-
if (!options) return;
|
|
64
|
-
if (options.type) return this.stepLayout(model, options);
|
|
65
|
-
|
|
66
|
-
const positions = model.getAllNodes().reduce(
|
|
67
|
-
(nodes, node) => {
|
|
68
|
-
if (!isPositionSpecified(node.data)) {
|
|
69
|
-
// 如果没有指定位置,将节点放置到邻居节点的中心 / If the position is not specified, place the node in the center of the neighboring node
|
|
70
|
-
let p: Point = [0, 0, 0];
|
|
71
|
-
let count = 0;
|
|
72
|
-
model.getNeighbors(node.id).forEach((neighbor) => {
|
|
73
|
-
if (isPositionSpecified(neighbor.data)) {
|
|
74
|
-
const { x: nx, y: ny, z: nz = 0 } = neighbor.data;
|
|
75
|
-
p = add(p, [nx, ny, nz] as Point);
|
|
76
|
-
count++;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (count) {
|
|
80
|
-
nodes.push({
|
|
81
|
-
id: node.id,
|
|
82
|
-
data: { x: p[0] / count, y: p[1] / count, z: p[2] / count },
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return nodes;
|
|
88
|
-
},
|
|
89
|
-
[] as LayoutMapping['nodes'],
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
this.updateElementPosition({ nodes: positions, edges: [] }, false);
|
|
54
|
+
public getLayoutInstance(): Layout<unknown>[];
|
|
55
|
+
public getLayoutInstance(index: number): Layout<unknown>;
|
|
56
|
+
public getLayoutInstance(index?: number) {
|
|
57
|
+
if (index === undefined) return this.instances;
|
|
58
|
+
return this.instance;
|
|
93
59
|
}
|
|
94
60
|
|
|
95
61
|
public async layout() {
|
|
@@ -98,10 +64,9 @@ export class LayoutController {
|
|
|
98
64
|
const { graph } = this.context;
|
|
99
65
|
emit(graph, new GraphLifeCycleEvent(GraphEvent.BEFORE_LAYOUT));
|
|
100
66
|
for (const options of pipeline) {
|
|
101
|
-
const
|
|
67
|
+
const index = pipeline.indexOf(options);
|
|
102
68
|
const model = this.getLayoutDataModel(options);
|
|
103
|
-
await this.
|
|
104
|
-
const result = await this.stepLayout(model, { ...this.presetOptions, ...options });
|
|
69
|
+
const result = await this.stepLayout(model, { ...this.presetOptions, ...options }, index);
|
|
105
70
|
|
|
106
71
|
if (!options.animation) {
|
|
107
72
|
this.updateElementPosition(result, false);
|
|
@@ -110,16 +75,24 @@ export class LayoutController {
|
|
|
110
75
|
emit(graph, new GraphLifeCycleEvent(GraphEvent.AFTER_LAYOUT));
|
|
111
76
|
}
|
|
112
77
|
|
|
113
|
-
public async stepLayout(
|
|
114
|
-
|
|
115
|
-
|
|
78
|
+
public async stepLayout(
|
|
79
|
+
model: LayoutGraphlibModel,
|
|
80
|
+
options: STDLayoutOptions,
|
|
81
|
+
index: number,
|
|
82
|
+
): Promise<LayoutMapping> {
|
|
83
|
+
if (isTreeLayout(options)) return await this.treeLayout(model, options, index);
|
|
84
|
+
return await this.graphLayout(model, options, index);
|
|
116
85
|
}
|
|
117
86
|
|
|
118
|
-
private async graphLayout(
|
|
119
|
-
|
|
87
|
+
private async graphLayout(
|
|
88
|
+
model: LayoutGraphlibModel,
|
|
89
|
+
options: STDLayoutOptions,
|
|
90
|
+
index: number,
|
|
91
|
+
): Promise<LayoutMapping> {
|
|
120
92
|
const { animation, enableWorker, iterations = 300 } = options;
|
|
121
93
|
|
|
122
94
|
const layout = this.initGraphLayout(model, options);
|
|
95
|
+
this.instances[index] = layout;
|
|
123
96
|
this.instance = layout;
|
|
124
97
|
|
|
125
98
|
// 使用 web worker 执行布局 / Use web worker to execute layout
|
|
@@ -155,7 +128,11 @@ export class LayoutController {
|
|
|
155
128
|
return layoutResult;
|
|
156
129
|
}
|
|
157
130
|
|
|
158
|
-
private async treeLayout(
|
|
131
|
+
private async treeLayout(
|
|
132
|
+
model: LayoutGraphlibModel,
|
|
133
|
+
options: STDLayoutOptions,
|
|
134
|
+
index: number,
|
|
135
|
+
): Promise<LayoutMapping> {
|
|
159
136
|
const { type, animation } = options;
|
|
160
137
|
// @ts-expect-error @antv/hierarchy 布局格式与 @antv/layout 不一致,其导出的是一个方法,而非 class
|
|
161
138
|
// The layout format of @antv/hierarchy is inconsistent with @antv/layout, it exports a method instead of a class
|
|
@@ -315,7 +292,7 @@ export class LayoutController {
|
|
|
315
292
|
const nodeSize: number | ((node: LayoutGraphlibNode) => number) =
|
|
316
293
|
(options?.nodeSize as number) ??
|
|
317
294
|
((node) => {
|
|
318
|
-
const nodeElement = element?.getElement(node.id);
|
|
295
|
+
const nodeElement = element?.getElement<Node | Combo>(node.id);
|
|
319
296
|
const { size } = nodeElement?.attributes || {};
|
|
320
297
|
return Math.max(...parseSize(size));
|
|
321
298
|
});
|
|
@@ -324,32 +301,23 @@ export class LayoutController {
|
|
|
324
301
|
|
|
325
302
|
if (!Ctor) throw new Error(`The layout type ${type} is not found`);
|
|
326
303
|
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (isPositionSpecified(model.getNode(id).data)) return 10;
|
|
341
|
-
if (isPositionSpecified(node.data)) return 10;
|
|
342
|
-
return 1;
|
|
343
|
-
},
|
|
344
|
-
});
|
|
345
|
-
} else if (type === 'dagre') {
|
|
346
|
-
Object.assign(config, {
|
|
347
|
-
// TODO 添加预设位置
|
|
348
|
-
preset: [],
|
|
349
|
-
});
|
|
304
|
+
const layout = new Ctor();
|
|
305
|
+
|
|
306
|
+
const config = { nodeSize, width, height, center };
|
|
307
|
+
|
|
308
|
+
switch (layout.id) {
|
|
309
|
+
case 'd3-force':
|
|
310
|
+
case 'd3-force-3d':
|
|
311
|
+
Object.assign(config, {
|
|
312
|
+
center: { x: width / 2, y: height / 2, z: 0 },
|
|
313
|
+
});
|
|
314
|
+
break;
|
|
315
|
+
default:
|
|
316
|
+
break;
|
|
350
317
|
}
|
|
351
318
|
|
|
352
|
-
|
|
319
|
+
deepMix(layout.options, config, restOptions);
|
|
320
|
+
return layout;
|
|
353
321
|
}
|
|
354
322
|
|
|
355
323
|
private updateElementPosition(layoutData: LayoutMapping, animation: boolean) {
|
|
@@ -385,6 +353,7 @@ export class LayoutController {
|
|
|
385
353
|
this.supervisor?.kill();
|
|
386
354
|
this.supervisor = undefined;
|
|
387
355
|
this.instance = undefined;
|
|
356
|
+
this.instances = [];
|
|
388
357
|
this.animationResult = undefined;
|
|
389
358
|
}
|
|
390
359
|
}
|
package/src/runtime/plugin.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { CustomPluginOption, PluginOptions } from '../spec/plugin';
|
|
|
4
4
|
import type { RuntimeContext } from './types';
|
|
5
5
|
|
|
6
6
|
export class PluginController extends ExtensionController<BasePlugin<CustomPluginOption>> {
|
|
7
|
-
public category
|
|
7
|
+
public category = 'plugin' as const;
|
|
8
8
|
|
|
9
9
|
constructor(context: RuntimeContext) {
|
|
10
10
|
super(context);
|
|
@@ -14,4 +14,8 @@ export class PluginController extends ExtensionController<BasePlugin<CustomPlugi
|
|
|
14
14
|
public setPlugins(plugins: PluginOptions) {
|
|
15
15
|
this.setExtensions(plugins);
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
public getPluginInstance(key: string) {
|
|
19
|
+
return this.extensionMap[key];
|
|
20
|
+
}
|
|
17
21
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ExtensionController } from '../registry/extension';
|
|
2
|
+
import type { CustomTransformOption, TransformOptions } from '../spec/transform';
|
|
3
|
+
import { BaseTransform } from '../transforms';
|
|
4
|
+
import type { RuntimeContext } from './types';
|
|
5
|
+
|
|
6
|
+
export const REQUIRED_TRANSFORMS: TransformOptions = [
|
|
7
|
+
'update-related-edges',
|
|
8
|
+
'arrange-draw-order',
|
|
9
|
+
'collapse-expand-combo',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export class TransformController extends ExtensionController<BaseTransform<CustomTransformOption>> {
|
|
13
|
+
public category = 'transform' as const;
|
|
14
|
+
|
|
15
|
+
constructor(context: RuntimeContext) {
|
|
16
|
+
super(context);
|
|
17
|
+
this.setTransforms(this.context.options.transforms || []);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public setTransforms(transforms: TransformOptions) {
|
|
21
|
+
this.setExtensions([...transforms, ...REQUIRED_TRANSFORMS]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public getTransformInstance(key?: string) {
|
|
25
|
+
return key ? this.extensionMap[key] : this.extensionMap;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/runtime/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { G6Spec } from '../spec';
|
|
2
|
+
import type { BatchController } from './batch';
|
|
2
3
|
import type { BehaviorController } from './behavior';
|
|
3
4
|
import type { Canvas } from './canvas';
|
|
4
5
|
import type { DataController } from './data';
|
|
@@ -6,6 +7,7 @@ import type { ElementController } from './element';
|
|
|
6
7
|
import type { Graph } from './graph';
|
|
7
8
|
import type { LayoutController } from './layout';
|
|
8
9
|
import type { PluginController } from './plugin';
|
|
10
|
+
import type { TransformController } from './transform';
|
|
9
11
|
import type { ViewportController } from './viewport';
|
|
10
12
|
|
|
11
13
|
export interface RuntimeContext {
|
|
@@ -33,6 +35,12 @@ export interface RuntimeContext {
|
|
|
33
35
|
* <en/> Data model
|
|
34
36
|
*/
|
|
35
37
|
model: DataController;
|
|
38
|
+
/**
|
|
39
|
+
* <zh/> 数据转换控制器
|
|
40
|
+
*
|
|
41
|
+
* <en/> Data transform controller
|
|
42
|
+
*/
|
|
43
|
+
transform: TransformController;
|
|
36
44
|
/**
|
|
37
45
|
* <zh/> 元素控制器
|
|
38
46
|
*
|
|
@@ -67,4 +75,10 @@ export interface RuntimeContext {
|
|
|
67
75
|
* <en/> Plugin controller
|
|
68
76
|
*/
|
|
69
77
|
plugin?: PluginController;
|
|
78
|
+
/**
|
|
79
|
+
* <zh/> 批量操作控制器
|
|
80
|
+
*
|
|
81
|
+
* <en/> Batch operation controller
|
|
82
|
+
*/
|
|
83
|
+
batch?: BatchController;
|
|
70
84
|
}
|
package/src/spec/index.ts
CHANGED
|
@@ -8,4 +8,5 @@ export type { LayoutOptions } from './layout';
|
|
|
8
8
|
export type { PluginOptions } from './plugin';
|
|
9
9
|
export type { G6Spec } from './spec';
|
|
10
10
|
export type { ThemeOptions } from './theme';
|
|
11
|
+
export type { TransformOptions } from './transform';
|
|
11
12
|
export type { ViewportOptions } from './viewport';
|
package/src/spec/spec.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { NodeOptions } from './element/node';
|
|
|
8
8
|
import type { LayoutOptions } from './layout';
|
|
9
9
|
import type { PluginOptions } from './plugin';
|
|
10
10
|
import type { ThemeOptions } from './theme';
|
|
11
|
+
import type { TransformOptions } from './transform';
|
|
11
12
|
import type { ViewportOptions } from './viewport';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -75,4 +76,10 @@ export interface G6Spec extends CanvasOptions, ViewportOptions {
|
|
|
75
76
|
* <en/> Canvas plugins
|
|
76
77
|
*/
|
|
77
78
|
plugins?: PluginOptions;
|
|
79
|
+
/**
|
|
80
|
+
* <zh/> 数据转换器
|
|
81
|
+
*
|
|
82
|
+
* <en/> Data transforms
|
|
83
|
+
*/
|
|
84
|
+
transforms?: TransformOptions;
|
|
78
85
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExtensionOptions } from '../registry/extension/types';
|
|
2
|
+
import type { BuiltInTransformOptions } from '../transforms/types';
|
|
3
|
+
|
|
4
|
+
export type TransformOptions = ExtensionOptions<BuiltInTransformOptions>;
|
|
5
|
+
|
|
6
|
+
export interface UpdateTransformOption {
|
|
7
|
+
key: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CustomTransformOption {
|
|
12
|
+
type?: string;
|
|
13
|
+
key?: string;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
package/src/themes/base.ts
CHANGED
|
@@ -91,12 +91,16 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
91
91
|
labelBackgroundPadding: [0, 2],
|
|
92
92
|
labelFill: textColor,
|
|
93
93
|
labelFontSize: 12,
|
|
94
|
+
labelFontWeight: 400,
|
|
94
95
|
labelOpacity: 1,
|
|
96
|
+
lineWidth: 0,
|
|
95
97
|
opacity: 1,
|
|
96
98
|
portFill: nodeColor,
|
|
97
99
|
portLineWidth: 1,
|
|
98
100
|
portStroke: nodeStroke,
|
|
99
101
|
portStrokeOpacity: 0.65,
|
|
102
|
+
stroke: nodeStroke,
|
|
103
|
+
strokeOpacity: 1,
|
|
100
104
|
},
|
|
101
105
|
state: {
|
|
102
106
|
selected: {
|
|
@@ -147,6 +151,7 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
147
151
|
labelBackgroundPadding: [4, 4, 4, 4],
|
|
148
152
|
labelFill: textColor,
|
|
149
153
|
labelFontSize: 12,
|
|
154
|
+
labelFontWeight: 400,
|
|
150
155
|
labelOpacity: 1,
|
|
151
156
|
labelPlacement: 'center',
|
|
152
157
|
labelTextBaseline: 'middle',
|
|
@@ -172,8 +177,8 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
172
177
|
opacity: 0.25,
|
|
173
178
|
},
|
|
174
179
|
disabled: {
|
|
175
|
-
labelOpacity: 0.25,
|
|
176
180
|
color: edgeColorDisabled,
|
|
181
|
+
labelOpacity: 0.25,
|
|
177
182
|
},
|
|
178
183
|
},
|
|
179
184
|
animation: {
|
|
@@ -189,7 +194,9 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
189
194
|
collapsedMaskFontSize: 12,
|
|
190
195
|
collapsedSize: 32,
|
|
191
196
|
color: comboColor,
|
|
197
|
+
halo: false,
|
|
192
198
|
haloLineWidth: 12,
|
|
199
|
+
haloStroke: comboStroke,
|
|
193
200
|
haloStrokeOpacity: 0.25,
|
|
194
201
|
labelBackground: false,
|
|
195
202
|
labelBackgroundFill: bgColor,
|
|
@@ -198,6 +205,7 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
198
205
|
labelBackgroundPadding: [2, 4, 2, 4],
|
|
199
206
|
labelFill: textColor,
|
|
200
207
|
labelFontSize: 12,
|
|
208
|
+
labelFontWeight: 400,
|
|
201
209
|
labelOpacity: 1,
|
|
202
210
|
lineDash: 0,
|
|
203
211
|
lineWidth: 1,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ID } from '@antv/graphlib';
|
|
2
|
+
import type { ComboData } from '../spec';
|
|
3
|
+
import { idOf } from '../utils/id';
|
|
4
|
+
import { BaseTransform } from './base-transform';
|
|
5
|
+
import type { DrawData } from './types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* <zh/> 调整元素绘制顺序
|
|
9
|
+
*
|
|
10
|
+
* <en/> Adjust the drawing order of elements
|
|
11
|
+
*/
|
|
12
|
+
export class ArrangeDrawOrder extends BaseTransform {
|
|
13
|
+
public beforeDraw(input: DrawData): DrawData {
|
|
14
|
+
const { model } = this.context;
|
|
15
|
+
|
|
16
|
+
const combosToAdd = input.add.combos;
|
|
17
|
+
|
|
18
|
+
const order: [ID, ComboData, number][] = [];
|
|
19
|
+
combosToAdd.forEach((combo, id) => {
|
|
20
|
+
const ancestors = model.getAncestorsData(id, 'combo');
|
|
21
|
+
const path = ancestors.map((ancestor) => idOf(ancestor)).reverse();
|
|
22
|
+
// combo 的 zIndex 为距离根 combo 的深度
|
|
23
|
+
// The zIndex of the combo is the depth from the root combo
|
|
24
|
+
order.push([id, combo, path.length]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
input.add.combos = new Map(
|
|
28
|
+
order
|
|
29
|
+
// 基于 zIndex 降序排序,优先绘制子 combo / Sort based on zIndex in descending order, draw child combo first
|
|
30
|
+
.sort(([, , zIndex1], [, , zIndex2]) => zIndex2 - zIndex1)
|
|
31
|
+
.map(([id, datum]) => [id, datum]),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return input;
|
|
35
|
+
}
|
|
36
|
+
}
|