@antv/g6 4.8.14 → 5.0.0-alpha.1
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 +19 -3
- package/esm/constant/index.d.ts +1 -0
- package/esm/constant/index.js +2 -0
- package/esm/constant/index.js.map +1 -0
- package/esm/constant/shape.d.ts +27 -0
- package/esm/constant/shape.js +26 -0
- package/esm/constant/shape.js.map +1 -0
- package/esm/index.d.ts +124 -0
- package/esm/index.js +11 -0
- package/esm/index.js.map +1 -0
- package/esm/item/combo.d.ts +4 -0
- package/esm/item/combo.js +4 -0
- package/esm/item/combo.js.map +1 -0
- package/esm/item/edge.d.ts +54 -0
- package/esm/item/edge.js +113 -0
- package/esm/item/edge.js.map +1 -0
- package/esm/item/item.d.ts +189 -0
- package/esm/item/item.js +636 -0
- package/esm/item/item.js.map +1 -0
- package/esm/item/node.d.ts +54 -0
- package/esm/item/node.js +170 -0
- package/esm/item/node.js.map +1 -0
- package/esm/runtime/controller/data.d.ts +65 -0
- package/esm/runtime/controller/data.js +489 -0
- package/esm/runtime/controller/data.js.map +1 -0
- package/esm/runtime/controller/extension.d.ts +9 -0
- package/esm/runtime/controller/extension.js +11 -0
- package/esm/runtime/controller/extension.js.map +1 -0
- package/esm/runtime/controller/index.d.ts +7 -0
- package/esm/runtime/controller/index.js +8 -0
- package/esm/runtime/controller/index.js.map +1 -0
- package/esm/runtime/controller/interaction.d.ts +51 -0
- package/esm/runtime/controller/interaction.js +259 -0
- package/esm/runtime/controller/interaction.js.map +1 -0
- package/esm/runtime/controller/item.d.ts +101 -0
- package/esm/runtime/controller/item.js +537 -0
- package/esm/runtime/controller/item.js.map +1 -0
- package/esm/runtime/controller/layout.d.ts +30 -0
- package/esm/runtime/controller/layout.js +204 -0
- package/esm/runtime/controller/layout.js.map +1 -0
- package/esm/runtime/controller/plugin.d.ts +34 -0
- package/esm/runtime/controller/plugin.js +140 -0
- package/esm/runtime/controller/plugin.js.map +1 -0
- package/esm/runtime/controller/theme.d.ts +29 -0
- package/esm/runtime/controller/theme.js +54 -0
- package/esm/runtime/controller/theme.js.map +1 -0
- package/esm/runtime/controller/viewport.d.ts +11 -0
- package/esm/runtime/controller/viewport.js +102 -0
- package/esm/runtime/controller/viewport.js.map +1 -0
- package/esm/runtime/graph.d.ts +462 -0
- package/esm/runtime/graph.js +1077 -0
- package/esm/runtime/graph.js.map +1 -0
- package/esm/runtime/hooks.d.ts +33 -0
- package/esm/runtime/hooks.js +74 -0
- package/esm/runtime/hooks.js.map +1 -0
- package/esm/stdlib/behavior/activate-relations.d.ts +62 -0
- package/esm/stdlib/behavior/activate-relations.js +81 -0
- package/esm/stdlib/behavior/activate-relations.js.map +1 -0
- package/esm/stdlib/behavior/brush-select.d.ts +110 -0
- package/esm/stdlib/behavior/brush-select.js +268 -0
- package/esm/stdlib/behavior/brush-select.js.map +1 -0
- package/esm/stdlib/behavior/click-select.d.ts +71 -0
- package/esm/stdlib/behavior/click-select.js +143 -0
- package/esm/stdlib/behavior/click-select.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +82 -0
- package/esm/stdlib/behavior/drag-canvas.js +246 -0
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +80 -0
- package/esm/stdlib/behavior/drag-node.js +250 -0
- package/esm/stdlib/behavior/drag-node.js.map +1 -0
- package/esm/stdlib/behavior/hover-activate.d.ts +41 -0
- package/esm/stdlib/behavior/hover-activate.js +63 -0
- package/esm/stdlib/behavior/hover-activate.js.map +1 -0
- package/esm/stdlib/behavior/lasso-select.d.ts +27 -0
- package/esm/stdlib/behavior/lasso-select.js +79 -0
- package/esm/stdlib/behavior/lasso-select.js.map +1 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +37 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.js +62 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +61 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.js +123 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/track-canvas-3d.d.ts +37 -0
- package/esm/stdlib/behavior/track-canvas-3d.js +62 -0
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +51 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js +74 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +61 -0
- package/esm/stdlib/behavior/zoom-canvas.js +160 -0
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -0
- package/esm/stdlib/data/comboFromNode.d.ts +9 -0
- package/esm/stdlib/data/comboFromNode.js +28 -0
- package/esm/stdlib/data/comboFromNode.js.map +1 -0
- package/esm/stdlib/index.d.ts +80 -0
- package/esm/stdlib/index.js +82 -0
- package/esm/stdlib/index.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +111 -0
- package/esm/stdlib/item/edge/base.js +341 -0
- package/esm/stdlib/item/edge/base.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +1 -0
- package/esm/stdlib/item/edge/index.js +2 -0
- package/esm/stdlib/item/edge/index.js.map +1 -0
- package/esm/stdlib/item/edge/line.d.ts +33 -0
- package/esm/stdlib/item/edge/line.js +45 -0
- package/esm/stdlib/item/edge/line.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +137 -0
- package/esm/stdlib/item/node/base.js +414 -0
- package/esm/stdlib/item/node/base.js.map +1 -0
- package/esm/stdlib/item/node/base3d.d.ts +72 -0
- package/esm/stdlib/item/node/base3d.js +113 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -0
- package/esm/stdlib/item/node/circle.d.ts +30 -0
- package/esm/stdlib/item/node/circle.js +56 -0
- package/esm/stdlib/item/node/circle.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +2 -0
- package/esm/stdlib/item/node/index.js +3 -0
- package/esm/stdlib/item/node/index.js.map +1 -0
- package/esm/stdlib/item/node/sphere.d.ts +33 -0
- package/esm/stdlib/item/node/sphere.js +52 -0
- package/esm/stdlib/item/node/sphere.js.map +1 -0
- package/esm/stdlib/plugin/legend/index.d.ts +121 -0
- package/esm/stdlib/plugin/legend/index.js +587 -0
- package/esm/stdlib/plugin/legend/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +106 -0
- package/esm/stdlib/plugin/minimap/index.js +578 -0
- package/esm/stdlib/plugin/minimap/index.js.map +1 -0
- package/esm/stdlib/selector/lasso.d.ts +15 -0
- package/esm/stdlib/selector/lasso.js +61 -0
- package/esm/stdlib/selector/lasso.js.map +1 -0
- package/esm/stdlib/selector/rect.d.ts +16 -0
- package/esm/stdlib/selector/rect.js +54 -0
- package/esm/stdlib/selector/rect.js.map +1 -0
- package/esm/stdlib/theme/dark.d.ts +3 -0
- package/esm/stdlib/theme/dark.js +279 -0
- package/esm/stdlib/theme/dark.js.map +1 -0
- package/esm/stdlib/theme/light.d.ts +3 -0
- package/esm/stdlib/theme/light.js +274 -0
- package/esm/stdlib/theme/light.js.map +1 -0
- package/esm/stdlib/themeSolver/base.d.ts +15 -0
- package/esm/stdlib/themeSolver/base.js +11 -0
- package/esm/stdlib/themeSolver/base.js.map +1 -0
- package/esm/stdlib/themeSolver/spec.d.ts +37 -0
- package/esm/stdlib/themeSolver/spec.js +66 -0
- package/esm/stdlib/themeSolver/spec.js.map +1 -0
- package/esm/stdlib/themeSolver/subject.d.ts +43 -0
- package/esm/stdlib/themeSolver/subject.js +396 -0
- package/esm/stdlib/themeSolver/subject.js.map +1 -0
- package/esm/types/animate.d.ts +59 -0
- package/esm/types/animate.js +2 -0
- package/esm/types/animate.js.map +1 -0
- package/esm/types/behavior.d.ts +45 -0
- package/esm/types/behavior.js +14 -0
- package/esm/types/behavior.js.map +1 -0
- package/esm/types/combo.d.ts +87 -0
- package/esm/types/combo.js +2 -0
- package/esm/types/combo.js.map +1 -0
- package/esm/types/common.d.ts +6 -0
- package/esm/types/common.js +2 -0
- package/esm/types/common.js.map +1 -0
- package/esm/types/data.d.ts +21 -0
- package/esm/types/data.js +2 -0
- package/esm/types/data.js.map +1 -0
- package/esm/types/edge.d.ts +100 -0
- package/esm/types/edge.js +2 -0
- package/esm/types/edge.js.map +1 -0
- package/esm/types/event.d.ts +30 -0
- package/esm/types/event.js +31 -0
- package/esm/types/event.js.map +1 -0
- package/esm/types/graph.d.ts +445 -0
- package/esm/types/graph.js +2 -0
- package/esm/types/graph.js.map +1 -0
- package/esm/types/hook.d.ts +97 -0
- package/esm/types/hook.js +2 -0
- package/esm/types/hook.js.map +1 -0
- package/esm/types/index.d.ts +10 -0
- package/esm/types/index.js +2 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/item.d.ts +229 -0
- package/esm/types/item.js +16 -0
- package/esm/types/item.js.map +1 -0
- package/esm/types/layout.d.ts +69 -0
- package/esm/types/layout.js +20 -0
- package/esm/types/layout.js.map +1 -0
- package/esm/types/node.d.ts +134 -0
- package/esm/types/node.js +2 -0
- package/esm/types/node.js.map +1 -0
- package/esm/types/plugin.d.ts +40 -0
- package/esm/types/plugin.js +53 -0
- package/esm/types/plugin.js.map +1 -0
- package/esm/types/render.d.ts +1 -0
- package/esm/types/render.js +2 -0
- package/esm/types/render.js.map +1 -0
- package/esm/types/spec.d.ts +65 -0
- package/esm/types/spec.js +2 -0
- package/esm/types/spec.js.map +1 -0
- package/esm/types/stdlib.d.ts +13 -0
- package/esm/types/stdlib.js +2 -0
- package/esm/types/stdlib.js.map +1 -0
- package/esm/types/theme.d.ts +102 -0
- package/esm/types/theme.js +15 -0
- package/esm/types/theme.js.map +1 -0
- package/esm/types/view.d.ts +23 -0
- package/esm/types/view.js +2 -0
- package/esm/types/view.js.map +1 -0
- package/esm/util/animate.d.ts +101 -0
- package/esm/util/animate.js +350 -0
- package/esm/util/animate.js.map +1 -0
- package/esm/util/array.d.ts +20 -0
- package/esm/util/array.js +60 -0
- package/esm/util/array.js.map +1 -0
- package/esm/util/canvas.d.ts +20 -0
- package/esm/util/canvas.js +81 -0
- package/esm/util/canvas.js.map +1 -0
- package/esm/util/event.d.ts +12 -0
- package/esm/util/event.js +26 -0
- package/esm/util/event.js.map +1 -0
- package/esm/util/extend.d.ts +21 -0
- package/esm/util/extend.js +22 -0
- package/esm/util/extend.js.map +1 -0
- package/esm/util/extension.d.ts +10 -0
- package/esm/util/extension.js +24 -0
- package/esm/util/extension.js.map +1 -0
- package/esm/util/index.d.ts +14 -0
- package/esm/util/index.js +5 -0
- package/esm/util/index.js.map +1 -0
- package/esm/util/item.d.ts +14 -0
- package/esm/util/item.js +42 -0
- package/esm/util/item.js.map +1 -0
- package/esm/util/mapper.d.ts +17 -0
- package/esm/util/mapper.js +60 -0
- package/esm/util/mapper.js.map +1 -0
- package/esm/util/math.d.ts +8 -0
- package/esm/util/math.js +9 -0
- package/esm/util/math.js.map +1 -0
- package/esm/util/point.d.ts +61 -0
- package/esm/util/point.js +160 -0
- package/esm/util/point.js.map +1 -0
- package/esm/util/shape.d.ts +105 -0
- package/esm/util/shape.js +504 -0
- package/esm/util/shape.js.map +1 -0
- package/esm/util/shape3d.d.ts +23 -0
- package/esm/util/shape3d.js +147 -0
- package/esm/util/shape3d.js.map +1 -0
- package/esm/util/text.d.ts +18 -0
- package/esm/util/text.js +36 -0
- package/esm/util/text.js.map +1 -0
- package/esm/util/type.d.ts +2 -0
- package/esm/util/type.js +2 -0
- package/esm/util/type.js.map +1 -0
- package/esm/util/zoom.d.ts +17 -0
- package/esm/util/zoom.js +36 -0
- package/esm/util/zoom.js.map +1 -0
- package/lib/constant/index.d.ts +1 -0
- package/lib/constant/index.js +18 -0
- package/lib/constant/index.js.map +1 -0
- package/lib/constant/shape.d.ts +27 -0
- package/lib/constant/shape.js +29 -0
- package/lib/constant/shape.js.map +1 -0
- package/lib/index.d.ts +124 -4
- package/lib/index.js +30 -27
- package/lib/index.js.map +1 -0
- package/lib/item/combo.d.ts +4 -0
- package/lib/item/combo.js +10 -0
- package/lib/item/combo.js.map +1 -0
- package/lib/item/edge.d.ts +54 -0
- package/lib/item/edge.js +119 -0
- package/lib/item/edge.js.map +1 -0
- package/lib/item/item.d.ts +189 -0
- package/lib/item/item.js +639 -0
- package/lib/item/item.js.map +1 -0
- package/lib/item/node.d.ts +54 -0
- package/lib/item/node.js +176 -0
- package/lib/item/node.js.map +1 -0
- package/lib/runtime/controller/data.d.ts +65 -0
- package/lib/runtime/controller/data.js +493 -0
- package/lib/runtime/controller/data.js.map +1 -0
- package/lib/runtime/controller/extension.d.ts +9 -0
- package/lib/runtime/controller/extension.js +15 -0
- package/lib/runtime/controller/extension.js.map +1 -0
- package/lib/runtime/controller/index.d.ts +7 -0
- package/lib/runtime/controller/index.js +24 -0
- package/lib/runtime/controller/index.js.map +1 -0
- package/lib/runtime/controller/interaction.d.ts +51 -0
- package/lib/runtime/controller/interaction.js +263 -0
- package/lib/runtime/controller/interaction.js.map +1 -0
- package/lib/runtime/controller/item.d.ts +101 -0
- package/lib/runtime/controller/item.js +544 -0
- package/lib/runtime/controller/item.js.map +1 -0
- package/lib/runtime/controller/layout.d.ts +30 -0
- package/lib/runtime/controller/layout.js +208 -0
- package/lib/runtime/controller/layout.js.map +1 -0
- package/lib/runtime/controller/plugin.d.ts +34 -0
- package/lib/runtime/controller/plugin.js +147 -0
- package/lib/runtime/controller/plugin.js.map +1 -0
- package/lib/runtime/controller/theme.d.ts +29 -0
- package/lib/runtime/controller/theme.js +61 -0
- package/lib/runtime/controller/theme.js.map +1 -0
- package/lib/runtime/controller/viewport.d.ts +11 -0
- package/lib/runtime/controller/viewport.js +106 -0
- package/lib/runtime/controller/viewport.js.map +1 -0
- package/lib/runtime/graph.d.ts +462 -0
- package/lib/runtime/graph.js +1083 -0
- package/lib/runtime/graph.js.map +1 -0
- package/lib/runtime/hooks.d.ts +33 -0
- package/lib/runtime/hooks.js +77 -0
- package/lib/runtime/hooks.js.map +1 -0
- package/lib/stdlib/behavior/activate-relations.d.ts +62 -0
- package/lib/stdlib/behavior/activate-relations.js +84 -0
- package/lib/stdlib/behavior/activate-relations.js.map +1 -0
- package/lib/stdlib/behavior/brush-select.d.ts +110 -0
- package/lib/stdlib/behavior/brush-select.js +271 -0
- package/lib/stdlib/behavior/brush-select.js.map +1 -0
- package/lib/stdlib/behavior/click-select.d.ts +71 -0
- package/lib/stdlib/behavior/click-select.js +146 -0
- package/lib/stdlib/behavior/click-select.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +82 -0
- package/lib/stdlib/behavior/drag-canvas.js +249 -0
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +80 -0
- package/lib/stdlib/behavior/drag-node.js +253 -0
- package/lib/stdlib/behavior/drag-node.js.map +1 -0
- package/lib/stdlib/behavior/hover-activate.d.ts +41 -0
- package/lib/stdlib/behavior/hover-activate.js +67 -0
- package/lib/stdlib/behavior/hover-activate.js.map +1 -0
- package/lib/stdlib/behavior/lasso-select.d.ts +27 -0
- package/lib/stdlib/behavior/lasso-select.js +85 -0
- package/lib/stdlib/behavior/lasso-select.js.map +1 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +37 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.js +68 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +61 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.js +126 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/track-canvas-3d.d.ts +37 -0
- package/lib/stdlib/behavior/track-canvas-3d.js +68 -0
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +51 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js +77 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +61 -0
- package/lib/stdlib/behavior/zoom-canvas.js +163 -0
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -0
- package/lib/stdlib/data/comboFromNode.d.ts +9 -0
- package/lib/stdlib/data/comboFromNode.js +32 -0
- package/lib/stdlib/data/comboFromNode.js.map +1 -0
- package/lib/stdlib/index.d.ts +80 -0
- package/lib/stdlib/index.js +90 -0
- package/lib/stdlib/index.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +111 -0
- package/lib/stdlib/item/edge/base.js +345 -0
- package/lib/stdlib/item/edge/base.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +1 -0
- package/lib/stdlib/item/edge/index.js +18 -0
- package/lib/stdlib/item/edge/index.js.map +1 -0
- package/lib/stdlib/item/edge/line.d.ts +33 -0
- package/lib/stdlib/item/edge/line.js +49 -0
- package/lib/stdlib/item/edge/line.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +137 -0
- package/lib/stdlib/item/node/base.js +418 -0
- package/lib/stdlib/item/node/base.js.map +1 -0
- package/lib/stdlib/item/node/base3d.d.ts +72 -0
- package/lib/stdlib/item/node/base3d.js +117 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -0
- package/lib/stdlib/item/node/circle.d.ts +30 -0
- package/lib/stdlib/item/node/circle.js +60 -0
- package/lib/stdlib/item/node/circle.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +2 -0
- package/lib/stdlib/item/node/index.js +19 -0
- package/lib/stdlib/item/node/index.js.map +1 -0
- package/lib/stdlib/item/node/sphere.d.ts +33 -0
- package/lib/stdlib/item/node/sphere.js +56 -0
- package/lib/stdlib/item/node/sphere.js.map +1 -0
- package/lib/stdlib/plugin/legend/index.d.ts +121 -0
- package/lib/stdlib/plugin/legend/index.js +590 -0
- package/lib/stdlib/plugin/legend/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +106 -0
- package/lib/stdlib/plugin/minimap/index.js +581 -0
- package/lib/stdlib/plugin/minimap/index.js.map +1 -0
- package/lib/stdlib/selector/lasso.d.ts +15 -0
- package/lib/stdlib/selector/lasso.js +63 -0
- package/lib/stdlib/selector/lasso.js.map +1 -0
- package/lib/stdlib/selector/rect.d.ts +16 -0
- package/lib/stdlib/selector/rect.js +56 -0
- package/lib/stdlib/selector/rect.js.map +1 -0
- package/lib/stdlib/theme/dark.d.ts +3 -0
- package/lib/stdlib/theme/dark.js +281 -0
- package/lib/stdlib/theme/dark.js.map +1 -0
- package/lib/stdlib/theme/light.d.ts +3 -0
- package/lib/stdlib/theme/light.js +276 -0
- package/lib/stdlib/theme/light.js.map +1 -0
- package/lib/stdlib/themeSolver/base.d.ts +15 -0
- package/lib/stdlib/themeSolver/base.js +14 -0
- package/lib/stdlib/themeSolver/base.js.map +1 -0
- package/lib/stdlib/themeSolver/spec.d.ts +37 -0
- package/lib/stdlib/themeSolver/spec.js +72 -0
- package/lib/stdlib/themeSolver/spec.js.map +1 -0
- package/lib/stdlib/themeSolver/subject.d.ts +43 -0
- package/lib/stdlib/themeSolver/subject.js +404 -0
- package/lib/stdlib/themeSolver/subject.js.map +1 -0
- package/lib/types/animate.d.ts +59 -0
- package/lib/types/animate.js +3 -0
- package/lib/types/animate.js.map +1 -0
- package/lib/types/behavior.d.ts +45 -0
- package/lib/types/behavior.js +18 -0
- package/lib/types/behavior.js.map +1 -0
- package/lib/types/combo.d.ts +87 -0
- package/lib/types/combo.js +3 -0
- package/lib/types/combo.js.map +1 -0
- package/lib/types/common.d.ts +6 -0
- package/lib/types/common.js +3 -0
- package/lib/types/common.js.map +1 -0
- package/lib/types/data.d.ts +21 -0
- package/lib/types/data.js +3 -0
- package/lib/types/data.js.map +1 -0
- package/lib/types/edge.d.ts +100 -0
- package/lib/types/edge.js +3 -0
- package/lib/types/edge.js.map +1 -0
- package/lib/types/event.d.ts +30 -0
- package/lib/types/event.js +34 -0
- package/lib/types/event.js.map +1 -0
- package/lib/types/graph.d.ts +445 -0
- package/lib/types/graph.js +3 -0
- package/lib/types/graph.js.map +1 -0
- package/lib/types/hook.d.ts +97 -0
- package/lib/types/hook.js +3 -0
- package/lib/types/hook.js.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +7 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/item.d.ts +229 -0
- package/lib/types/item.js +19 -0
- package/lib/types/item.js.map +1 -0
- package/lib/types/layout.d.ts +69 -0
- package/lib/types/layout.js +25 -0
- package/lib/types/layout.js.map +1 -0
- package/lib/types/node.d.ts +134 -0
- package/lib/types/node.js +3 -0
- package/lib/types/node.js.map +1 -0
- package/lib/types/plugin.d.ts +40 -0
- package/lib/types/plugin.js +57 -0
- package/lib/types/plugin.js.map +1 -0
- package/lib/types/render.d.ts +1 -0
- package/lib/types/render.js +3 -0
- package/lib/types/render.js.map +1 -0
- package/lib/types/spec.d.ts +65 -0
- package/lib/types/spec.js +3 -0
- package/lib/types/spec.js.map +1 -0
- package/lib/types/stdlib.d.ts +13 -0
- package/lib/types/stdlib.js +3 -0
- package/lib/types/stdlib.js.map +1 -0
- package/lib/types/theme.d.ts +102 -0
- package/lib/types/theme.js +19 -0
- package/lib/types/theme.js.map +1 -0
- package/lib/types/view.d.ts +23 -0
- package/lib/types/view.js +3 -0
- package/lib/types/view.js.map +1 -0
- package/lib/util/animate.d.ts +101 -0
- package/lib/util/animate.js +358 -0
- package/lib/util/animate.js.map +1 -0
- package/lib/util/array.d.ts +20 -0
- package/lib/util/array.js +68 -0
- package/lib/util/array.js.map +1 -0
- package/lib/util/canvas.d.ts +20 -0
- package/lib/util/canvas.js +86 -0
- package/lib/util/canvas.js.map +1 -0
- package/lib/util/event.d.ts +12 -0
- package/lib/util/event.js +30 -0
- package/lib/util/event.js.map +1 -0
- package/lib/util/extend.d.ts +21 -0
- package/lib/util/extend.js +29 -0
- package/lib/util/extend.js.map +1 -0
- package/lib/util/extension.d.ts +10 -0
- package/lib/util/extension.js +29 -0
- package/lib/util/extension.js.map +1 -0
- package/lib/util/index.d.ts +14 -0
- package/lib/util/index.js +7 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/item.d.ts +14 -0
- package/lib/util/item.js +47 -0
- package/lib/util/item.js.map +1 -0
- package/lib/util/mapper.d.ts +17 -0
- package/lib/util/mapper.js +63 -0
- package/lib/util/mapper.js.map +1 -0
- package/lib/util/math.d.ts +8 -0
- package/lib/util/math.js +13 -0
- package/lib/util/math.js.map +1 -0
- package/lib/util/point.d.ts +61 -0
- package/lib/util/point.js +169 -0
- package/lib/util/point.js.map +1 -0
- package/lib/util/shape.d.ts +105 -0
- package/lib/util/shape.js +519 -0
- package/lib/util/shape.js.map +1 -0
- package/lib/util/shape3d.d.ts +23 -0
- package/lib/util/shape3d.js +153 -0
- package/lib/util/shape3d.js.map +1 -0
- package/lib/util/text.d.ts +18 -0
- package/lib/util/text.js +41 -0
- package/lib/util/text.js.map +1 -0
- package/lib/util/type.d.ts +2 -0
- package/lib/util/type.js +6 -0
- package/lib/util/type.js.map +1 -0
- package/lib/util/zoom.d.ts +17 -0
- package/lib/util/zoom.js +41 -0
- package/lib/util/zoom.js.map +1 -0
- package/package.json +82 -50
- package/src/constant/index.ts +1 -0
- package/src/constant/shape.ts +33 -0
- package/src/index.ts +13 -0
- package/src/item/combo.ts +5 -0
- package/src/item/edge.ts +177 -0
- package/src/item/item.ts +812 -0
- package/src/item/node.ts +275 -0
- package/src/runtime/controller/data.ts +575 -0
- package/src/runtime/controller/extension.ts +14 -0
- package/src/runtime/controller/index.ts +7 -0
- package/src/runtime/controller/interaction.ts +343 -0
- package/src/runtime/controller/item.ts +780 -0
- package/src/runtime/controller/layout.ts +251 -0
- package/src/runtime/controller/plugin.ts +171 -0
- package/src/runtime/controller/theme.ts +69 -0
- package/src/runtime/controller/viewport.ts +131 -0
- package/src/runtime/graph.ts +1439 -0
- package/src/runtime/hooks.ts +64 -0
- package/src/stdlib/behavior/activate-relations.ts +139 -0
- package/src/stdlib/behavior/brush-select.ts +386 -0
- package/src/stdlib/behavior/click-select.ts +201 -0
- package/src/stdlib/behavior/drag-canvas.ts +333 -0
- package/src/stdlib/behavior/drag-node.ts +402 -0
- package/src/stdlib/behavior/hover-activate.ts +106 -0
- package/src/stdlib/behavior/lasso-select.ts +94 -0
- package/src/stdlib/behavior/orbit-canvas-3d.ts +104 -0
- package/src/stdlib/behavior/rotate-canvas-3d.ts +172 -0
- package/src/stdlib/behavior/track-canvas-3d.ts +104 -0
- package/src/stdlib/behavior/zoom-canvas-3d.ts +127 -0
- package/src/stdlib/behavior/zoom-canvas.ts +244 -0
- package/src/stdlib/data/comboFromNode.ts +28 -0
- package/src/stdlib/index.ts +87 -0
- package/src/stdlib/item/edge/base.ts +571 -0
- package/src/stdlib/item/edge/index.ts +1 -0
- package/src/stdlib/item/edge/line.ts +98 -0
- package/src/stdlib/item/node/base.ts +726 -0
- package/src/stdlib/item/node/base3d.ts +192 -0
- package/src/stdlib/item/node/circle.ts +113 -0
- package/src/stdlib/item/node/index.ts +2 -0
- package/src/stdlib/item/node/sphere.ts +99 -0
- package/src/stdlib/plugin/legend/index.ts +733 -0
- package/src/stdlib/plugin/minimap/index.ts +689 -0
- package/src/stdlib/selector/lasso.ts +75 -0
- package/src/stdlib/selector/rect.ts +78 -0
- package/src/stdlib/theme/dark.ts +340 -0
- package/src/stdlib/theme/light.ts +333 -0
- package/src/stdlib/themeSolver/base.ts +22 -0
- package/src/stdlib/themeSolver/spec.ts +110 -0
- package/src/stdlib/themeSolver/subject.ts +502 -0
- package/src/types/animate.ts +71 -0
- package/src/types/behavior.ts +49 -0
- package/src/types/combo.ts +120 -0
- package/src/types/common.ts +7 -0
- package/src/types/data.ts +35 -0
- package/src/types/edge.ts +119 -0
- package/src/types/event.ts +47 -0
- package/src/types/graph.ts +573 -0
- package/src/types/hook.ts +98 -0
- package/src/types/index.ts +29 -0
- package/src/types/item.ts +324 -0
- package/src/types/layout.ts +138 -0
- package/src/types/node.ts +162 -0
- package/src/types/plugin.ts +77 -0
- package/src/types/render.ts +1 -0
- package/src/types/spec.ts +116 -0
- package/src/types/stdlib.ts +25 -0
- package/src/types/theme.ts +101 -0
- package/src/types/view.ts +31 -0
- package/src/util/animate.ts +430 -0
- package/src/util/array.ts +57 -0
- package/src/util/canvas.ts +95 -0
- package/src/util/event.ts +34 -0
- package/src/util/extend.ts +42 -0
- package/src/util/extension.ts +29 -0
- package/src/util/index.ts +4 -0
- package/src/util/item.ts +70 -0
- package/src/util/mapper.ts +61 -0
- package/src/util/math.ts +9 -0
- package/src/util/point.ts +195 -0
- package/src/util/shape.ts +609 -0
- package/src/util/shape3d.ts +198 -0
- package/src/util/text.ts +49 -0
- package/src/util/type.ts +4 -0
- package/src/util/zoom.ts +39 -0
- package/README.en-US.md +0 -170
- package/README.md +0 -177
- package/dist/g6.min.js.map +0 -1
- package/es/index.d.ts +0 -4
- package/es/index.js +0 -5
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { registry as layoutRegistry } from '@antv/layout';
|
|
2
|
+
import { Lib } from '../types/stdlib';
|
|
3
|
+
import ActivateRelations from './behavior/activate-relations';
|
|
4
|
+
import BrushSelect from './behavior/brush-select';
|
|
5
|
+
import ClickSelect from './behavior/click-select';
|
|
6
|
+
import DragCanvas from './behavior/drag-canvas';
|
|
7
|
+
import LassoSelect from './behavior/lasso-select';
|
|
8
|
+
import DragNode from './behavior/drag-node';
|
|
9
|
+
import { comboFromNode } from './data/comboFromNode';
|
|
10
|
+
import { LineEdge } from './item/edge';
|
|
11
|
+
import { CircleNode, SphereNode } from './item/node';
|
|
12
|
+
import DarkTheme from './theme/dark';
|
|
13
|
+
import LightTheme from './theme/light';
|
|
14
|
+
import SpecThemeSolver from './themeSolver/spec';
|
|
15
|
+
import SubjectThemeSolver from './themeSolver/subject';
|
|
16
|
+
|
|
17
|
+
import lassoSelector from './selector/lasso';
|
|
18
|
+
import rectSelector from './selector/rect';
|
|
19
|
+
import Minimap from './plugin/minimap';
|
|
20
|
+
import Legend from './plugin/legend';
|
|
21
|
+
import ZoomCanvas from './behavior/zoom-canvas';
|
|
22
|
+
import ZoomCanvas3D from './behavior/zoom-canvas-3d';
|
|
23
|
+
import RotateCanvas3D from './behavior/rotate-canvas-3d';
|
|
24
|
+
import TrackCanvas3D from './behavior/track-canvas-3d';
|
|
25
|
+
import OrbitCanvas3D from './behavior/orbit-canvas-3d';
|
|
26
|
+
import { HoverActivate } from './behavior/hover-activate';
|
|
27
|
+
|
|
28
|
+
const stdLib = {
|
|
29
|
+
transforms: {
|
|
30
|
+
comboFromNode,
|
|
31
|
+
},
|
|
32
|
+
themes: {
|
|
33
|
+
light: LightTheme,
|
|
34
|
+
dark: DarkTheme,
|
|
35
|
+
},
|
|
36
|
+
themeSolvers: {
|
|
37
|
+
spec: SpecThemeSolver,
|
|
38
|
+
subject: SubjectThemeSolver,
|
|
39
|
+
},
|
|
40
|
+
layouts: layoutRegistry,
|
|
41
|
+
behaviors: {
|
|
42
|
+
'activate-relations': ActivateRelations,
|
|
43
|
+
'drag-canvas': DragCanvas,
|
|
44
|
+
'hover-activate': HoverActivate,
|
|
45
|
+
'zoom-canvas': ZoomCanvas,
|
|
46
|
+
'drag-node': DragNode,
|
|
47
|
+
'click-select': ClickSelect,
|
|
48
|
+
'brush-select': BrushSelect,
|
|
49
|
+
'lasso-select': LassoSelect,
|
|
50
|
+
'zoom-canvas-3d': ZoomCanvas3D,
|
|
51
|
+
'rotate-canvas-3d': RotateCanvas3D,
|
|
52
|
+
'track-canvas-3d': TrackCanvas3D,
|
|
53
|
+
'orbit-canvas-3d': OrbitCanvas3D,
|
|
54
|
+
},
|
|
55
|
+
plugins: {
|
|
56
|
+
minimap: Minimap,
|
|
57
|
+
legend: Legend,
|
|
58
|
+
},
|
|
59
|
+
nodes: {
|
|
60
|
+
'circle-node': CircleNode,
|
|
61
|
+
'sphere-node': SphereNode,
|
|
62
|
+
},
|
|
63
|
+
edges: {
|
|
64
|
+
'line-edge': LineEdge,
|
|
65
|
+
},
|
|
66
|
+
combos: {},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const useLib: Lib = {
|
|
70
|
+
transforms: {},
|
|
71
|
+
themes: {},
|
|
72
|
+
layouts: {},
|
|
73
|
+
behaviors: {},
|
|
74
|
+
plugins: {},
|
|
75
|
+
nodes: {},
|
|
76
|
+
edges: {},
|
|
77
|
+
combos: {},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const utils = {
|
|
81
|
+
rectSelector,
|
|
82
|
+
lassoSelector,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const registery = { useLib };
|
|
86
|
+
export default registery;
|
|
87
|
+
export { stdLib, registery, utils };
|
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import { AABB, DisplayObject, Line, Polyline } from '@antv/g';
|
|
2
|
+
import { isNumber } from '@antv/util';
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_LABEL_BG_PADDING,
|
|
5
|
+
OTHER_SHAPES_FIELD_NAME,
|
|
6
|
+
RESERVED_SHAPE_IDS,
|
|
7
|
+
} from '../../../constant';
|
|
8
|
+
import { Point } from '../../../types/common';
|
|
9
|
+
import {
|
|
10
|
+
EdgeDisplayModel,
|
|
11
|
+
EdgeModelData,
|
|
12
|
+
EdgeShapeMap,
|
|
13
|
+
EdgeShapeStyles,
|
|
14
|
+
} from '../../../types/edge';
|
|
15
|
+
import {
|
|
16
|
+
GShapeStyle,
|
|
17
|
+
SHAPE_TYPE,
|
|
18
|
+
ShapeStyle,
|
|
19
|
+
State,
|
|
20
|
+
lodStrategyObj,
|
|
21
|
+
} from '../../../types/item';
|
|
22
|
+
import {
|
|
23
|
+
LOCAL_BOUNDS_DIRTY_FLAG_KEY,
|
|
24
|
+
formatPadding,
|
|
25
|
+
mergeStyles,
|
|
26
|
+
upsertShape,
|
|
27
|
+
} from '../../../util/shape';
|
|
28
|
+
import { DEFAULT_ANIMATE_CFG, fadeIn, fadeOut } from '../../../util/animate';
|
|
29
|
+
import { getWordWrapWidthByEnds } from '../../../util/text';
|
|
30
|
+
import { AnimateCfg } from '../../../types/animate';
|
|
31
|
+
import { getZoomLevel } from '../../../util/zoom';
|
|
32
|
+
|
|
33
|
+
export abstract class BaseEdge {
|
|
34
|
+
type: string;
|
|
35
|
+
defaultStyles: EdgeShapeStyles = {};
|
|
36
|
+
themeStyles: EdgeShapeStyles;
|
|
37
|
+
mergedStyles: EdgeShapeStyles;
|
|
38
|
+
sourcePoint: Point;
|
|
39
|
+
targetPoint: Point;
|
|
40
|
+
lodStrategy?: lodStrategyObj;
|
|
41
|
+
labelPosition: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
transform: string;
|
|
45
|
+
isRevert: boolean;
|
|
46
|
+
};
|
|
47
|
+
boundsCache: {
|
|
48
|
+
labelShapeGeometry?: AABB;
|
|
49
|
+
labelBackgroundShapeGeometry?: AABB;
|
|
50
|
+
labelShapeTransform?: string;
|
|
51
|
+
labelBackgroundShapeTransform?: string;
|
|
52
|
+
};
|
|
53
|
+
// cache the zoom level infomations
|
|
54
|
+
private zoomCache: {
|
|
55
|
+
// the id of shapes which are hidden by zoom changing.
|
|
56
|
+
hiddenShape: { [shapeId: string]: boolean };
|
|
57
|
+
// the ratio to scale the size of shapes whose visual size should be kept, e.g. label and badges.
|
|
58
|
+
balanceRatio: number;
|
|
59
|
+
// last responsed zoom ratio.
|
|
60
|
+
zoom: number;
|
|
61
|
+
// last responsed zoom level where the zoom ratio at. Zoom ratio 1 at level 0.
|
|
62
|
+
zoomLevel: number;
|
|
63
|
+
// shape ids in different zoom levels.
|
|
64
|
+
levelShapes: {
|
|
65
|
+
[level: string]: string[];
|
|
66
|
+
};
|
|
67
|
+
// wordWrapWidth of labelShape according to the maxWidth
|
|
68
|
+
wordWrapWidth: number;
|
|
69
|
+
// animate configurations for zoom level changing
|
|
70
|
+
animateConfig: AnimateCfg;
|
|
71
|
+
// the tag of first rendering
|
|
72
|
+
firstRender: boolean;
|
|
73
|
+
} = {
|
|
74
|
+
hiddenShape: {},
|
|
75
|
+
balanceRatio: 1,
|
|
76
|
+
zoom: 1,
|
|
77
|
+
zoomLevel: 0,
|
|
78
|
+
levelShapes: {},
|
|
79
|
+
wordWrapWidth: 50,
|
|
80
|
+
animateConfig: DEFAULT_ANIMATE_CFG.zoom,
|
|
81
|
+
firstRender: true,
|
|
82
|
+
};
|
|
83
|
+
constructor(props) {
|
|
84
|
+
const { themeStyles, lodStrategy, zoom } = props;
|
|
85
|
+
if (themeStyles) this.themeStyles = themeStyles;
|
|
86
|
+
this.lodStrategy = lodStrategy;
|
|
87
|
+
this.boundsCache = {};
|
|
88
|
+
this.zoomCache.zoom = zoom;
|
|
89
|
+
this.zoomCache.balanceRatio = 1 / zoom;
|
|
90
|
+
this.zoomCache.animateConfig = {
|
|
91
|
+
...DEFAULT_ANIMATE_CFG.zoom,
|
|
92
|
+
...lodStrategy?.animateCfg,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
public mergeStyles(model: EdgeDisplayModel) {
|
|
96
|
+
this.mergedStyles = this.getMergedStyles(model);
|
|
97
|
+
}
|
|
98
|
+
public getMergedStyles(model: EdgeDisplayModel) {
|
|
99
|
+
const { data } = model;
|
|
100
|
+
const dataStyles = {} as EdgeShapeStyles;
|
|
101
|
+
Object.keys(data).forEach((fieldName) => {
|
|
102
|
+
if (RESERVED_SHAPE_IDS.includes(fieldName))
|
|
103
|
+
dataStyles[fieldName] = data[fieldName] as ShapeStyle;
|
|
104
|
+
else if (fieldName === OTHER_SHAPES_FIELD_NAME) {
|
|
105
|
+
Object.keys(data[fieldName]).forEach(
|
|
106
|
+
(otherShapeId) =>
|
|
107
|
+
(dataStyles[otherShapeId] = data[fieldName][otherShapeId]),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
const merged = mergeStyles([
|
|
112
|
+
this.themeStyles,
|
|
113
|
+
this.defaultStyles,
|
|
114
|
+
dataStyles,
|
|
115
|
+
]) as EdgeShapeStyles;
|
|
116
|
+
|
|
117
|
+
const padding = merged.labelBackgroundShape?.padding;
|
|
118
|
+
if (padding) {
|
|
119
|
+
merged.labelBackgroundShape.padding = formatPadding(
|
|
120
|
+
padding,
|
|
121
|
+
DEFAULT_LABEL_BG_PADDING,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return merged;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Call it after calling draw function to update cache about bounds and zoom levels.
|
|
129
|
+
*/
|
|
130
|
+
public updateCache(shapeMap) {
|
|
131
|
+
['labelShape', 'labelBackgroundShape'].forEach((id) => {
|
|
132
|
+
const shape = shapeMap[id];
|
|
133
|
+
if (shape?.getAttribute(LOCAL_BOUNDS_DIRTY_FLAG_KEY)) {
|
|
134
|
+
this.boundsCache[`${id}Geometry`] = shape.getGeometryBounds();
|
|
135
|
+
this.boundsCache[`${id}Transform`] = shape.style.transform;
|
|
136
|
+
shape.setAttribute(LOCAL_BOUNDS_DIRTY_FLAG_KEY, false);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const { levelShapes, zoom } = this.zoomCache;
|
|
141
|
+
Object.keys(shapeMap).forEach((shapeId) => {
|
|
142
|
+
const { lod } = shapeMap[shapeId].attributes;
|
|
143
|
+
if (lod !== undefined) {
|
|
144
|
+
levelShapes[lod] = levelShapes[lod] || [];
|
|
145
|
+
levelShapes[lod].push(shapeId);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const { maxWidth = '60%' } = this.mergedStyles.labelShape || {};
|
|
150
|
+
this.zoomCache.wordWrapWidth = getWordWrapWidthByEnds(
|
|
151
|
+
[this.sourcePoint, this.targetPoint],
|
|
152
|
+
maxWidth,
|
|
153
|
+
1,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
this.zoomCache.zoom = 1;
|
|
157
|
+
this.zoomCache.zoomLevel = 0;
|
|
158
|
+
if (zoom !== 1) this.onZoom(shapeMap, zoom);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
abstract draw(
|
|
162
|
+
model: EdgeDisplayModel,
|
|
163
|
+
sourcePoint: Point,
|
|
164
|
+
targetPoint: Point,
|
|
165
|
+
shapeMap: { [shapeId: string]: DisplayObject },
|
|
166
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
167
|
+
diffState?: { previous: State[]; current: State[] },
|
|
168
|
+
): {
|
|
169
|
+
keyShape: DisplayObject;
|
|
170
|
+
labelShape?: DisplayObject;
|
|
171
|
+
iconShape?: DisplayObject;
|
|
172
|
+
[otherShapeId: string]: DisplayObject;
|
|
173
|
+
};
|
|
174
|
+
public afterDraw(
|
|
175
|
+
model: EdgeDisplayModel,
|
|
176
|
+
shapeMap: { [shapeId: string]: DisplayObject },
|
|
177
|
+
shapesChanged?: string[],
|
|
178
|
+
): { [otherShapeId: string]: DisplayObject } {
|
|
179
|
+
return {};
|
|
180
|
+
}
|
|
181
|
+
// shouldUpdate: (model: EdgeDisplayModel, prevModel: EdgeDisplayModel) => boolean = () => true;
|
|
182
|
+
public setState: (
|
|
183
|
+
name: string,
|
|
184
|
+
value: boolean,
|
|
185
|
+
shapeMap: { [shapeId: string]: DisplayObject },
|
|
186
|
+
) => void;
|
|
187
|
+
|
|
188
|
+
public drawLabelShape(
|
|
189
|
+
model: EdgeDisplayModel,
|
|
190
|
+
shapeMap: EdgeShapeMap,
|
|
191
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
192
|
+
diffState?: { previous: State[]; current: State[] },
|
|
193
|
+
): DisplayObject {
|
|
194
|
+
const { keyShape } = shapeMap;
|
|
195
|
+
|
|
196
|
+
const { labelShape: shapeStyle } = this.mergedStyles;
|
|
197
|
+
const {
|
|
198
|
+
position,
|
|
199
|
+
offsetX: propsOffsetX,
|
|
200
|
+
offsetY: propsOffsetY,
|
|
201
|
+
autoRotate = true,
|
|
202
|
+
maxWidth,
|
|
203
|
+
...otherStyle
|
|
204
|
+
} = shapeStyle;
|
|
205
|
+
|
|
206
|
+
const positionPreset = {
|
|
207
|
+
textAlign: 'center',
|
|
208
|
+
offsetX: 0,
|
|
209
|
+
offsetY: 0,
|
|
210
|
+
pointRatio: [0.5, 0.501],
|
|
211
|
+
};
|
|
212
|
+
if (isNumber(position)) {
|
|
213
|
+
positionPreset.pointRatio = [position, position + 0.01];
|
|
214
|
+
}
|
|
215
|
+
switch (position) {
|
|
216
|
+
case 'start':
|
|
217
|
+
positionPreset.pointRatio = [0, 0.01];
|
|
218
|
+
positionPreset.textAlign = 'left';
|
|
219
|
+
positionPreset.offsetX = 4;
|
|
220
|
+
break;
|
|
221
|
+
case 'end':
|
|
222
|
+
positionPreset.pointRatio = [0.99, 1];
|
|
223
|
+
positionPreset.textAlign = 'right';
|
|
224
|
+
positionPreset.offsetX = -4;
|
|
225
|
+
break;
|
|
226
|
+
default: // at middle by default
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const point = (keyShape as Line | Polyline).getPoint(
|
|
231
|
+
positionPreset.pointRatio[0],
|
|
232
|
+
);
|
|
233
|
+
let positionStyle: any = { x: point.x, y: point.y };
|
|
234
|
+
let isRevert = false;
|
|
235
|
+
if (autoRotate) {
|
|
236
|
+
const pointOffset = (keyShape as Line | Polyline).getPoint(
|
|
237
|
+
positionPreset.pointRatio[1],
|
|
238
|
+
);
|
|
239
|
+
const angle = Math.atan(
|
|
240
|
+
(point.y - pointOffset.y) / (point.x - pointOffset.x),
|
|
241
|
+
); // TODO: NaN
|
|
242
|
+
|
|
243
|
+
// revert
|
|
244
|
+
isRevert = pointOffset.x < point.x;
|
|
245
|
+
if (isRevert) {
|
|
246
|
+
if (position === 'start') {
|
|
247
|
+
positionPreset.textAlign = 'right';
|
|
248
|
+
positionPreset.offsetX = -4;
|
|
249
|
+
} else if (position === 'end') {
|
|
250
|
+
positionPreset.textAlign = 'left';
|
|
251
|
+
positionPreset.offsetX = 4;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const offsetX = (
|
|
255
|
+
propsOffsetX === undefined ? positionPreset.offsetX : propsOffsetX
|
|
256
|
+
) as number;
|
|
257
|
+
const offsetY = (
|
|
258
|
+
propsOffsetY === undefined ? positionPreset.offsetY : propsOffsetY
|
|
259
|
+
) as number;
|
|
260
|
+
// the projection is |offsetX| away from point, along the tangent line of the keyShape's path at point
|
|
261
|
+
const projection = {
|
|
262
|
+
x: point.x + offsetX * Math.cos(angle),
|
|
263
|
+
y: point.y + offsetX * Math.sin(angle),
|
|
264
|
+
};
|
|
265
|
+
// the position of the text is |offsetY| away from projection, along the vertical line of the tangent line at point
|
|
266
|
+
positionStyle = {
|
|
267
|
+
x: projection.x + offsetY * Math.cos(Math.PI - angle),
|
|
268
|
+
y: projection.y + offsetY * Math.sin(Math.PI - angle),
|
|
269
|
+
transform: `rotate(${(angle / Math.PI) * 180})`,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
this.labelPosition = {
|
|
273
|
+
...positionStyle,
|
|
274
|
+
isRevert,
|
|
275
|
+
};
|
|
276
|
+
const wordWrapWidth = getWordWrapWidthByEnds(
|
|
277
|
+
[this.sourcePoint, this.targetPoint],
|
|
278
|
+
maxWidth,
|
|
279
|
+
this.zoomCache.zoom,
|
|
280
|
+
);
|
|
281
|
+
const style = {
|
|
282
|
+
...this.defaultStyles.labelShape,
|
|
283
|
+
textAlign: positionPreset.textAlign,
|
|
284
|
+
wordWrapWidth,
|
|
285
|
+
...positionStyle,
|
|
286
|
+
...otherStyle,
|
|
287
|
+
};
|
|
288
|
+
return this.upsertShape('text', 'labelShape', style, shapeMap, model);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public drawLabelBackgroundShape(
|
|
292
|
+
model: EdgeDisplayModel,
|
|
293
|
+
shapeMap: EdgeShapeMap,
|
|
294
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
295
|
+
diffState?: { previous: State[]; current: State[] },
|
|
296
|
+
): DisplayObject {
|
|
297
|
+
const { labelShape } = shapeMap;
|
|
298
|
+
if (!labelShape || !model.data.labelShape) return;
|
|
299
|
+
|
|
300
|
+
const { labelBackgroundShape, labelShape: labelShapeStyle } =
|
|
301
|
+
this.mergedStyles;
|
|
302
|
+
|
|
303
|
+
const textBBox =
|
|
304
|
+
this.boundsCache.labelShapeGeometry || labelShape.getGeometryBounds();
|
|
305
|
+
const { x, y, transform, isRevert } = this.labelPosition;
|
|
306
|
+
const { padding, ...backgroundStyle } = labelBackgroundShape;
|
|
307
|
+
const { balanceRatio = 1 } = this.zoomCache;
|
|
308
|
+
const textWidth = textBBox.max[0] - textBBox.min[0];
|
|
309
|
+
const textHeight = textBBox.max[1] - textBBox.min[1];
|
|
310
|
+
const bgStyle = {
|
|
311
|
+
fill: '#fff',
|
|
312
|
+
...backgroundStyle,
|
|
313
|
+
x: textBBox.min[0] - padding[3] + x,
|
|
314
|
+
y: textBBox.min[1] - padding[0] / balanceRatio + y,
|
|
315
|
+
width: textWidth + padding[1] + padding[3],
|
|
316
|
+
height: textHeight + (padding[0] + padding[2]) / balanceRatio,
|
|
317
|
+
transform: transform,
|
|
318
|
+
};
|
|
319
|
+
if (labelShapeStyle.position === 'start') {
|
|
320
|
+
if (isRevert) {
|
|
321
|
+
bgStyle.transformOrigin = `${bgStyle.width - padding[1]} ${
|
|
322
|
+
bgStyle.height / 2
|
|
323
|
+
}`;
|
|
324
|
+
} else {
|
|
325
|
+
bgStyle.transformOrigin = `${padding[3]} ${bgStyle.height / 2}`;
|
|
326
|
+
}
|
|
327
|
+
} else if (labelShapeStyle.position === 'end') {
|
|
328
|
+
if (isRevert) {
|
|
329
|
+
bgStyle.transformOrigin = `${padding[3]} ${bgStyle.height / 2}`;
|
|
330
|
+
} else {
|
|
331
|
+
bgStyle.transformOrigin = `${bgStyle.width - padding[1]} ${
|
|
332
|
+
bgStyle.height / 2
|
|
333
|
+
}`;
|
|
334
|
+
}
|
|
335
|
+
} else {
|
|
336
|
+
bgStyle.transformOrigin = `${textWidth / 2 + padding[3]} ${
|
|
337
|
+
textHeight / 2 + padding[0]
|
|
338
|
+
}`;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return this.upsertShape(
|
|
342
|
+
'rect',
|
|
343
|
+
'labelBackgroundShape',
|
|
344
|
+
bgStyle,
|
|
345
|
+
shapeMap,
|
|
346
|
+
model,
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
public drawIconShape(
|
|
351
|
+
model: EdgeDisplayModel,
|
|
352
|
+
shapeMap: EdgeShapeMap,
|
|
353
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
354
|
+
diffState?: { previous: State[]; current: State[] },
|
|
355
|
+
): DisplayObject {
|
|
356
|
+
const { labelShape, labelBackgroundShape, keyShape } = shapeMap;
|
|
357
|
+
const { iconShape: shapeStyle, labelShape: labelShapeProps } =
|
|
358
|
+
this.mergedStyles;
|
|
359
|
+
|
|
360
|
+
const {
|
|
361
|
+
width,
|
|
362
|
+
height,
|
|
363
|
+
fontSize,
|
|
364
|
+
text,
|
|
365
|
+
offsetX = 0,
|
|
366
|
+
offsetY = 0,
|
|
367
|
+
} = shapeStyle;
|
|
368
|
+
const w = (width || fontSize) as number;
|
|
369
|
+
const h = (height || fontSize) as number;
|
|
370
|
+
|
|
371
|
+
const iconShapeType = text ? 'text' : 'image';
|
|
372
|
+
if (iconShapeType === 'text') {
|
|
373
|
+
shapeStyle.textAlign = 'left';
|
|
374
|
+
shapeStyle.textBaseline = 'top';
|
|
375
|
+
shapeStyle.fontSize = w;
|
|
376
|
+
} else {
|
|
377
|
+
shapeStyle.width = w;
|
|
378
|
+
shapeStyle.height = h;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (labelShapeProps) {
|
|
382
|
+
const referShape = labelBackgroundShape || labelShape;
|
|
383
|
+
const referBounds =
|
|
384
|
+
this.boundsCache.labelBackgroundShapeGeometry ||
|
|
385
|
+
this.boundsCache.labelShapeGeometry ||
|
|
386
|
+
referShape.getGeometryBounds();
|
|
387
|
+
const {
|
|
388
|
+
min: referMin,
|
|
389
|
+
max: referMax,
|
|
390
|
+
halfExtents: referHalExtents,
|
|
391
|
+
} = referBounds;
|
|
392
|
+
const referHeight = referMax[1] - referMin[1];
|
|
393
|
+
const referWidth = referMax[0] - referMin[0];
|
|
394
|
+
const {
|
|
395
|
+
x: referX,
|
|
396
|
+
y: referY,
|
|
397
|
+
transform: referTransform,
|
|
398
|
+
} = referShape.attributes;
|
|
399
|
+
const { textAlign: labelAlign } = labelShape.attributes;
|
|
400
|
+
shapeStyle.x = referMin[0] - w + 4 + referX + offsetX;
|
|
401
|
+
shapeStyle.y = referMin[1] + (referHeight - h) / 2 + referY + offsetY;
|
|
402
|
+
if (referTransform) {
|
|
403
|
+
shapeStyle.transform = referTransform;
|
|
404
|
+
if (labelAlign === 'right') {
|
|
405
|
+
shapeStyle.transformOrigin = `${
|
|
406
|
+
referWidth / 2 - w / 2 + 4 + referHalExtents[0] - offsetX
|
|
407
|
+
} ${h / 2 - offsetY}`;
|
|
408
|
+
} else if (labelAlign === 'left') {
|
|
409
|
+
shapeStyle.transformOrigin = `${w + 4 - offsetX} ${h / 2 - offsetY}`;
|
|
410
|
+
} else {
|
|
411
|
+
// labelShape align 'center'
|
|
412
|
+
shapeStyle.transformOrigin = `${(w + referWidth) / 2 - offsetX} ${
|
|
413
|
+
h / 2 - offsetY
|
|
414
|
+
}`;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
const midPoint = (keyShape as Line | Polyline).getPoint(0.5);
|
|
419
|
+
shapeStyle.x = midPoint.x + offsetX;
|
|
420
|
+
shapeStyle.y = midPoint.y + offsetY;
|
|
421
|
+
// TODO: rotate
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return this.upsertShape(
|
|
425
|
+
iconShapeType,
|
|
426
|
+
'iconShape',
|
|
427
|
+
shapeStyle as GShapeStyle,
|
|
428
|
+
shapeMap,
|
|
429
|
+
model,
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
public drawHaloShape(
|
|
434
|
+
model: EdgeDisplayModel,
|
|
435
|
+
shapeMap: EdgeShapeMap,
|
|
436
|
+
diffData?: { previous: EdgeModelData; current: EdgeModelData },
|
|
437
|
+
diffState?: { previous: State[]; current: State[] },
|
|
438
|
+
): DisplayObject {
|
|
439
|
+
const { keyShape } = shapeMap;
|
|
440
|
+
const { haloShape: haloShapeStyle } = this.mergedStyles;
|
|
441
|
+
if (haloShapeStyle.visible === false) return;
|
|
442
|
+
const { nodeName, attributes } = keyShape;
|
|
443
|
+
return this.upsertShape(
|
|
444
|
+
nodeName as SHAPE_TYPE,
|
|
445
|
+
'haloShape',
|
|
446
|
+
{
|
|
447
|
+
...attributes,
|
|
448
|
+
stroke: attributes.stroke,
|
|
449
|
+
...haloShapeStyle,
|
|
450
|
+
},
|
|
451
|
+
shapeMap,
|
|
452
|
+
model,
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The listener for graph zooming.
|
|
458
|
+
* 1. show / hide some shapes while zoom level changed;
|
|
459
|
+
* 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
|
|
460
|
+
* @param shapeMap
|
|
461
|
+
* @param zoom
|
|
462
|
+
*/
|
|
463
|
+
public onZoom = (shapeMap: EdgeShapeMap, zoom: number) => {
|
|
464
|
+
// balance the size for label, badges
|
|
465
|
+
this.balanceShapeSize(shapeMap, zoom);
|
|
466
|
+
|
|
467
|
+
// zoomLevel changed
|
|
468
|
+
if (!this.lodStrategy) return;
|
|
469
|
+
const { levels } = this.lodStrategy;
|
|
470
|
+
const {
|
|
471
|
+
levelShapes,
|
|
472
|
+
hiddenShape,
|
|
473
|
+
animateConfig,
|
|
474
|
+
firstRender = true,
|
|
475
|
+
zoomLevel: previousLevel,
|
|
476
|
+
} = this.zoomCache;
|
|
477
|
+
|
|
478
|
+
// last zoom ratio responsed by zoom changing, which might not equal to zoom.previous in props since the function is debounced.
|
|
479
|
+
const currentLevel = getZoomLevel(levels, zoom);
|
|
480
|
+
const levelNums = Object.keys(levelShapes).map(Number);
|
|
481
|
+
const maxLevel = Math.max(...levelNums);
|
|
482
|
+
const minLevel = Math.min(...levelNums);
|
|
483
|
+
if (currentLevel < previousLevel) {
|
|
484
|
+
// zoomLevel changed, from higher to lower, hide something
|
|
485
|
+
if (firstRender) {
|
|
486
|
+
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
487
|
+
levelShapes[String(i)]?.forEach((id) => shapeMap[id]?.hide());
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
491
|
+
levelShapes[String(i)]?.forEach((id) =>
|
|
492
|
+
fadeOut(id, shapeMap[id], hiddenShape, animateConfig),
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
} else if (currentLevel > previousLevel) {
|
|
497
|
+
// zoomLevel changed, from lower to higher, show something
|
|
498
|
+
for (let i = currentLevel; i >= minLevel; i--) {
|
|
499
|
+
levelShapes[String(i)]?.forEach((id) =>
|
|
500
|
+
fadeIn(
|
|
501
|
+
id,
|
|
502
|
+
shapeMap[id],
|
|
503
|
+
this.mergedStyles[id] ||
|
|
504
|
+
this.mergedStyles[id.replace('Background', '')],
|
|
505
|
+
hiddenShape,
|
|
506
|
+
animateConfig,
|
|
507
|
+
),
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
this.zoomCache.zoom = zoom;
|
|
513
|
+
this.zoomCache.zoomLevel = currentLevel;
|
|
514
|
+
this.zoomCache.firstRender = false;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Update the shapes' sizes e.g. labelShape, labelBackgroundShape, to keep the visual size while zooming.
|
|
519
|
+
* @param shapeMap
|
|
520
|
+
* @param zoom
|
|
521
|
+
* @returns
|
|
522
|
+
*/
|
|
523
|
+
private balanceShapeSize(shapeMap, zoom) {
|
|
524
|
+
const { labelShape, labelBackgroundShape } = shapeMap;
|
|
525
|
+
const balanceRatio = 1 / zoom || 1;
|
|
526
|
+
this.zoomCache.balanceRatio = balanceRatio;
|
|
527
|
+
const { labelShape: labelStyle } = this.mergedStyles;
|
|
528
|
+
const { position = 'bottom' } = labelStyle;
|
|
529
|
+
if (!labelShape) return;
|
|
530
|
+
|
|
531
|
+
if (position === 'bottom') labelShape.style.transformOrigin = '0';
|
|
532
|
+
else labelShape.style.transformOrigin = '';
|
|
533
|
+
|
|
534
|
+
const oriTransform = this.boundsCache.labelShapeTransform;
|
|
535
|
+
labelShape.style.transform = `${oriTransform} scale(${balanceRatio}, ${balanceRatio})`;
|
|
536
|
+
|
|
537
|
+
const wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
|
|
538
|
+
labelShape.style.wordWrapWidth = wordWrapWidth;
|
|
539
|
+
|
|
540
|
+
if (!labelBackgroundShape) return;
|
|
541
|
+
|
|
542
|
+
const oriBgTransform = this.boundsCache.labelBackgroundShapeTransform;
|
|
543
|
+
labelBackgroundShape.style.transform = `${oriBgTransform} scale(${balanceRatio}, ${balanceRatio})`;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Update the source point { x, y } for the edge. Called in item's draw func.
|
|
548
|
+
* @param point
|
|
549
|
+
*/
|
|
550
|
+
public setSourcePoint(point: Point) {
|
|
551
|
+
this.sourcePoint = point;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Update the target point { x, y } for the edge. Called in item's draw func.
|
|
556
|
+
* @param point
|
|
557
|
+
*/
|
|
558
|
+
public setTargetPoint(point: Point) {
|
|
559
|
+
this.targetPoint = point;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
public upsertShape(
|
|
563
|
+
type: SHAPE_TYPE,
|
|
564
|
+
id: string,
|
|
565
|
+
style: ShapeStyle,
|
|
566
|
+
shapeMap: { [shapeId: string]: DisplayObject },
|
|
567
|
+
model: EdgeDisplayModel,
|
|
568
|
+
): DisplayObject {
|
|
569
|
+
return upsertShape(type, id, style as GShapeStyle, shapeMap, model);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './line';
|