@antv/g6 4.8.14 → 5.0.0-alpha.2
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,251 @@
|
|
|
1
|
+
import { Animation, DisplayObject, IAnimationEffectTiming } from '@antv/g';
|
|
2
|
+
import {
|
|
3
|
+
isLayoutWithIterations,
|
|
4
|
+
Layout,
|
|
5
|
+
LayoutMapping,
|
|
6
|
+
OutNode,
|
|
7
|
+
Supervisor,
|
|
8
|
+
} from '@antv/layout';
|
|
9
|
+
import { stdLib } from '../../stdlib';
|
|
10
|
+
import {
|
|
11
|
+
IGraph,
|
|
12
|
+
isImmediatelyInvokedLayoutOptions,
|
|
13
|
+
isLayoutWorkerized,
|
|
14
|
+
LayoutOptions,
|
|
15
|
+
} from '../../types';
|
|
16
|
+
import { GraphCore } from '../../types/data';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Manages layout extensions and graph layout.
|
|
20
|
+
* It will also emit `afterlayout` & `tick` events on Graph.
|
|
21
|
+
*/
|
|
22
|
+
export class LayoutController {
|
|
23
|
+
public extensions = {};
|
|
24
|
+
public graph: IGraph;
|
|
25
|
+
|
|
26
|
+
private currentLayout: Layout<any> | null;
|
|
27
|
+
private currentSupervisor: Supervisor | null;
|
|
28
|
+
private currentAnimation: Animation | null;
|
|
29
|
+
private animatedDisplayObject: DisplayObject;
|
|
30
|
+
|
|
31
|
+
constructor(graph: IGraph<any, any>) {
|
|
32
|
+
this.graph = graph;
|
|
33
|
+
this.animatedDisplayObject = new DisplayObject({});
|
|
34
|
+
this.tap();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Subscribe the lifecycle of graph.
|
|
39
|
+
*/
|
|
40
|
+
private tap() {
|
|
41
|
+
this.graph.hooks.layout.tap(this.onLayout.bind(this));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private async onLayout(params: {
|
|
45
|
+
graphCore: GraphCore;
|
|
46
|
+
options: LayoutOptions;
|
|
47
|
+
}) {
|
|
48
|
+
/**
|
|
49
|
+
* The final calculated result.
|
|
50
|
+
*/
|
|
51
|
+
let positions: LayoutMapping;
|
|
52
|
+
|
|
53
|
+
// Stop currentLayout if any.
|
|
54
|
+
this.stopLayout();
|
|
55
|
+
|
|
56
|
+
const { graphCore, options } = params;
|
|
57
|
+
|
|
58
|
+
this.graph.emit('startlayout');
|
|
59
|
+
|
|
60
|
+
if (isImmediatelyInvokedLayoutOptions(options)) {
|
|
61
|
+
const {
|
|
62
|
+
animated = false,
|
|
63
|
+
animationEffectTiming = {
|
|
64
|
+
duration: 1000,
|
|
65
|
+
} as Partial<IAnimationEffectTiming>,
|
|
66
|
+
execute,
|
|
67
|
+
...rest
|
|
68
|
+
} = options;
|
|
69
|
+
|
|
70
|
+
// It will ignore some layout options such as `type` and `workerEnabled`.
|
|
71
|
+
positions = await execute(graphCore, rest);
|
|
72
|
+
|
|
73
|
+
if (animated) {
|
|
74
|
+
await this.animateLayoutWithoutIterations(
|
|
75
|
+
positions,
|
|
76
|
+
animationEffectTiming,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
const {
|
|
81
|
+
type = 'grid',
|
|
82
|
+
animated = false,
|
|
83
|
+
animationEffectTiming = {
|
|
84
|
+
duration: 1000,
|
|
85
|
+
} as Partial<IAnimationEffectTiming>,
|
|
86
|
+
iterations = 300,
|
|
87
|
+
...rest
|
|
88
|
+
} = options;
|
|
89
|
+
let { workerEnabled = false } = options;
|
|
90
|
+
|
|
91
|
+
// Find built-in layout algorithms.
|
|
92
|
+
const layoutCtor = stdLib.layouts[type];
|
|
93
|
+
if (!layoutCtor) {
|
|
94
|
+
throw new Error(`Unknown layout algorithm: ${type}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Initialize layout.
|
|
98
|
+
const layout = new layoutCtor(rest);
|
|
99
|
+
this.currentLayout = layout;
|
|
100
|
+
|
|
101
|
+
// CustomLayout is not workerized.
|
|
102
|
+
if (!isLayoutWorkerized(options)) {
|
|
103
|
+
workerEnabled = false;
|
|
104
|
+
// TODO: console.warn();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (workerEnabled) {
|
|
108
|
+
/**
|
|
109
|
+
* Run algorithm in WebWorker, `animated` option will be ignored.
|
|
110
|
+
*/
|
|
111
|
+
const supervisor = new Supervisor(graphCore, layout, { iterations });
|
|
112
|
+
this.currentSupervisor = supervisor;
|
|
113
|
+
positions = await supervisor.execute();
|
|
114
|
+
} else {
|
|
115
|
+
// e.g. Force layout
|
|
116
|
+
if (isLayoutWithIterations(layout)) {
|
|
117
|
+
if (animated) {
|
|
118
|
+
/**
|
|
119
|
+
* `onTick` will get triggered in this case.
|
|
120
|
+
*/
|
|
121
|
+
positions = await layout.execute(graphCore, {
|
|
122
|
+
onTick: (positionsOnTick: LayoutMapping) => {
|
|
123
|
+
// Display the animated process of layout.
|
|
124
|
+
this.updateNodesPosition(positionsOnTick);
|
|
125
|
+
this.graph.emit('tick', positionsOnTick);
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
/**
|
|
130
|
+
* Manually step simulation in a sync way. `onTick` won't get triggered in this case,
|
|
131
|
+
* there will be no animation either.
|
|
132
|
+
*/
|
|
133
|
+
layout.execute(graphCore);
|
|
134
|
+
layout.stop();
|
|
135
|
+
positions = layout.tick(iterations);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
positions = await layout.execute(graphCore);
|
|
139
|
+
|
|
140
|
+
if (animated) {
|
|
141
|
+
await this.animateLayoutWithoutIterations(
|
|
142
|
+
positions,
|
|
143
|
+
animationEffectTiming,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this.graph.emit('endlayout');
|
|
151
|
+
|
|
152
|
+
// Update nodes' positions.
|
|
153
|
+
this.updateNodesPosition(positions);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
stopLayout() {
|
|
157
|
+
if (this.currentLayout && isLayoutWithIterations(this.currentLayout)) {
|
|
158
|
+
this.currentLayout.stop();
|
|
159
|
+
this.currentLayout = null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.currentSupervisor) {
|
|
163
|
+
this.currentSupervisor.stop();
|
|
164
|
+
this.currentSupervisor = null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (this.currentAnimation) {
|
|
168
|
+
this.currentAnimation.finish();
|
|
169
|
+
this.currentAnimation = null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
destroy() {
|
|
174
|
+
this.stopLayout();
|
|
175
|
+
|
|
176
|
+
if (this.currentSupervisor) {
|
|
177
|
+
this.currentSupervisor.kill();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private updateNodesPosition(positions: LayoutMapping) {
|
|
182
|
+
this.graph.updateNodePosition(positions.nodes);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* For those layout without iterations, e.g. circular, random, since they don't have `onTick` callback,
|
|
187
|
+
* we have to translate each node from its initial position to final one after layout,
|
|
188
|
+
* with the help of `onframe` from G's animation API.
|
|
189
|
+
* @param positions
|
|
190
|
+
* @param animationEffectTiming
|
|
191
|
+
*/
|
|
192
|
+
private async animateLayoutWithoutIterations(
|
|
193
|
+
positions: LayoutMapping,
|
|
194
|
+
animationEffectTiming: Partial<IAnimationEffectTiming>,
|
|
195
|
+
) {
|
|
196
|
+
// Animation should be executed only once.
|
|
197
|
+
animationEffectTiming.iterations = 1;
|
|
198
|
+
|
|
199
|
+
const initialPositions = positions.nodes.map((node) => {
|
|
200
|
+
// Should clone each node's initial data since it will be updated during the layout process.
|
|
201
|
+
return { ...this.graph.getNodeData(`${node.id}`)! };
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Add a connected displayobject so that we can animate it.
|
|
205
|
+
if (!this.animatedDisplayObject.isConnected) {
|
|
206
|
+
await this.graph.canvas.ready;
|
|
207
|
+
this.graph.canvas.appendChild(this.animatedDisplayObject);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Use `opacity` since it is an interpolated property.
|
|
211
|
+
this.currentAnimation = this.animatedDisplayObject.animate(
|
|
212
|
+
[
|
|
213
|
+
{
|
|
214
|
+
opacity: 0,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
opacity: 1,
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
animationEffectTiming,
|
|
221
|
+
) as Animation;
|
|
222
|
+
|
|
223
|
+
// Update each node's position on each frame.
|
|
224
|
+
// @see https://g.antv.antgroup.com/api/animation/waapi#%E5%B1%9E%E6%80%A7
|
|
225
|
+
this.currentAnimation.onframe = (e) => {
|
|
226
|
+
// @see https://g.antv.antgroup.com/api/animation/waapi#progress
|
|
227
|
+
const progress = (e.target as Animation).effect.getComputedTiming()
|
|
228
|
+
.progress as number;
|
|
229
|
+
const interpolatedNodesPosition = (initialPositions as OutNode[]).map(
|
|
230
|
+
({ id, data }, i) => {
|
|
231
|
+
const { x: fromX = 0, y: fromY = 0 } = data;
|
|
232
|
+
const { x: toX, y: toY } = positions.nodes[i].data;
|
|
233
|
+
return {
|
|
234
|
+
id,
|
|
235
|
+
data: {
|
|
236
|
+
x: fromX + (toX - fromX) * progress,
|
|
237
|
+
y: fromY + (toY - fromY) * progress,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
this.updateNodesPosition({
|
|
244
|
+
nodes: interpolatedNodesPosition,
|
|
245
|
+
edges: [],
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
await this.currentAnimation.finished;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { IGraph } from '../../types';
|
|
2
|
+
import registry from '../../stdlib';
|
|
3
|
+
import { getExtension } from '../../util/extension';
|
|
4
|
+
import { Plugin } from '../../types/plugin';
|
|
5
|
+
import { IG6GraphEvent } from '../../types/event';
|
|
6
|
+
|
|
7
|
+
type Listener = (event: IG6GraphEvent) => void;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Wraps the listener with error logging.
|
|
11
|
+
* @returns a new listener with error logging.
|
|
12
|
+
*/
|
|
13
|
+
const wrapListener = (
|
|
14
|
+
type: string,
|
|
15
|
+
eventName: string,
|
|
16
|
+
listener: Listener,
|
|
17
|
+
): Listener => {
|
|
18
|
+
return (event: any) => {
|
|
19
|
+
try {
|
|
20
|
+
listener(event);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(
|
|
23
|
+
`G6: Error occurred in "${eventName}" phase of the plugin "${type}"!`,
|
|
24
|
+
);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Manages free plugin extensions and graph layout.
|
|
32
|
+
*/
|
|
33
|
+
export class PluginController {
|
|
34
|
+
public extensions: any = [];
|
|
35
|
+
public graph: IGraph;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Plugins on graph.
|
|
39
|
+
* @example
|
|
40
|
+
* { 'minimap': Minimap, 'tooltip': Tooltip }
|
|
41
|
+
*/
|
|
42
|
+
private pluginMap: Map<string, { type: string; plugin: Plugin }> = new Map();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Listeners added by all current plugins.
|
|
46
|
+
* @example
|
|
47
|
+
* {
|
|
48
|
+
* 'minimap': { 'afterlayout': function },
|
|
49
|
+
* }
|
|
50
|
+
*/
|
|
51
|
+
private listenersMap: Record<string, Record<string, Listener>> = {};
|
|
52
|
+
|
|
53
|
+
constructor(graph: IGraph<any, any>) {
|
|
54
|
+
this.graph = graph;
|
|
55
|
+
this.tap();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Subscribe the lifecycle of graph.
|
|
60
|
+
*/
|
|
61
|
+
private tap() {
|
|
62
|
+
this.graph.hooks.init.tap(this.onPluginInit.bind(this));
|
|
63
|
+
this.graph.hooks.pluginchange.tap(this.onPluginChange.bind(this));
|
|
64
|
+
this.graph.hooks.destroy.tap(this.onDestroy.bind(this));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private onPluginInit() {
|
|
68
|
+
// 1. Initialize new behaviors.
|
|
69
|
+
this.pluginMap.clear();
|
|
70
|
+
const { graph } = this;
|
|
71
|
+
const pluginConfigs = graph.getSpecification().plugins || [];
|
|
72
|
+
pluginConfigs.forEach((config) => {
|
|
73
|
+
this.initPlugin(config);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// 2. Add listeners for each behavior.
|
|
77
|
+
this.listenersMap = {};
|
|
78
|
+
this.pluginMap.forEach((item, key) => {
|
|
79
|
+
const { plugin } = item;
|
|
80
|
+
this.addListeners(key, plugin);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private initPlugin(config) {
|
|
85
|
+
const { graph } = this;
|
|
86
|
+
const Plugin = getExtension(config, registry.useLib, 'plugin');
|
|
87
|
+
const options = typeof config === 'string' ? {} : config;
|
|
88
|
+
const type = typeof config === 'string' ? config : config.type;
|
|
89
|
+
const key = typeof config === 'string' ? config : config.key || type;
|
|
90
|
+
const plugin = new Plugin(options);
|
|
91
|
+
plugin.init(graph);
|
|
92
|
+
this.pluginMap.set(key, { type, plugin });
|
|
93
|
+
return { key, type, plugin };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private onPluginChange(params: {
|
|
97
|
+
action: 'update' | 'add' | 'remove';
|
|
98
|
+
plugins: (string | { key: string; type: string; options: any })[];
|
|
99
|
+
}) {
|
|
100
|
+
const { action, plugins: pluginCfgs } = params;
|
|
101
|
+
if (action === 'add') {
|
|
102
|
+
pluginCfgs.forEach((config) => {
|
|
103
|
+
const { key, plugin } = this.initPlugin(config);
|
|
104
|
+
this.addListeners(key, plugin);
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (action === 'remove') {
|
|
110
|
+
pluginCfgs.forEach((config) => {
|
|
111
|
+
const key =
|
|
112
|
+
typeof config === 'string' ? config : config.key || config.type;
|
|
113
|
+
const item = this.pluginMap.get(key);
|
|
114
|
+
if (!item) return;
|
|
115
|
+
const { plugin } = item;
|
|
116
|
+
this.removeListeners(key);
|
|
117
|
+
plugin.destroy();
|
|
118
|
+
this.pluginMap.delete(key);
|
|
119
|
+
});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (action === 'update') {
|
|
124
|
+
pluginCfgs.forEach((config) => {
|
|
125
|
+
if (typeof config === 'string') return;
|
|
126
|
+
const key = config.key || config.type;
|
|
127
|
+
const item = this.pluginMap.get(key);
|
|
128
|
+
if (!item) return;
|
|
129
|
+
const { plugin } = item;
|
|
130
|
+
plugin.updateCfgs(config);
|
|
131
|
+
this.removeListeners(key);
|
|
132
|
+
this.addListeners(key, plugin);
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private addListeners = (key: string, plugin: Plugin) => {
|
|
139
|
+
const events = plugin.getEvents();
|
|
140
|
+
this.listenersMap[key] = {};
|
|
141
|
+
Object.keys(events).forEach((eventName) => {
|
|
142
|
+
// Wrap the listener with error logging.
|
|
143
|
+
const listener = wrapListener(
|
|
144
|
+
key,
|
|
145
|
+
eventName,
|
|
146
|
+
events[eventName].bind(plugin),
|
|
147
|
+
);
|
|
148
|
+
this.graph.on(eventName, listener);
|
|
149
|
+
this.listenersMap[key][eventName] = listener;
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
private removeListeners = (key: string) => {
|
|
154
|
+
const listeners = this.listenersMap[key];
|
|
155
|
+
Object.keys(listeners).forEach((eventName) => {
|
|
156
|
+
const listener = listeners[eventName];
|
|
157
|
+
if (listener) {
|
|
158
|
+
this.graph.off(eventName, listener);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
private onDestroy() {
|
|
164
|
+
this.pluginMap.forEach((item) => {
|
|
165
|
+
const { plugin } = item;
|
|
166
|
+
plugin.destroy();
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
destroy() {}
|
|
171
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import registry from '../../stdlib';
|
|
2
|
+
import { IGraph } from '../../types';
|
|
3
|
+
import { ThemeSpecification } from '../../types/theme';
|
|
4
|
+
import { getCatExtensions, getExtension } from '../../util/extension';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Manages theme extensions for graph.
|
|
8
|
+
* Themes are the mapper from item's inner model to display model.
|
|
9
|
+
*/
|
|
10
|
+
export class ThemeController {
|
|
11
|
+
public extension;
|
|
12
|
+
public graph: IGraph;
|
|
13
|
+
|
|
14
|
+
private themeConfig;
|
|
15
|
+
private solver;
|
|
16
|
+
public specification: ThemeSpecification;
|
|
17
|
+
private themes: {
|
|
18
|
+
[themeName: string]: ThemeSpecification;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
constructor(graph: IGraph<any, any>) {
|
|
22
|
+
this.graph = graph;
|
|
23
|
+
this.tap();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe the lifecycle of graph.
|
|
27
|
+
*/
|
|
28
|
+
private tap() {
|
|
29
|
+
this.extension = this.getExtension();
|
|
30
|
+
this.themes = this.getThemes();
|
|
31
|
+
this.graph.hooks.init.tap(this.onInit.bind(this));
|
|
32
|
+
this.graph.hooks.themechange.tap(this.onThemeChange.bind(this));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the extensions from useLib.
|
|
37
|
+
*/
|
|
38
|
+
private getExtension() {
|
|
39
|
+
const { theme = {} } = this.graph.getSpecification();
|
|
40
|
+
this.themeConfig = theme;
|
|
41
|
+
return theme
|
|
42
|
+
? getExtension(theme, registry.useLib, 'themeSolver')
|
|
43
|
+
: undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private getThemes() {
|
|
47
|
+
return getCatExtensions(registry.useLib, 'theme');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Graph init listener, create theme solver and generate theme
|
|
52
|
+
*/
|
|
53
|
+
private onInit({ canvases }) {
|
|
54
|
+
if (this.extension) {
|
|
55
|
+
this.solver = new this.extension(this.themeConfig, this.themes);
|
|
56
|
+
this.specification = this.solver.specification;
|
|
57
|
+
// apply canvas style in theme to the background canvas dom
|
|
58
|
+
const { canvas } = this.specification;
|
|
59
|
+
const dom = canvases.background.getContextService().getDomElement();
|
|
60
|
+
Object.keys(canvas).forEach((key) => (dom.style[key] = canvas[key]));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private onThemeChange({ canvases }) {
|
|
65
|
+
if (!canvases) return;
|
|
66
|
+
this.extension = this.getExtension();
|
|
67
|
+
this.onInit({ canvases });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ICamera, PointLike } from '@antv/g';
|
|
2
|
+
import { IGraph } from '../../types';
|
|
3
|
+
import { CameraAnimationOptions } from '../../types/animate';
|
|
4
|
+
import { ViewportChangeHookParams } from '../../types/hook';
|
|
5
|
+
|
|
6
|
+
let landmarkCounter = 0;
|
|
7
|
+
|
|
8
|
+
export class ViewportController {
|
|
9
|
+
public graph: IGraph;
|
|
10
|
+
|
|
11
|
+
constructor(graph: IGraph<any, any>) {
|
|
12
|
+
this.graph = graph;
|
|
13
|
+
this.tap();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Subscribe the lifecycle of graph.
|
|
18
|
+
*/
|
|
19
|
+
private tap() {
|
|
20
|
+
this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private async onViewportChange({
|
|
24
|
+
transform,
|
|
25
|
+
effectTiming,
|
|
26
|
+
}: ViewportChangeHookParams) {
|
|
27
|
+
const camera = this.graph.canvas.getCamera();
|
|
28
|
+
const transientCamera = this.graph.transientCanvas.getCamera();
|
|
29
|
+
const {
|
|
30
|
+
translate,
|
|
31
|
+
rotate,
|
|
32
|
+
zoom,
|
|
33
|
+
origin = this.graph.getViewportCenter(),
|
|
34
|
+
} = transform;
|
|
35
|
+
const currentZoom = camera.getZoom();
|
|
36
|
+
|
|
37
|
+
if (effectTiming) {
|
|
38
|
+
const {
|
|
39
|
+
duration = 1000,
|
|
40
|
+
easing = 'linear',
|
|
41
|
+
easingFunction,
|
|
42
|
+
} = effectTiming;
|
|
43
|
+
const landmarkOptions: Partial<{
|
|
44
|
+
position: [number, number] | [number, number, number] | Float32Array;
|
|
45
|
+
focalPoint: [number, number] | [number, number, number] | Float32Array;
|
|
46
|
+
zoom: number;
|
|
47
|
+
roll: number;
|
|
48
|
+
}> = {};
|
|
49
|
+
|
|
50
|
+
if (translate) {
|
|
51
|
+
const { dx = 0, dy = 0, dz = 0 } = translate;
|
|
52
|
+
const [px, py, pz] = camera.getPosition();
|
|
53
|
+
const [fx, fy, fz] = camera.getFocalPoint();
|
|
54
|
+
landmarkOptions.position = [px - dx, py - dy, pz - dz];
|
|
55
|
+
landmarkOptions.focalPoint = [fx - dx, fy - dy, fz - dz];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (zoom) {
|
|
59
|
+
const { ratio } = zoom;
|
|
60
|
+
landmarkOptions.zoom = currentZoom * ratio;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (rotate) {
|
|
64
|
+
const { angle } = rotate;
|
|
65
|
+
landmarkOptions.roll = camera.getRoll() + angle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const landmark = camera.createLandmark(
|
|
69
|
+
`mark${landmarkCounter++}`,
|
|
70
|
+
landmarkOptions,
|
|
71
|
+
);
|
|
72
|
+
const transientLandmark = transientCamera.createLandmark(
|
|
73
|
+
`mark${landmarkCounter}`,
|
|
74
|
+
landmarkOptions,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return new Promise((resolve) => {
|
|
78
|
+
transientCamera.gotoLandmark(transientLandmark, {
|
|
79
|
+
duration: Number(duration),
|
|
80
|
+
easing,
|
|
81
|
+
easingFunction,
|
|
82
|
+
});
|
|
83
|
+
camera.gotoLandmark(landmark, {
|
|
84
|
+
duration: Number(duration),
|
|
85
|
+
easing,
|
|
86
|
+
easingFunction,
|
|
87
|
+
onfinish: () => {
|
|
88
|
+
resolve(undefined);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
if (translate) {
|
|
94
|
+
const { dx = 0, dy = 0 } = translate;
|
|
95
|
+
camera.pan(-dx / currentZoom, -dy / currentZoom);
|
|
96
|
+
transientCamera.pan(-dx / currentZoom, -dy / currentZoom);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (rotate) {
|
|
100
|
+
const { angle } = rotate;
|
|
101
|
+
const [x, y] = camera.getPosition();
|
|
102
|
+
if (origin) {
|
|
103
|
+
camera.setPosition(origin.x, origin.y);
|
|
104
|
+
camera.setFocalPoint(origin.x, origin.y);
|
|
105
|
+
transientCamera.setPosition(origin.x, origin.y);
|
|
106
|
+
transientCamera.setFocalPoint(origin.x, origin.y);
|
|
107
|
+
}
|
|
108
|
+
camera.rotate(0, 0, angle);
|
|
109
|
+
transientCamera.rotate(0, 0, angle);
|
|
110
|
+
if (origin) {
|
|
111
|
+
camera.pan(x - origin.x, y - origin.y);
|
|
112
|
+
transientCamera.pan(x - origin.x, y - origin.y);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (zoom) {
|
|
117
|
+
const { ratio } = zoom;
|
|
118
|
+
camera.setZoomByViewportPoint(currentZoom * ratio, [
|
|
119
|
+
origin.x,
|
|
120
|
+
origin.y,
|
|
121
|
+
]);
|
|
122
|
+
transientCamera.setZoomByViewportPoint(currentZoom * ratio, [
|
|
123
|
+
origin.x,
|
|
124
|
+
origin.y,
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
destroy() {}
|
|
131
|
+
}
|