@antv/g6 4.8.14-beta.0 → 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,57 @@
|
|
|
1
|
+
export const isArrayOverlap = (arr1, arr2): boolean => {
|
|
2
|
+
if (!arr1?.length || !arr2.length) return false;
|
|
3
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
4
|
+
for (let j = 0; j < arr2.length; j++) {
|
|
5
|
+
if (arr1[i] === arr2[j]) return true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get the set of a - b.
|
|
13
|
+
* @param a
|
|
14
|
+
* @param b
|
|
15
|
+
*/
|
|
16
|
+
export function diffSet<T>(a: T[] = [], b: T[] = []): T[] {
|
|
17
|
+
const valueMap: any = {};
|
|
18
|
+
b.forEach((value) => {
|
|
19
|
+
if (typeof value === 'object') valueMap[JSON.stringify(value)] = true;
|
|
20
|
+
valueMap[value] = true;
|
|
21
|
+
});
|
|
22
|
+
return a.filter((value) => !valueMap[value]);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the set of a + b.
|
|
26
|
+
* @param a
|
|
27
|
+
* @param b
|
|
28
|
+
*/
|
|
29
|
+
export function unionSet<T>(a: T[], b: T[]): T[] {
|
|
30
|
+
const resultSet = new Set(a);
|
|
31
|
+
b.forEach((value) => {
|
|
32
|
+
resultSet.add(value);
|
|
33
|
+
});
|
|
34
|
+
return Array.from(resultSet);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the intersect set of a and b.
|
|
38
|
+
* @param a
|
|
39
|
+
* @param b
|
|
40
|
+
*/
|
|
41
|
+
export function intersectSet<T>(a: T[], b: T[]): T[] {
|
|
42
|
+
const aSet = new Set(a);
|
|
43
|
+
const result = [];
|
|
44
|
+
b.forEach((value) => {
|
|
45
|
+
if (aSet.has(value)) result.push(value);
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function replaceElements(arr, target, replaceWith) {
|
|
51
|
+
for (let i = 0; i < arr.length; i++) {
|
|
52
|
+
if (arr[i] === target) {
|
|
53
|
+
arr[i] = replaceWith;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return arr;
|
|
57
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Canvas, CanvasLike } from '@antv/g';
|
|
2
|
+
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
3
|
+
import { Renderer as SVGRenderer } from '@antv/g-svg';
|
|
4
|
+
import { Renderer as WebGLRenderer } from '@antv/g-webgl';
|
|
5
|
+
import { Plugin as Plugin3D } from '@antv/g-plugin-3d';
|
|
6
|
+
import { RendererName } from '../types/render';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a canvas
|
|
10
|
+
* @param {RendererName} rendererType
|
|
11
|
+
* @param {string | HTMLElement} container
|
|
12
|
+
* @param {number} width
|
|
13
|
+
* @param {number} height
|
|
14
|
+
* @param {number} pixelRatio optional
|
|
15
|
+
* @param {boolean} customCanvasTag whether create a <canvas /> for multiple canvas under the container
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export const createCanvas = (
|
|
19
|
+
rendererType: RendererName,
|
|
20
|
+
container: HTMLElement,
|
|
21
|
+
width: number,
|
|
22
|
+
height: number,
|
|
23
|
+
pixelRatio?: number,
|
|
24
|
+
customCanvasTag = true,
|
|
25
|
+
style: any = {},
|
|
26
|
+
): Canvas => {
|
|
27
|
+
let renderer;
|
|
28
|
+
switch (rendererType.toLowerCase()) {
|
|
29
|
+
case 'svg':
|
|
30
|
+
renderer = new SVGRenderer();
|
|
31
|
+
break;
|
|
32
|
+
case 'webgl-3d':
|
|
33
|
+
case 'webgl':
|
|
34
|
+
renderer = new WebGLRenderer();
|
|
35
|
+
renderer.registerPlugin(new Plugin3D());
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
renderer = new CanvasRenderer();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof document !== 'undefined' && customCanvasTag) {
|
|
43
|
+
const canvasTag = document.createElement('canvas');
|
|
44
|
+
const dpr = pixelRatio || window.devicePixelRatio;
|
|
45
|
+
canvasTag.width = dpr * width;
|
|
46
|
+
canvasTag.height = dpr * height;
|
|
47
|
+
canvasTag.style.width = `${width}px`;
|
|
48
|
+
canvasTag.style.height = `${height}px`;
|
|
49
|
+
canvasTag.style.position = 'fixed';
|
|
50
|
+
canvasTag.style.outline = 'none';
|
|
51
|
+
canvasTag.tabIndex = 1; // Enable keyboard events
|
|
52
|
+
Object.assign(canvasTag.style, style);
|
|
53
|
+
container!.appendChild(canvasTag);
|
|
54
|
+
return new Canvas({
|
|
55
|
+
canvas: canvasTag as CanvasLike,
|
|
56
|
+
devicePixelRatio: pixelRatio,
|
|
57
|
+
renderer,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return new Canvas({
|
|
61
|
+
container,
|
|
62
|
+
width,
|
|
63
|
+
height,
|
|
64
|
+
devicePixelRatio: pixelRatio,
|
|
65
|
+
renderer,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Change renderer type for the canvas.
|
|
71
|
+
* @param rendererType renderer type
|
|
72
|
+
* @param canvas Canvas instance
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
export const changeRenderer = (
|
|
76
|
+
rendererType: RendererName,
|
|
77
|
+
canvas: Canvas,
|
|
78
|
+
): Canvas => {
|
|
79
|
+
let renderer;
|
|
80
|
+
switch (rendererType.toLowerCase()) {
|
|
81
|
+
case 'svg':
|
|
82
|
+
renderer = new SVGRenderer();
|
|
83
|
+
break;
|
|
84
|
+
case 'webgl-3d':
|
|
85
|
+
case 'webgl':
|
|
86
|
+
renderer = new WebGLRenderer();
|
|
87
|
+
renderer.registerPlugin(new Plugin3D());
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
renderer = new CanvasRenderer();
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
canvas.setRenderer(renderer);
|
|
94
|
+
return canvas;
|
|
95
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IElement } from '@antv/g';
|
|
2
|
+
import { ID } from '@antv/graphlib';
|
|
3
|
+
|
|
4
|
+
export type ItemInfo = {
|
|
5
|
+
itemType: 'canvas' | 'node' | 'edge' | 'combo';
|
|
6
|
+
itemId: ID | undefined;
|
|
7
|
+
groupElement: IElement;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Given an element, which might be a child shape of a node/edge,
|
|
12
|
+
* get its belonging item.
|
|
13
|
+
*/
|
|
14
|
+
export const getItemInfoFromElement = (element: IElement): ItemInfo | null => {
|
|
15
|
+
if (element.nodeName === 'document') {
|
|
16
|
+
return {
|
|
17
|
+
itemType: 'canvas',
|
|
18
|
+
itemId: undefined,
|
|
19
|
+
groupElement: element,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let parent = element;
|
|
24
|
+
while (parent && !parent.getAttribute?.('data-item-type')) {
|
|
25
|
+
parent = parent.parentElement;
|
|
26
|
+
}
|
|
27
|
+
if (!parent) return null;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
itemType: parent.getAttribute('data-item-type'),
|
|
31
|
+
itemId: parent.getAttribute('data-item-id'),
|
|
32
|
+
groupElement: parent,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BehaviorRegistry } from '../types/behavior';
|
|
2
|
+
import { ThemeRegistry } from '../types/theme';
|
|
3
|
+
import Graph from '../runtime/graph';
|
|
4
|
+
import registry from '../stdlib';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extend graph class with custom libs (extendLibrary), and extendLibrary will be merged into useLib.
|
|
8
|
+
* B1 is the Behavior lib from user, B2 is the Behavior lib of the graph to be extended(built-in graph)
|
|
9
|
+
* TODO: more templates, and might be merged to be two templates for the whole extendLibrary
|
|
10
|
+
* @param GraphClass graph class to be extended
|
|
11
|
+
* @param extendLibrary custom libs to extend
|
|
12
|
+
* @returns extended graph class
|
|
13
|
+
*/
|
|
14
|
+
export const extend = <
|
|
15
|
+
B1 extends BehaviorRegistry,
|
|
16
|
+
B2 extends BehaviorRegistry,
|
|
17
|
+
T1 extends ThemeRegistry,
|
|
18
|
+
T2 extends ThemeRegistry,
|
|
19
|
+
>(
|
|
20
|
+
GraphClass: typeof Graph<B2, T2>,
|
|
21
|
+
extendLibrary: {
|
|
22
|
+
behaviors?: B1;
|
|
23
|
+
themeSolvers?: T1;
|
|
24
|
+
nodes?: any; // TODO
|
|
25
|
+
edges?: any; // TODO
|
|
26
|
+
},
|
|
27
|
+
): typeof Graph<B1 & B2, T1 & T2> => {
|
|
28
|
+
// merged the extendLibrary to useLib for global usage
|
|
29
|
+
Object.keys(extendLibrary).forEach((cat) => {
|
|
30
|
+
registry.useLib[cat] = Object.assign(
|
|
31
|
+
{},
|
|
32
|
+
registry.useLib[cat],
|
|
33
|
+
extendLibrary[cat] || {},
|
|
34
|
+
);
|
|
35
|
+
Object.keys(registry.useLib[cat]).forEach((type) => {
|
|
36
|
+
const extension = registry.useLib[cat][type];
|
|
37
|
+
extension.type = type;
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
return GraphClass;
|
|
42
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isFunction } from 'util';
|
|
2
|
+
import { StdLibCategory } from '../types/stdlib';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get one extension from a (std)lib.
|
|
6
|
+
* @param config extension's config
|
|
7
|
+
* @param lib any lib
|
|
8
|
+
* @param {StdLibCategory} cat category of the extension
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export const getExtension = (
|
|
12
|
+
config: string | Function | object,
|
|
13
|
+
lib,
|
|
14
|
+
cat: StdLibCategory,
|
|
15
|
+
) => {
|
|
16
|
+
const catKey = `${cat}s`;
|
|
17
|
+
// TODO: whether keep function type config?
|
|
18
|
+
if (isFunction(config)) {
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
const type = typeof config === 'string' ? config : (config as any).type;
|
|
22
|
+
const ext = lib[catKey]?.[type];
|
|
23
|
+
return ext;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getCatExtensions = (lib, cat: StdLibCategory) => {
|
|
27
|
+
const catKey = `${cat}s`;
|
|
28
|
+
return lib[catKey];
|
|
29
|
+
};
|
package/src/util/item.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ID } from '@antv/graphlib';
|
|
2
|
+
import { Group } from '@antv/g';
|
|
3
|
+
import { IGraph } from '../types';
|
|
4
|
+
import Combo from '../item/combo';
|
|
5
|
+
import Edge from '../item/edge';
|
|
6
|
+
import Node from '../item/node';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Find the edges whose source and target are both in the ids.
|
|
10
|
+
* @param graph graph instance
|
|
11
|
+
* @param ids the end nodes/combos id list
|
|
12
|
+
* @returns id list of the edges meet the condition
|
|
13
|
+
*/
|
|
14
|
+
export const getEdgesBetween = (graph: IGraph, ids: ID[]): ID[] => {
|
|
15
|
+
const edgeIdSet = new Set<ID>();
|
|
16
|
+
ids.forEach((endId) => {
|
|
17
|
+
const edgesData = graph.getRelatedEdgesData(endId);
|
|
18
|
+
edgesData.forEach((edge) => {
|
|
19
|
+
const { source, target, id } = edge;
|
|
20
|
+
if (!graph.getItemVisible(id)) return; // hidden edge is not selectable
|
|
21
|
+
if (ids.includes(source) && ids.includes(target)) edgeIdSet.add(id);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return Array.from(edgeIdSet);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const upsertTransientItem = (
|
|
28
|
+
item: Node | Edge | Combo,
|
|
29
|
+
nodeGroup: Group,
|
|
30
|
+
edgeGroup: Group,
|
|
31
|
+
transientItemMap: Record<string, Node | Edge | Combo | Group>,
|
|
32
|
+
onlyDrawKeyShape?: boolean,
|
|
33
|
+
) => {
|
|
34
|
+
const transientItem = transientItemMap[item.model.id];
|
|
35
|
+
if (transientItem) {
|
|
36
|
+
return transientItem;
|
|
37
|
+
}
|
|
38
|
+
if (item.type === 'node') {
|
|
39
|
+
const transientNode = item.clone(nodeGroup, onlyDrawKeyShape, true) as Node;
|
|
40
|
+
transientItemMap[item.model.id] = transientNode;
|
|
41
|
+
transientNode.transient = true;
|
|
42
|
+
return transientNode;
|
|
43
|
+
} else if (item.type === 'edge') {
|
|
44
|
+
const source = upsertTransientItem(
|
|
45
|
+
item.sourceItem,
|
|
46
|
+
nodeGroup,
|
|
47
|
+
edgeGroup,
|
|
48
|
+
transientItemMap,
|
|
49
|
+
onlyDrawKeyShape,
|
|
50
|
+
) as Node;
|
|
51
|
+
const target = upsertTransientItem(
|
|
52
|
+
item.targetItem,
|
|
53
|
+
nodeGroup,
|
|
54
|
+
edgeGroup,
|
|
55
|
+
transientItemMap,
|
|
56
|
+
onlyDrawKeyShape,
|
|
57
|
+
) as Node;
|
|
58
|
+
const transientEdge = item.clone(
|
|
59
|
+
edgeGroup,
|
|
60
|
+
source,
|
|
61
|
+
target,
|
|
62
|
+
undefined,
|
|
63
|
+
true,
|
|
64
|
+
) as Edge;
|
|
65
|
+
transientEdge.transient = true;
|
|
66
|
+
transientItemMap[item.model.id] = transientEdge;
|
|
67
|
+
return transientEdge;
|
|
68
|
+
}
|
|
69
|
+
// TODO: clone combo
|
|
70
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { NodeDisplayModelData } from '../types/node';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default mapper to transform simple styles in inner data.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_MAPPER = {
|
|
7
|
+
node: (innerNodeModel) => {
|
|
8
|
+
const { id, data } = innerNodeModel;
|
|
9
|
+
const { color, label, icon, badges, anchorPoints } = data;
|
|
10
|
+
const resultData: NodeDisplayModelData = { ...data, keyShape: {} };
|
|
11
|
+
if (color) {
|
|
12
|
+
resultData.keyShape.fill = color;
|
|
13
|
+
}
|
|
14
|
+
if (label) {
|
|
15
|
+
resultData.labelShape = {
|
|
16
|
+
text: label,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (icon) {
|
|
20
|
+
resultData.iconShape = icon;
|
|
21
|
+
}
|
|
22
|
+
if (badges) {
|
|
23
|
+
resultData.badgeShapes = badges;
|
|
24
|
+
}
|
|
25
|
+
if (anchorPoints) {
|
|
26
|
+
resultData.anchorShapes = anchorPoints.map((point) => ({
|
|
27
|
+
position: point,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
data: resultData,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
edge: (innerEdgeModel) => {
|
|
36
|
+
const { id, source, target, data } = innerEdgeModel;
|
|
37
|
+
const { color, label, icon, badge } = data;
|
|
38
|
+
const resultData: NodeDisplayModelData = { ...data, keyShape: {} };
|
|
39
|
+
if (color) {
|
|
40
|
+
resultData.keyShape.stroke = color;
|
|
41
|
+
}
|
|
42
|
+
if (label) {
|
|
43
|
+
resultData.labelShape = {
|
|
44
|
+
text: label,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (icon) {
|
|
48
|
+
resultData.iconShape = icon;
|
|
49
|
+
}
|
|
50
|
+
if (badge) {
|
|
51
|
+
resultData.badgeShape = badge;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
id,
|
|
55
|
+
source,
|
|
56
|
+
target,
|
|
57
|
+
data: resultData,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
combo: (innerComboModel) => innerComboModel,
|
|
61
|
+
};
|
package/src/util/math.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the value is begween the range of [min, max]
|
|
3
|
+
* @param {number} value the value to be judged
|
|
4
|
+
* @param {number} min the min of the range
|
|
5
|
+
* @param {number} max the max of the range
|
|
6
|
+
* @return {boolean} bool the result boolean
|
|
7
|
+
*/
|
|
8
|
+
export const isBetween = (value: number, min: number, max: number) =>
|
|
9
|
+
value >= min && value <= max;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Point } from '../types/common';
|
|
2
|
+
import { isBetween } from './math';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Find the nearest on in points to the curPoint.
|
|
6
|
+
* @param points
|
|
7
|
+
* @param curPoint
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export const getNearestPoint = (
|
|
11
|
+
points: Point[],
|
|
12
|
+
curPoint: Point,
|
|
13
|
+
): {
|
|
14
|
+
index: number;
|
|
15
|
+
nearestPoint: Point;
|
|
16
|
+
} => {
|
|
17
|
+
let index = 0;
|
|
18
|
+
let nearestPoint = points[0];
|
|
19
|
+
let minDistance = distance(points[0], curPoint);
|
|
20
|
+
for (let i = 0; i < points.length; i++) {
|
|
21
|
+
const point = points[i];
|
|
22
|
+
const dis = distance(point, curPoint);
|
|
23
|
+
if (dis < minDistance) {
|
|
24
|
+
nearestPoint = point;
|
|
25
|
+
minDistance = dis;
|
|
26
|
+
index = i;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
index,
|
|
31
|
+
nearestPoint,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get distance by two points.
|
|
37
|
+
* @param p1 first point
|
|
38
|
+
* @param p2 second point
|
|
39
|
+
*/
|
|
40
|
+
export const distance = (p1: Point, p2: Point): number => {
|
|
41
|
+
const vx = p1.x - p2.x;
|
|
42
|
+
const vy = p1.y - p2.y;
|
|
43
|
+
return Math.sqrt(vx * vx + vy * vy);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get point and circle intersect point.
|
|
48
|
+
* @param {ICircle} circle Circle's center x,y and radius r
|
|
49
|
+
* @param {Point} point Point x,y
|
|
50
|
+
* @return {Point} calculated intersect point
|
|
51
|
+
*/
|
|
52
|
+
export const getCircleIntersectByPoint = (
|
|
53
|
+
circleProps: { x: number; y: number; r: number },
|
|
54
|
+
point: Point,
|
|
55
|
+
): Point | null => {
|
|
56
|
+
const { x: cx, y: cy, r } = circleProps;
|
|
57
|
+
const { x, y } = point;
|
|
58
|
+
|
|
59
|
+
const dx = x - cx;
|
|
60
|
+
const dy = y - cy;
|
|
61
|
+
if (dx * dx + dy * dy < r * r) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const angle = Math.atan(dy / dx);
|
|
65
|
+
return {
|
|
66
|
+
x: cx + Math.abs(r * Math.cos(angle)) * Math.sign(dx),
|
|
67
|
+
y: cy + Math.abs(r * Math.sin(angle)) * Math.sign(dy),
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get point and ellipse inIntersect.
|
|
73
|
+
* @param {Object} ellipse ellipse center x,y and radius rx,ry
|
|
74
|
+
* @param {Object} point Point x,y
|
|
75
|
+
* @return {object} calculated intersect point
|
|
76
|
+
*/
|
|
77
|
+
export const getEllipseIntersectByPoint = (
|
|
78
|
+
ellipseProps: {
|
|
79
|
+
rx: number;
|
|
80
|
+
ry: number;
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
},
|
|
84
|
+
point: Point,
|
|
85
|
+
): Point => {
|
|
86
|
+
const { rx: a, ry: b, x: cx, y: cy } = ellipseProps;
|
|
87
|
+
|
|
88
|
+
const dx = point.x - cx;
|
|
89
|
+
const dy = point.y - cy;
|
|
90
|
+
// The angle will be in range [-PI, PI]
|
|
91
|
+
let angle = Math.atan2(dy / b, dx / a);
|
|
92
|
+
|
|
93
|
+
if (angle < 0) {
|
|
94
|
+
// transfer to [0, 2*PI]
|
|
95
|
+
angle += 2 * Math.PI;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
x: cx + a * Math.cos(angle),
|
|
100
|
+
y: cy + b * Math.sin(angle),
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Point and rectangular intersection point.
|
|
106
|
+
* @param {IRect} rect rect
|
|
107
|
+
* @param {Point} point point
|
|
108
|
+
* @return {PointPoint} rst;
|
|
109
|
+
*/
|
|
110
|
+
export const getRectIntersectByPoint = (
|
|
111
|
+
rectProps: { x: number; y: number; width: number; height: number },
|
|
112
|
+
point: Point,
|
|
113
|
+
): Point | null => {
|
|
114
|
+
const { x, y, width, height } = rectProps;
|
|
115
|
+
const cx = x + width / 2;
|
|
116
|
+
const cy = y + height / 2;
|
|
117
|
+
const points: Point[] = [];
|
|
118
|
+
const center: Point = {
|
|
119
|
+
x: cx,
|
|
120
|
+
y: cy,
|
|
121
|
+
};
|
|
122
|
+
points.push({
|
|
123
|
+
x,
|
|
124
|
+
y,
|
|
125
|
+
});
|
|
126
|
+
points.push({
|
|
127
|
+
x: x + width,
|
|
128
|
+
y,
|
|
129
|
+
});
|
|
130
|
+
points.push({
|
|
131
|
+
x: x + width,
|
|
132
|
+
y: y + height,
|
|
133
|
+
});
|
|
134
|
+
points.push({
|
|
135
|
+
x,
|
|
136
|
+
y: y + height,
|
|
137
|
+
});
|
|
138
|
+
points.push({
|
|
139
|
+
x,
|
|
140
|
+
y,
|
|
141
|
+
});
|
|
142
|
+
let rst: Point | null = null;
|
|
143
|
+
for (let i = 1; i < points.length; i++) {
|
|
144
|
+
rst = getLineIntersect(points[i - 1], points[i], center, point);
|
|
145
|
+
if (rst) {
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return rst;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Get the intersect point of two lines.
|
|
154
|
+
* @param {Point} p0 The start point of the first line.
|
|
155
|
+
* @param {Point} p1 The end point of the first line.
|
|
156
|
+
* @param {Point} p2 The start point of the second line.
|
|
157
|
+
* @param {Point} p3 The end point of the second line.
|
|
158
|
+
* @return {Point} Calculated intersect point.
|
|
159
|
+
*/
|
|
160
|
+
export const getLineIntersect = (
|
|
161
|
+
p0: Point,
|
|
162
|
+
p1: Point,
|
|
163
|
+
p2: Point,
|
|
164
|
+
p3: Point,
|
|
165
|
+
): Point | null => {
|
|
166
|
+
const tolerance = 0.0001;
|
|
167
|
+
|
|
168
|
+
const E: Point = {
|
|
169
|
+
x: p2.x - p0.x,
|
|
170
|
+
y: p2.y - p0.y,
|
|
171
|
+
};
|
|
172
|
+
const D0: Point = {
|
|
173
|
+
x: p1.x - p0.x,
|
|
174
|
+
y: p1.y - p0.y,
|
|
175
|
+
};
|
|
176
|
+
const D1: Point = {
|
|
177
|
+
x: p3.x - p2.x,
|
|
178
|
+
y: p3.y - p2.y,
|
|
179
|
+
};
|
|
180
|
+
const kross: number = D0.x * D1.y - D0.y * D1.x;
|
|
181
|
+
const sqrKross: number = kross * kross;
|
|
182
|
+
const invertKross: number = 1 / kross;
|
|
183
|
+
const sqrLen0: number = D0.x * D0.x + D0.y * D0.y;
|
|
184
|
+
const sqrLen1: number = D1.x * D1.x + D1.y * D1.y;
|
|
185
|
+
if (sqrKross > tolerance * sqrLen0 * sqrLen1) {
|
|
186
|
+
const s = (E.x * D1.y - E.y * D1.x) * invertKross;
|
|
187
|
+
const t = (E.x * D0.y - E.y * D0.x) * invertKross;
|
|
188
|
+
if (!isBetween(s, 0, 1) || !isBetween(t, 0, 1)) return null;
|
|
189
|
+
return {
|
|
190
|
+
x: p0.x + s * D0.x,
|
|
191
|
+
y: p0.y + s * D0.y,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
};
|