@antv/g6 5.0.0-beta.0 → 5.0.0-beta.10
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/api-doc/item.d.ts +2 -0
- package/esm/api-doc/item.js +2 -0
- package/esm/api-doc/item.js.map +1 -1
- 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 +33 -16
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +7 -10
- package/esm/runtime/controller/data.js +127 -283
- 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/controller/plugin.js +3 -3
- package/esm/runtime/controller/plugin.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 +57 -26
- 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 +16 -11
- 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 +96 -6
- package/esm/stdlib/item/edge/base.js +92 -19
- 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 +90 -16
- package/esm/stdlib/item/node/base.js +91 -41
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +24 -0
- package/esm/stdlib/item/node/base3d.js +24 -8
- 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 +5 -3
- 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 +20 -4
- 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/api-doc/item.d.ts +2 -0
- package/lib/api-doc/item.js +5 -1
- package/lib/api-doc/item.js.map +1 -1
- 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 +33 -16
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +7 -10
- package/lib/runtime/controller/data.js +127 -283
- 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/controller/plugin.js +3 -3
- package/lib/runtime/controller/plugin.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 +57 -26
- 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 +16 -11
- 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 +96 -6
- package/lib/stdlib/item/edge/base.js +92 -19
- 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 +90 -16
- package/lib/stdlib/item/node/base.js +91 -41
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +24 -0
- package/lib/stdlib/item/node/base3d.js +24 -8
- 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 +5 -3
- 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 +20 -4
- 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/api-doc/item.ts +2 -0
- 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 +38 -24
- package/src/runtime/controller/data.ts +142 -341
- package/src/runtime/controller/item.ts +236 -72
- package/src/runtime/controller/plugin.ts +15 -3
- 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 +76 -27
- 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 +16 -11
- package/src/stdlib/index.ts +33 -9
- package/src/stdlib/item/edge/base.ts +118 -19
- 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 +117 -46
- package/src/stdlib/item/node/base3d.ts +24 -9
- 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 +5 -4
- 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 +23 -4
- 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
|
@@ -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
|
|
|
@@ -97,11 +97,18 @@ export abstract class BaseNode {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Get merged styles from `getMergedStyles` and assigns the merged styles to the 'mergedStyles' property.
|
|
101
|
+
* @param model - The NodeDisplayModel or ComboDisplayModel to merge the styles from.
|
|
101
102
|
*/
|
|
102
103
|
public mergeStyles(model: NodeDisplayModel | ComboDisplayModel) {
|
|
103
104
|
this.mergedStyles = this.getMergedStyles(model);
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Merge style
|
|
109
|
+
* @param model - The NodeDisplayModel or ComboDisplayModel to retrieve the merged styles from.
|
|
110
|
+
* @returns The merged styles as a NodeShapeStyles object.
|
|
111
|
+
*/
|
|
105
112
|
public getMergedStyles(model: NodeDisplayModel | ComboDisplayModel) {
|
|
106
113
|
const { data } = model;
|
|
107
114
|
const dataStyles = {} as NodeShapeStyles | ComboShapeStyles;
|
|
@@ -151,6 +158,7 @@ export abstract class BaseNode {
|
|
|
151
158
|
}
|
|
152
159
|
/**
|
|
153
160
|
* Call it after calling draw function to update cache about bounds and zoom levels.
|
|
161
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
154
162
|
*/
|
|
155
163
|
public updateCache(shapeMap) {
|
|
156
164
|
['keyShape', 'labelShape']
|
|
@@ -178,18 +186,23 @@ export abstract class BaseNode {
|
|
|
178
186
|
});
|
|
179
187
|
this.zoomCache.levelShapes = levelShapes;
|
|
180
188
|
|
|
181
|
-
if (shapeMap.labelShape
|
|
189
|
+
if (shapeMap.labelShape) {
|
|
182
190
|
const { maxWidth = '200%' } = this.mergedStyles.labelShape || {};
|
|
183
191
|
this.zoomCache.wordWrapWidth = getWordWrapWidthByBox(
|
|
184
|
-
|
|
192
|
+
shapeMap.keyShape.getLocalBounds(),
|
|
185
193
|
maxWidth,
|
|
186
194
|
1,
|
|
187
195
|
);
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
/**
|
|
191
|
-
* Draw all elements related to the
|
|
199
|
+
* Draw all elements related to the node.
|
|
192
200
|
* You should call `drawKeyShape` and `drawAnchorShape`,`drawLabelShape`,`drawIconShape`...as you like.
|
|
201
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
202
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
203
|
+
* @param diffData An object that contains previous and current data.
|
|
204
|
+
* @param diffState An object that contains previous and current node's state.
|
|
205
|
+
* @returns An object containing the keyShape and optional labelShape, iconShape, and some otherShapes properties
|
|
193
206
|
*/
|
|
194
207
|
abstract draw(
|
|
195
208
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -206,6 +219,13 @@ export abstract class BaseNode {
|
|
|
206
219
|
[otherShapeId: string]: DisplayObject;
|
|
207
220
|
};
|
|
208
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Perform additional drawing operations or add custom shapes after drawing node.
|
|
224
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
225
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
226
|
+
* @param shapesChanged An array of shape IDs that have changed and need to be updated.
|
|
227
|
+
* @returns An object that contains some new shapes to be added to the node.
|
|
228
|
+
*/
|
|
209
229
|
public afterDraw(
|
|
210
230
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
211
231
|
shapeMap: { [shapeId: string]: DisplayObject },
|
|
@@ -214,6 +234,13 @@ export abstract class BaseNode {
|
|
|
214
234
|
return {};
|
|
215
235
|
}
|
|
216
236
|
// shouldUpdate: (model: NodeDisplayModel, prevModel: NodeDisplayModel) => boolean = () => true;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Set the state for the node.
|
|
240
|
+
* @param state state name
|
|
241
|
+
* @param value state value
|
|
242
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
243
|
+
*/
|
|
217
244
|
public setState: (
|
|
218
245
|
name: string,
|
|
219
246
|
value: boolean,
|
|
@@ -222,7 +249,12 @@ export abstract class BaseNode {
|
|
|
222
249
|
|
|
223
250
|
/**
|
|
224
251
|
* The key function of drawing shape.
|
|
225
|
-
*
|
|
252
|
+
* Draw the key shape of the node based on the provided model and shape map.
|
|
253
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
254
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
255
|
+
* @param diffData An object that contains previous and current data.
|
|
256
|
+
* @param diffState An object that contains previous and current node's state.
|
|
257
|
+
* @returns The display object representing the key shape of the node.
|
|
226
258
|
*/
|
|
227
259
|
abstract drawKeyShape(
|
|
228
260
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -235,7 +267,12 @@ export abstract class BaseNode {
|
|
|
235
267
|
): DisplayObject;
|
|
236
268
|
|
|
237
269
|
/**
|
|
238
|
-
* Draw the label of the node
|
|
270
|
+
* Draw the label shape of the node
|
|
271
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
272
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
273
|
+
* @param diffData An object that contains previous and current data.
|
|
274
|
+
* @param diffState An object that contains previous and current node's state.
|
|
275
|
+
* @returns The display object representing the label shape of the node.
|
|
239
276
|
*/
|
|
240
277
|
public drawLabelShape(
|
|
241
278
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -247,14 +284,12 @@ export abstract class BaseNode {
|
|
|
247
284
|
diffState?: { previous: State[]; current: State[] },
|
|
248
285
|
): DisplayObject {
|
|
249
286
|
const { labelShape: shapeStyle } = this.mergedStyles;
|
|
250
|
-
if (!shapeStyle) return;
|
|
287
|
+
if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
|
|
251
288
|
const { keyShape } = shapeMap;
|
|
252
|
-
this.boundsCache.keyShapeLocal =
|
|
253
|
-
this.boundsCache.keyShapeLocal || keyShape.getLocalBounds();
|
|
254
289
|
const keyShapeBox = getShapeLocalBoundsByStyle(
|
|
255
290
|
keyShape,
|
|
256
291
|
this.mergedStyles.keyShape,
|
|
257
|
-
|
|
292
|
+
keyShape.getLocalBounds(),
|
|
258
293
|
);
|
|
259
294
|
const {
|
|
260
295
|
position,
|
|
@@ -338,7 +373,12 @@ export abstract class BaseNode {
|
|
|
338
373
|
}
|
|
339
374
|
|
|
340
375
|
/**
|
|
341
|
-
* Draw the label background of the node
|
|
376
|
+
* Draw the label background shape of the node
|
|
377
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
378
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
379
|
+
* @param diffData An object that contains previous and current data.
|
|
380
|
+
* @param diffState An object that contains previous and current node's state.
|
|
381
|
+
* @returns The display object representing the label background shape of the node.
|
|
342
382
|
*/
|
|
343
383
|
public drawLabelBackgroundShape(
|
|
344
384
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -350,7 +390,7 @@ export abstract class BaseNode {
|
|
|
350
390
|
diffState?: { oldState: State[]; newState: State[] },
|
|
351
391
|
): DisplayObject {
|
|
352
392
|
const { labelShape } = shapeMap;
|
|
353
|
-
if (!labelShape || !model.data.labelShape) return;
|
|
393
|
+
if (!labelShape || !labelShape.style.text || !model.data.labelShape) return;
|
|
354
394
|
if (
|
|
355
395
|
!this.boundsCache.labelShapeGeometry ||
|
|
356
396
|
labelShape.getAttribute(LOCAL_BOUNDS_DIRTY_FLAG_KEY)
|
|
@@ -390,7 +430,12 @@ export abstract class BaseNode {
|
|
|
390
430
|
}
|
|
391
431
|
|
|
392
432
|
/**
|
|
393
|
-
* Draw the icon of the node
|
|
433
|
+
* Draw the icon shape of the node
|
|
434
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
435
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
436
|
+
* @param diffData An object that contains previous and current data.
|
|
437
|
+
* @param diffState An object that contains previous and current node's state.
|
|
438
|
+
* @returns The display object representing the icon shape of the node.
|
|
394
439
|
*/
|
|
395
440
|
public drawIconShape(
|
|
396
441
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -436,7 +481,12 @@ export abstract class BaseNode {
|
|
|
436
481
|
}
|
|
437
482
|
|
|
438
483
|
/**
|
|
439
|
-
* Draw the halo of the node
|
|
484
|
+
* Draw the halo shape of the node
|
|
485
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
486
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
487
|
+
* @param diffData An object that contains previous and current data.
|
|
488
|
+
* @param diffState An object that contains previous and current node's state.
|
|
489
|
+
* @returns The display object representing the halo shape of the node.
|
|
440
490
|
*/
|
|
441
491
|
public drawHaloShape(
|
|
442
492
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -471,7 +521,12 @@ export abstract class BaseNode {
|
|
|
471
521
|
}
|
|
472
522
|
|
|
473
523
|
/**
|
|
474
|
-
* Draw the anchors of the node
|
|
524
|
+
* Draw the anchors shape of the node
|
|
525
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
526
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
527
|
+
* @param diffData An object that contains previous and current data.
|
|
528
|
+
* @param diffState An object that contains previous and current node's state.
|
|
529
|
+
* @returns The display object representing the anchors shape of the node.
|
|
475
530
|
*/
|
|
476
531
|
public drawAnchorShapes(
|
|
477
532
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -520,12 +575,12 @@ export abstract class BaseNode {
|
|
|
520
575
|
position: string | [number, number],
|
|
521
576
|
anchorPositionMap: IAnchorPositionMap,
|
|
522
577
|
): [number, number] {
|
|
523
|
-
const keyShapeBBox = this.boundsCache.keyShapeLocal
|
|
578
|
+
const keyShapeBBox = this.boundsCache.keyShapeLocal!;
|
|
524
579
|
const keyShapeWidth = keyShapeBBox.max[0] - keyShapeBBox.min[0];
|
|
525
580
|
const keyShapeHeight = keyShapeBBox.max[1] - keyShapeBBox.min[1];
|
|
526
581
|
const defaultPosition: [number, number] = [
|
|
527
|
-
keyShapeBBox.max[0],
|
|
528
|
-
keyShapeBBox.min[1],
|
|
582
|
+
keyShapeBBox.max[0] - keyShapeBBox.center[0],
|
|
583
|
+
keyShapeBBox.min[1] - keyShapeBBox.center[1],
|
|
529
584
|
]; //topRight
|
|
530
585
|
if (position instanceof Array) {
|
|
531
586
|
return [
|
|
@@ -546,10 +601,10 @@ export abstract class BaseNode {
|
|
|
546
601
|
}
|
|
547
602
|
|
|
548
603
|
/**
|
|
549
|
-
*
|
|
550
|
-
* e.g CircleNode `
|
|
551
|
-
* @param
|
|
552
|
-
* @
|
|
604
|
+
* Configures the anchor positions based on the provided keyShapeStyle and returns the configuration.
|
|
605
|
+
* e.g for a CircleNode, it returns: `{"right":keyShapeStyle.x+keyShapeStyle.r, keyShapeStyle.y}`
|
|
606
|
+
* @param keyShapeStyle - The keyShapeStyle object that contains the style information of the key shape.
|
|
607
|
+
* @returns The anchor position configuration as an IAnchorPositionMap object.
|
|
553
608
|
*/
|
|
554
609
|
public calculateAnchorPosition(keyShapeStyle: any): IAnchorPositionMap {
|
|
555
610
|
const x = convertToNumber(keyShapeStyle.x);
|
|
@@ -564,7 +619,12 @@ export abstract class BaseNode {
|
|
|
564
619
|
}
|
|
565
620
|
|
|
566
621
|
/**
|
|
567
|
-
* Draw the badges of the node
|
|
622
|
+
* Draw the badges shape of the node
|
|
623
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
624
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
625
|
+
* @param diffData An object that contains previous and current data.
|
|
626
|
+
* @param diffState An object that contains previous and current node's state.
|
|
627
|
+
* @returns The display object representing the badges shape of the node.
|
|
568
628
|
*/
|
|
569
629
|
public drawBadgeShapes(
|
|
570
630
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -583,12 +643,10 @@ export abstract class BaseNode {
|
|
|
583
643
|
(style) => style.tag === 'badgeShape',
|
|
584
644
|
);
|
|
585
645
|
if (!individualConfigs.length) return {};
|
|
586
|
-
this.boundsCache.keyShapeLocal =
|
|
587
|
-
this.boundsCache.keyShapeLocal || shapeMap.keyShape.getLocalBounds();
|
|
588
646
|
const keyShapeBBox = getShapeLocalBoundsByStyle(
|
|
589
647
|
shapeMap.keyShape,
|
|
590
648
|
keyShapeStyle,
|
|
591
|
-
|
|
649
|
+
shapeMap.keyShape.getLocalBounds(),
|
|
592
650
|
);
|
|
593
651
|
const keyShapeSize = Math.min(
|
|
594
652
|
keyShapeBBox.max[0] - keyShapeBBox.min[0],
|
|
@@ -697,8 +755,6 @@ export abstract class BaseNode {
|
|
|
697
755
|
(text as string).length <= 1
|
|
698
756
|
? bgHeight
|
|
699
757
|
: Math.max(bgHeight, bbox.max[0] - bbox.min[0]) + 8;
|
|
700
|
-
let bgX = isLeft ? pos.x - bgWidth : pos.x;
|
|
701
|
-
if (isCenter) bgX = pos.x - bgWidth / 2;
|
|
702
758
|
shapes[bgShapeId] = this.upsertShape(
|
|
703
759
|
'rect',
|
|
704
760
|
bgShapeId,
|
|
@@ -709,8 +765,8 @@ export abstract class BaseNode {
|
|
|
709
765
|
width: bgWidth,
|
|
710
766
|
radius: bgHeight / 2,
|
|
711
767
|
zIndex,
|
|
712
|
-
x:
|
|
713
|
-
y:
|
|
768
|
+
x: bbox.center[0] - bgWidth / 2,
|
|
769
|
+
y: bbox.center[1] - bgHeight / 2,
|
|
714
770
|
...otherStyles,
|
|
715
771
|
} as GShapeStyle,
|
|
716
772
|
shapeMap,
|
|
@@ -723,6 +779,11 @@ export abstract class BaseNode {
|
|
|
723
779
|
|
|
724
780
|
/**
|
|
725
781
|
* Draw other shapes(such as preRect,stateIcon) of the node
|
|
782
|
+
* @param model The displayed model of this node, only for drawing and not received by users.
|
|
783
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
784
|
+
* @param diffData An object that contains previous and current data.
|
|
785
|
+
* @param diffState An object that contains previous and current node's state.
|
|
786
|
+
* @returns The display object representing the other shapes of the node.
|
|
726
787
|
*/
|
|
727
788
|
public drawOtherShapes(
|
|
728
789
|
model: NodeDisplayModel | ComboDisplayModel,
|
|
@@ -740,10 +801,14 @@ export abstract class BaseNode {
|
|
|
740
801
|
* The listener for graph zooming.
|
|
741
802
|
* 1. show / hide some shapes while zoom level changed;
|
|
742
803
|
* 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
|
|
743
|
-
* @param shapeMap
|
|
744
|
-
* @param zoom
|
|
804
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
805
|
+
* @param zoom The zoom level of the graph.
|
|
745
806
|
*/
|
|
746
|
-
public onZoom = (
|
|
807
|
+
public onZoom = (
|
|
808
|
+
shapeMap: NodeShapeMap | ComboShapeMap,
|
|
809
|
+
zoom: number,
|
|
810
|
+
cacheHiddenShape = {},
|
|
811
|
+
) => {
|
|
747
812
|
// zoomLevel changed
|
|
748
813
|
if (this.lodStrategy) {
|
|
749
814
|
const { levels } = this.lodStrategy;
|
|
@@ -764,7 +829,7 @@ export abstract class BaseNode {
|
|
|
764
829
|
// zoomLevel changed, from higher to lower, hide something
|
|
765
830
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
766
831
|
levelShapes[String(i)]?.forEach((id) => {
|
|
767
|
-
if (!shapeMap[id]) return;
|
|
832
|
+
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
768
833
|
shapeMap[id].hide();
|
|
769
834
|
hiddenShape[id] = true;
|
|
770
835
|
});
|
|
@@ -813,8 +878,7 @@ export abstract class BaseNode {
|
|
|
813
878
|
const balanceRatio = 1 / zoom || 1;
|
|
814
879
|
this.zoomCache.balanceRatio = balanceRatio;
|
|
815
880
|
if (!labelShape || !labelShape.isVisible()) return;
|
|
816
|
-
const {
|
|
817
|
-
const { position = 'bottom' } = labelStyle;
|
|
881
|
+
const { position = 'bottom' } = this.mergedStyles.labelShape;
|
|
818
882
|
|
|
819
883
|
const keyShapeLocal = keyShape.getLocalBounds();
|
|
820
884
|
if (zoom < 1) {
|
|
@@ -856,21 +920,20 @@ export abstract class BaseNode {
|
|
|
856
920
|
const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
|
|
857
921
|
labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
|
|
858
922
|
this.scaleTransformCache = scaleTransform;
|
|
859
|
-
|
|
860
|
-
labelShape.style.wordWrapWidth = wordWrapWidth;
|
|
923
|
+
labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
|
|
861
924
|
|
|
862
925
|
if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
|
|
863
926
|
|
|
864
|
-
const
|
|
927
|
+
const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
|
|
928
|
+
.mergedStyles.labelBackgroundShape.padding as number[];
|
|
929
|
+
const sidePadding = paddingRight + paddingLeft;
|
|
865
930
|
const { width, height, x, y } = labelBackgroundShape.attributes;
|
|
866
|
-
const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
|
|
867
|
-
padding as number[];
|
|
868
931
|
|
|
869
932
|
switch (position) {
|
|
870
933
|
case 'top':
|
|
871
934
|
// if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
|
|
872
935
|
labelBackgroundShape.style.transformOrigin = `${
|
|
873
|
-
paddingLeft + (width -
|
|
936
|
+
paddingLeft + (width - sidePadding) / 2
|
|
874
937
|
} ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
|
|
875
938
|
break;
|
|
876
939
|
case 'left':
|
|
@@ -885,7 +948,7 @@ export abstract class BaseNode {
|
|
|
885
948
|
break;
|
|
886
949
|
case 'bottom':
|
|
887
950
|
labelBackgroundShape.style.transformOrigin = `${
|
|
888
|
-
paddingLeft + (width -
|
|
951
|
+
paddingLeft + (width - sidePadding) / 2
|
|
889
952
|
} ${
|
|
890
953
|
zoom < 1
|
|
891
954
|
? paddingTop + (height - paddingTop - paddingBottom) / 2
|
|
@@ -895,18 +958,26 @@ export abstract class BaseNode {
|
|
|
895
958
|
default:
|
|
896
959
|
// center
|
|
897
960
|
labelBackgroundShape.style.transformOrigin = `${
|
|
898
|
-
paddingLeft + (width -
|
|
961
|
+
paddingLeft + (width - sidePadding) / 2
|
|
899
962
|
} ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
|
|
900
963
|
}
|
|
901
964
|
|
|
902
965
|
const { labelShapeGeometry: labelBBox } = this.boundsCache;
|
|
903
966
|
const labelWidth = labelBBox.max[0] - labelBBox.min[0];
|
|
904
|
-
const xAxistRatio =
|
|
905
|
-
(labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
|
|
967
|
+
const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
|
|
906
968
|
|
|
907
969
|
labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
|
|
908
970
|
}
|
|
909
971
|
|
|
972
|
+
/**
|
|
973
|
+
* Create (if does not exit in shapeMap) or update the shape according to the configurations.
|
|
974
|
+
* @param type shape's type
|
|
975
|
+
* @param id unique string to indicates the shape
|
|
976
|
+
* @param style style to be updated
|
|
977
|
+
* @param shapeMap the shape map of a node / combo
|
|
978
|
+
* @param model data model of the node / combo
|
|
979
|
+
* @returns The display object representing the shape.
|
|
980
|
+
*/
|
|
910
981
|
public upsertShape(
|
|
911
982
|
type: SHAPE_TYPE | SHAPE_TYPE_3D,
|
|
912
983
|
id: string,
|
|
@@ -21,12 +21,20 @@ export abstract class BaseNode3D extends BaseNode {
|
|
|
21
21
|
themeStyles: NodeShapeStyles;
|
|
22
22
|
mergedStyles: NodeShapeStyles;
|
|
23
23
|
device: any; // for 3d renderer
|
|
24
|
+
dimensions: number = 3;
|
|
24
25
|
constructor(props) {
|
|
25
26
|
super(props);
|
|
26
27
|
this.device = props.device;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Draw the label shape of the 3D node
|
|
32
|
+
* @param model The displayed model of this 3D node, only for drawing and not received by users.
|
|
33
|
+
* @param shapeMap The shape map that contains all of the elements to show on the 3D node.
|
|
34
|
+
* @param diffData An object that contains previous and current data.
|
|
35
|
+
* @param diffState An object that contains previous and current 3D node's state.
|
|
36
|
+
* @returns The display object representing the label shape of the 3D node.
|
|
37
|
+
*/
|
|
30
38
|
public drawLabelShape(
|
|
31
39
|
model: NodeDisplayModel,
|
|
32
40
|
shapeMap: NodeShapeMap,
|
|
@@ -49,13 +57,6 @@ export abstract class BaseNode3D extends BaseNode {
|
|
|
49
57
|
...otherStyle
|
|
50
58
|
} = shapeStyle;
|
|
51
59
|
|
|
52
|
-
// TODO
|
|
53
|
-
// const wordWrapWidth = getWordWrapWidthByBox(
|
|
54
|
-
// keyShapeBox,
|
|
55
|
-
// maxWidth,
|
|
56
|
-
// this.zoomCache.zoom,
|
|
57
|
-
// );
|
|
58
|
-
|
|
59
60
|
const positionPreset = {
|
|
60
61
|
x: keyShapeBox.center[0],
|
|
61
62
|
y: keyShapeBox.max[1],
|
|
@@ -109,7 +110,14 @@ export abstract class BaseNode3D extends BaseNode {
|
|
|
109
110
|
return this.upsertShape('text', 'labelShape', style, shapeMap);
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Draw the icon shape of the 3D node
|
|
115
|
+
* @param model The displayed model of this 3D node, only for drawing and not received by users.
|
|
116
|
+
* @param shapeMap The shape map that contains all of the elements to show on the 3D node.
|
|
117
|
+
* @param diffData An object that contains previous and current data.
|
|
118
|
+
* @param diffState An object that contains previous and current 3D node's state.
|
|
119
|
+
* @returns The display object representing the icon shape of the 3D node.
|
|
120
|
+
*/
|
|
113
121
|
public drawIconShape(
|
|
114
122
|
model: NodeDisplayModel,
|
|
115
123
|
shapeMap: NodeShapeMap,
|
|
@@ -192,5 +200,12 @@ export abstract class BaseNode3D extends BaseNode {
|
|
|
192
200
|
return upsertShape3D(type, id, style as GShapeStyle, shapeMap, this.device);
|
|
193
201
|
}
|
|
194
202
|
|
|
203
|
+
/**
|
|
204
|
+
* The listener for graph zooming.
|
|
205
|
+
* 1. show / hide some shapes while zoom level changed;
|
|
206
|
+
* 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
|
|
207
|
+
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
208
|
+
* @param zoom The zoom level of the graph.
|
|
209
|
+
*/
|
|
195
210
|
public onZoom = (shapeMap: NodeShapeMap, zoom: number) => {};
|
|
196
211
|
}
|
|
@@ -9,13 +9,18 @@ import {
|
|
|
9
9
|
} from '../../../types/node';
|
|
10
10
|
import { BaseNode } from './base';
|
|
11
11
|
|
|
12
|
+
const offsetAngleMap = {
|
|
13
|
+
horizontal: 0,
|
|
14
|
+
vertical: Math.PI / 2,
|
|
15
|
+
};
|
|
16
|
+
|
|
12
17
|
export class HexagonNode extends BaseNode {
|
|
13
18
|
override defaultStyles = {
|
|
14
19
|
keyShape: {
|
|
15
|
-
r:
|
|
20
|
+
r: 16,
|
|
16
21
|
x: 0,
|
|
17
22
|
y: 0,
|
|
18
|
-
direction: '
|
|
23
|
+
direction: 'vertical',
|
|
19
24
|
},
|
|
20
25
|
};
|
|
21
26
|
mergedStyles: NodeShapeStyles;
|
|
@@ -119,9 +124,9 @@ export class HexagonNode extends BaseNode {
|
|
|
119
124
|
private getHexagonPoints(r: number, direction: string): [number, number][] {
|
|
120
125
|
const angleIncrement = Math.PI / 3; //The angle increment between vertex.
|
|
121
126
|
const v = [];
|
|
122
|
-
|
|
127
|
+
|
|
123
128
|
for (let i = 0; i < 6; i++) {
|
|
124
|
-
const angle = i * angleIncrement +
|
|
129
|
+
const angle = i * angleIncrement + offsetAngleMap[direction];
|
|
125
130
|
const vx = r * Math.cos(angle);
|
|
126
131
|
const vy = r * Math.sin(angle);
|
|
127
132
|
v.push([vx, vy]);
|
|
@@ -153,8 +158,7 @@ export class HexagonNode extends BaseNode {
|
|
|
153
158
|
? anchorPositionHorizontal
|
|
154
159
|
: anchorPositionVertical;
|
|
155
160
|
const angleIncrement = Math.PI / 3; //The angle increment between vertex.
|
|
156
|
-
const offsetAngle =
|
|
157
|
-
keyShapeStyle.direction === 'horizontal' ? 0 : Math.PI / 2;
|
|
161
|
+
const offsetAngle = offsetAngleMap[keyShapeStyle.direction];
|
|
158
162
|
const r = keyShapeStyle.r;
|
|
159
163
|
const anchorPositionMap = {};
|
|
160
164
|
for (let i = 0; i < 6; i++) {
|
|
@@ -163,6 +167,10 @@ export class HexagonNode extends BaseNode {
|
|
|
163
167
|
const vy = r * Math.sin(angle);
|
|
164
168
|
anchorPositionMap[anchorPositionDirection[i]] = [vx, vy];
|
|
165
169
|
}
|
|
170
|
+
if (!anchorPositionMap.hasOwnProperty('default')) {
|
|
171
|
+
anchorPositionMap['default'] =
|
|
172
|
+
anchorPositionMap[anchorPositionDirection[0]];
|
|
173
|
+
}
|
|
166
174
|
return anchorPositionMap;
|
|
167
175
|
}
|
|
168
176
|
}
|