@antv/g6 5.0.0-beta.1 → 5.0.0-beta.11
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/esm/constant/shape.d.ts +4 -1
- package/esm/constant/shape.js.map +1 -1
- package/esm/index.d.ts +22 -7
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +16 -9
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +20 -3
- package/esm/item/edge.js +99 -43
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +21 -11
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +2 -1
- package/esm/item/node.js +32 -16
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +7 -10
- package/esm/runtime/controller/data.js +125 -281
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +267 -151
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/graph.d.ts +103 -23
- package/esm/runtime/graph.js +460 -88
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.d.ts +9 -9
- package/esm/stdlib/behavior/activate-relations.js +8 -8
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.js +1 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +1 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +207 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/drag-canvas.js +59 -28
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +43 -32
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +76 -63
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +3 -0
- package/esm/stdlib/behavior/index.js +3 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +1 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/esm/stdlib/behavior/shortcuts-call.js +80 -0
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/zoom-canvas.js +55 -24
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/transformV4Data.d.ts +2 -2
- package/esm/stdlib/data/transformV4Data.js +2 -2
- package/esm/stdlib/data/transformV4Data.js.map +1 -1
- package/esm/stdlib/data/validateData.d.ts +2 -2
- package/esm/stdlib/data/validateData.js +9 -9
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +16 -6
- package/esm/stdlib/index.js +20 -10
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +10 -1
- package/esm/stdlib/item/edge/base.js +20 -13
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/line.js +5 -2
- package/esm/stdlib/item/edge/line.js.map +1 -1
- package/esm/stdlib/item/edge/polyline.d.ts +3 -2
- package/esm/stdlib/item/edge/polyline.js +3 -3
- package/esm/stdlib/item/edge/polyline.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +1 -1
- package/esm/stdlib/item/node/base.js +18 -26
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +1 -0
- package/esm/stdlib/item/node/base3d.js +1 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/diamond.js +1 -1
- package/esm/stdlib/item/node/ellipse.js +2 -2
- package/esm/stdlib/item/node/hexagon.js +12 -5
- package/esm/stdlib/item/node/hexagon.js.map +1 -1
- package/esm/stdlib/item/node/image.d.ts +40 -0
- package/esm/stdlib/item/node/image.js +110 -0
- package/esm/stdlib/item/node/image.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/history/combo-command.js +2 -2
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
- package/esm/stdlib/plugin/history/index.d.ts +10 -10
- package/esm/stdlib/plugin/history/index.js +14 -14
- package/esm/stdlib/plugin/history/index.js.map +1 -1
- package/esm/stdlib/plugin/history/item-data-command.js +25 -16
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +2 -0
- package/esm/stdlib/plugin/index.js +2 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/legend/index.js +1 -1
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/map/index.d.ts +118 -0
- package/esm/stdlib/plugin/map/index.js +683 -0
- package/esm/stdlib/plugin/map/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
- package/esm/stdlib/plugin/minimap/index.js +116 -9
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
- package/esm/stdlib/plugin/snapline/index.js +1063 -0
- package/esm/stdlib/plugin/snapline/index.js.map +1 -0
- package/esm/stdlib/plugin/timebar/index.d.ts +98 -0
- package/esm/stdlib/plugin/timebar/index.js +303 -0
- package/esm/stdlib/plugin/timebar/index.js.map +1 -0
- package/esm/stdlib/plugin/toolbar/index.js +1 -1
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +2 -0
- package/esm/stdlib/theme/dark.js +42 -2
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +4 -4
- package/esm/types/common.d.ts +1 -0
- package/esm/types/event.d.ts +1 -0
- package/esm/types/graph.d.ts +48 -22
- package/esm/types/hook.d.ts +22 -2
- package/esm/types/item.d.ts +6 -0
- package/esm/types/item.js.map +1 -1
- package/esm/types/spec.d.ts +19 -3
- package/esm/types/view.d.ts +5 -0
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +29 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/canvas.d.ts +2 -2
- package/esm/util/canvas.js +5 -11
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/event.d.ts +3 -1
- package/esm/util/event.js +8 -1
- package/esm/util/event.js.map +1 -1
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/layout.d.ts +11 -0
- package/esm/util/layout.js +45 -0
- package/esm/util/layout.js.map +1 -1
- package/esm/util/point.js +9 -2
- package/esm/util/point.js.map +1 -1
- package/esm/util/router.d.ts +4 -3
- package/esm/util/router.js +8 -5
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +3 -3
- package/esm/util/shape.js +8 -12
- package/esm/util/shape.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/constant/shape.d.ts +4 -1
- package/lib/constant/shape.js.map +1 -1
- package/lib/index.d.ts +22 -7
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +16 -9
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +20 -3
- package/lib/item/edge.js +98 -42
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +21 -11
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +2 -1
- package/lib/item/node.js +32 -16
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +7 -10
- package/lib/runtime/controller/data.js +125 -281
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +266 -150
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/graph.d.ts +103 -23
- package/lib/runtime/graph.js +460 -88
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.d.ts +9 -9
- package/lib/stdlib/behavior/activate-relations.js +8 -8
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.js +1 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +1 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +211 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/drag-canvas.js +59 -28
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +43 -32
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +76 -63
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +3 -0
- package/lib/stdlib/behavior/index.js +3 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +1 -2
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/lib/stdlib/behavior/shortcuts-call.js +84 -0
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/zoom-canvas.js +55 -24
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/transformV4Data.d.ts +2 -2
- package/lib/stdlib/data/transformV4Data.js +2 -2
- package/lib/stdlib/data/transformV4Data.js.map +1 -1
- package/lib/stdlib/data/validateData.d.ts +2 -2
- package/lib/stdlib/data/validateData.js +9 -9
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +16 -6
- package/lib/stdlib/index.js +20 -10
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +10 -1
- package/lib/stdlib/item/edge/base.js +20 -13
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/line.js +5 -2
- package/lib/stdlib/item/edge/line.js.map +1 -1
- package/lib/stdlib/item/edge/polyline.d.ts +3 -2
- package/lib/stdlib/item/edge/polyline.js +3 -3
- package/lib/stdlib/item/edge/polyline.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +1 -1
- package/lib/stdlib/item/node/base.js +18 -26
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +1 -0
- package/lib/stdlib/item/node/base3d.js +1 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/diamond.js +1 -1
- package/lib/stdlib/item/node/ellipse.js +2 -2
- package/lib/stdlib/item/node/hexagon.js +12 -5
- package/lib/stdlib/item/node/hexagon.js.map +1 -1
- package/lib/stdlib/item/node/image.d.ts +40 -0
- package/lib/stdlib/item/node/image.js +114 -0
- package/lib/stdlib/item/node/image.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/history/combo-command.js +2 -2
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
- package/lib/stdlib/plugin/history/index.d.ts +10 -10
- package/lib/stdlib/plugin/history/index.js +14 -14
- package/lib/stdlib/plugin/history/index.js.map +1 -1
- package/lib/stdlib/plugin/history/item-data-command.js +25 -16
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +2 -0
- package/lib/stdlib/plugin/index.js +2 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/legend/index.js +1 -1
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/map/index.d.ts +118 -0
- package/lib/stdlib/plugin/map/index.js +687 -0
- package/lib/stdlib/plugin/map/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
- package/lib/stdlib/plugin/minimap/index.js +116 -9
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
- package/lib/stdlib/plugin/snapline/index.js +1067 -0
- package/lib/stdlib/plugin/snapline/index.js.map +1 -0
- package/lib/stdlib/plugin/timebar/index.d.ts +98 -0
- package/lib/stdlib/plugin/timebar/index.js +307 -0
- package/lib/stdlib/plugin/timebar/index.js.map +1 -0
- package/lib/stdlib/plugin/toolbar/index.js +1 -1
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +2 -0
- package/lib/stdlib/theme/dark.js +42 -2
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +4 -4
- package/lib/types/common.d.ts +1 -0
- package/lib/types/event.d.ts +1 -0
- package/lib/types/graph.d.ts +48 -22
- package/lib/types/hook.d.ts +22 -2
- package/lib/types/item.d.ts +6 -0
- package/lib/types/item.js.map +1 -1
- package/lib/types/spec.d.ts +19 -3
- package/lib/types/view.d.ts +5 -0
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +32 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/canvas.d.ts +2 -2
- package/lib/util/canvas.js +5 -11
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/event.d.ts +3 -1
- package/lib/util/event.js +8 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/layout.d.ts +11 -0
- package/lib/util/layout.js +47 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/point.js +9 -2
- package/lib/util/point.js.map +1 -1
- package/lib/util/router.d.ts +4 -3
- package/lib/util/router.js +8 -5
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +3 -3
- package/lib/util/shape.js +8 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +10 -10
- package/src/constant/shape.ts +2 -1
- package/src/index.ts +4 -2
- package/src/item/combo.ts +14 -9
- package/src/item/edge.ts +131 -57
- package/src/item/item.ts +24 -15
- package/src/item/node.ts +37 -24
- package/src/runtime/controller/data.ts +140 -339
- package/src/runtime/controller/item.ts +236 -72
- package/src/runtime/graph.ts +592 -96
- package/src/stdlib/behavior/activate-relations.ts +8 -8
- package/src/stdlib/behavior/brush-select.ts +4 -2
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/create-edge.ts +296 -0
- package/src/stdlib/behavior/drag-canvas.ts +78 -29
- package/src/stdlib/behavior/drag-combo.ts +10 -10
- package/src/stdlib/behavior/drag-node.ts +18 -18
- package/src/stdlib/behavior/index.ts +3 -0
- package/src/stdlib/behavior/lasso-select.ts +5 -3
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/shortcuts-call.ts +120 -0
- package/src/stdlib/behavior/zoom-canvas.ts +72 -25
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/transformV4Data.ts +2 -2
- package/src/stdlib/data/validateData.ts +9 -9
- package/src/stdlib/index.ts +33 -9
- package/src/stdlib/item/edge/base.ts +26 -13
- package/src/stdlib/item/edge/line.ts +8 -2
- package/src/stdlib/item/edge/polyline.ts +7 -5
- package/src/stdlib/item/node/base.ts +24 -29
- package/src/stdlib/item/node/base3d.ts +1 -0
- package/src/stdlib/item/node/diamond.ts +1 -1
- package/src/stdlib/item/node/ellipse.ts +2 -2
- package/src/stdlib/item/node/hexagon.ts +14 -6
- package/src/stdlib/item/node/image.ts +190 -0
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/plugin/history/combo-command.ts +2 -2
- package/src/stdlib/plugin/history/index.ts +14 -14
- package/src/stdlib/plugin/history/item-data-command.ts +35 -17
- package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
- package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
- package/src/stdlib/plugin/index.ts +2 -0
- package/src/stdlib/plugin/legend/index.ts +1 -1
- package/src/stdlib/plugin/map/index.ts +808 -0
- package/src/stdlib/plugin/minimap/index.ts +120 -10
- package/src/stdlib/plugin/snapline/index.ts +1297 -0
- package/src/stdlib/plugin/timebar/index.ts +473 -0
- package/src/stdlib/plugin/toolbar/index.ts +1 -1
- package/src/stdlib/plugin/types.ts +2 -0
- package/src/stdlib/theme/dark.ts +66 -2
- package/src/stdlib/theme/light.ts +4 -4
- package/src/types/common.ts +1 -0
- package/src/types/event.ts +1 -0
- package/src/types/graph.ts +59 -25
- package/src/types/hook.ts +22 -2
- package/src/types/item.ts +10 -0
- package/src/types/spec.ts +22 -3
- package/src/types/view.ts +8 -3
- package/src/util/bbox.ts +38 -1
- package/src/util/canvas.ts +5 -5
- package/src/util/event.ts +14 -1
- package/src/util/item.ts +65 -28
- package/src/util/layout.ts +45 -0
- package/src/util/point.ts +8 -3
- package/src/util/router.ts +15 -6
- package/src/util/shape.ts +16 -14
- package/src/util/warn.ts +20 -0
- package/src/api-doc/readme.md +0 -59
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNumber } from '@antv/util';
|
|
2
|
+
import { ID, IG6GraphEvent } from '../../types';
|
|
2
3
|
import { Behavior } from '../../types/behavior';
|
|
3
4
|
|
|
4
5
|
const VALID_TRIGGERS = ['wheel', 'upDownKeys'];
|
|
@@ -56,7 +57,7 @@ export interface ZoomCanvasOptions {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
|
|
59
|
-
enableOptimize:
|
|
60
|
+
enableOptimize: undefined,
|
|
60
61
|
triggerOnItems: true,
|
|
61
62
|
sensitivity: 2,
|
|
62
63
|
trigger: 'wheel',
|
|
@@ -75,6 +76,7 @@ export class ZoomCanvas extends Behavior {
|
|
|
75
76
|
private hiddenEdgeIds: ID[];
|
|
76
77
|
private hiddenNodeIds: ID[];
|
|
77
78
|
private zoomTimer: ReturnType<typeof setTimeout>;
|
|
79
|
+
private tileRequestId?: number;
|
|
78
80
|
|
|
79
81
|
constructor(options: Partial<ZoomCanvasOptions>) {
|
|
80
82
|
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
@@ -114,43 +116,88 @@ export class ZoomCanvas extends Behavior {
|
|
|
114
116
|
|
|
115
117
|
private hideShapes() {
|
|
116
118
|
const { graph } = this;
|
|
117
|
-
|
|
119
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
120
|
+
graph.getSpecification().optimize || {};
|
|
121
|
+
const optimize =
|
|
122
|
+
this.options.enableOptimize !== undefined
|
|
123
|
+
? this.options.enableOptimize
|
|
124
|
+
: graphBehaviorOptimize;
|
|
125
|
+
const shouldOptimze = isNumber(optimize)
|
|
126
|
+
? graph.getAllNodesData().length > optimize
|
|
127
|
+
: optimize;
|
|
128
|
+
if (shouldOptimze) {
|
|
118
129
|
this.hiddenEdgeIds = graph
|
|
119
130
|
.getAllEdgesData()
|
|
120
131
|
.map((edge) => edge.id)
|
|
121
132
|
.filter((id) => graph.getItemVisible(id) === true);
|
|
122
|
-
// TODO
|
|
123
|
-
graph.hideItem(this.hiddenEdgeIds, false);
|
|
124
133
|
this.hiddenNodeIds = graph
|
|
125
134
|
.getAllNodesData()
|
|
126
135
|
.map((node) => node.id)
|
|
127
136
|
.filter((id) => graph.getItemVisible(id) === true);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
|
|
138
|
+
const hiddenIds = [...this.hiddenNodeIds];
|
|
139
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
140
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
141
|
+
hiddenIds.slice(
|
|
142
|
+
i * tileBehaviorSize,
|
|
143
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
const update = () => {
|
|
147
|
+
if (!sections.length && this.tileRequestId) {
|
|
148
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
149
|
+
this.tileRequestId = undefined;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const section = sections.shift();
|
|
153
|
+
graph.startHistoryBatch();
|
|
154
|
+
graph.hideItem(section, false, true);
|
|
155
|
+
graph.stopHistoryBatch();
|
|
156
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
157
|
+
};
|
|
158
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
135
159
|
}
|
|
136
160
|
}
|
|
137
161
|
|
|
138
162
|
private endZoom() {
|
|
139
|
-
const { graph, hiddenEdgeIds, hiddenNodeIds } = this;
|
|
140
|
-
const {
|
|
163
|
+
const { graph, hiddenEdgeIds = [], hiddenNodeIds } = this;
|
|
164
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
165
|
+
graph.getSpecification().optimize || {};
|
|
166
|
+
const optimize =
|
|
167
|
+
this.options.enableOptimize !== undefined
|
|
168
|
+
? this.options.enableOptimize
|
|
169
|
+
: graphBehaviorOptimize;
|
|
170
|
+
const shouldOptimze = isNumber(optimize)
|
|
171
|
+
? graph.getAllNodesData().length > optimize
|
|
172
|
+
: optimize;
|
|
141
173
|
this.zooming = false;
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
174
|
+
if (shouldOptimze) {
|
|
175
|
+
if (this.tileRequestId) {
|
|
176
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
177
|
+
this.tileRequestId = undefined;
|
|
178
|
+
}
|
|
179
|
+
if (hiddenNodeIds) {
|
|
180
|
+
const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
|
|
181
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
182
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
183
|
+
hiddenIds.slice(
|
|
184
|
+
i * tileBehaviorSize,
|
|
185
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
186
|
+
),
|
|
187
|
+
);
|
|
188
|
+
const update = () => {
|
|
189
|
+
if (!sections.length && this.tileRequestId) {
|
|
190
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
191
|
+
this.tileRequestId = undefined;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
graph.executeWithNoStack(() => {
|
|
195
|
+
graph.showItem(sections.shift(), false);
|
|
196
|
+
});
|
|
197
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
198
|
+
};
|
|
199
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
146
200
|
}
|
|
147
|
-
// TODO
|
|
148
|
-
// if (hiddenNodeIds) {
|
|
149
|
-
// hiddenNodeIds.forEach((id) => {
|
|
150
|
-
// graph.drawTransient('node', id, { action: 'remove' });
|
|
151
|
-
// });
|
|
152
|
-
// graph.showItem(hiddenNodeIds, false);
|
|
153
|
-
// }
|
|
154
201
|
}
|
|
155
202
|
this.hiddenEdgeIds = [];
|
|
156
203
|
this.hiddenNodeIds = [];
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
/**
|
|
10
10
|
* Validate and format the graph data.
|
|
11
11
|
* @param data input user data.
|
|
12
|
-
* @param
|
|
12
|
+
* @param graphCore the graph core stores the previous data.
|
|
13
13
|
* @returns formatted data.
|
|
14
14
|
*/
|
|
15
15
|
export const MapNodeSize = (
|
|
@@ -18,7 +18,7 @@ export const MapNodeSize = (
|
|
|
18
18
|
field?: string;
|
|
19
19
|
range?: [number, number];
|
|
20
20
|
} = {},
|
|
21
|
-
|
|
21
|
+
graphCore?: GraphCore,
|
|
22
22
|
): GraphData => {
|
|
23
23
|
const { field, range = [8, 40] } = options;
|
|
24
24
|
if (!field) return data;
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
/**
|
|
11
11
|
* Validate and format the graph data.
|
|
12
12
|
* @param data input user data.
|
|
13
|
-
* @param
|
|
13
|
+
* @param graphCore the graph core stores the previous data.
|
|
14
14
|
* @returns formatted data.
|
|
15
15
|
*/
|
|
16
16
|
export const TransformV4Data = (
|
|
17
17
|
data: GraphData,
|
|
18
18
|
options = {},
|
|
19
|
-
|
|
19
|
+
graphCore?: GraphCore,
|
|
20
20
|
): GraphData => {
|
|
21
21
|
const { nodes = [], edges = [], combos = [] } = data;
|
|
22
22
|
const formattedNodes = nodes.map((node: any) => {
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
/**
|
|
11
11
|
* Validate and format the graph data.
|
|
12
12
|
* @param data input user data.
|
|
13
|
-
* @param
|
|
13
|
+
* @param graphCore the graph core stores the previous data.
|
|
14
14
|
* @returns formatted data.
|
|
15
15
|
*/
|
|
16
16
|
export const ValidateData = (
|
|
17
17
|
data: GraphData,
|
|
18
18
|
options = {},
|
|
19
|
-
|
|
19
|
+
graphCore?: GraphCore,
|
|
20
20
|
): GraphData => {
|
|
21
21
|
const { nodes, edges, combos } = data;
|
|
22
22
|
const idMap = new Map();
|
|
@@ -64,7 +64,7 @@ export const ValidateData = (
|
|
|
64
64
|
if (
|
|
65
65
|
parentId !== undefined &&
|
|
66
66
|
!comboIdMap.has(parentId) &&
|
|
67
|
-
(!
|
|
67
|
+
(!graphCore || !graphCore.hasNode(parentId))
|
|
68
68
|
) {
|
|
69
69
|
console.error(
|
|
70
70
|
`The parentId of combo with id ${combo.id} will be removed since it is not exist in combos.`,
|
|
@@ -80,9 +80,9 @@ export const ValidateData = (
|
|
|
80
80
|
if (
|
|
81
81
|
parentId !== undefined &&
|
|
82
82
|
!comboIdMap.has(parentId) &&
|
|
83
|
-
(!
|
|
83
|
+
(!graphCore || !graphCore.hasNode(parentId))
|
|
84
84
|
) {
|
|
85
|
-
// TODO: parentId is a node in
|
|
85
|
+
// TODO: parentId is a node in graphCore
|
|
86
86
|
console.error(
|
|
87
87
|
`The parentId of node with id ${node.id} will be removed since it is not exist in combos.`,
|
|
88
88
|
);
|
|
@@ -100,8 +100,8 @@ export const ValidateData = (
|
|
|
100
100
|
let { source, target } = edge;
|
|
101
101
|
if (!idAndDataCheck(edge, 'edge', true)) return false;
|
|
102
102
|
|
|
103
|
-
if (
|
|
104
|
-
const existEdge =
|
|
103
|
+
if (graphCore?.hasEdge(id)) {
|
|
104
|
+
const existEdge = graphCore?.getEdge(id);
|
|
105
105
|
if (source === undefined) source = existEdge.source;
|
|
106
106
|
if (target === undefined) target = existEdge.target;
|
|
107
107
|
}
|
|
@@ -121,7 +121,7 @@ export const ValidateData = (
|
|
|
121
121
|
if (
|
|
122
122
|
!nodeIdMap.has(source) &&
|
|
123
123
|
!comboIdMap.has(source) &&
|
|
124
|
-
(!
|
|
124
|
+
(!graphCore || !graphCore.hasNode(source))
|
|
125
125
|
) {
|
|
126
126
|
console.error(
|
|
127
127
|
`The edge with id ${id} will be ignored since its source ${source} is not existed in nodes and combos.`,
|
|
@@ -131,7 +131,7 @@ export const ValidateData = (
|
|
|
131
131
|
if (
|
|
132
132
|
!nodeIdMap.has(target) &&
|
|
133
133
|
!comboIdMap.has(target) &&
|
|
134
|
-
(!
|
|
134
|
+
(!graphCore || !graphCore.hasNode(target))
|
|
135
135
|
) {
|
|
136
136
|
console.error(
|
|
137
137
|
`The edge with id ${id} will be ignored since its target ${target} is not existed in nodes and combos.`,
|
package/src/stdlib/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
TriangleNode,
|
|
32
32
|
EllipseNode,
|
|
33
33
|
ModelRectNode,
|
|
34
|
+
ImageNode,
|
|
34
35
|
} = Nodes;
|
|
35
36
|
|
|
36
37
|
const {
|
|
@@ -60,9 +61,22 @@ const {
|
|
|
60
61
|
DragNode,
|
|
61
62
|
DragCombo,
|
|
62
63
|
ClickSelect,
|
|
64
|
+
CreateEdge,
|
|
65
|
+
ShortcutsCall,
|
|
66
|
+
ScrollCanvas,
|
|
63
67
|
} = Behaviors;
|
|
64
|
-
const {
|
|
65
|
-
|
|
68
|
+
const {
|
|
69
|
+
History,
|
|
70
|
+
Tooltip,
|
|
71
|
+
Minimap,
|
|
72
|
+
Grid,
|
|
73
|
+
Menu,
|
|
74
|
+
Fisheye,
|
|
75
|
+
Legend,
|
|
76
|
+
Toolbar,
|
|
77
|
+
Timebar,
|
|
78
|
+
Snapline,
|
|
79
|
+
} = Plugins;
|
|
66
80
|
|
|
67
81
|
const {
|
|
68
82
|
ForceLayout,
|
|
@@ -81,6 +95,7 @@ const {
|
|
|
81
95
|
|
|
82
96
|
import lassoSelector from './selector/lasso';
|
|
83
97
|
import rectSelector from './selector/rect';
|
|
98
|
+
import Hull from './plugin/hull';
|
|
84
99
|
|
|
85
100
|
const stdLib = {
|
|
86
101
|
transforms: {
|
|
@@ -108,6 +123,7 @@ const stdLib = {
|
|
|
108
123
|
'zoom-canvas': ZoomCanvas,
|
|
109
124
|
'drag-node': DragNode,
|
|
110
125
|
'drag-combo': DragCombo,
|
|
126
|
+
'create-edge': CreateEdge,
|
|
111
127
|
'collapse-expand-combo': CollapseExpandCombo,
|
|
112
128
|
'collapse-expand-tree': CollapseExpandTree,
|
|
113
129
|
'click-select': ClickSelect,
|
|
@@ -118,9 +134,11 @@ const stdLib = {
|
|
|
118
134
|
nodes: {
|
|
119
135
|
'circle-node': CircleNode,
|
|
120
136
|
'rect-node': RectNode,
|
|
137
|
+
'image-node': ImageNode,
|
|
121
138
|
},
|
|
122
139
|
edges: {
|
|
123
140
|
'line-edge': LineEdge,
|
|
141
|
+
'loop-edge': LoopEdge,
|
|
124
142
|
},
|
|
125
143
|
combos: {
|
|
126
144
|
'circle-combo': CircleCombo,
|
|
@@ -193,13 +211,13 @@ const Extensions = {
|
|
|
193
211
|
ValidateData,
|
|
194
212
|
TransformV4Data,
|
|
195
213
|
MapNodeSize,
|
|
196
|
-
//themes
|
|
214
|
+
// themes
|
|
197
215
|
LightTheme,
|
|
198
216
|
DarkTheme,
|
|
199
|
-
//themeSolvers
|
|
217
|
+
// themeSolvers
|
|
200
218
|
SpecThemeSolver,
|
|
201
219
|
SubjectThemeSolver,
|
|
202
|
-
//layout
|
|
220
|
+
// layout
|
|
203
221
|
ForceLayout,
|
|
204
222
|
GridLayout,
|
|
205
223
|
CircularLayout,
|
|
@@ -212,12 +230,12 @@ const Extensions = {
|
|
|
212
230
|
ForceAtlas2Layout,
|
|
213
231
|
DagreLayout,
|
|
214
232
|
ComboCombinedLayout,
|
|
215
|
-
//Hierarchy
|
|
233
|
+
// Hierarchy
|
|
216
234
|
compactBox,
|
|
217
235
|
dendrogram,
|
|
218
236
|
indented,
|
|
219
237
|
mindmap,
|
|
220
|
-
//nodes
|
|
238
|
+
// nodes
|
|
221
239
|
CircleNode,
|
|
222
240
|
RectNode,
|
|
223
241
|
DiamondNode,
|
|
@@ -239,7 +257,7 @@ const Extensions = {
|
|
|
239
257
|
// combos
|
|
240
258
|
CircleCombo,
|
|
241
259
|
RectCombo,
|
|
242
|
-
//behaviors
|
|
260
|
+
// behaviors
|
|
243
261
|
BaseBehavior,
|
|
244
262
|
ActivateRelations,
|
|
245
263
|
BrushSelect,
|
|
@@ -255,7 +273,10 @@ const Extensions = {
|
|
|
255
273
|
CollapseExpandCombo,
|
|
256
274
|
DragNode,
|
|
257
275
|
DragCombo,
|
|
258
|
-
|
|
276
|
+
CreateEdge,
|
|
277
|
+
ShortcutsCall,
|
|
278
|
+
ScrollCanvas,
|
|
279
|
+
// plugins
|
|
259
280
|
BasePlugin,
|
|
260
281
|
History,
|
|
261
282
|
Toolbar,
|
|
@@ -265,6 +286,9 @@ const Extensions = {
|
|
|
265
286
|
Menu,
|
|
266
287
|
Fisheye,
|
|
267
288
|
Legend,
|
|
289
|
+
Timebar,
|
|
290
|
+
Hull,
|
|
291
|
+
Snapline,
|
|
268
292
|
};
|
|
269
293
|
|
|
270
294
|
export default registery;
|
|
@@ -534,6 +534,15 @@ export abstract class BaseEdge {
|
|
|
534
534
|
);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
+
public drawOtherShapes(
|
|
538
|
+
model: EdgeDisplayModel,
|
|
539
|
+
shapeMap: EdgeShapeMap,
|
|
540
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
541
|
+
diffState?: { previous: State[]; current: State[] },
|
|
542
|
+
): { [id: string]: DisplayObject } {
|
|
543
|
+
return {};
|
|
544
|
+
}
|
|
545
|
+
|
|
537
546
|
/**
|
|
538
547
|
* The listener for graph zooming.
|
|
539
548
|
* 1. show / hide some shapes while zoom level changed;
|
|
@@ -541,7 +550,11 @@ export abstract class BaseEdge {
|
|
|
541
550
|
* @param shapeMap The shape map that contains all of the elements to show on the edge.
|
|
542
551
|
* @param zoom The zoom level of the graph.
|
|
543
552
|
*/
|
|
544
|
-
public onZoom = (
|
|
553
|
+
public onZoom = (
|
|
554
|
+
shapeMap: EdgeShapeMap,
|
|
555
|
+
zoom: number,
|
|
556
|
+
cacheHiddenShape = {},
|
|
557
|
+
) => {
|
|
545
558
|
// balance the size for label, badges
|
|
546
559
|
this.balanceShapeSize(shapeMap, zoom);
|
|
547
560
|
|
|
@@ -565,7 +578,10 @@ export abstract class BaseEdge {
|
|
|
565
578
|
// zoomLevel changed, from higher to lower, hide something
|
|
566
579
|
if (firstRender) {
|
|
567
580
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
568
|
-
levelShapes[String(i)]?.forEach((id) =>
|
|
581
|
+
levelShapes[String(i)]?.forEach((id) => {
|
|
582
|
+
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
583
|
+
shapeMap[id]?.hide();
|
|
584
|
+
});
|
|
569
585
|
}
|
|
570
586
|
} else {
|
|
571
587
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
@@ -577,7 +593,8 @@ export abstract class BaseEdge {
|
|
|
577
593
|
} else if (currentLevel > previousLevel) {
|
|
578
594
|
// zoomLevel changed, from lower to higher, show something
|
|
579
595
|
for (let i = currentLevel; i >= minLevel; i--) {
|
|
580
|
-
levelShapes[String(i)]?.forEach((id) =>
|
|
596
|
+
levelShapes[String(i)]?.forEach((id) => {
|
|
597
|
+
if (hiddenShape[id]) return;
|
|
581
598
|
fadeIn(
|
|
582
599
|
id,
|
|
583
600
|
shapeMap[id],
|
|
@@ -585,8 +602,8 @@ export abstract class BaseEdge {
|
|
|
585
602
|
this.mergedStyles[id.replace('Background', '')],
|
|
586
603
|
hiddenShape,
|
|
587
604
|
animateConfig,
|
|
588
|
-
)
|
|
589
|
-
);
|
|
605
|
+
);
|
|
606
|
+
});
|
|
590
607
|
}
|
|
591
608
|
}
|
|
592
609
|
|
|
@@ -669,12 +686,9 @@ export abstract class BaseEdge {
|
|
|
669
686
|
resultStyle[`${markerField}Offset`] = 0;
|
|
670
687
|
return;
|
|
671
688
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
} else {
|
|
676
|
-
arrowStyle = arrowConfig;
|
|
677
|
-
}
|
|
689
|
+
const arrowStyle = isBoolean(arrowConfig)
|
|
690
|
+
? ({ ...DEFAULT_ARROW_CONFIG } as ArrowStyle)
|
|
691
|
+
: arrowConfig;
|
|
678
692
|
const {
|
|
679
693
|
type = 'triangle',
|
|
680
694
|
width = 10,
|
|
@@ -683,14 +697,13 @@ export abstract class BaseEdge {
|
|
|
683
697
|
offset = 0,
|
|
684
698
|
...others
|
|
685
699
|
} = arrowStyle;
|
|
686
|
-
const path = propPath ? propPath : getArrowPath(type, width, height);
|
|
687
700
|
resultStyle[markerField] = this.upsertShape(
|
|
688
701
|
'path',
|
|
689
702
|
`${markerField}Shape`,
|
|
690
703
|
{
|
|
691
704
|
...bodyStyle,
|
|
692
705
|
fill: type === 'simple' ? '' : bodyStyle.stroke,
|
|
693
|
-
path,
|
|
706
|
+
path: propPath || getArrowPath(type, width, height),
|
|
694
707
|
anchor: '0.5 0.5',
|
|
695
708
|
transformOrigin: 'center',
|
|
696
709
|
...others,
|
|
@@ -35,7 +35,7 @@ export class LineEdge extends BaseEdge {
|
|
|
35
35
|
): EdgeShapeMap {
|
|
36
36
|
const { data = {} } = model;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
let shapes: EdgeShapeMap = { keyShape: undefined };
|
|
39
39
|
|
|
40
40
|
shapes.keyShape = this.drawKeyShape(
|
|
41
41
|
model,
|
|
@@ -66,7 +66,13 @@ export class LineEdge extends BaseEdge {
|
|
|
66
66
|
shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// otherShapes
|
|
70
|
+
if (data.otherShapes) {
|
|
71
|
+
shapes = {
|
|
72
|
+
...shapes,
|
|
73
|
+
...this.drawOtherShapes(model, shapeMap, diffData),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
70
76
|
|
|
71
77
|
return shapes;
|
|
72
78
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../../../types/edge';
|
|
9
9
|
import { State } from '../../../types/item';
|
|
10
10
|
import { getPolylinePath } from '../../../util/polyline';
|
|
11
|
-
import { pathFinder } from '../../../util/router';
|
|
11
|
+
import { RouterCfg, pathFinder } from '../../../util/router';
|
|
12
12
|
import Node from '../../../item/node';
|
|
13
13
|
import { LineEdge } from './line';
|
|
14
14
|
export class PolylineEdge extends LineEdge {
|
|
@@ -74,7 +74,7 @@ export class PolylineEdge extends LineEdge {
|
|
|
74
74
|
|
|
75
75
|
return shapes;
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
public getControlPoints(
|
|
78
78
|
model: EdgeDisplayModel,
|
|
79
79
|
sourcePoint: Point,
|
|
80
80
|
targetPoint: Point,
|
|
@@ -95,16 +95,18 @@ export class PolylineEdge extends LineEdge {
|
|
|
95
95
|
model: EdgeDisplayModel,
|
|
96
96
|
points: Point[],
|
|
97
97
|
radius: number,
|
|
98
|
-
routeCfg?:
|
|
98
|
+
routeCfg?: RouterCfg,
|
|
99
99
|
auto?: boolean,
|
|
100
100
|
): string {
|
|
101
101
|
const { id: edgeId, source: sourceNodeId, target: targetNodeId } = model;
|
|
102
102
|
|
|
103
103
|
// Draw a polyline with control points
|
|
104
|
-
if (!auto
|
|
104
|
+
if (!auto && routeCfg.name !== 'er')
|
|
105
|
+
return getPolylinePath(edgeId, points, radius);
|
|
105
106
|
|
|
106
107
|
// Find the shortest path computed by A* routing algorithm
|
|
107
108
|
const polylinePoints = pathFinder(
|
|
109
|
+
points,
|
|
108
110
|
sourceNodeId,
|
|
109
111
|
targetNodeId,
|
|
110
112
|
this.nodeMap as unknown as Map<ID, Node>,
|
|
@@ -136,7 +138,7 @@ export class PolylineEdge extends LineEdge {
|
|
|
136
138
|
|
|
137
139
|
const routeCfg = mix(
|
|
138
140
|
{},
|
|
139
|
-
{ offset: keyShapeStyle.offset },
|
|
141
|
+
{ offset: keyShapeStyle.offset, name: 'orth' },
|
|
140
142
|
keyShapeStyle.routeCfg,
|
|
141
143
|
);
|
|
142
144
|
|
|
@@ -186,10 +186,10 @@ export abstract class BaseNode {
|
|
|
186
186
|
});
|
|
187
187
|
this.zoomCache.levelShapes = levelShapes;
|
|
188
188
|
|
|
189
|
-
if (shapeMap.labelShape
|
|
189
|
+
if (shapeMap.labelShape) {
|
|
190
190
|
const { maxWidth = '200%' } = this.mergedStyles.labelShape || {};
|
|
191
191
|
this.zoomCache.wordWrapWidth = getWordWrapWidthByBox(
|
|
192
|
-
|
|
192
|
+
shapeMap.keyShape.getLocalBounds(),
|
|
193
193
|
maxWidth,
|
|
194
194
|
1,
|
|
195
195
|
);
|
|
@@ -286,12 +286,10 @@ export abstract class BaseNode {
|
|
|
286
286
|
const { labelShape: shapeStyle } = this.mergedStyles;
|
|
287
287
|
if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
|
|
288
288
|
const { keyShape } = shapeMap;
|
|
289
|
-
this.boundsCache.keyShapeLocal =
|
|
290
|
-
this.boundsCache.keyShapeLocal || keyShape.getLocalBounds();
|
|
291
289
|
const keyShapeBox = getShapeLocalBoundsByStyle(
|
|
292
290
|
keyShape,
|
|
293
291
|
this.mergedStyles.keyShape,
|
|
294
|
-
|
|
292
|
+
keyShape.getLocalBounds(),
|
|
295
293
|
);
|
|
296
294
|
const {
|
|
297
295
|
position,
|
|
@@ -577,12 +575,12 @@ export abstract class BaseNode {
|
|
|
577
575
|
position: string | [number, number],
|
|
578
576
|
anchorPositionMap: IAnchorPositionMap,
|
|
579
577
|
): [number, number] {
|
|
580
|
-
const keyShapeBBox = this.boundsCache.keyShapeLocal
|
|
578
|
+
const keyShapeBBox = this.boundsCache.keyShapeLocal!;
|
|
581
579
|
const keyShapeWidth = keyShapeBBox.max[0] - keyShapeBBox.min[0];
|
|
582
580
|
const keyShapeHeight = keyShapeBBox.max[1] - keyShapeBBox.min[1];
|
|
583
581
|
const defaultPosition: [number, number] = [
|
|
584
|
-
keyShapeBBox.max[0],
|
|
585
|
-
keyShapeBBox.min[1],
|
|
582
|
+
keyShapeBBox.max[0] - keyShapeBBox.center[0],
|
|
583
|
+
keyShapeBBox.min[1] - keyShapeBBox.center[1],
|
|
586
584
|
]; //topRight
|
|
587
585
|
if (position instanceof Array) {
|
|
588
586
|
return [
|
|
@@ -645,12 +643,10 @@ export abstract class BaseNode {
|
|
|
645
643
|
(style) => style.tag === 'badgeShape',
|
|
646
644
|
);
|
|
647
645
|
if (!individualConfigs.length) return {};
|
|
648
|
-
this.boundsCache.keyShapeLocal =
|
|
649
|
-
this.boundsCache.keyShapeLocal || shapeMap.keyShape.getLocalBounds();
|
|
650
646
|
const keyShapeBBox = getShapeLocalBoundsByStyle(
|
|
651
647
|
shapeMap.keyShape,
|
|
652
648
|
keyShapeStyle,
|
|
653
|
-
|
|
649
|
+
shapeMap.keyShape.getLocalBounds(),
|
|
654
650
|
);
|
|
655
651
|
const keyShapeSize = Math.min(
|
|
656
652
|
keyShapeBBox.max[0] - keyShapeBBox.min[0],
|
|
@@ -759,8 +755,6 @@ export abstract class BaseNode {
|
|
|
759
755
|
(text as string).length <= 1
|
|
760
756
|
? bgHeight
|
|
761
757
|
: Math.max(bgHeight, bbox.max[0] - bbox.min[0]) + 8;
|
|
762
|
-
let bgX = isLeft ? pos.x - bgWidth : pos.x;
|
|
763
|
-
if (isCenter) bgX = pos.x - bgWidth / 2;
|
|
764
758
|
shapes[bgShapeId] = this.upsertShape(
|
|
765
759
|
'rect',
|
|
766
760
|
bgShapeId,
|
|
@@ -771,8 +765,8 @@ export abstract class BaseNode {
|
|
|
771
765
|
width: bgWidth,
|
|
772
766
|
radius: bgHeight / 2,
|
|
773
767
|
zIndex,
|
|
774
|
-
x:
|
|
775
|
-
y:
|
|
768
|
+
x: bbox.center[0] - bgWidth / 2,
|
|
769
|
+
y: bbox.center[1] - bgHeight / 2,
|
|
776
770
|
...otherStyles,
|
|
777
771
|
} as GShapeStyle,
|
|
778
772
|
shapeMap,
|
|
@@ -810,7 +804,11 @@ export abstract class BaseNode {
|
|
|
810
804
|
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
811
805
|
* @param zoom The zoom level of the graph.
|
|
812
806
|
*/
|
|
813
|
-
public onZoom = (
|
|
807
|
+
public onZoom = (
|
|
808
|
+
shapeMap: NodeShapeMap | ComboShapeMap,
|
|
809
|
+
zoom: number,
|
|
810
|
+
cacheHiddenShape = {},
|
|
811
|
+
) => {
|
|
814
812
|
// zoomLevel changed
|
|
815
813
|
if (this.lodStrategy) {
|
|
816
814
|
const { levels } = this.lodStrategy;
|
|
@@ -831,7 +829,7 @@ export abstract class BaseNode {
|
|
|
831
829
|
// zoomLevel changed, from higher to lower, hide something
|
|
832
830
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
833
831
|
levelShapes[String(i)]?.forEach((id) => {
|
|
834
|
-
if (!shapeMap[id]) return;
|
|
832
|
+
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
835
833
|
shapeMap[id].hide();
|
|
836
834
|
hiddenShape[id] = true;
|
|
837
835
|
});
|
|
@@ -880,8 +878,7 @@ export abstract class BaseNode {
|
|
|
880
878
|
const balanceRatio = 1 / zoom || 1;
|
|
881
879
|
this.zoomCache.balanceRatio = balanceRatio;
|
|
882
880
|
if (!labelShape || !labelShape.isVisible()) return;
|
|
883
|
-
const {
|
|
884
|
-
const { position = 'bottom' } = labelStyle;
|
|
881
|
+
const { position = 'bottom' } = this.mergedStyles.labelShape;
|
|
885
882
|
|
|
886
883
|
const keyShapeLocal = keyShape.getLocalBounds();
|
|
887
884
|
if (zoom < 1) {
|
|
@@ -923,21 +920,20 @@ export abstract class BaseNode {
|
|
|
923
920
|
const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
|
|
924
921
|
labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
|
|
925
922
|
this.scaleTransformCache = scaleTransform;
|
|
926
|
-
|
|
927
|
-
labelShape.style.wordWrapWidth = wordWrapWidth;
|
|
923
|
+
labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
|
|
928
924
|
|
|
929
925
|
if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
|
|
930
926
|
|
|
931
|
-
const
|
|
927
|
+
const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
|
|
928
|
+
.mergedStyles.labelBackgroundShape.padding as number[];
|
|
929
|
+
const sidePadding = paddingRight + paddingLeft;
|
|
932
930
|
const { width, height, x, y } = labelBackgroundShape.attributes;
|
|
933
|
-
const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
|
|
934
|
-
padding as number[];
|
|
935
931
|
|
|
936
932
|
switch (position) {
|
|
937
933
|
case 'top':
|
|
938
934
|
// if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
|
|
939
935
|
labelBackgroundShape.style.transformOrigin = `${
|
|
940
|
-
paddingLeft + (width -
|
|
936
|
+
paddingLeft + (width - sidePadding) / 2
|
|
941
937
|
} ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
|
|
942
938
|
break;
|
|
943
939
|
case 'left':
|
|
@@ -952,7 +948,7 @@ export abstract class BaseNode {
|
|
|
952
948
|
break;
|
|
953
949
|
case 'bottom':
|
|
954
950
|
labelBackgroundShape.style.transformOrigin = `${
|
|
955
|
-
paddingLeft + (width -
|
|
951
|
+
paddingLeft + (width - sidePadding) / 2
|
|
956
952
|
} ${
|
|
957
953
|
zoom < 1
|
|
958
954
|
? paddingTop + (height - paddingTop - paddingBottom) / 2
|
|
@@ -962,14 +958,13 @@ export abstract class BaseNode {
|
|
|
962
958
|
default:
|
|
963
959
|
// center
|
|
964
960
|
labelBackgroundShape.style.transformOrigin = `${
|
|
965
|
-
paddingLeft + (width -
|
|
961
|
+
paddingLeft + (width - sidePadding) / 2
|
|
966
962
|
} ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
|
|
967
963
|
}
|
|
968
964
|
|
|
969
965
|
const { labelShapeGeometry: labelBBox } = this.boundsCache;
|
|
970
966
|
const labelWidth = labelBBox.max[0] - labelBBox.min[0];
|
|
971
|
-
const xAxistRatio =
|
|
972
|
-
(labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
|
|
967
|
+
const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
|
|
973
968
|
|
|
974
969
|
labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
|
|
975
970
|
}
|