@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,1083 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const event_emitter_1 = __importDefault(require("@antv/event-emitter"));
|
|
16
|
+
const g_1 = require("@antv/g");
|
|
17
|
+
const util_1 = require("@antv/util");
|
|
18
|
+
const canvas_1 = require("../util/canvas");
|
|
19
|
+
const shape_1 = require("../util/shape");
|
|
20
|
+
const controller_1 = require("./controller");
|
|
21
|
+
const plugin_1 = require("./controller/plugin");
|
|
22
|
+
const hooks_1 = __importDefault(require("./hooks"));
|
|
23
|
+
/**
|
|
24
|
+
* Disable CSS parsing for better performance.
|
|
25
|
+
*/
|
|
26
|
+
g_1.runtime.enableCSSParsing = false;
|
|
27
|
+
class Graph extends event_emitter_1.default {
|
|
28
|
+
constructor(spec) {
|
|
29
|
+
super();
|
|
30
|
+
this.defaultSpecification = {
|
|
31
|
+
theme: {
|
|
32
|
+
type: 'spec',
|
|
33
|
+
base: 'light',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
// TODO: analyse cfg
|
|
37
|
+
this.specification = Object.assign({}, this.defaultSpecification, spec);
|
|
38
|
+
this.initHooks();
|
|
39
|
+
this.initCanvas();
|
|
40
|
+
this.initControllers();
|
|
41
|
+
this.hooks.init.emit({
|
|
42
|
+
canvases: {
|
|
43
|
+
background: this.backgroundCanvas,
|
|
44
|
+
main: this.canvas,
|
|
45
|
+
transient: this.transientCanvas,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const { data } = spec;
|
|
49
|
+
if (data) {
|
|
50
|
+
// TODO: handle multiple type data configs
|
|
51
|
+
this.read(data);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Initialize the controllers for different plugins.
|
|
56
|
+
*/
|
|
57
|
+
initControllers() {
|
|
58
|
+
this.dataController = new controller_1.DataController(this);
|
|
59
|
+
this.interactionController = new controller_1.InteractionController(this);
|
|
60
|
+
this.layoutController = new controller_1.LayoutController(this);
|
|
61
|
+
this.themeController = new controller_1.ThemeController(this);
|
|
62
|
+
this.itemController = new controller_1.ItemController(this);
|
|
63
|
+
this.viewportController = new controller_1.ViewportController(this);
|
|
64
|
+
this.extensionController = new controller_1.ExtensionController(this);
|
|
65
|
+
this.pluginController = new plugin_1.PluginController(this);
|
|
66
|
+
}
|
|
67
|
+
initCanvas() {
|
|
68
|
+
const { renderer, container, width, height } = this.specification;
|
|
69
|
+
let pixelRatio;
|
|
70
|
+
if (renderer && !(0, util_1.isString)(renderer)) {
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
this.rendererType = renderer.type || 'canvas';
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
pixelRatio = renderer.pixelRatio;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
this.rendererType = renderer || 'canvas';
|
|
79
|
+
}
|
|
80
|
+
const containerDOM = (0, util_1.isString)(container)
|
|
81
|
+
? document.getElementById(container)
|
|
82
|
+
: container;
|
|
83
|
+
if (!containerDOM) {
|
|
84
|
+
console.error(`Create graph failed. The container for graph ${containerDOM} is not exist.`);
|
|
85
|
+
this.destroy();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.container = containerDOM;
|
|
89
|
+
const size = [width, height];
|
|
90
|
+
if (size[0] === undefined) {
|
|
91
|
+
size[0] = containerDOM.scrollWidth;
|
|
92
|
+
}
|
|
93
|
+
if (size[1] === undefined) {
|
|
94
|
+
size[1] = containerDOM.scrollHeight;
|
|
95
|
+
}
|
|
96
|
+
this.backgroundCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
97
|
+
this.canvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
98
|
+
this.transientCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio, true, {
|
|
99
|
+
pointerEvents: 'none',
|
|
100
|
+
});
|
|
101
|
+
Promise.all([this.backgroundCanvas, this.canvas, this.transientCanvas].map((canvas) => canvas.ready)).then(() => (this.canvasReady = true));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Change the renderer at runtime.
|
|
105
|
+
* @param type renderer name
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
changeRenderer(type) {
|
|
109
|
+
this.rendererType = type || 'canvas';
|
|
110
|
+
(0, canvas_1.changeRenderer)(this.rendererType, this.canvas);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Initialize the hooks for graph's lifecycles.
|
|
114
|
+
*/
|
|
115
|
+
initHooks() {
|
|
116
|
+
this.hooks = {
|
|
117
|
+
init: new hooks_1.default({ name: 'init' }),
|
|
118
|
+
datachange: new hooks_1.default({
|
|
119
|
+
name: 'datachange',
|
|
120
|
+
}),
|
|
121
|
+
itemchange: new hooks_1.default({ name: 'itemchange' }),
|
|
122
|
+
render: new hooks_1.default({
|
|
123
|
+
name: 'render',
|
|
124
|
+
}),
|
|
125
|
+
layout: new hooks_1.default({ name: 'layout' }),
|
|
126
|
+
viewportchange: new hooks_1.default({ name: 'viewport' }),
|
|
127
|
+
modechange: new hooks_1.default({ name: 'modechange' }),
|
|
128
|
+
behaviorchange: new hooks_1.default({ name: 'behaviorchange' }),
|
|
129
|
+
itemstatechange: new hooks_1.default({
|
|
130
|
+
name: 'itemstatechange',
|
|
131
|
+
}),
|
|
132
|
+
itemvisibilitychange: new hooks_1.default({
|
|
133
|
+
name: 'itemvisibilitychange',
|
|
134
|
+
}),
|
|
135
|
+
transientupdate: new hooks_1.default({ name: 'transientupdate' }),
|
|
136
|
+
pluginchange: new hooks_1.default({ name: 'pluginchange' }),
|
|
137
|
+
themechange: new hooks_1.default({ name: 'init' }),
|
|
138
|
+
destroy: new hooks_1.default({ name: 'destroy' }),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Update the specs(configurations).
|
|
143
|
+
*/
|
|
144
|
+
updateSpecification(spec) {
|
|
145
|
+
return Object.assign(this.specification, spec);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Update the theme specs (configurations).
|
|
149
|
+
*/
|
|
150
|
+
updateTheme(theme) {
|
|
151
|
+
this.specification.theme = theme;
|
|
152
|
+
// const { specification } = this.themeController;
|
|
153
|
+
// notifiying the themeController
|
|
154
|
+
this.hooks.themechange.emit({
|
|
155
|
+
canvases: {
|
|
156
|
+
background: this.backgroundCanvas,
|
|
157
|
+
main: this.canvas,
|
|
158
|
+
transient: this.transientCanvas,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
// theme is formatted by themeController, notify the item controller to update the items
|
|
162
|
+
this.hooks.themechange.emit({
|
|
163
|
+
theme: this.themeController.specification,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get the copy of specs(configurations).
|
|
168
|
+
* @returns graph specs
|
|
169
|
+
*/
|
|
170
|
+
getSpecification() {
|
|
171
|
+
return this.specification;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Input data and render the graph.
|
|
175
|
+
* If there is old data, diffs and changes it.
|
|
176
|
+
* @param data
|
|
177
|
+
* @returns
|
|
178
|
+
* @group Data
|
|
179
|
+
*/
|
|
180
|
+
read(data) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
this.hooks.datachange.emit({ data, type: 'replace' });
|
|
183
|
+
const emitRender = () => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
this.hooks.render.emit({
|
|
185
|
+
graphCore: this.dataController.graphCore,
|
|
186
|
+
theme: this.themeController.specification,
|
|
187
|
+
transientCanvas: this.transientCanvas,
|
|
188
|
+
});
|
|
189
|
+
this.emit('afterrender');
|
|
190
|
+
yield this.layout();
|
|
191
|
+
});
|
|
192
|
+
if (this.canvasReady) {
|
|
193
|
+
yield emitRender();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
yield Promise.all([this.backgroundCanvas, this.canvas, this.transientCanvas].map((canvas) => canvas.ready));
|
|
197
|
+
yield emitRender();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Change graph data.
|
|
203
|
+
* @param data new data
|
|
204
|
+
* @param type the way to change data, 'replace' means discard the old data and use the new one; 'mergeReplace' means merge the common part, remove (old - new), add (new - old)
|
|
205
|
+
* @returns
|
|
206
|
+
* @group Data
|
|
207
|
+
*/
|
|
208
|
+
changeData(data, type = 'mergeReplace') {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
this.hooks.datachange.emit({ data, type });
|
|
211
|
+
this.hooks.render.emit({
|
|
212
|
+
graphCore: this.dataController.graphCore,
|
|
213
|
+
theme: this.themeController.specification,
|
|
214
|
+
transientCanvas: this.transientCanvas,
|
|
215
|
+
});
|
|
216
|
+
this.emit('afterrender');
|
|
217
|
+
yield this.layout();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Clear the graph, means remove all the items on the graph.
|
|
222
|
+
* @returns
|
|
223
|
+
*/
|
|
224
|
+
clear() {
|
|
225
|
+
// TODO
|
|
226
|
+
}
|
|
227
|
+
getViewportCenter() {
|
|
228
|
+
const { width, height } = this.canvas.getConfig();
|
|
229
|
+
return { x: width / 2, y: height / 2 };
|
|
230
|
+
}
|
|
231
|
+
transform(options, effectTiming) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
yield this.hooks.viewportchange.emitLinearAsync({
|
|
234
|
+
transform: options,
|
|
235
|
+
effectTiming,
|
|
236
|
+
});
|
|
237
|
+
this.emit('viewportchange', options);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Stop the current transition of transform immediately.
|
|
242
|
+
*/
|
|
243
|
+
stopTransformTransition() {
|
|
244
|
+
this.canvas.getCamera().cancelLandmarkAnimation();
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Move the graph with a relative distance under viewport coordinates.
|
|
248
|
+
* @param dx x of the relative distance
|
|
249
|
+
* @param dy y of the relative distance
|
|
250
|
+
* @param effectTiming animation configurations
|
|
251
|
+
*/
|
|
252
|
+
translate(distance, effectTiming) {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
+
yield this.transform({
|
|
255
|
+
translate: distance,
|
|
256
|
+
}, effectTiming);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Move the graph to destination under viewport coordinates.
|
|
261
|
+
* @param destination destination under viewport coordinates.
|
|
262
|
+
* @param effectTiming animation configurations
|
|
263
|
+
*/
|
|
264
|
+
translateTo({ x, y }, effectTiming) {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
const { x: cx, y: cy } = this.getViewportCenter();
|
|
267
|
+
yield this.translate({ dx: cx - x, dy: cy - y }, effectTiming);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Zoom the graph with a relative ratio.
|
|
272
|
+
* @param ratio relative ratio to zoom
|
|
273
|
+
* @param origin origin under viewport coordinates.
|
|
274
|
+
* @param effectTiming animation configurations
|
|
275
|
+
*/
|
|
276
|
+
zoom(ratio, origin, effectTiming) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
yield this.transform({
|
|
279
|
+
zoom: {
|
|
280
|
+
ratio,
|
|
281
|
+
},
|
|
282
|
+
origin,
|
|
283
|
+
}, effectTiming);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Zoom the graph to a specified ratio.
|
|
288
|
+
* @param zoom specified ratio
|
|
289
|
+
* @param origin zoom center
|
|
290
|
+
* @param effectTiming animation configurations
|
|
291
|
+
*/
|
|
292
|
+
zoomTo(zoom, origin, effectTiming) {
|
|
293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
294
|
+
yield this.zoom(zoom / this.canvas.getCamera().getZoom(), origin, effectTiming);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Return the current zoom level of camera.
|
|
299
|
+
* @returns current zoom
|
|
300
|
+
*/
|
|
301
|
+
getZoom() {
|
|
302
|
+
return this.canvas.getCamera().getZoom();
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Rotate the graph with a relative angle.
|
|
306
|
+
* @param angle
|
|
307
|
+
* @param origin
|
|
308
|
+
* @param effectTiming
|
|
309
|
+
*/
|
|
310
|
+
rotate(angle, origin, effectTiming) {
|
|
311
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
312
|
+
yield this.transform({
|
|
313
|
+
rotate: {
|
|
314
|
+
angle,
|
|
315
|
+
},
|
|
316
|
+
origin,
|
|
317
|
+
}, effectTiming);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Rotate the graph to an absolute angle.
|
|
322
|
+
* @param angle
|
|
323
|
+
* @param origin
|
|
324
|
+
* @param effectTiming
|
|
325
|
+
*/
|
|
326
|
+
rotateTo(angle, origin, effectTiming) {
|
|
327
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
328
|
+
yield this.rotate(angle - this.canvas.getCamera().getRoll(), origin, effectTiming);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Fit the graph content to the view.
|
|
333
|
+
* @param options.padding padding while fitting
|
|
334
|
+
* @param options.rules rules for fitting
|
|
335
|
+
* @param effectTiming animation configurations
|
|
336
|
+
*/
|
|
337
|
+
fitView(options, effectTiming) {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
339
|
+
const { padding, rules } = options || {};
|
|
340
|
+
const [top, right, bottom, left] = padding
|
|
341
|
+
? (0, shape_1.formatPadding)(padding)
|
|
342
|
+
: [0, 0, 0, 0];
|
|
343
|
+
const { direction = 'both', ratioRule = 'min' } = rules || {};
|
|
344
|
+
// Get the bounds of the whole graph.
|
|
345
|
+
const { center: [graphCenterX, graphCenterY], halfExtents, } = this.canvas.document.documentElement.getBounds();
|
|
346
|
+
const origin = this.canvas.canvas2Viewport({
|
|
347
|
+
x: graphCenterX,
|
|
348
|
+
y: graphCenterY,
|
|
349
|
+
});
|
|
350
|
+
const { width: viewportWidth, height: viewportHeight } = this.canvas.getConfig();
|
|
351
|
+
const graphWidth = halfExtents[0] * 2;
|
|
352
|
+
const graphHeight = halfExtents[1] * 2;
|
|
353
|
+
const tlInCanvas = this.canvas.viewport2Canvas({ x: left, y: top });
|
|
354
|
+
const brInCanvas = this.canvas.viewport2Canvas({
|
|
355
|
+
x: viewportWidth - right,
|
|
356
|
+
y: viewportHeight - bottom,
|
|
357
|
+
});
|
|
358
|
+
const targetViewWidth = brInCanvas.x - tlInCanvas.x;
|
|
359
|
+
const targetViewHeight = brInCanvas.y - tlInCanvas.y;
|
|
360
|
+
const wRatio = targetViewWidth / graphWidth;
|
|
361
|
+
const hRatio = targetViewHeight / graphHeight;
|
|
362
|
+
let ratio;
|
|
363
|
+
if (direction === 'x') {
|
|
364
|
+
ratio = wRatio;
|
|
365
|
+
}
|
|
366
|
+
else if (direction === 'y') {
|
|
367
|
+
ratio = hRatio;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
ratio =
|
|
371
|
+
ratioRule === 'max'
|
|
372
|
+
? Math.max(wRatio, hRatio)
|
|
373
|
+
: Math.min(wRatio, hRatio);
|
|
374
|
+
}
|
|
375
|
+
yield this.transform({
|
|
376
|
+
translate: {
|
|
377
|
+
dx: viewportWidth / 2 - origin.x,
|
|
378
|
+
dy: viewportHeight / 2 - origin.y,
|
|
379
|
+
},
|
|
380
|
+
zoom: {
|
|
381
|
+
ratio,
|
|
382
|
+
},
|
|
383
|
+
}, effectTiming);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Fit the graph center to the view center.
|
|
388
|
+
* @param effectTiming animation configurations
|
|
389
|
+
*/
|
|
390
|
+
fitCenter(effectTiming) {
|
|
391
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
392
|
+
// Get the bounds of the whole graph.
|
|
393
|
+
const { center: [graphCenterX, graphCenterY], } = this.canvas.document.documentElement.getBounds();
|
|
394
|
+
yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Move the graph to make the item align the view center.
|
|
399
|
+
* @param item node/edge/combo item or its id
|
|
400
|
+
* @param effectTiming animation configurations
|
|
401
|
+
*/
|
|
402
|
+
focusItem(id, effectTiming) {
|
|
403
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
404
|
+
let bounds = null;
|
|
405
|
+
for (const itemId of !(0, util_1.isArray)(id) ? [id] : id) {
|
|
406
|
+
const item = this.itemController.getItemById(itemId);
|
|
407
|
+
if (item) {
|
|
408
|
+
const itemBounds = item.group.getBounds();
|
|
409
|
+
if (!bounds) {
|
|
410
|
+
bounds = itemBounds;
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
bounds.add(itemBounds);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (bounds) {
|
|
418
|
+
const { center: [itemCenterX, itemCenterY], } = bounds;
|
|
419
|
+
yield this.translateTo(this.canvas.canvas2Viewport({ x: itemCenterX, y: itemCenterY }), effectTiming);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Get the size of the graph canvas.
|
|
425
|
+
* @returns [width, height]
|
|
426
|
+
* @group View
|
|
427
|
+
*/
|
|
428
|
+
getSize() {
|
|
429
|
+
const { width = 500, height = 500 } = this.specification;
|
|
430
|
+
return [width, height];
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Set the size for the graph canvas.
|
|
434
|
+
* @param number[] [width, height]
|
|
435
|
+
* @group View
|
|
436
|
+
*/
|
|
437
|
+
setSize(size) {
|
|
438
|
+
if (!(0, util_1.isArray)(size) || size.length < 2) {
|
|
439
|
+
console.warn(`Failed to setSize. The parameter size: ${size} is invalid. It must be an array with 2 number elements.`);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
this.specification.width = size[0];
|
|
443
|
+
this.specification.height = size[1];
|
|
444
|
+
this.canvas.resize(size[0], size[1]);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Get the rendering coordinate according to the canvas dom (viewport) coordinate.
|
|
448
|
+
* @param Point rendering coordinate
|
|
449
|
+
* @returns canvas dom (viewport) coordinate
|
|
450
|
+
* @group View
|
|
451
|
+
*/
|
|
452
|
+
getCanvasByViewport(viewportPoint) {
|
|
453
|
+
return this.canvas.viewport2Canvas(viewportPoint);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Get the canvas dom (viewport) coordinate according to the rendering coordinate.
|
|
457
|
+
* @param Point canvas dom (viewport) coordinate
|
|
458
|
+
* @returns rendering coordinate
|
|
459
|
+
* @group View
|
|
460
|
+
*/
|
|
461
|
+
getViewportByCanvas(canvasPoint) {
|
|
462
|
+
return this.canvas.canvas2Viewport(canvasPoint);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Get the browser coordinate according to the rendering coordinate.
|
|
466
|
+
* @param Point rendering coordinate
|
|
467
|
+
* @returns browser coordinate
|
|
468
|
+
* @group View
|
|
469
|
+
*/
|
|
470
|
+
getClientByCanvas(canvasPoint) {
|
|
471
|
+
const viewportPoint = this.canvas.canvas2Viewport(canvasPoint);
|
|
472
|
+
return this.canvas.viewport2Client(viewportPoint);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Get the rendering coordinate according to the browser coordinate.
|
|
476
|
+
* @param Point browser coordinate
|
|
477
|
+
* @returns rendering coordinate
|
|
478
|
+
* @group View
|
|
479
|
+
*/
|
|
480
|
+
getCanvasByClient(clientPoint) {
|
|
481
|
+
const viewportPoint = this.canvas.client2Viewport(clientPoint);
|
|
482
|
+
return this.canvas.viewport2Canvas(viewportPoint);
|
|
483
|
+
}
|
|
484
|
+
// ===== item operations =====
|
|
485
|
+
/**
|
|
486
|
+
* Find a node's inner data according to id or function.
|
|
487
|
+
* @param { ID | Function } condition id or condition function
|
|
488
|
+
* @returns result node's inner data
|
|
489
|
+
* @group Data
|
|
490
|
+
*/
|
|
491
|
+
getNodeData(condition) {
|
|
492
|
+
var _a;
|
|
493
|
+
const conds = (0, util_1.isString)(condition) || (0, util_1.isNumber)(condition) ? [condition] : condition;
|
|
494
|
+
return (_a = this.dataController.findData('node', conds)) === null || _a === void 0 ? void 0 : _a[0];
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Find an edge's inner data according to id or function.
|
|
498
|
+
* @param { ID | Function } condition id or condition function
|
|
499
|
+
* @returns result edge's inner data
|
|
500
|
+
* @group Data
|
|
501
|
+
*/
|
|
502
|
+
getEdgeData(condition) {
|
|
503
|
+
var _a;
|
|
504
|
+
const conds = (0, util_1.isString)(condition) || (0, util_1.isNumber)(condition) || (0, util_1.isNumber)(condition)
|
|
505
|
+
? [condition]
|
|
506
|
+
: condition;
|
|
507
|
+
return (_a = this.dataController.findData('edge', conds)) === null || _a === void 0 ? void 0 : _a[0];
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Find an combo's inner data according to id or function.
|
|
511
|
+
* @param { ID | Function } condition id or condition function
|
|
512
|
+
* @returns result combo's inner data
|
|
513
|
+
* @group Data
|
|
514
|
+
*/
|
|
515
|
+
getComboData(condition) {
|
|
516
|
+
var _a;
|
|
517
|
+
const conds = (0, util_1.isString)(condition) || (0, util_1.isNumber)(condition) ? [condition] : condition;
|
|
518
|
+
return (_a = this.dataController.findData('combo', conds)) === null || _a === void 0 ? void 0 : _a[0];
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get all the nodes' inner data
|
|
522
|
+
* @returns all nodes' inner data on the graph
|
|
523
|
+
* @group Data
|
|
524
|
+
*/
|
|
525
|
+
getAllNodesData() {
|
|
526
|
+
return this.dataController.findAllData('node');
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Get all the edges' inner data
|
|
530
|
+
* @returns all edges' inner data on the graph
|
|
531
|
+
* @group Data
|
|
532
|
+
*/
|
|
533
|
+
getAllEdgesData() {
|
|
534
|
+
return this.dataController.findAllData('edge');
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Get all the combos' inner data
|
|
538
|
+
* @returns all combos' inner data on the graph
|
|
539
|
+
* @group Data
|
|
540
|
+
*/
|
|
541
|
+
getAllCombosData() {
|
|
542
|
+
return this.dataController.findAllData('combo');
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Get one-hop edge ids from a start node.
|
|
546
|
+
* @param nodeId id of the start node
|
|
547
|
+
* @returns one-hop edge ids
|
|
548
|
+
* @group Data
|
|
549
|
+
*/
|
|
550
|
+
getRelatedEdgesData(nodeId, direction = 'both') {
|
|
551
|
+
return this.dataController.findRelatedEdgeIds(nodeId, direction);
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Get one-hop node ids from a start node.
|
|
555
|
+
* @param nodeId id of the start node
|
|
556
|
+
* @returns one-hop node ids
|
|
557
|
+
* @group Data
|
|
558
|
+
*/
|
|
559
|
+
getNeighborNodesData(nodeId, direction = 'both') {
|
|
560
|
+
return this.dataController.findNeighborNodeIds(nodeId, direction);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Find items which has the state.
|
|
564
|
+
* @param itemType item type
|
|
565
|
+
* @param state state name
|
|
566
|
+
* @param additionalFilter additional filter function
|
|
567
|
+
* @returns items that is the type and has the state
|
|
568
|
+
* @group Item
|
|
569
|
+
*/
|
|
570
|
+
findIdByState(itemType, state, value = true, additionalFilter) {
|
|
571
|
+
let ids = this.itemController.findIdByState(itemType, state, value);
|
|
572
|
+
if (additionalFilter) {
|
|
573
|
+
const getDataFunc = itemType === 'node' ? this.getNodeData : this.getEdgeData; // TODO: combo
|
|
574
|
+
ids = ids.filter((id) => additionalFilter(getDataFunc(id)));
|
|
575
|
+
}
|
|
576
|
+
return ids;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Add one or more node/edge/combo data to the graph.
|
|
580
|
+
* @param itemType item type
|
|
581
|
+
* @param model user data
|
|
582
|
+
* @param stack whether push this operation to stack
|
|
583
|
+
* @returns whether success
|
|
584
|
+
* @group Data
|
|
585
|
+
*/
|
|
586
|
+
addData(itemType, models, stack) {
|
|
587
|
+
// data controller and item controller subscribe additem in order
|
|
588
|
+
const { graphCore } = this.dataController;
|
|
589
|
+
const { specification } = this.themeController;
|
|
590
|
+
graphCore.once('changed', (event) => {
|
|
591
|
+
if (!event.changes.length)
|
|
592
|
+
return;
|
|
593
|
+
this.hooks.itemchange.emit({
|
|
594
|
+
type: itemType,
|
|
595
|
+
changes: graphCore.reduceChanges(event.changes),
|
|
596
|
+
graphCore,
|
|
597
|
+
theme: specification,
|
|
598
|
+
});
|
|
599
|
+
this.emit('afteritemchange', { type: itemType, action: 'add', models });
|
|
600
|
+
});
|
|
601
|
+
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
602
|
+
const data = { nodes: [], edges: [], combos: [] };
|
|
603
|
+
data[`${itemType}s`] = modelArr;
|
|
604
|
+
this.hooks.datachange.emit({
|
|
605
|
+
data,
|
|
606
|
+
type: 'union',
|
|
607
|
+
});
|
|
608
|
+
const dataList = this.dataController.findData(itemType, modelArr.map((model) => model.id));
|
|
609
|
+
return (0, util_1.isArray)(models) ? dataList : dataList[0];
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Remove one or more node/edge/combo data from the graph.
|
|
613
|
+
* @param item the item to be removed
|
|
614
|
+
* @param stack whether push this operation to stack
|
|
615
|
+
* @returns whether success
|
|
616
|
+
* @group Data
|
|
617
|
+
*/
|
|
618
|
+
removeData(itemType, ids, stack) {
|
|
619
|
+
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
620
|
+
const data = { nodes: [], edges: [], combos: [] };
|
|
621
|
+
const { userGraphCore, graphCore } = this.dataController;
|
|
622
|
+
const { specification } = this.themeController;
|
|
623
|
+
const getItem = itemType === 'edge' ? userGraphCore.getEdge : userGraphCore.getNode; // TODO: combo
|
|
624
|
+
data[`${itemType}s`] = idArr.map((id) => getItem.bind(userGraphCore)(id));
|
|
625
|
+
graphCore.once('changed', (event) => {
|
|
626
|
+
if (!event.changes.length)
|
|
627
|
+
return;
|
|
628
|
+
this.hooks.itemchange.emit({
|
|
629
|
+
type: itemType,
|
|
630
|
+
changes: event.changes,
|
|
631
|
+
graphCore,
|
|
632
|
+
theme: specification,
|
|
633
|
+
});
|
|
634
|
+
this.emit('afteritemchange', { type: itemType, action: 'remove', ids });
|
|
635
|
+
});
|
|
636
|
+
this.hooks.datachange.emit({
|
|
637
|
+
data,
|
|
638
|
+
type: 'remove',
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Update one or more node/edge/combo data on the graph.
|
|
643
|
+
* @param {ITEM_TYPE} itemType 'node' | 'edge' | 'combo'
|
|
644
|
+
* @param models new configurations for every node/edge/combo, which has id field to indicate the specific item
|
|
645
|
+
* @param {boolean} stack whether push this operation into graph's stack, true by default
|
|
646
|
+
* @group Data
|
|
647
|
+
*/
|
|
648
|
+
updateData(itemType, models, stack) {
|
|
649
|
+
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
650
|
+
const data = { nodes: [], edges: [], combos: [] };
|
|
651
|
+
data[`${itemType}s`] = modelArr;
|
|
652
|
+
const { graphCore } = this.dataController;
|
|
653
|
+
const { specification } = this.themeController;
|
|
654
|
+
graphCore.once('changed', (event) => {
|
|
655
|
+
this.hooks.itemchange.emit({
|
|
656
|
+
type: itemType,
|
|
657
|
+
changes: event.changes,
|
|
658
|
+
graphCore,
|
|
659
|
+
theme: specification,
|
|
660
|
+
});
|
|
661
|
+
this.emit('afteritemchange', {
|
|
662
|
+
type: itemType,
|
|
663
|
+
action: 'update',
|
|
664
|
+
models,
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
this.hooks.datachange.emit({
|
|
668
|
+
data,
|
|
669
|
+
type: 'update',
|
|
670
|
+
});
|
|
671
|
+
const dataList = this.dataController.findData(itemType, modelArr.map((model) => model.id));
|
|
672
|
+
return (0, util_1.isArray)(models) ? dataList : dataList[0];
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Update one or more nodes' positions,
|
|
676
|
+
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
677
|
+
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
678
|
+
* @param {boolean} stack whether push this operation into graph's stack, true by default
|
|
679
|
+
* @group Data
|
|
680
|
+
*/
|
|
681
|
+
updateNodePosition(models, stack) {
|
|
682
|
+
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
683
|
+
const { graphCore } = this.dataController;
|
|
684
|
+
const { specification } = this.themeController;
|
|
685
|
+
graphCore.once('changed', (event) => {
|
|
686
|
+
if (!event.changes.length)
|
|
687
|
+
return;
|
|
688
|
+
this.hooks.itemchange.emit({
|
|
689
|
+
type: 'node',
|
|
690
|
+
changes: event.changes,
|
|
691
|
+
graphCore,
|
|
692
|
+
theme: specification,
|
|
693
|
+
action: 'updateNodePosition',
|
|
694
|
+
});
|
|
695
|
+
this.emit('afteritemchange', {
|
|
696
|
+
type: 'node',
|
|
697
|
+
action: 'updateNodePosition',
|
|
698
|
+
models,
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
this.hooks.datachange.emit({
|
|
702
|
+
data: {
|
|
703
|
+
nodes: modelArr,
|
|
704
|
+
edges: [],
|
|
705
|
+
},
|
|
706
|
+
type: 'update',
|
|
707
|
+
});
|
|
708
|
+
const dataList = this.dataController.findData('node', modelArr.map((model) => model.id));
|
|
709
|
+
return (0, util_1.isArray)(models) ? dataList : dataList[0];
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Show the item(s).
|
|
713
|
+
* @param item the item to be shown
|
|
714
|
+
* @returns
|
|
715
|
+
* @group Item
|
|
716
|
+
*/
|
|
717
|
+
showItem(ids, disableAniamte) {
|
|
718
|
+
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
719
|
+
this.hooks.itemvisibilitychange.emit({
|
|
720
|
+
ids: idArr,
|
|
721
|
+
value: true,
|
|
722
|
+
animate: !disableAniamte,
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Hide the item(s).
|
|
727
|
+
* @param item the item to be hidden
|
|
728
|
+
* @returns
|
|
729
|
+
* @group Item
|
|
730
|
+
*/
|
|
731
|
+
hideItem(ids, disableAniamte) {
|
|
732
|
+
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
733
|
+
this.hooks.itemvisibilitychange.emit({
|
|
734
|
+
ids: idArr,
|
|
735
|
+
value: false,
|
|
736
|
+
animate: !disableAniamte,
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Set state for the item.
|
|
741
|
+
* @param item the item to be set
|
|
742
|
+
* @param state the state name
|
|
743
|
+
* @param value state value
|
|
744
|
+
* @returns
|
|
745
|
+
* @group Item
|
|
746
|
+
*/
|
|
747
|
+
setItemState(ids, states, value) {
|
|
748
|
+
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
749
|
+
const stateArr = (0, util_1.isArray)(states) ? states : [states];
|
|
750
|
+
this.hooks.itemstatechange.emit({
|
|
751
|
+
ids: idArr,
|
|
752
|
+
states: stateArr,
|
|
753
|
+
value,
|
|
754
|
+
});
|
|
755
|
+
this.emit('afteritemstatechange', { ids, states, value });
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Get the state value for an item.
|
|
759
|
+
* @param id the id for the item
|
|
760
|
+
* @param states the state name
|
|
761
|
+
* @returns {boolean} the state value
|
|
762
|
+
* @group Item
|
|
763
|
+
*/
|
|
764
|
+
getItemState(id, state) {
|
|
765
|
+
return this.itemController.getItemState(id, state);
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Clear all the states for item(s).
|
|
769
|
+
* @param ids the id(s) for the item(s) to be clear
|
|
770
|
+
* @param states the states' names, all the states wil be cleared if states is not assigned
|
|
771
|
+
* @returns
|
|
772
|
+
* @group Item
|
|
773
|
+
*/
|
|
774
|
+
clearItemState(ids, states) {
|
|
775
|
+
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
776
|
+
this.hooks.itemstatechange.emit({
|
|
777
|
+
ids: idArr,
|
|
778
|
+
states,
|
|
779
|
+
value: false,
|
|
780
|
+
});
|
|
781
|
+
this.emit('afteritemstatechange', { ids, states, value: false });
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Get the rendering bbox for a node / edge / combo, or the graph (when the id is not assigned).
|
|
785
|
+
* @param id the id for the node / edge / combo, undefined for the whole graph
|
|
786
|
+
* @returns rendering bounding box. returns false if the item is not exist
|
|
787
|
+
* @group Item
|
|
788
|
+
*/
|
|
789
|
+
getRenderBBox(id) {
|
|
790
|
+
if (!id)
|
|
791
|
+
return this.canvas.getRoot().getRenderBounds();
|
|
792
|
+
return this.itemController.getItemBBox(id);
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Get the visibility for a node / edge / combo.
|
|
796
|
+
* @param id the id for the node / edge / combo
|
|
797
|
+
* @returns visibility for the item, false for invisible or unexistence for the item
|
|
798
|
+
* @group Item
|
|
799
|
+
*/
|
|
800
|
+
getItemVisible(id) {
|
|
801
|
+
return this.itemController.getItemVisible(id);
|
|
802
|
+
}
|
|
803
|
+
// ===== combo operations =====
|
|
804
|
+
/**
|
|
805
|
+
* Create a new combo with existing child nodes and combos.
|
|
806
|
+
* @param combo combo ID or Combo model
|
|
807
|
+
* @param childrenIds id array of children of the new combo
|
|
808
|
+
* @group Combo
|
|
809
|
+
*/
|
|
810
|
+
createCombo(combo, childrenIds, stack) {
|
|
811
|
+
// TODO
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* dissolve combo
|
|
815
|
+
* @param {String | ICombo} item combo item or id to be dissolve
|
|
816
|
+
* @group Combo
|
|
817
|
+
*/
|
|
818
|
+
uncombo(comboId, stack) {
|
|
819
|
+
// TODO
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Collapse a combo.
|
|
823
|
+
* @param comboId combo id or item
|
|
824
|
+
* @group Combo
|
|
825
|
+
*/
|
|
826
|
+
collapseCombo(comboId, stack) {
|
|
827
|
+
// TODO
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Expand a combo.
|
|
831
|
+
* @param combo combo ID 或 combo 实例
|
|
832
|
+
* @group Combo
|
|
833
|
+
*/
|
|
834
|
+
expandCombo(comboId, stack) {
|
|
835
|
+
// TODO
|
|
836
|
+
}
|
|
837
|
+
// ===== layout =====
|
|
838
|
+
/**
|
|
839
|
+
* Layout the graph (with current configurations if cfg is not assigned).
|
|
840
|
+
*/
|
|
841
|
+
layout(options) {
|
|
842
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
843
|
+
const { graphCore } = this.dataController;
|
|
844
|
+
const formattedOptions = Object.assign(Object.assign({}, this.getSpecification().layout), options);
|
|
845
|
+
const layoutUnset = !options && !this.getSpecification().layout;
|
|
846
|
+
if (layoutUnset) {
|
|
847
|
+
const nodes = graphCore.getAllNodes();
|
|
848
|
+
if (nodes.every((node) => (0, util_1.isNil)(node.data.x) && (0, util_1.isNil)(node.data.y))) {
|
|
849
|
+
// Use `grid` layout as default when x/y of each node is unset.
|
|
850
|
+
formattedOptions.type = 'grid';
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
// Use user-defined position(x/y default to 0).
|
|
854
|
+
formattedOptions.execute = (graph) => __awaiter(this, void 0, void 0, function* () {
|
|
855
|
+
const nodes = graph.getAllNodes();
|
|
856
|
+
return {
|
|
857
|
+
nodes: nodes.map((node) => ({
|
|
858
|
+
id: node.id,
|
|
859
|
+
data: {
|
|
860
|
+
x: Number(node.data.x) || 0,
|
|
861
|
+
y: Number(node.data.y) || 0,
|
|
862
|
+
},
|
|
863
|
+
})),
|
|
864
|
+
edges: [],
|
|
865
|
+
};
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
yield this.hooks.layout.emitLinearAsync({
|
|
870
|
+
graphCore,
|
|
871
|
+
options: formattedOptions,
|
|
872
|
+
});
|
|
873
|
+
this.emit('afterlayout');
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Some layout algorithms has many iterations which can be stopped at any time.
|
|
878
|
+
*/
|
|
879
|
+
stopLayout() {
|
|
880
|
+
this.layoutController.stopLayout();
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Switch mode.
|
|
884
|
+
* @param mode mode name
|
|
885
|
+
* @returns
|
|
886
|
+
* @group Interaction
|
|
887
|
+
*/
|
|
888
|
+
setMode(mode) {
|
|
889
|
+
this.hooks.modechange.emit({ mode });
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Add behavior(s) to mode(s).
|
|
893
|
+
* @param behaviors behavior names or configs
|
|
894
|
+
* @param modes mode names
|
|
895
|
+
* @returns
|
|
896
|
+
* @group Interaction
|
|
897
|
+
*/
|
|
898
|
+
addBehaviors(behaviors, modes) {
|
|
899
|
+
const modesArr = (0, util_1.isArray)(modes) ? modes : [modes];
|
|
900
|
+
const behaviorsArr = (0, util_1.isArray)(behaviors) ? behaviors : [behaviors];
|
|
901
|
+
this.hooks.behaviorchange.emit({
|
|
902
|
+
action: 'add',
|
|
903
|
+
modes: modesArr,
|
|
904
|
+
// TODO: update type define.
|
|
905
|
+
// @ts-ignore
|
|
906
|
+
behaviors: behaviorsArr,
|
|
907
|
+
});
|
|
908
|
+
// update the graph specification
|
|
909
|
+
modesArr.forEach((mode) => {
|
|
910
|
+
this.specification.modes[mode] =
|
|
911
|
+
this.specification.modes[mode].concat(behaviorsArr);
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Remove behavior(s) from mode(s).
|
|
916
|
+
* @param behaviors behavior configs with unique key
|
|
917
|
+
* @param modes mode names
|
|
918
|
+
* @returns
|
|
919
|
+
* @group Interaction
|
|
920
|
+
*/
|
|
921
|
+
removeBehaviors(behaviorKeys, modes) {
|
|
922
|
+
const modesArr = (0, util_1.isArray)(modes) ? modes : [modes];
|
|
923
|
+
this.hooks.behaviorchange.emit({
|
|
924
|
+
action: 'remove',
|
|
925
|
+
modes: modesArr,
|
|
926
|
+
behaviors: behaviorKeys,
|
|
927
|
+
});
|
|
928
|
+
// update the graph specification
|
|
929
|
+
modesArr.forEach((mode) => {
|
|
930
|
+
behaviorKeys.forEach((key) => {
|
|
931
|
+
const oldBehavior = this.specification.modes[mode].find((behavior) => (0, util_1.isObject)(behavior) && behavior.key === key);
|
|
932
|
+
const indexOfOldBehavior = this.specification.modes[mode].indexOf(oldBehavior);
|
|
933
|
+
this.specification.modes[mode].splice(indexOfOldBehavior, 1);
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Update a behavior on a mode.
|
|
939
|
+
* @param behavior behavior configs, whose name indicates the behavior to be updated
|
|
940
|
+
* @param mode mode name
|
|
941
|
+
* @returns
|
|
942
|
+
* @group Interaction
|
|
943
|
+
*/
|
|
944
|
+
updateBehavior(behavior, mode) {
|
|
945
|
+
this.hooks.behaviorchange.emit({
|
|
946
|
+
action: 'update',
|
|
947
|
+
modes: [mode],
|
|
948
|
+
// TODO: update type define.
|
|
949
|
+
// @ts-ignore
|
|
950
|
+
behaviors: [behavior],
|
|
951
|
+
});
|
|
952
|
+
// no need to update specification since the corresponding part is the same object as the behavior's option
|
|
953
|
+
// this.specification.modes[mode].forEach((b, i) => {
|
|
954
|
+
// if (isObject(b) && b.key === behavior.key) {
|
|
955
|
+
// this.specification.modes[mode][i] = behavior;
|
|
956
|
+
// }
|
|
957
|
+
// });
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Add plugin(s) to graph.
|
|
961
|
+
* @param pluginCfgs
|
|
962
|
+
* @returns
|
|
963
|
+
* @group Plugin
|
|
964
|
+
*/
|
|
965
|
+
addPlugins(pluginCfgs) {
|
|
966
|
+
const pluginsArr = (0, util_1.isArray)(pluginCfgs) ? pluginCfgs : [pluginCfgs];
|
|
967
|
+
// update the graph specification
|
|
968
|
+
if (!this.specification.plugins)
|
|
969
|
+
this.specification.plugins = [];
|
|
970
|
+
const oldPlugins = this.specification.plugins;
|
|
971
|
+
const validPlugins = [];
|
|
972
|
+
pluginsArr.forEach((config) => {
|
|
973
|
+
const oldPlugin = oldPlugins.find((oldPlugin) => {
|
|
974
|
+
if (typeof oldPlugin === 'string' || typeof config === 'string')
|
|
975
|
+
return false;
|
|
976
|
+
return oldPlugin.key === config.key;
|
|
977
|
+
});
|
|
978
|
+
if (oldPlugin) {
|
|
979
|
+
console.warn(`Add plugin with key ${config.key} failed, the key is duplicated to the existing plugins on the graph.`);
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
validPlugins.push(config);
|
|
983
|
+
});
|
|
984
|
+
this.specification.plugins = oldPlugins.concat(validPlugins);
|
|
985
|
+
this.hooks.pluginchange.emit({
|
|
986
|
+
action: 'add',
|
|
987
|
+
plugins: validPlugins,
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Remove plugin(s) from graph.
|
|
992
|
+
* @param pluginKeys
|
|
993
|
+
* @returns
|
|
994
|
+
* @group Plugin
|
|
995
|
+
*/
|
|
996
|
+
removePlugins(pluginKeys) {
|
|
997
|
+
this.hooks.pluginchange.emit({
|
|
998
|
+
action: 'remove',
|
|
999
|
+
plugins: pluginKeys,
|
|
1000
|
+
});
|
|
1001
|
+
// update the graph specification
|
|
1002
|
+
const { plugins } = this.specification;
|
|
1003
|
+
this.specification.plugins = plugins === null || plugins === void 0 ? void 0 : plugins.filter((plugin) => {
|
|
1004
|
+
if ((0, util_1.isObject)(plugin))
|
|
1005
|
+
return !pluginKeys.includes(plugin.key);
|
|
1006
|
+
return !pluginKeys.includes(plugin);
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Update a plugin of the graph.
|
|
1011
|
+
* @param plugin plugin configs, whose key indicates the behavior to be updated
|
|
1012
|
+
* @returns
|
|
1013
|
+
* @group Interaction
|
|
1014
|
+
*/
|
|
1015
|
+
updatePlugin(plugin) {
|
|
1016
|
+
const { key } = plugin;
|
|
1017
|
+
if (!key) {
|
|
1018
|
+
console.warn('Update plugin failed, the key for the plugin to be updated should be assign.');
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
const { plugins } = this.specification;
|
|
1022
|
+
if (!plugins) {
|
|
1023
|
+
console.warn('Update plugin failed, the plugin to be updated does not exist.');
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
const oldPlugin = plugins === null || plugins === void 0 ? void 0 : plugins.find((p) => {
|
|
1027
|
+
if (typeof p === 'string')
|
|
1028
|
+
return p === key;
|
|
1029
|
+
return p.key === key;
|
|
1030
|
+
});
|
|
1031
|
+
if (!oldPlugin) {
|
|
1032
|
+
console.warn('Update plugin failed, the key for the plugin to be updated should be assign.');
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const idx = plugins.indexOf(oldPlugin);
|
|
1036
|
+
plugins[idx] = Object.assign(Object.assign({}, oldPlugin), plugin);
|
|
1037
|
+
this.hooks.pluginchange.emit({
|
|
1038
|
+
action: 'update',
|
|
1039
|
+
plugins: [plugin],
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Draw or update a G shape or group to the transient canvas.
|
|
1044
|
+
* @param type shape type or item type
|
|
1045
|
+
* @param id new shape id or updated shape id for a interation shape, node/edge/combo id for item interaction group drawing
|
|
1046
|
+
* @returns upserted shape or group
|
|
1047
|
+
* @group Interaction
|
|
1048
|
+
*/
|
|
1049
|
+
drawTransient(type, id, config) {
|
|
1050
|
+
this.hooks.transientupdate.emit({
|
|
1051
|
+
type,
|
|
1052
|
+
id,
|
|
1053
|
+
config,
|
|
1054
|
+
canvas: this.transientCanvas,
|
|
1055
|
+
});
|
|
1056
|
+
return this.itemController.getTransient(String(id));
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Destroy the graph instance and remove the related canvases.
|
|
1060
|
+
* @returns
|
|
1061
|
+
* @group Graph Instance
|
|
1062
|
+
*/
|
|
1063
|
+
destroy(callback) {
|
|
1064
|
+
// TODO: call the destroy functions after items' buildOut animations finished
|
|
1065
|
+
setTimeout(() => {
|
|
1066
|
+
this.canvas.destroy();
|
|
1067
|
+
this.backgroundCanvas.destroy();
|
|
1068
|
+
this.transientCanvas.destroy();
|
|
1069
|
+
callback === null || callback === void 0 ? void 0 : callback();
|
|
1070
|
+
}, 500);
|
|
1071
|
+
this.hooks.destroy.emit({});
|
|
1072
|
+
// TODO: destroy controllers and off the listeners
|
|
1073
|
+
// this.dataController.destroy();
|
|
1074
|
+
// this.interactionController.destroy();
|
|
1075
|
+
// this.layoutController.destroy();
|
|
1076
|
+
// this.themeController.destroy();
|
|
1077
|
+
// this.itemController.destroy();
|
|
1078
|
+
// this.extensionController.destroy();
|
|
1079
|
+
this.destroyed = true;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
exports.default = Graph;
|
|
1083
|
+
//# sourceMappingURL=graph.js.map
|