@antv/g6 4.8.14 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g6.min.js +19 -3
- package/esm/constant/index.d.ts +1 -0
- package/esm/constant/index.js +2 -0
- package/esm/constant/index.js.map +1 -0
- package/esm/constant/shape.d.ts +27 -0
- package/esm/constant/shape.js +26 -0
- package/esm/constant/shape.js.map +1 -0
- package/esm/index.d.ts +124 -0
- package/esm/index.js +11 -0
- package/esm/index.js.map +1 -0
- package/esm/item/combo.d.ts +4 -0
- package/esm/item/combo.js +4 -0
- package/esm/item/combo.js.map +1 -0
- package/esm/item/edge.d.ts +54 -0
- package/esm/item/edge.js +113 -0
- package/esm/item/edge.js.map +1 -0
- package/esm/item/item.d.ts +189 -0
- package/esm/item/item.js +636 -0
- package/esm/item/item.js.map +1 -0
- package/esm/item/node.d.ts +54 -0
- package/esm/item/node.js +170 -0
- package/esm/item/node.js.map +1 -0
- package/esm/runtime/controller/data.d.ts +65 -0
- package/esm/runtime/controller/data.js +489 -0
- package/esm/runtime/controller/data.js.map +1 -0
- package/esm/runtime/controller/extension.d.ts +9 -0
- package/esm/runtime/controller/extension.js +11 -0
- package/esm/runtime/controller/extension.js.map +1 -0
- package/esm/runtime/controller/index.d.ts +7 -0
- package/esm/runtime/controller/index.js +8 -0
- package/esm/runtime/controller/index.js.map +1 -0
- package/esm/runtime/controller/interaction.d.ts +51 -0
- package/esm/runtime/controller/interaction.js +259 -0
- package/esm/runtime/controller/interaction.js.map +1 -0
- package/esm/runtime/controller/item.d.ts +101 -0
- package/esm/runtime/controller/item.js +537 -0
- package/esm/runtime/controller/item.js.map +1 -0
- package/esm/runtime/controller/layout.d.ts +30 -0
- package/esm/runtime/controller/layout.js +204 -0
- package/esm/runtime/controller/layout.js.map +1 -0
- package/esm/runtime/controller/plugin.d.ts +34 -0
- package/esm/runtime/controller/plugin.js +140 -0
- package/esm/runtime/controller/plugin.js.map +1 -0
- package/esm/runtime/controller/theme.d.ts +29 -0
- package/esm/runtime/controller/theme.js +54 -0
- package/esm/runtime/controller/theme.js.map +1 -0
- package/esm/runtime/controller/viewport.d.ts +11 -0
- package/esm/runtime/controller/viewport.js +102 -0
- package/esm/runtime/controller/viewport.js.map +1 -0
- package/esm/runtime/graph.d.ts +462 -0
- package/esm/runtime/graph.js +1077 -0
- package/esm/runtime/graph.js.map +1 -0
- package/esm/runtime/hooks.d.ts +33 -0
- package/esm/runtime/hooks.js +74 -0
- package/esm/runtime/hooks.js.map +1 -0
- package/esm/stdlib/behavior/activate-relations.d.ts +62 -0
- package/esm/stdlib/behavior/activate-relations.js +81 -0
- package/esm/stdlib/behavior/activate-relations.js.map +1 -0
- package/esm/stdlib/behavior/brush-select.d.ts +110 -0
- package/esm/stdlib/behavior/brush-select.js +268 -0
- package/esm/stdlib/behavior/brush-select.js.map +1 -0
- package/esm/stdlib/behavior/click-select.d.ts +71 -0
- package/esm/stdlib/behavior/click-select.js +143 -0
- package/esm/stdlib/behavior/click-select.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +82 -0
- package/esm/stdlib/behavior/drag-canvas.js +246 -0
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +80 -0
- package/esm/stdlib/behavior/drag-node.js +250 -0
- package/esm/stdlib/behavior/drag-node.js.map +1 -0
- package/esm/stdlib/behavior/hover-activate.d.ts +41 -0
- package/esm/stdlib/behavior/hover-activate.js +63 -0
- package/esm/stdlib/behavior/hover-activate.js.map +1 -0
- package/esm/stdlib/behavior/lasso-select.d.ts +27 -0
- package/esm/stdlib/behavior/lasso-select.js +79 -0
- package/esm/stdlib/behavior/lasso-select.js.map +1 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +37 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.js +62 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +61 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.js +123 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/track-canvas-3d.d.ts +37 -0
- package/esm/stdlib/behavior/track-canvas-3d.js +62 -0
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +51 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js +74 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +61 -0
- package/esm/stdlib/behavior/zoom-canvas.js +160 -0
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -0
- package/esm/stdlib/data/comboFromNode.d.ts +9 -0
- package/esm/stdlib/data/comboFromNode.js +28 -0
- package/esm/stdlib/data/comboFromNode.js.map +1 -0
- package/esm/stdlib/index.d.ts +80 -0
- package/esm/stdlib/index.js +82 -0
- package/esm/stdlib/index.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +111 -0
- package/esm/stdlib/item/edge/base.js +341 -0
- package/esm/stdlib/item/edge/base.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +1 -0
- package/esm/stdlib/item/edge/index.js +2 -0
- package/esm/stdlib/item/edge/index.js.map +1 -0
- package/esm/stdlib/item/edge/line.d.ts +33 -0
- package/esm/stdlib/item/edge/line.js +45 -0
- package/esm/stdlib/item/edge/line.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +137 -0
- package/esm/stdlib/item/node/base.js +414 -0
- package/esm/stdlib/item/node/base.js.map +1 -0
- package/esm/stdlib/item/node/base3d.d.ts +72 -0
- package/esm/stdlib/item/node/base3d.js +113 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -0
- package/esm/stdlib/item/node/circle.d.ts +30 -0
- package/esm/stdlib/item/node/circle.js +56 -0
- package/esm/stdlib/item/node/circle.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +2 -0
- package/esm/stdlib/item/node/index.js +3 -0
- package/esm/stdlib/item/node/index.js.map +1 -0
- package/esm/stdlib/item/node/sphere.d.ts +33 -0
- package/esm/stdlib/item/node/sphere.js +52 -0
- package/esm/stdlib/item/node/sphere.js.map +1 -0
- package/esm/stdlib/plugin/legend/index.d.ts +121 -0
- package/esm/stdlib/plugin/legend/index.js +587 -0
- package/esm/stdlib/plugin/legend/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +106 -0
- package/esm/stdlib/plugin/minimap/index.js +578 -0
- package/esm/stdlib/plugin/minimap/index.js.map +1 -0
- package/esm/stdlib/selector/lasso.d.ts +15 -0
- package/esm/stdlib/selector/lasso.js +61 -0
- package/esm/stdlib/selector/lasso.js.map +1 -0
- package/esm/stdlib/selector/rect.d.ts +16 -0
- package/esm/stdlib/selector/rect.js +54 -0
- package/esm/stdlib/selector/rect.js.map +1 -0
- package/esm/stdlib/theme/dark.d.ts +3 -0
- package/esm/stdlib/theme/dark.js +279 -0
- package/esm/stdlib/theme/dark.js.map +1 -0
- package/esm/stdlib/theme/light.d.ts +3 -0
- package/esm/stdlib/theme/light.js +274 -0
- package/esm/stdlib/theme/light.js.map +1 -0
- package/esm/stdlib/themeSolver/base.d.ts +15 -0
- package/esm/stdlib/themeSolver/base.js +11 -0
- package/esm/stdlib/themeSolver/base.js.map +1 -0
- package/esm/stdlib/themeSolver/spec.d.ts +37 -0
- package/esm/stdlib/themeSolver/spec.js +66 -0
- package/esm/stdlib/themeSolver/spec.js.map +1 -0
- package/esm/stdlib/themeSolver/subject.d.ts +43 -0
- package/esm/stdlib/themeSolver/subject.js +396 -0
- package/esm/stdlib/themeSolver/subject.js.map +1 -0
- package/esm/types/animate.d.ts +59 -0
- package/esm/types/animate.js +2 -0
- package/esm/types/animate.js.map +1 -0
- package/esm/types/behavior.d.ts +45 -0
- package/esm/types/behavior.js +14 -0
- package/esm/types/behavior.js.map +1 -0
- package/esm/types/combo.d.ts +87 -0
- package/esm/types/combo.js +2 -0
- package/esm/types/combo.js.map +1 -0
- package/esm/types/common.d.ts +6 -0
- package/esm/types/common.js +2 -0
- package/esm/types/common.js.map +1 -0
- package/esm/types/data.d.ts +21 -0
- package/esm/types/data.js +2 -0
- package/esm/types/data.js.map +1 -0
- package/esm/types/edge.d.ts +100 -0
- package/esm/types/edge.js +2 -0
- package/esm/types/edge.js.map +1 -0
- package/esm/types/event.d.ts +30 -0
- package/esm/types/event.js +31 -0
- package/esm/types/event.js.map +1 -0
- package/esm/types/graph.d.ts +445 -0
- package/esm/types/graph.js +2 -0
- package/esm/types/graph.js.map +1 -0
- package/esm/types/hook.d.ts +97 -0
- package/esm/types/hook.js +2 -0
- package/esm/types/hook.js.map +1 -0
- package/esm/types/index.d.ts +10 -0
- package/esm/types/index.js +2 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/item.d.ts +229 -0
- package/esm/types/item.js +16 -0
- package/esm/types/item.js.map +1 -0
- package/esm/types/layout.d.ts +69 -0
- package/esm/types/layout.js +20 -0
- package/esm/types/layout.js.map +1 -0
- package/esm/types/node.d.ts +134 -0
- package/esm/types/node.js +2 -0
- package/esm/types/node.js.map +1 -0
- package/esm/types/plugin.d.ts +40 -0
- package/esm/types/plugin.js +53 -0
- package/esm/types/plugin.js.map +1 -0
- package/esm/types/render.d.ts +1 -0
- package/esm/types/render.js +2 -0
- package/esm/types/render.js.map +1 -0
- package/esm/types/spec.d.ts +65 -0
- package/esm/types/spec.js +2 -0
- package/esm/types/spec.js.map +1 -0
- package/esm/types/stdlib.d.ts +13 -0
- package/esm/types/stdlib.js +2 -0
- package/esm/types/stdlib.js.map +1 -0
- package/esm/types/theme.d.ts +102 -0
- package/esm/types/theme.js +15 -0
- package/esm/types/theme.js.map +1 -0
- package/esm/types/view.d.ts +23 -0
- package/esm/types/view.js +2 -0
- package/esm/types/view.js.map +1 -0
- package/esm/util/animate.d.ts +101 -0
- package/esm/util/animate.js +350 -0
- package/esm/util/animate.js.map +1 -0
- package/esm/util/array.d.ts +20 -0
- package/esm/util/array.js +60 -0
- package/esm/util/array.js.map +1 -0
- package/esm/util/canvas.d.ts +20 -0
- package/esm/util/canvas.js +81 -0
- package/esm/util/canvas.js.map +1 -0
- package/esm/util/event.d.ts +12 -0
- package/esm/util/event.js +26 -0
- package/esm/util/event.js.map +1 -0
- package/esm/util/extend.d.ts +21 -0
- package/esm/util/extend.js +22 -0
- package/esm/util/extend.js.map +1 -0
- package/esm/util/extension.d.ts +10 -0
- package/esm/util/extension.js +24 -0
- package/esm/util/extension.js.map +1 -0
- package/esm/util/index.d.ts +14 -0
- package/esm/util/index.js +5 -0
- package/esm/util/index.js.map +1 -0
- package/esm/util/item.d.ts +14 -0
- package/esm/util/item.js +42 -0
- package/esm/util/item.js.map +1 -0
- package/esm/util/mapper.d.ts +17 -0
- package/esm/util/mapper.js +60 -0
- package/esm/util/mapper.js.map +1 -0
- package/esm/util/math.d.ts +8 -0
- package/esm/util/math.js +9 -0
- package/esm/util/math.js.map +1 -0
- package/esm/util/point.d.ts +61 -0
- package/esm/util/point.js +160 -0
- package/esm/util/point.js.map +1 -0
- package/esm/util/shape.d.ts +105 -0
- package/esm/util/shape.js +504 -0
- package/esm/util/shape.js.map +1 -0
- package/esm/util/shape3d.d.ts +23 -0
- package/esm/util/shape3d.js +147 -0
- package/esm/util/shape3d.js.map +1 -0
- package/esm/util/text.d.ts +18 -0
- package/esm/util/text.js +36 -0
- package/esm/util/text.js.map +1 -0
- package/esm/util/type.d.ts +2 -0
- package/esm/util/type.js +2 -0
- package/esm/util/type.js.map +1 -0
- package/esm/util/zoom.d.ts +17 -0
- package/esm/util/zoom.js +36 -0
- package/esm/util/zoom.js.map +1 -0
- package/lib/constant/index.d.ts +1 -0
- package/lib/constant/index.js +18 -0
- package/lib/constant/index.js.map +1 -0
- package/lib/constant/shape.d.ts +27 -0
- package/lib/constant/shape.js +29 -0
- package/lib/constant/shape.js.map +1 -0
- package/lib/index.d.ts +124 -4
- package/lib/index.js +30 -27
- package/lib/index.js.map +1 -0
- package/lib/item/combo.d.ts +4 -0
- package/lib/item/combo.js +10 -0
- package/lib/item/combo.js.map +1 -0
- package/lib/item/edge.d.ts +54 -0
- package/lib/item/edge.js +119 -0
- package/lib/item/edge.js.map +1 -0
- package/lib/item/item.d.ts +189 -0
- package/lib/item/item.js +639 -0
- package/lib/item/item.js.map +1 -0
- package/lib/item/node.d.ts +54 -0
- package/lib/item/node.js +176 -0
- package/lib/item/node.js.map +1 -0
- package/lib/runtime/controller/data.d.ts +65 -0
- package/lib/runtime/controller/data.js +493 -0
- package/lib/runtime/controller/data.js.map +1 -0
- package/lib/runtime/controller/extension.d.ts +9 -0
- package/lib/runtime/controller/extension.js +15 -0
- package/lib/runtime/controller/extension.js.map +1 -0
- package/lib/runtime/controller/index.d.ts +7 -0
- package/lib/runtime/controller/index.js +24 -0
- package/lib/runtime/controller/index.js.map +1 -0
- package/lib/runtime/controller/interaction.d.ts +51 -0
- package/lib/runtime/controller/interaction.js +263 -0
- package/lib/runtime/controller/interaction.js.map +1 -0
- package/lib/runtime/controller/item.d.ts +101 -0
- package/lib/runtime/controller/item.js +544 -0
- package/lib/runtime/controller/item.js.map +1 -0
- package/lib/runtime/controller/layout.d.ts +30 -0
- package/lib/runtime/controller/layout.js +208 -0
- package/lib/runtime/controller/layout.js.map +1 -0
- package/lib/runtime/controller/plugin.d.ts +34 -0
- package/lib/runtime/controller/plugin.js +147 -0
- package/lib/runtime/controller/plugin.js.map +1 -0
- package/lib/runtime/controller/theme.d.ts +29 -0
- package/lib/runtime/controller/theme.js +61 -0
- package/lib/runtime/controller/theme.js.map +1 -0
- package/lib/runtime/controller/viewport.d.ts +11 -0
- package/lib/runtime/controller/viewport.js +106 -0
- package/lib/runtime/controller/viewport.js.map +1 -0
- package/lib/runtime/graph.d.ts +462 -0
- package/lib/runtime/graph.js +1083 -0
- package/lib/runtime/graph.js.map +1 -0
- package/lib/runtime/hooks.d.ts +33 -0
- package/lib/runtime/hooks.js +77 -0
- package/lib/runtime/hooks.js.map +1 -0
- package/lib/stdlib/behavior/activate-relations.d.ts +62 -0
- package/lib/stdlib/behavior/activate-relations.js +84 -0
- package/lib/stdlib/behavior/activate-relations.js.map +1 -0
- package/lib/stdlib/behavior/brush-select.d.ts +110 -0
- package/lib/stdlib/behavior/brush-select.js +271 -0
- package/lib/stdlib/behavior/brush-select.js.map +1 -0
- package/lib/stdlib/behavior/click-select.d.ts +71 -0
- package/lib/stdlib/behavior/click-select.js +146 -0
- package/lib/stdlib/behavior/click-select.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +82 -0
- package/lib/stdlib/behavior/drag-canvas.js +249 -0
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +80 -0
- package/lib/stdlib/behavior/drag-node.js +253 -0
- package/lib/stdlib/behavior/drag-node.js.map +1 -0
- package/lib/stdlib/behavior/hover-activate.d.ts +41 -0
- package/lib/stdlib/behavior/hover-activate.js +67 -0
- package/lib/stdlib/behavior/hover-activate.js.map +1 -0
- package/lib/stdlib/behavior/lasso-select.d.ts +27 -0
- package/lib/stdlib/behavior/lasso-select.js +85 -0
- package/lib/stdlib/behavior/lasso-select.js.map +1 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +37 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.js +68 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +61 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.js +126 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/track-canvas-3d.d.ts +37 -0
- package/lib/stdlib/behavior/track-canvas-3d.js +68 -0
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +51 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js +77 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +61 -0
- package/lib/stdlib/behavior/zoom-canvas.js +163 -0
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -0
- package/lib/stdlib/data/comboFromNode.d.ts +9 -0
- package/lib/stdlib/data/comboFromNode.js +32 -0
- package/lib/stdlib/data/comboFromNode.js.map +1 -0
- package/lib/stdlib/index.d.ts +80 -0
- package/lib/stdlib/index.js +90 -0
- package/lib/stdlib/index.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +111 -0
- package/lib/stdlib/item/edge/base.js +345 -0
- package/lib/stdlib/item/edge/base.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +1 -0
- package/lib/stdlib/item/edge/index.js +18 -0
- package/lib/stdlib/item/edge/index.js.map +1 -0
- package/lib/stdlib/item/edge/line.d.ts +33 -0
- package/lib/stdlib/item/edge/line.js +49 -0
- package/lib/stdlib/item/edge/line.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +137 -0
- package/lib/stdlib/item/node/base.js +418 -0
- package/lib/stdlib/item/node/base.js.map +1 -0
- package/lib/stdlib/item/node/base3d.d.ts +72 -0
- package/lib/stdlib/item/node/base3d.js +117 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -0
- package/lib/stdlib/item/node/circle.d.ts +30 -0
- package/lib/stdlib/item/node/circle.js +60 -0
- package/lib/stdlib/item/node/circle.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +2 -0
- package/lib/stdlib/item/node/index.js +19 -0
- package/lib/stdlib/item/node/index.js.map +1 -0
- package/lib/stdlib/item/node/sphere.d.ts +33 -0
- package/lib/stdlib/item/node/sphere.js +56 -0
- package/lib/stdlib/item/node/sphere.js.map +1 -0
- package/lib/stdlib/plugin/legend/index.d.ts +121 -0
- package/lib/stdlib/plugin/legend/index.js +590 -0
- package/lib/stdlib/plugin/legend/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +106 -0
- package/lib/stdlib/plugin/minimap/index.js +581 -0
- package/lib/stdlib/plugin/minimap/index.js.map +1 -0
- package/lib/stdlib/selector/lasso.d.ts +15 -0
- package/lib/stdlib/selector/lasso.js +63 -0
- package/lib/stdlib/selector/lasso.js.map +1 -0
- package/lib/stdlib/selector/rect.d.ts +16 -0
- package/lib/stdlib/selector/rect.js +56 -0
- package/lib/stdlib/selector/rect.js.map +1 -0
- package/lib/stdlib/theme/dark.d.ts +3 -0
- package/lib/stdlib/theme/dark.js +281 -0
- package/lib/stdlib/theme/dark.js.map +1 -0
- package/lib/stdlib/theme/light.d.ts +3 -0
- package/lib/stdlib/theme/light.js +276 -0
- package/lib/stdlib/theme/light.js.map +1 -0
- package/lib/stdlib/themeSolver/base.d.ts +15 -0
- package/lib/stdlib/themeSolver/base.js +14 -0
- package/lib/stdlib/themeSolver/base.js.map +1 -0
- package/lib/stdlib/themeSolver/spec.d.ts +37 -0
- package/lib/stdlib/themeSolver/spec.js +72 -0
- package/lib/stdlib/themeSolver/spec.js.map +1 -0
- package/lib/stdlib/themeSolver/subject.d.ts +43 -0
- package/lib/stdlib/themeSolver/subject.js +404 -0
- package/lib/stdlib/themeSolver/subject.js.map +1 -0
- package/lib/types/animate.d.ts +59 -0
- package/lib/types/animate.js +3 -0
- package/lib/types/animate.js.map +1 -0
- package/lib/types/behavior.d.ts +45 -0
- package/lib/types/behavior.js +18 -0
- package/lib/types/behavior.js.map +1 -0
- package/lib/types/combo.d.ts +87 -0
- package/lib/types/combo.js +3 -0
- package/lib/types/combo.js.map +1 -0
- package/lib/types/common.d.ts +6 -0
- package/lib/types/common.js +3 -0
- package/lib/types/common.js.map +1 -0
- package/lib/types/data.d.ts +21 -0
- package/lib/types/data.js +3 -0
- package/lib/types/data.js.map +1 -0
- package/lib/types/edge.d.ts +100 -0
- package/lib/types/edge.js +3 -0
- package/lib/types/edge.js.map +1 -0
- package/lib/types/event.d.ts +30 -0
- package/lib/types/event.js +34 -0
- package/lib/types/event.js.map +1 -0
- package/lib/types/graph.d.ts +445 -0
- package/lib/types/graph.js +3 -0
- package/lib/types/graph.js.map +1 -0
- package/lib/types/hook.d.ts +97 -0
- package/lib/types/hook.js +3 -0
- package/lib/types/hook.js.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +7 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/item.d.ts +229 -0
- package/lib/types/item.js +19 -0
- package/lib/types/item.js.map +1 -0
- package/lib/types/layout.d.ts +69 -0
- package/lib/types/layout.js +25 -0
- package/lib/types/layout.js.map +1 -0
- package/lib/types/node.d.ts +134 -0
- package/lib/types/node.js +3 -0
- package/lib/types/node.js.map +1 -0
- package/lib/types/plugin.d.ts +40 -0
- package/lib/types/plugin.js +57 -0
- package/lib/types/plugin.js.map +1 -0
- package/lib/types/render.d.ts +1 -0
- package/lib/types/render.js +3 -0
- package/lib/types/render.js.map +1 -0
- package/lib/types/spec.d.ts +65 -0
- package/lib/types/spec.js +3 -0
- package/lib/types/spec.js.map +1 -0
- package/lib/types/stdlib.d.ts +13 -0
- package/lib/types/stdlib.js +3 -0
- package/lib/types/stdlib.js.map +1 -0
- package/lib/types/theme.d.ts +102 -0
- package/lib/types/theme.js +19 -0
- package/lib/types/theme.js.map +1 -0
- package/lib/types/view.d.ts +23 -0
- package/lib/types/view.js +3 -0
- package/lib/types/view.js.map +1 -0
- package/lib/util/animate.d.ts +101 -0
- package/lib/util/animate.js +358 -0
- package/lib/util/animate.js.map +1 -0
- package/lib/util/array.d.ts +20 -0
- package/lib/util/array.js +68 -0
- package/lib/util/array.js.map +1 -0
- package/lib/util/canvas.d.ts +20 -0
- package/lib/util/canvas.js +86 -0
- package/lib/util/canvas.js.map +1 -0
- package/lib/util/event.d.ts +12 -0
- package/lib/util/event.js +30 -0
- package/lib/util/event.js.map +1 -0
- package/lib/util/extend.d.ts +21 -0
- package/lib/util/extend.js +29 -0
- package/lib/util/extend.js.map +1 -0
- package/lib/util/extension.d.ts +10 -0
- package/lib/util/extension.js +29 -0
- package/lib/util/extension.js.map +1 -0
- package/lib/util/index.d.ts +14 -0
- package/lib/util/index.js +7 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/item.d.ts +14 -0
- package/lib/util/item.js +47 -0
- package/lib/util/item.js.map +1 -0
- package/lib/util/mapper.d.ts +17 -0
- package/lib/util/mapper.js +63 -0
- package/lib/util/mapper.js.map +1 -0
- package/lib/util/math.d.ts +8 -0
- package/lib/util/math.js +13 -0
- package/lib/util/math.js.map +1 -0
- package/lib/util/point.d.ts +61 -0
- package/lib/util/point.js +169 -0
- package/lib/util/point.js.map +1 -0
- package/lib/util/shape.d.ts +105 -0
- package/lib/util/shape.js +519 -0
- package/lib/util/shape.js.map +1 -0
- package/lib/util/shape3d.d.ts +23 -0
- package/lib/util/shape3d.js +153 -0
- package/lib/util/shape3d.js.map +1 -0
- package/lib/util/text.d.ts +18 -0
- package/lib/util/text.js +41 -0
- package/lib/util/text.js.map +1 -0
- package/lib/util/type.d.ts +2 -0
- package/lib/util/type.js +6 -0
- package/lib/util/type.js.map +1 -0
- package/lib/util/zoom.d.ts +17 -0
- package/lib/util/zoom.js +41 -0
- package/lib/util/zoom.js.map +1 -0
- package/package.json +82 -50
- package/src/constant/index.ts +1 -0
- package/src/constant/shape.ts +33 -0
- package/src/index.ts +13 -0
- package/src/item/combo.ts +5 -0
- package/src/item/edge.ts +177 -0
- package/src/item/item.ts +812 -0
- package/src/item/node.ts +275 -0
- package/src/runtime/controller/data.ts +575 -0
- package/src/runtime/controller/extension.ts +14 -0
- package/src/runtime/controller/index.ts +7 -0
- package/src/runtime/controller/interaction.ts +343 -0
- package/src/runtime/controller/item.ts +780 -0
- package/src/runtime/controller/layout.ts +251 -0
- package/src/runtime/controller/plugin.ts +171 -0
- package/src/runtime/controller/theme.ts +69 -0
- package/src/runtime/controller/viewport.ts +131 -0
- package/src/runtime/graph.ts +1439 -0
- package/src/runtime/hooks.ts +64 -0
- package/src/stdlib/behavior/activate-relations.ts +139 -0
- package/src/stdlib/behavior/brush-select.ts +386 -0
- package/src/stdlib/behavior/click-select.ts +201 -0
- package/src/stdlib/behavior/drag-canvas.ts +333 -0
- package/src/stdlib/behavior/drag-node.ts +402 -0
- package/src/stdlib/behavior/hover-activate.ts +106 -0
- package/src/stdlib/behavior/lasso-select.ts +94 -0
- package/src/stdlib/behavior/orbit-canvas-3d.ts +104 -0
- package/src/stdlib/behavior/rotate-canvas-3d.ts +172 -0
- package/src/stdlib/behavior/track-canvas-3d.ts +104 -0
- package/src/stdlib/behavior/zoom-canvas-3d.ts +127 -0
- package/src/stdlib/behavior/zoom-canvas.ts +244 -0
- package/src/stdlib/data/comboFromNode.ts +28 -0
- package/src/stdlib/index.ts +87 -0
- package/src/stdlib/item/edge/base.ts +571 -0
- package/src/stdlib/item/edge/index.ts +1 -0
- package/src/stdlib/item/edge/line.ts +98 -0
- package/src/stdlib/item/node/base.ts +726 -0
- package/src/stdlib/item/node/base3d.ts +192 -0
- package/src/stdlib/item/node/circle.ts +113 -0
- package/src/stdlib/item/node/index.ts +2 -0
- package/src/stdlib/item/node/sphere.ts +99 -0
- package/src/stdlib/plugin/legend/index.ts +733 -0
- package/src/stdlib/plugin/minimap/index.ts +689 -0
- package/src/stdlib/selector/lasso.ts +75 -0
- package/src/stdlib/selector/rect.ts +78 -0
- package/src/stdlib/theme/dark.ts +340 -0
- package/src/stdlib/theme/light.ts +333 -0
- package/src/stdlib/themeSolver/base.ts +22 -0
- package/src/stdlib/themeSolver/spec.ts +110 -0
- package/src/stdlib/themeSolver/subject.ts +502 -0
- package/src/types/animate.ts +71 -0
- package/src/types/behavior.ts +49 -0
- package/src/types/combo.ts +120 -0
- package/src/types/common.ts +7 -0
- package/src/types/data.ts +35 -0
- package/src/types/edge.ts +119 -0
- package/src/types/event.ts +47 -0
- package/src/types/graph.ts +573 -0
- package/src/types/hook.ts +98 -0
- package/src/types/index.ts +29 -0
- package/src/types/item.ts +324 -0
- package/src/types/layout.ts +138 -0
- package/src/types/node.ts +162 -0
- package/src/types/plugin.ts +77 -0
- package/src/types/render.ts +1 -0
- package/src/types/spec.ts +116 -0
- package/src/types/stdlib.ts +25 -0
- package/src/types/theme.ts +101 -0
- package/src/types/view.ts +31 -0
- package/src/util/animate.ts +430 -0
- package/src/util/array.ts +57 -0
- package/src/util/canvas.ts +95 -0
- package/src/util/event.ts +34 -0
- package/src/util/extend.ts +42 -0
- package/src/util/extension.ts +29 -0
- package/src/util/index.ts +4 -0
- package/src/util/item.ts +70 -0
- package/src/util/mapper.ts +61 -0
- package/src/util/math.ts +9 -0
- package/src/util/point.ts +195 -0
- package/src/util/shape.ts +609 -0
- package/src/util/shape3d.ts +198 -0
- package/src/util/text.ts +49 -0
- package/src/util/type.ts +4 -0
- package/src/util/zoom.ts +39 -0
- package/README.en-US.md +0 -170
- package/README.md +0 -177
- package/dist/g6.min.js.map +0 -1
- package/es/index.d.ts +0 -4
- package/es/index.js +0 -5
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ICamera } from '@antv/g';
|
|
2
|
+
import { Behavior } from '../../types/behavior';
|
|
3
|
+
import { IG6GraphEvent } from '../../types/event';
|
|
4
|
+
import { Point } from '../../types/common';
|
|
5
|
+
|
|
6
|
+
const VALID_TRIGGERS = ['drag', 'directionKeys'];
|
|
7
|
+
|
|
8
|
+
export interface RotateCanvas3DOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The way to tranlate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
|
|
11
|
+
*/
|
|
12
|
+
trigger?: 'drag' | 'directionKeys';
|
|
13
|
+
/**
|
|
14
|
+
* The assistance secondary key to trigger the behavior.
|
|
15
|
+
* If it is not assigned, triggered only by trigger.
|
|
16
|
+
* You can also assigned it with a key on keyboard e.g. 'shift',
|
|
17
|
+
* to make the behavior triggered only when the key is pressing and trigger is happening.
|
|
18
|
+
*/
|
|
19
|
+
secondaryKey?: string;
|
|
20
|
+
/**
|
|
21
|
+
* To speed up rotating while pressing and rotate the canvas by direciton keys (trigger = 'directionKeys').
|
|
22
|
+
*/
|
|
23
|
+
speedUpKey?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether allow zooming canvas on a node/edge/combo.
|
|
26
|
+
*/
|
|
27
|
+
triggerOnItems?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The event name to trigger when drag end.
|
|
30
|
+
*/
|
|
31
|
+
eventName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether allow the behavior happen on the current item.
|
|
34
|
+
*/
|
|
35
|
+
shouldBegin?: (event: IG6GraphEvent) => boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const DEFAULT_OPTIONS: Required<RotateCanvas3DOptions> = {
|
|
39
|
+
trigger: 'drag',
|
|
40
|
+
secondaryKey: '',
|
|
41
|
+
speedUpKey: 'shift',
|
|
42
|
+
eventName: '',
|
|
43
|
+
triggerOnItems: false,
|
|
44
|
+
shouldBegin: () => true,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const MOTION_FACTOR = 10;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Rotate the 3d canvas with the center of the graph.
|
|
51
|
+
*/
|
|
52
|
+
export default class RotateCanvas3D extends Behavior {
|
|
53
|
+
options: RotateCanvas3DOptions;
|
|
54
|
+
|
|
55
|
+
public pointStartAt: Point;
|
|
56
|
+
public keydown: boolean;
|
|
57
|
+
public speedUpKeydown: boolean;
|
|
58
|
+
|
|
59
|
+
constructor(options: Partial<RotateCanvas3DOptions>) {
|
|
60
|
+
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
61
|
+
if (!VALID_TRIGGERS.includes(finalOptions.trigger)) {
|
|
62
|
+
console.warn(
|
|
63
|
+
`The trigger ${
|
|
64
|
+
finalOptions.trigger
|
|
65
|
+
} is not valid for rotate-canvas-3d behavior, "drag" will take effect instead. Only "${VALID_TRIGGERS.join(
|
|
66
|
+
'", "',
|
|
67
|
+
)}" are available.`,
|
|
68
|
+
);
|
|
69
|
+
finalOptions.trigger = 'drag';
|
|
70
|
+
}
|
|
71
|
+
super(finalOptions);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getEvents = () => {
|
|
75
|
+
if (this.options.trigger === 'drag') {
|
|
76
|
+
return {
|
|
77
|
+
pointerdown: this.onPointerDown,
|
|
78
|
+
pointermove: this.onPointerMove,
|
|
79
|
+
pointerup: this.onPointerUp,
|
|
80
|
+
keydown: this.onKeydown,
|
|
81
|
+
keyup: this.onKeyup,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
keydown: this.onKeydown,
|
|
86
|
+
keyup: this.onKeyup,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
public onPointerDown(event) {
|
|
91
|
+
const { triggerOnItems, shouldBegin } = this.options;
|
|
92
|
+
if ((event.itemId && !triggerOnItems) || !shouldBegin(event)) return;
|
|
93
|
+
const { client } = event;
|
|
94
|
+
this.pointStartAt = {
|
|
95
|
+
x: client.x,
|
|
96
|
+
y: client.y,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public onPointerMove(event) {
|
|
101
|
+
if (!this.pointStartAt) return;
|
|
102
|
+
const { shouldBegin, secondaryKey } = this.options;
|
|
103
|
+
|
|
104
|
+
if (secondaryKey && !this.keydown) return;
|
|
105
|
+
if (!shouldBegin(event)) return;
|
|
106
|
+
|
|
107
|
+
const { client } = event;
|
|
108
|
+
const diff = {
|
|
109
|
+
x: client.x - this.pointStartAt.x,
|
|
110
|
+
y: client.y - this.pointStartAt.y,
|
|
111
|
+
};
|
|
112
|
+
const { graph } = this;
|
|
113
|
+
const camera = graph.canvas.getCamera();
|
|
114
|
+
this.rotate(camera, diff.x, diff.y);
|
|
115
|
+
|
|
116
|
+
this.pointStartAt = {
|
|
117
|
+
x: client.x,
|
|
118
|
+
y: client.y,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public onPointerUp(event) {
|
|
123
|
+
this.pointStartAt = undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public onKeydown(event) {
|
|
127
|
+
const { key } = event;
|
|
128
|
+
const { trigger, secondaryKey, speedUpKey } = this.options;
|
|
129
|
+
if (trigger === 'directionKeys') {
|
|
130
|
+
if (!secondaryKey || (secondaryKey && this.keydown)) {
|
|
131
|
+
const { graph } = this;
|
|
132
|
+
const camera = graph.canvas.getCamera();
|
|
133
|
+
const speed = 1 * (this.speedUpKeydown ? 10 : 1);
|
|
134
|
+
if (key === 'ArrowUp') camera.pan(0, speed);
|
|
135
|
+
if (key === 'ArrowDown') camera.pan(0, -speed);
|
|
136
|
+
if (key === 'ArrowLeft') camera.pan(speed, 0);
|
|
137
|
+
if (key === 'ArrowRight') camera.pan(-speed, 0);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (secondaryKey === key.toLowerCase()) {
|
|
141
|
+
this.keydown = true;
|
|
142
|
+
}
|
|
143
|
+
if (speedUpKey === key.toLowerCase()) {
|
|
144
|
+
this.speedUpKeydown = true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public onKeyup(event) {
|
|
149
|
+
const { key } = event;
|
|
150
|
+
const { secondaryKey, speedUpKey } = this.options;
|
|
151
|
+
if (secondaryKey === key.toLowerCase()) this.keydown = false;
|
|
152
|
+
if (speedUpKey === key.toLowerCase()) this.speedUpKeydown = false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private rotate(camera: ICamera, rx: number, ry: number) {
|
|
156
|
+
const { width, height } = this.graph.canvas.getConfig();
|
|
157
|
+
const dx = 20.0 / height;
|
|
158
|
+
const dy = 20.0 / width;
|
|
159
|
+
let motionFactorX = MOTION_FACTOR;
|
|
160
|
+
let motionFactorY = MOTION_FACTOR;
|
|
161
|
+
if (rx * rx > 2 * ry * ry) {
|
|
162
|
+
motionFactorY *= 0.5;
|
|
163
|
+
} else if (ry * ry > 2 * rx * rx) {
|
|
164
|
+
motionFactorX *= 0.5;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const rotX = rx * dx * motionFactorX;
|
|
168
|
+
const rotY = ry * dy * motionFactorY;
|
|
169
|
+
|
|
170
|
+
camera.rotate(rotX, -rotY, 0);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { IG6GraphEvent } from '../../types/event';
|
|
2
|
+
import RotateCanvas3D from './rotate-canvas-3d';
|
|
3
|
+
import { CameraType } from '@antv/g';
|
|
4
|
+
|
|
5
|
+
// TODO: truck canvas
|
|
6
|
+
|
|
7
|
+
const VALID_TRIGGERS = ['drag', 'directionKeys'];
|
|
8
|
+
|
|
9
|
+
export interface TrackCanvas3DOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The way to tranlate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
|
|
12
|
+
*/
|
|
13
|
+
trigger?: 'drag' | 'directionKeys';
|
|
14
|
+
/**
|
|
15
|
+
* The assistance secondary key to trigger the behavior.
|
|
16
|
+
* If it is not assigned, triggered only by trigger.
|
|
17
|
+
* You can also assigned it with a key on keyboard e.g. 'shift',
|
|
18
|
+
* to make the behavior triggered only when the key is pressing and trigger is happening.
|
|
19
|
+
*/
|
|
20
|
+
secondaryKey?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The event name to trigger when drag end.
|
|
23
|
+
*/
|
|
24
|
+
eventName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether allow the behavior happen on the current item.
|
|
27
|
+
*/
|
|
28
|
+
shouldBegin?: (event: IG6GraphEvent) => boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const DEFAULT_OPTIONS: Required<TrackCanvas3DOptions> = {
|
|
32
|
+
trigger: 'directionKeys',
|
|
33
|
+
secondaryKey: '',
|
|
34
|
+
eventName: '',
|
|
35
|
+
shouldBegin: () => true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Translate the 3d canvas along the plane parallel to the screen.
|
|
40
|
+
*/
|
|
41
|
+
export default class TrackCanvas3D extends RotateCanvas3D {
|
|
42
|
+
options: TrackCanvas3DOptions;
|
|
43
|
+
|
|
44
|
+
private previousType: CameraType;
|
|
45
|
+
|
|
46
|
+
constructor(options: Partial<TrackCanvas3DOptions>) {
|
|
47
|
+
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
48
|
+
if (!VALID_TRIGGERS.includes(finalOptions.trigger)) {
|
|
49
|
+
console.warn(
|
|
50
|
+
`The trigger ${
|
|
51
|
+
finalOptions.trigger
|
|
52
|
+
} is not valid for track-canvas-3d behavior, "drag" will take effect instead. Only "${VALID_TRIGGERS.join(
|
|
53
|
+
'", "',
|
|
54
|
+
)}" are available.`,
|
|
55
|
+
);
|
|
56
|
+
finalOptions.trigger = 'drag';
|
|
57
|
+
}
|
|
58
|
+
super(finalOptions);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private setTrackingCamera() {
|
|
62
|
+
const { graph } = this;
|
|
63
|
+
const camera: any = graph.canvas.getCamera();
|
|
64
|
+
this.previousType = camera.type;
|
|
65
|
+
graph.canvas.getCamera().setType(CameraType.TRACKING);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private restoreCameraType() {
|
|
69
|
+
if (this.previousType !== undefined) {
|
|
70
|
+
const { graph } = this;
|
|
71
|
+
graph.canvas.getCamera().setType(this.previousType);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public onPointerDown(event) {
|
|
76
|
+
this.setTrackingCamera();
|
|
77
|
+
super.onPointerDown(event);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public onPointerUp(event) {
|
|
81
|
+
this.restoreCameraType();
|
|
82
|
+
super.onPointerUp(event);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public onKeydown(event) {
|
|
86
|
+
const { trigger, secondaryKey } = this.options;
|
|
87
|
+
if (trigger === 'directionKeys') {
|
|
88
|
+
if (!secondaryKey || (secondaryKey && this.keydown)) {
|
|
89
|
+
this.setTrackingCamera();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
super.onKeydown(event);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public onKeyup(event) {
|
|
96
|
+
const { trigger, secondaryKey } = this.options;
|
|
97
|
+
if (trigger === 'directionKeys') {
|
|
98
|
+
if (!secondaryKey || (secondaryKey && this.keydown)) {
|
|
99
|
+
this.restoreCameraType();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
super.onKeyup(event);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ID } from '@antv/graphlib';
|
|
2
|
+
import { debounce, uniq } from '@antv/util';
|
|
3
|
+
import { EdgeModel } from '../../types';
|
|
4
|
+
import { Behavior } from '../../types/behavior';
|
|
5
|
+
import { IG6GraphEvent } from '../../types/event';
|
|
6
|
+
import { Point } from '../../types/common';
|
|
7
|
+
|
|
8
|
+
const VALID_TRIGGERS = ['wheel', 'upDownKeys'];
|
|
9
|
+
|
|
10
|
+
export interface ZoomCanvas3DOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The way to tranlate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
|
|
13
|
+
*/
|
|
14
|
+
trigger?: 'wheel' | 'upDownKeys';
|
|
15
|
+
/**
|
|
16
|
+
* The assistance secondary key to trigger the behavior.
|
|
17
|
+
* If it is not assigned, triggered only by trigger.
|
|
18
|
+
* You can also assigned it with a key on keyboard e.g. 'shift',
|
|
19
|
+
* to make the behavior triggered only when the key is pressing and trigger is happening.
|
|
20
|
+
*/
|
|
21
|
+
secondaryKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Sensitivity of zooming.
|
|
24
|
+
*/
|
|
25
|
+
sensitivity?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether allow zooming canvas on a node/edge/combo.
|
|
28
|
+
*/
|
|
29
|
+
triggerOnItems?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The event name to trigger when drag end.
|
|
32
|
+
*/
|
|
33
|
+
eventName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether allow the behavior happen on the current item.
|
|
36
|
+
*/
|
|
37
|
+
shouldBegin?: (event: IG6GraphEvent) => boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const DEFAULT_OPTIONS: Required<ZoomCanvas3DOptions> = {
|
|
41
|
+
trigger: 'wheel',
|
|
42
|
+
secondaryKey: '',
|
|
43
|
+
eventName: '',
|
|
44
|
+
sensitivity: 1,
|
|
45
|
+
triggerOnItems: true,
|
|
46
|
+
shouldBegin: () => true,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Zoom the 3d canvas along the ray vertical to the screen.
|
|
51
|
+
*/
|
|
52
|
+
export default class ZoomCanvas3D extends Behavior {
|
|
53
|
+
options: ZoomCanvas3DOptions;
|
|
54
|
+
|
|
55
|
+
private keydown: boolean;
|
|
56
|
+
|
|
57
|
+
constructor(options: Partial<ZoomCanvas3DOptions>) {
|
|
58
|
+
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
59
|
+
if (!VALID_TRIGGERS.includes(finalOptions.trigger)) {
|
|
60
|
+
console.warn(
|
|
61
|
+
`The trigger ${
|
|
62
|
+
finalOptions.trigger
|
|
63
|
+
} is not valid for zoom-canvas-3d behavior, "wheel" will take effect instead. Only "${VALID_TRIGGERS.join(
|
|
64
|
+
'", "',
|
|
65
|
+
)}" are available.`,
|
|
66
|
+
);
|
|
67
|
+
finalOptions.trigger = 'wheel';
|
|
68
|
+
}
|
|
69
|
+
super(finalOptions);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getEvents = () => {
|
|
73
|
+
if (this.options.trigger === 'wheel') {
|
|
74
|
+
return {
|
|
75
|
+
wheel: this.onWheel,
|
|
76
|
+
keydown: this.onKeydown,
|
|
77
|
+
keyup: this.onKeyup,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
keydown: this.onKeydown,
|
|
82
|
+
keyup: this.onKeyup,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
public onWheel(event) {
|
|
87
|
+
const { graph, options } = this;
|
|
88
|
+
const {
|
|
89
|
+
secondaryKey,
|
|
90
|
+
triggerOnItems,
|
|
91
|
+
eventName,
|
|
92
|
+
sensitivity = 1,
|
|
93
|
+
shouldBegin,
|
|
94
|
+
} = options;
|
|
95
|
+
if (event.itemId && !triggerOnItems) return;
|
|
96
|
+
if (!shouldBegin(event)) return;
|
|
97
|
+
if (secondaryKey && !this.keydown) return;
|
|
98
|
+
const camera = graph.canvas.getCamera();
|
|
99
|
+
|
|
100
|
+
camera.dolly(event.deltaY * sensitivity);
|
|
101
|
+
|
|
102
|
+
// Emit event.
|
|
103
|
+
if (eventName) {
|
|
104
|
+
graph.emit(eventName, {
|
|
105
|
+
zoom: camera.getZoom(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public onKeydown(event) {
|
|
111
|
+
const { key } = event;
|
|
112
|
+
const { trigger, secondaryKey } = this.options;
|
|
113
|
+
if (trigger === 'upDownKeys') {
|
|
114
|
+
if (key === 'ArrowUp') this.onWheel({ deltaY: -1 });
|
|
115
|
+
if (key === 'ArrowDown') this.onWheel({ deltaY: 1 });
|
|
116
|
+
}
|
|
117
|
+
if (secondaryKey === key.toLowerCase()) {
|
|
118
|
+
this.keydown = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public onKeyup(event) {
|
|
123
|
+
const { key } = event;
|
|
124
|
+
const { secondaryKey } = this.options;
|
|
125
|
+
if (secondaryKey === key.toLowerCase()) this.keydown = false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { ID, IG6GraphEvent } from 'types';
|
|
2
|
+
import { Behavior } from '../../types/behavior';
|
|
3
|
+
|
|
4
|
+
const VALID_TRIGGERS = ['wheel', 'upDownKeys'];
|
|
5
|
+
export interface ZoomCanvasOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether enable optimize strategies, which will hide all the shapes excluding node keyShape while zooming.
|
|
8
|
+
* TODO: optimize when trigger is upDownKeys
|
|
9
|
+
*/
|
|
10
|
+
enableOptimize?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether allow trigger this behavior when wheeling start on nodes / edges / combos.
|
|
13
|
+
*/
|
|
14
|
+
triggerOnItems?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The trigger for the behavior, 'wheel' by default. 'upDownKeys' means trigger this behavior by up / down keys on keyboard.
|
|
17
|
+
*/
|
|
18
|
+
trigger?: 'wheel' | 'upDownKeys';
|
|
19
|
+
/**
|
|
20
|
+
* The assistant secondary key on keyboard. If it is not assigned, the behavior will be triggered when trigger happens.
|
|
21
|
+
*/
|
|
22
|
+
secondaryKey?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The key on keyboard to speed up translating while pressing and zoom-canvas by direction keys. The trigger should be 'directionKeys' for this option.
|
|
25
|
+
*/
|
|
26
|
+
speedUpKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The sensitivity / speed of zooming.
|
|
29
|
+
*/
|
|
30
|
+
sensitivity?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The event name to trigger when zoom end.
|
|
33
|
+
*/
|
|
34
|
+
eventName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether allow the behavior happen on the current item.
|
|
37
|
+
*/
|
|
38
|
+
shouldBegin?: (event: IG6GraphEvent) => boolean;
|
|
39
|
+
|
|
40
|
+
// TODO: fixSelectedItems, optimizeZoom
|
|
41
|
+
// fixSelectedItems: {
|
|
42
|
+
// fixAll: false,
|
|
43
|
+
// fixLineWidth: false,
|
|
44
|
+
// fixLabel: false,
|
|
45
|
+
// fixState: 'selected',
|
|
46
|
+
// },
|
|
47
|
+
// optimizeZoom: hide shapes when zoom ratio is smaller than optimizeZoom
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
|
|
51
|
+
enableOptimize: false,
|
|
52
|
+
triggerOnItems: true,
|
|
53
|
+
sensitivity: 2,
|
|
54
|
+
trigger: 'wheel',
|
|
55
|
+
secondaryKey: '',
|
|
56
|
+
speedUpKey: 'shift',
|
|
57
|
+
eventName: '',
|
|
58
|
+
shouldBegin: () => true,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default class ZoomCanvas extends Behavior {
|
|
62
|
+
options: ZoomCanvasOptions;
|
|
63
|
+
|
|
64
|
+
private zooming: boolean; // pointerdown + pointermove a distance
|
|
65
|
+
private keydown: boolean;
|
|
66
|
+
private speedupKeydown: boolean;
|
|
67
|
+
private hiddenEdgeIds: ID[];
|
|
68
|
+
private hiddenNodeIds: ID[];
|
|
69
|
+
private zoomTimer: NodeJS.Timeout;
|
|
70
|
+
|
|
71
|
+
constructor(options: Partial<ZoomCanvasOptions>) {
|
|
72
|
+
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
73
|
+
if (!VALID_TRIGGERS.includes(finalOptions.trigger)) {
|
|
74
|
+
console.warn(
|
|
75
|
+
`The trigger ${finalOptions.trigger} is not valid, 'wheel' will take effect.`,
|
|
76
|
+
);
|
|
77
|
+
finalOptions.trigger = 'wheel';
|
|
78
|
+
}
|
|
79
|
+
super(finalOptions);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getEvents() {
|
|
83
|
+
this.graph.canvas
|
|
84
|
+
.getContextService()
|
|
85
|
+
.getDomElement()
|
|
86
|
+
.addEventListener(
|
|
87
|
+
'wheel',
|
|
88
|
+
(e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
},
|
|
91
|
+
{ passive: false },
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (this.options.trigger === 'upDownKeys') {
|
|
95
|
+
return {
|
|
96
|
+
keydown: this.onKeydown,
|
|
97
|
+
keyup: this.onKeyup,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
wheel: this.onWheel,
|
|
102
|
+
keydown: this.onKeydown,
|
|
103
|
+
keyup: this.onKeyup,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private hideShapes() {
|
|
108
|
+
const { graph } = this;
|
|
109
|
+
if (this.options.enableOptimize) {
|
|
110
|
+
this.hiddenEdgeIds = graph
|
|
111
|
+
.getAllEdgesData()
|
|
112
|
+
.map((edge) => edge.id)
|
|
113
|
+
.filter((id) => graph.getItemVisible(id) === true);
|
|
114
|
+
graph.hideItem(this.hiddenEdgeIds);
|
|
115
|
+
this.hiddenNodeIds = graph
|
|
116
|
+
.getAllNodesData()
|
|
117
|
+
.map((node) => node.id)
|
|
118
|
+
.filter((id) => graph.getItemVisible(id) === true);
|
|
119
|
+
// draw node's keyShapes on transient, and then hidden the real nodes;
|
|
120
|
+
this.hiddenNodeIds.forEach((id) => {
|
|
121
|
+
graph.drawTransient('node', id, {
|
|
122
|
+
onlyDrawKeyShape: true,
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
graph.hideItem(this.hiddenNodeIds);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private endZoom() {
|
|
130
|
+
const { graph, hiddenEdgeIds, hiddenNodeIds } = this;
|
|
131
|
+
const { enableOptimize } = this.options;
|
|
132
|
+
this.zooming = false;
|
|
133
|
+
if (enableOptimize) {
|
|
134
|
+
// restore hidden items
|
|
135
|
+
if (hiddenEdgeIds) {
|
|
136
|
+
graph.showItem(hiddenEdgeIds);
|
|
137
|
+
}
|
|
138
|
+
if (hiddenNodeIds) {
|
|
139
|
+
hiddenNodeIds.forEach((id) => {
|
|
140
|
+
graph.drawTransient('node', id, { action: 'remove' });
|
|
141
|
+
});
|
|
142
|
+
graph.showItem(hiddenNodeIds);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
this.hiddenEdgeIds = [];
|
|
146
|
+
this.hiddenNodeIds = [];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public onWheel(event) {
|
|
150
|
+
const { graph, keydown } = this;
|
|
151
|
+
const { deltaY, client, itemId } = event;
|
|
152
|
+
const {
|
|
153
|
+
eventName,
|
|
154
|
+
sensitivity,
|
|
155
|
+
secondaryKey,
|
|
156
|
+
triggerOnItems,
|
|
157
|
+
shouldBegin,
|
|
158
|
+
} = this.options;
|
|
159
|
+
|
|
160
|
+
// TODO: CANVAS
|
|
161
|
+
const isOnItem = itemId && itemId !== 'CANVAS';
|
|
162
|
+
if (
|
|
163
|
+
(secondaryKey && !keydown) ||
|
|
164
|
+
(isOnItem && !triggerOnItems) ||
|
|
165
|
+
!shouldBegin(event)
|
|
166
|
+
) {
|
|
167
|
+
this.endZoom();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// begin zooming
|
|
172
|
+
if (!this.zooming) {
|
|
173
|
+
this.hideShapes();
|
|
174
|
+
this.zooming = true;
|
|
175
|
+
}
|
|
176
|
+
let zoomRatio = 1;
|
|
177
|
+
if (deltaY < 0) zoomRatio = (100 + sensitivity) / 100;
|
|
178
|
+
if (deltaY > 0) zoomRatio = 100 / (100 + sensitivity);
|
|
179
|
+
// TODO: the zoom center is wrong?
|
|
180
|
+
graph.zoom(zoomRatio, { x: client.x, y: client.y });
|
|
181
|
+
|
|
182
|
+
clearTimeout(this.zoomTimer);
|
|
183
|
+
this.zoomTimer = setTimeout(() => {
|
|
184
|
+
this.endZoom();
|
|
185
|
+
}, 300);
|
|
186
|
+
|
|
187
|
+
// Emit event.
|
|
188
|
+
if (eventName) {
|
|
189
|
+
graph.emit(eventName, { zoom: { ratio: zoomRatio } });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public onKeydown(event) {
|
|
194
|
+
const { key } = event;
|
|
195
|
+
const {
|
|
196
|
+
secondaryKey,
|
|
197
|
+
trigger,
|
|
198
|
+
speedUpKey,
|
|
199
|
+
eventName,
|
|
200
|
+
sensitivity,
|
|
201
|
+
shouldBegin,
|
|
202
|
+
} = this.options;
|
|
203
|
+
if (secondaryKey && secondaryKey === key.toLowerCase()) {
|
|
204
|
+
this.keydown = true;
|
|
205
|
+
}
|
|
206
|
+
if (speedUpKey && speedUpKey === key.toLowerCase()) {
|
|
207
|
+
this.speedupKeydown = true;
|
|
208
|
+
}
|
|
209
|
+
if (trigger === 'upDownKeys') {
|
|
210
|
+
if (secondaryKey && !this.keydown) return;
|
|
211
|
+
if (!shouldBegin(event)) return;
|
|
212
|
+
const { graph, speedupKeydown } = this;
|
|
213
|
+
const speed = speedupKeydown ? 20 : 1;
|
|
214
|
+
let zoomRatio = 1;
|
|
215
|
+
switch (key) {
|
|
216
|
+
case 'ArrowUp':
|
|
217
|
+
// Zoom in.
|
|
218
|
+
zoomRatio = (100 + sensitivity * speed) / 100;
|
|
219
|
+
break;
|
|
220
|
+
case 'ArrowDown':
|
|
221
|
+
// Zoom out.
|
|
222
|
+
zoomRatio = 100 / (100 + sensitivity * speed);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (zoomRatio !== 1) {
|
|
226
|
+
graph.zoom(zoomRatio);
|
|
227
|
+
if (eventName) {
|
|
228
|
+
graph.emit(eventName, { zoom: { ratio: zoomRatio } });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public onKeyup(event) {
|
|
235
|
+
const { key } = event;
|
|
236
|
+
const { secondaryKey, speedUpKey } = this.options;
|
|
237
|
+
if (secondaryKey && secondaryKey === key.toLowerCase()) {
|
|
238
|
+
this.keydown = false;
|
|
239
|
+
}
|
|
240
|
+
if (speedUpKey && speedUpKey === key.toLowerCase()) {
|
|
241
|
+
this.speedupKeydown = false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GraphData } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A demo, generates combo data from nodes
|
|
5
|
+
*/
|
|
6
|
+
export const comboFromNode = (data: GraphData) => {
|
|
7
|
+
const { nodes } = data;
|
|
8
|
+
const combos = [];
|
|
9
|
+
const nodeMap = {};
|
|
10
|
+
const comboMap = {};
|
|
11
|
+
nodes.forEach((node) => (nodeMap[node.id] = node));
|
|
12
|
+
nodes.forEach((node) => {
|
|
13
|
+
const { parentId } = node.data || {};
|
|
14
|
+
if (parentId) {
|
|
15
|
+
if (nodeMap[parentId]) {
|
|
16
|
+
combos.push(nodeMap[parentId]);
|
|
17
|
+
} else {
|
|
18
|
+
combos.push({ id: parentId });
|
|
19
|
+
}
|
|
20
|
+
comboMap[parentId] = node;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
nodes: nodes.filter((node) => !comboMap[node.id]),
|
|
25
|
+
edges: data.edges,
|
|
26
|
+
combos,
|
|
27
|
+
};
|
|
28
|
+
};
|