@unovis/ts 1.1.1-beta.6 → 1.1.1-beta.7
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/declaration.d.ts +1 -0
- package/index.ts +1 -0
- package/licences.txt +43 -0
- package/maps.ts +1 -0
- package/package.json +1 -1
- package/rollup.config.js +71 -0
- package/rules/ts-getter-setter.js +35 -0
- package/src/components/area/config.ts +29 -0
- package/src/components/area/index.ts +133 -0
- package/{components/area/style.js → src/components/area/style.ts} +9 -10
- package/src/components/area/types.ts +2 -0
- package/src/components/axis/config.ts +76 -0
- package/src/components/axis/index.ts +363 -0
- package/{components/axis/style.js → src/components/axis/style.ts} +27 -22
- package/src/components/axis/types.ts +4 -0
- package/src/components/brush/config.ts +51 -0
- package/src/components/brush/index.ts +233 -0
- package/{components/brush/style.js → src/components/brush/style.ts} +15 -14
- package/src/components/brush/types.ts +8 -0
- package/src/components/bullet-legend/config.ts +38 -0
- package/src/components/bullet-legend/index.ts +104 -0
- package/{components/bullet-legend/style.js → src/components/bullet-legend/style.ts} +18 -16
- package/src/components/bullet-legend/types.ts +7 -0
- package/src/components/chord-diagram/config.ts +53 -0
- package/src/components/chord-diagram/index.ts +401 -0
- package/src/components/chord-diagram/modules/label.ts +155 -0
- package/src/components/chord-diagram/modules/link.ts +91 -0
- package/src/components/chord-diagram/modules/node.ts +80 -0
- package/{components/chord-diagram/style.js → src/components/chord-diagram/style.ts} +39 -30
- package/src/components/chord-diagram/types.ts +68 -0
- package/src/components/crosshair/config.ts +48 -0
- package/src/components/crosshair/index.ts +220 -0
- package/{components/crosshair/style.js → src/components/crosshair/style.ts} +12 -12
- package/src/components/crosshair/types.ts +15 -0
- package/src/components/donut/config.ts +65 -0
- package/src/components/donut/index.ts +148 -0
- package/src/components/donut/modules/arc.ts +86 -0
- package/{components/donut/style.js → src/components/donut/style.ts} +20 -18
- package/src/components/donut/types.ts +17 -0
- package/src/components/flow-legend/config.ts +31 -0
- package/src/components/flow-legend/index.ts +103 -0
- package/{components/flow-legend/style.js → src/components/flow-legend/style.ts} +25 -21
- package/src/components/flow-legend/types.ts +10 -0
- package/src/components/free-brush/config.ts +54 -0
- package/src/components/free-brush/index.ts +207 -0
- package/{components/free-brush/style.js → src/components/free-brush/style.ts} +12 -12
- package/src/components/free-brush/types.ts +8 -0
- package/src/components/graph/config.ts +280 -0
- package/src/components/graph/index.ts +809 -0
- package/src/components/graph/modules/layout-helpers.ts +96 -0
- package/src/components/graph/modules/layout.ts +502 -0
- package/src/components/graph/modules/link/helper.ts +105 -0
- package/src/components/graph/modules/link/index.ts +302 -0
- package/{components/graph/modules/link/style.js → src/components/graph/modules/link/style.ts} +45 -34
- package/src/components/graph/modules/node/helper.ts +162 -0
- package/src/components/graph/modules/node/index.ts +343 -0
- package/{components/graph/modules/node/style.js → src/components/graph/modules/node/style.ts} +72 -52
- package/src/components/graph/modules/panel/helper.ts +160 -0
- package/src/components/graph/modules/panel/index.ts +137 -0
- package/{components/graph/modules/panel/style.js → src/components/graph/modules/panel/style.ts} +42 -32
- package/src/components/graph/modules/shape.ts +108 -0
- package/src/components/graph/modules/zoom-levels.ts +6 -0
- package/src/components/graph/style.ts +72 -0
- package/src/components/graph/types.ts +152 -0
- package/src/components/grouped-bar/config.ts +40 -0
- package/src/components/grouped-bar/index.ts +325 -0
- package/{components/grouped-bar/style.js → src/components/grouped-bar/style.ts} +15 -14
- package/src/components/leaflet-flow-map/config.ts +60 -0
- package/src/components/leaflet-flow-map/index.ts +279 -0
- package/src/components/leaflet-flow-map/renderer-utils.ts +14 -0
- package/src/components/leaflet-flow-map/renderer.ts +146 -0
- package/{components/leaflet-flow-map/shaders.js → src/components/leaflet-flow-map/shaders.ts} +4 -7
- package/src/components/leaflet-flow-map/types.ts +18 -0
- package/src/components/leaflet-map/config.ts +234 -0
- package/src/components/leaflet-map/index.ts +808 -0
- package/src/components/leaflet-map/leaflet.css +625 -0
- package/src/components/leaflet-map/modules/clusterBackground.ts +34 -0
- package/src/components/leaflet-map/modules/donut.ts +37 -0
- package/src/components/leaflet-map/modules/map.ts +178 -0
- package/src/components/leaflet-map/modules/node.ts +208 -0
- package/src/components/leaflet-map/modules/selectionRing.ts +63 -0
- package/src/components/leaflet-map/modules/utils.ts +290 -0
- package/{components → src/components}/leaflet-map/renderer/leaflet-maplibre-gl.js +76 -78
- package/src/components/leaflet-map/renderer/map-style.ts +24 -0
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json +35 -0
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json +35 -0
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json +2185 -0
- package/src/components/leaflet-map/renderer/mapboxgl-layer.ts +43 -0
- package/src/components/leaflet-map/renderer/mapboxgl-utils.ts +40 -0
- package/{components → src/components}/leaflet-map/renderer/maplibre-gl.css.js +2 -4
- package/src/components/leaflet-map/style.ts +217 -0
- package/src/components/leaflet-map/types.ts +75 -0
- package/src/components/line/config.ts +34 -0
- package/src/components/line/index.ts +188 -0
- package/{components/line/style.js → src/components/line/style.ts} +18 -16
- package/src/components/line/types.ts +3 -0
- package/src/components/nested-donut/config.ts +75 -0
- package/src/components/nested-donut/index.ts +176 -0
- package/src/components/nested-donut/modules/arc.ts +78 -0
- package/src/components/nested-donut/modules/label.ts +63 -0
- package/src/components/nested-donut/style.ts +82 -0
- package/src/components/nested-donut/types.ts +29 -0
- package/src/components/sankey/config.ts +195 -0
- package/src/components/sankey/index.ts +387 -0
- package/src/components/sankey/modules/label.ts +228 -0
- package/src/components/sankey/modules/link.ts +141 -0
- package/src/components/sankey/modules/node.ts +221 -0
- package/{components/sankey/style.js → src/components/sankey/style.ts} +60 -44
- package/src/components/sankey/types.ts +95 -0
- package/src/components/scatter/config.ts +49 -0
- package/src/components/scatter/index.ts +220 -0
- package/src/components/scatter/modules/point.ts +123 -0
- package/src/components/scatter/modules/utils.ts +150 -0
- package/{components/scatter/style.js → src/components/scatter/style.ts} +15 -14
- package/src/components/scatter/types.ts +21 -0
- package/src/components/stacked-bar/config.ts +42 -0
- package/src/components/stacked-bar/index.ts +267 -0
- package/{components/stacked-bar/style.js → src/components/stacked-bar/style.ts} +15 -14
- package/src/components/stacked-bar/types.ts +5 -0
- package/src/components/timeline/config.ts +49 -0
- package/src/components/timeline/index.ts +302 -0
- package/{components/timeline/style.js → src/components/timeline/style.ts} +39 -30
- package/src/components/tooltip/config.ts +69 -0
- package/src/components/tooltip/index.ts +220 -0
- package/{components → src/components}/tooltip/style.js +11 -14
- package/src/components/topojson-map/config.ts +124 -0
- package/src/components/topojson-map/index.ts +436 -0
- package/{components/topojson-map/style.js → src/components/topojson-map/style.ts} +33 -26
- package/src/components/topojson-map/types.ts +123 -0
- package/src/components/topojson-map/utils.ts +29 -0
- package/src/components/vis-controls/config.ts +16 -0
- package/src/components/vis-controls/index.ts +68 -0
- package/{components/vis-controls/style.js → src/components/vis-controls/style.ts} +34 -27
- package/src/components/vis-controls/types.ts +14 -0
- package/src/components/xy-labels/config.ts +56 -0
- package/src/components/xy-labels/index.ts +109 -0
- package/src/components/xy-labels/modules/label.ts +140 -0
- package/{components/xy-labels/style.js → src/components/xy-labels/style.ts} +15 -14
- package/src/components/xy-labels/types.ts +26 -0
- package/src/components.ts +56 -0
- package/src/containers/single-container/config.ts +15 -0
- package/src/containers/single-container/index.ts +150 -0
- package/src/containers/xy-container/config.ts +112 -0
- package/src/containers/xy-container/index.ts +407 -0
- package/src/containers.ts +6 -0
- package/src/core/component/config.ts +61 -0
- package/src/core/component/index.ts +154 -0
- package/src/core/component/types.ts +9 -0
- package/src/core/config/index.ts +12 -0
- package/src/core/container/config.ts +56 -0
- package/src/core/container/index.ts +136 -0
- package/src/core/xy-component/config.ts +46 -0
- package/src/core/xy-component/index.ts +90 -0
- package/src/data-models/core.ts +15 -0
- package/src/data-models/graph.ts +138 -0
- package/src/data-models/map-graph.ts +72 -0
- package/src/data-models/map.ts +18 -0
- package/src/data-models/series.ts +16 -0
- package/src/index.ts +7 -0
- package/src/maps/china-provinces.json +1 -0
- package/src/maps/fr-regions.json +1 -0
- package/src/maps/germany-regions.json +1 -0
- package/src/maps/ind-regions.json +1 -0
- package/src/maps/uk-regions.json +1 -0
- package/src/maps/us-counties.json +1 -0
- package/src/maps/us-states.json +1 -0
- package/src/maps/world-110m-alpha.json +1 -0
- package/src/maps/world-simple.json +1 -0
- package/src/maps/world-simplest.json +1 -0
- package/src/maps.ts +34 -0
- package/src/styles/colors.ts +28 -0
- package/src/styles/index.ts +38 -0
- package/{styles/sizes.js → src/styles/sizes.ts} +6 -8
- package/src/types/accessor.ts +5 -0
- package/src/types/component.ts +15 -0
- package/src/types/curve.ts +62 -0
- package/src/types/data.ts +5 -0
- package/src/types/direction.ts +6 -0
- package/src/types/graph.ts +40 -0
- package/src/types/map.ts +5 -0
- package/src/types/misc.ts +10 -0
- package/src/types/position.ts +23 -0
- package/src/types/scale.ts +47 -0
- package/src/types/shape.ts +7 -0
- package/src/types/spacing.ts +6 -0
- package/src/types/svg.ts +32 -0
- package/src/types/symbol.ts +21 -0
- package/src/types/text.ts +71 -0
- package/src/types.ts +31 -0
- package/src/utils/color.ts +41 -0
- package/src/utils/d3.ts +15 -0
- package/src/utils/data.ts +328 -0
- package/src/utils/html.ts +13 -0
- package/src/utils/map.ts +29 -0
- package/src/utils/misc.ts +54 -0
- package/src/utils/path.ts +196 -0
- package/src/utils/scale.ts +1 -0
- package/src/utils/style.ts +37 -0
- package/src/utils/svg.ts +49 -0
- package/src/utils/text.ts +529 -0
- package/src/utils/type.ts +9 -0
- package/tsconfig.json +29 -0
- package/components/area/config.d.ts +0 -25
- package/components/area/config.js +0 -16
- package/components/area/config.js.map +0 -1
- package/components/area/index.d.ts +0 -19
- package/components/area/index.js +0 -102
- package/components/area/index.js.map +0 -1
- package/components/area/style.d.ts +0 -3
- package/components/area/style.js.map +0 -1
- package/components/area/types.d.ts +0 -6
- package/components/axis/config.d.ts +0 -71
- package/components/axis/config.js +0 -32
- package/components/axis/config.js.map +0 -1
- package/components/axis/index.d.ts +0 -44
- package/components/axis/index.js +0 -305
- package/components/axis/index.js.map +0 -1
- package/components/axis/style.d.ts +0 -9
- package/components/axis/style.js.map +0 -1
- package/components/axis/types.d.ts +0 -4
- package/components/axis/types.js +0 -8
- package/components/axis/types.js.map +0 -1
- package/components/brush/config.d.ts +0 -42
- package/components/brush/config.js +0 -24
- package/components/brush/config.js.map +0 -1
- package/components/brush/index.d.ts +0 -28
- package/components/brush/index.js +0 -199
- package/components/brush/index.js.map +0 -1
- package/components/brush/style.d.ts +0 -5
- package/components/brush/style.js.map +0 -1
- package/components/brush/types.d.ts +0 -7
- package/components/brush/types.js +0 -8
- package/components/brush/types.js.map +0 -1
- package/components/bullet-legend/config.d.ts +0 -34
- package/components/bullet-legend/config.js +0 -16
- package/components/bullet-legend/config.js.map +0 -1
- package/components/bullet-legend/index.d.ts +0 -19
- package/components/bullet-legend/index.js +0 -79
- package/components/bullet-legend/index.js.map +0 -1
- package/components/bullet-legend/style.d.ts +0 -6
- package/components/bullet-legend/style.js.map +0 -1
- package/components/bullet-legend/types.d.ts +0 -7
- package/components/bullet-legend/types.js +0 -2
- package/components/bullet-legend/types.js.map +0 -1
- package/components/chord-diagram/config.d.ts +0 -44
- package/components/chord-diagram/config.js +0 -25
- package/components/chord-diagram/config.js.map +0 -1
- package/components/chord-diagram/index.d.ts +0 -42
- package/components/chord-diagram/index.js +0 -305
- package/components/chord-diagram/index.js.map +0 -1
- package/components/chord-diagram/modules/label.d.ts +0 -8
- package/components/chord-diagram/modules/label.js +0 -115
- package/components/chord-diagram/modules/label.js.map +0 -1
- package/components/chord-diagram/modules/link.d.ts +0 -21
- package/components/chord-diagram/modules/link.js +0 -63
- package/components/chord-diagram/modules/link.js.map +0 -1
- package/components/chord-diagram/modules/node.d.ts +0 -17
- package/components/chord-diagram/modules/node.js +0 -52
- package/components/chord-diagram/modules/node.js.map +0 -1
- package/components/chord-diagram/style.d.ts +0 -13
- package/components/chord-diagram/style.js.map +0 -1
- package/components/chord-diagram/types.d.ts +0 -58
- package/components/chord-diagram/types.js +0 -8
- package/components/chord-diagram/types.js.map +0 -1
- package/components/crosshair/config.d.ts +0 -43
- package/components/crosshair/config.js +0 -19
- package/components/crosshair/config.js.map +0 -1
- package/components/crosshair/index.d.ts +0 -35
- package/components/crosshair/index.js +0 -183
- package/components/crosshair/index.js.map +0 -1
- package/components/crosshair/style.d.ts +0 -4
- package/components/crosshair/style.js.map +0 -1
- package/components/crosshair/types.d.ts +0 -13
- package/components/crosshair/types.js +0 -2
- package/components/crosshair/types.js.map +0 -1
- package/components/donut/config.d.ts +0 -59
- package/components/donut/config.js +0 -28
- package/components/donut/config.js.map +0 -1
- package/components/donut/index.d.ts +0 -21
- package/components/donut/index.js +0 -107
- package/components/donut/index.js.map +0 -1
- package/components/donut/modules/arc.d.ts +0 -10
- package/components/donut/modules/arc.js +0 -59
- package/components/donut/modules/arc.js.map +0 -1
- package/components/donut/style.d.ts +0 -7
- package/components/donut/style.js.map +0 -1
- package/components/donut/types.d.ts +0 -20
- package/components/flow-legend/config.d.ts +0 -29
- package/components/flow-legend/config.js +0 -18
- package/components/flow-legend/config.js.map +0 -1
- package/components/flow-legend/index.d.ts +0 -16
- package/components/flow-legend/index.js +0 -75
- package/components/flow-legend/index.js.map +0 -1
- package/components/flow-legend/style.d.ts +0 -8
- package/components/flow-legend/style.js.map +0 -1
- package/components/flow-legend/types.d.ts +0 -9
- package/components/flow-legend/types.js +0 -8
- package/components/flow-legend/types.js.map +0 -1
- package/components/free-brush/config.d.ts +0 -45
- package/components/free-brush/config.js +0 -24
- package/components/free-brush/config.js.map +0 -1
- package/components/free-brush/index.d.ts +0 -20
- package/components/free-brush/index.js +0 -192
- package/components/free-brush/index.js.map +0 -1
- package/components/free-brush/style.d.ts +0 -4
- package/components/free-brush/style.js.map +0 -1
- package/components/free-brush/types.d.ts +0 -7
- package/components/free-brush/types.js +0 -9
- package/components/free-brush/types.js.map +0 -1
- package/components/graph/config.d.ts +0 -238
- package/components/graph/config.js +0 -84
- package/components/graph/config.js.map +0 -1
- package/components/graph/index.d.ts +0 -126
- package/components/graph/index.js +0 -656
- package/components/graph/index.js.map +0 -1
- package/components/graph/modules/layout-helpers.d.ts +0 -21
- package/components/graph/modules/layout-helpers.js +0 -69
- package/components/graph/modules/layout-helpers.js.map +0 -1
- package/components/graph/modules/layout.d.ts +0 -10
- package/components/graph/modules/layout.js +0 -399
- package/components/graph/modules/layout.js.map +0 -1
- package/components/graph/modules/link/helper.d.ts +0 -25
- package/components/graph/modules/link/helper.js +0 -74
- package/components/graph/modules/link/helper.js.map +0 -1
- package/components/graph/modules/link/index.d.ts +0 -11
- package/components/graph/modules/link/index.js +0 -212
- package/components/graph/modules/link/index.js.map +0 -1
- package/components/graph/modules/link/style.d.ts +0 -15
- package/components/graph/modules/link/style.js.map +0 -1
- package/components/graph/modules/node/helper.d.ts +0 -21
- package/components/graph/modules/node/helper.js +0 -126
- package/components/graph/modules/node/helper.js.map +0 -1
- package/components/graph/modules/node/index.d.ts +0 -11
- package/components/graph/modules/node/index.js +0 -252
- package/components/graph/modules/node/index.js.map +0 -1
- package/components/graph/modules/node/style.d.ts +0 -24
- package/components/graph/modules/node/style.js.map +0 -1
- package/components/graph/modules/panel/helper.d.ts +0 -18
- package/components/graph/modules/panel/helper.js +0 -111
- package/components/graph/modules/panel/helper.js.map +0 -1
- package/components/graph/modules/panel/index.d.ts +0 -7
- package/components/graph/modules/panel/index.js +0 -98
- package/components/graph/modules/panel/index.js.map +0 -1
- package/components/graph/modules/panel/style.d.ts +0 -14
- package/components/graph/modules/panel/style.js.map +0 -1
- package/components/graph/modules/shape.d.ts +0 -6
- package/components/graph/modules/shape.js +0 -80
- package/components/graph/modules/shape.js.map +0 -1
- package/components/graph/modules/zoom-levels.d.ts +0 -6
- package/components/graph/modules/zoom-levels.js +0 -10
- package/components/graph/modules/zoom-levels.js.map +0 -1
- package/components/graph/style.d.ts +0 -6
- package/components/graph/style.js +0 -66
- package/components/graph/style.js.map +0 -1
- package/components/graph/types.d.ts +0 -125
- package/components/graph/types.js +0 -30
- package/components/graph/types.js.map +0 -1
- package/components/grouped-bar/config.d.ts +0 -36
- package/components/grouped-bar/config.js +0 -20
- package/components/grouped-bar/config.js.map +0 -1
- package/components/grouped-bar/index.d.ts +0 -32
- package/components/grouped-bar/index.js +0 -249
- package/components/grouped-bar/index.js.map +0 -1
- package/components/grouped-bar/style.d.ts +0 -5
- package/components/grouped-bar/style.js.map +0 -1
- package/components/leaflet-flow-map/config.d.ts +0 -46
- package/components/leaflet-flow-map/config.js +0 -25
- package/components/leaflet-flow-map/config.js.map +0 -1
- package/components/leaflet-flow-map/index.d.ts +0 -52
- package/components/leaflet-flow-map/index.js +0 -220
- package/components/leaflet-flow-map/index.js.map +0 -1
- package/components/leaflet-flow-map/renderer-utils.d.ts +0 -5
- package/components/leaflet-flow-map/renderer-utils.js +0 -15
- package/components/leaflet-flow-map/renderer-utils.js.map +0 -1
- package/components/leaflet-flow-map/renderer.d.ts +0 -26
- package/components/leaflet-flow-map/renderer.js +0 -117
- package/components/leaflet-flow-map/renderer.js.map +0 -1
- package/components/leaflet-flow-map/shaders.d.ts +0 -2
- package/components/leaflet-flow-map/shaders.js.map +0 -1
- package/components/leaflet-flow-map/types.d.ts +0 -23
- package/components/leaflet-map/config.d.ts +0 -193
- package/components/leaflet-map/config.js +0 -71
- package/components/leaflet-map/config.js.map +0 -1
- package/components/leaflet-map/index.d.ts +0 -130
- package/components/leaflet-map/index.js +0 -690
- package/components/leaflet-map/index.js.map +0 -1
- package/components/leaflet-map/leaflet.css.js +0 -5
- package/components/leaflet-map/leaflet.css.js.map +0 -1
- package/components/leaflet-map/modules/clusterBackground.d.ts +0 -5
- package/components/leaflet-map/modules/clusterBackground.js +0 -27
- package/components/leaflet-map/modules/clusterBackground.js.map +0 -1
- package/components/leaflet-map/modules/donut.d.ts +0 -3
- package/components/leaflet-map/modules/donut.js +0 -25
- package/components/leaflet-map/modules/donut.js.map +0 -1
- package/components/leaflet-map/modules/map.d.ts +0 -14
- package/components/leaflet-map/modules/map.js +0 -154
- package/components/leaflet-map/modules/map.js.map +0 -1
- package/components/leaflet-map/modules/node.d.ts +0 -9
- package/components/leaflet-map/modules/node.js +0 -162
- package/components/leaflet-map/modules/node.js.map +0 -1
- package/components/leaflet-map/modules/selectionRing.d.ts +0 -7
- package/components/leaflet-map/modules/selectionRing.js +0 -41
- package/components/leaflet-map/modules/selectionRing.js.map +0 -1
- package/components/leaflet-map/modules/utils.d.ts +0 -50
- package/components/leaflet-map/modules/utils.js +0 -210
- package/components/leaflet-map/modules/utils.js.map +0 -1
- package/components/leaflet-map/renderer/leaflet-maplibre-gl.js.map +0 -1
- package/components/leaflet-map/renderer/map-style.d.ts +0 -4
- package/components/leaflet-map/renderer/map-style.js +0 -15
- package/components/leaflet-map/renderer/map-style.js.map +0 -1
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js +0 -40
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js.map +0 -1
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js +0 -40
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js.map +0 -1
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js +0 -4981
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js.map +0 -1
- package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +0 -8
- package/components/leaflet-map/renderer/mapboxgl-layer.js +0 -27
- package/components/leaflet-map/renderer/mapboxgl-layer.js.map +0 -1
- package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +0 -4
- package/components/leaflet-map/renderer/mapboxgl-utils.js +0 -39
- package/components/leaflet-map/renderer/mapboxgl-utils.js.map +0 -1
- package/components/leaflet-map/renderer/maplibre-gl.css.js.map +0 -1
- package/components/leaflet-map/style.d.ts +0 -52
- package/components/leaflet-map/style.js +0 -183
- package/components/leaflet-map/style.js.map +0 -1
- package/components/leaflet-map/types.d.ts +0 -75
- package/components/leaflet-map/types.js +0 -15
- package/components/leaflet-map/types.js.map +0 -1
- package/components/line/config.d.ts +0 -30
- package/components/line/config.js +0 -17
- package/components/line/config.js.map +0 -1
- package/components/line/index.d.ts +0 -27
- package/components/line/index.js +0 -152
- package/components/line/index.js.map +0 -1
- package/components/line/style.d.ts +0 -6
- package/components/line/style.js.map +0 -1
- package/components/line/types.d.ts +0 -12
- package/components/nested-donut/config.d.ts +0 -59
- package/components/nested-donut/config.js +0 -19
- package/components/nested-donut/config.js.map +0 -1
- package/components/nested-donut/index.d.ts +0 -38
- package/components/nested-donut/index.js +0 -133
- package/components/nested-donut/index.js.map +0 -1
- package/components/nested-donut/modules/arc.d.ts +0 -17
- package/components/nested-donut/modules/arc.js +0 -50
- package/components/nested-donut/modules/arc.js.map +0 -1
- package/components/nested-donut/modules/label.d.ts +0 -7
- package/components/nested-donut/modules/label.js +0 -34
- package/components/nested-donut/modules/label.js.map +0 -1
- package/components/nested-donut/style.d.ts +0 -26
- package/components/nested-donut/style.js +0 -70
- package/components/nested-donut/style.js.map +0 -1
- package/components/nested-donut/types.d.ts +0 -24
- package/components/nested-donut/types.js +0 -11
- package/components/nested-donut/types.js.map +0 -1
- package/components/sankey/config.d.ts +0 -162
- package/components/sankey/config.js +0 -65
- package/components/sankey/config.js.map +0 -1
- package/components/sankey/index.d.ts +0 -59
- package/components/sankey/index.js +0 -306
- package/components/sankey/index.js.map +0 -1
- package/components/sankey/modules/label.d.ts +0 -23
- package/components/sankey/modules/label.js +0 -168
- package/components/sankey/modules/label.js.map +0 -1
- package/components/sankey/modules/link.d.ts +0 -14
- package/components/sankey/modules/link.js +0 -108
- package/components/sankey/modules/link.js.map +0 -1
- package/components/sankey/modules/node.d.ts +0 -10
- package/components/sankey/modules/node.js +0 -156
- package/components/sankey/modules/node.js.map +0 -1
- package/components/sankey/style.d.ts +0 -20
- package/components/sankey/style.js.map +0 -1
- package/components/sankey/types.d.ts +0 -84
- package/components/sankey/types.js +0 -34
- package/components/sankey/types.js.map +0 -1
- package/components/scatter/config.d.ts +0 -44
- package/components/scatter/config.js +0 -23
- package/components/scatter/config.js.map +0 -1
- package/components/scatter/index.d.ts +0 -28
- package/components/scatter/index.js +0 -167
- package/components/scatter/index.js.map +0 -1
- package/components/scatter/modules/point.d.ts +0 -7
- package/components/scatter/modules/point.js +0 -86
- package/components/scatter/modules/point.js.map +0 -1
- package/components/scatter/modules/utils.d.ts +0 -11
- package/components/scatter/modules/utils.js +0 -112
- package/components/scatter/modules/utils.js.map +0 -1
- package/components/scatter/style.d.ts +0 -5
- package/components/scatter/style.js.map +0 -1
- package/components/scatter/types.d.ts +0 -19
- package/components/stacked-bar/config.d.ts +0 -38
- package/components/stacked-bar/config.js +0 -20
- package/components/stacked-bar/config.js.map +0 -1
- package/components/stacked-bar/index.d.ts +0 -28
- package/components/stacked-bar/index.js +0 -208
- package/components/stacked-bar/index.js.map +0 -1
- package/components/stacked-bar/style.d.ts +0 -5
- package/components/stacked-bar/style.js.map +0 -1
- package/components/stacked-bar/types.d.ts +0 -5
- package/components/timeline/config.d.ts +0 -43
- package/components/timeline/config.js +0 -24
- package/components/timeline/config.js.map +0 -1
- package/components/timeline/index.d.ts +0 -41
- package/components/timeline/index.js +0 -244
- package/components/timeline/index.js.map +0 -1
- package/components/timeline/style.d.ts +0 -13
- package/components/timeline/style.js.map +0 -1
- package/components/tooltip/config.d.ts +0 -68
- package/components/tooltip/config.js +0 -20
- package/components/tooltip/config.js.map +0 -1
- package/components/tooltip/index.d.ts +0 -36
- package/components/tooltip/index.js +0 -184
- package/components/tooltip/index.js.map +0 -1
- package/components/tooltip/style.js.map +0 -1
- package/components/topojson-map/config.d.ts +0 -99
- package/components/topojson-map/config.js +0 -42
- package/components/topojson-map/config.js.map +0 -1
- package/components/topojson-map/index.d.ts +0 -52
- package/components/topojson-map/index.js +0 -355
- package/components/topojson-map/index.js.map +0 -1
- package/components/topojson-map/style.d.ts +0 -11
- package/components/topojson-map/style.js.map +0 -1
- package/components/topojson-map/types.d.ts +0 -78
- package/components/topojson-map/types.js +0 -80
- package/components/topojson-map/types.js.map +0 -1
- package/components/topojson-map/utils.d.ts +0 -3
- package/components/topojson-map/utils.js +0 -30
- package/components/topojson-map/utils.js.map +0 -1
- package/components/vis-controls/config.d.ts +0 -12
- package/components/vis-controls/config.js +0 -13
- package/components/vis-controls/config.js.map +0 -1
- package/components/vis-controls/index.d.ts +0 -14
- package/components/vis-controls/index.js +0 -52
- package/components/vis-controls/index.js.map +0 -1
- package/components/vis-controls/style.d.ts +0 -11
- package/components/vis-controls/style.js.map +0 -1
- package/components/vis-controls/types.d.ts +0 -13
- package/components/vis-controls/types.js +0 -8
- package/components/vis-controls/types.js.map +0 -1
- package/components/xy-labels/config.d.ts +0 -48
- package/components/xy-labels/config.js +0 -25
- package/components/xy-labels/config.js.map +0 -1
- package/components/xy-labels/index.d.ts +0 -15
- package/components/xy-labels/index.js +0 -87
- package/components/xy-labels/index.js.map +0 -1
- package/components/xy-labels/modules/label.d.ts +0 -9
- package/components/xy-labels/modules/label.js +0 -107
- package/components/xy-labels/modules/label.js.map +0 -1
- package/components/xy-labels/style.d.ts +0 -5
- package/components/xy-labels/style.js.map +0 -1
- package/components/xy-labels/types.d.ts +0 -23
- package/components/xy-labels/types.js +0 -9
- package/components/xy-labels/types.js.map +0 -1
- package/components.d.ts +0 -51
- package/components.js +0 -29
- package/components.js.map +0 -1
- package/containers/single-container/config.d.ts +0 -12
- package/containers/single-container/config.js +0 -12
- package/containers/single-container/config.js.map +0 -1
- package/containers/single-container/index.d.ts +0 -19
- package/containers/single-container/index.js +0 -128
- package/containers/single-container/index.js.map +0 -1
- package/containers/xy-container/config.d.ts +0 -99
- package/containers/xy-container/config.js +0 -30
- package/containers/xy-container/config.js.map +0 -1
- package/containers/xy-container/index.d.ts +0 -34
- package/containers/xy-container/index.js +0 -330
- package/containers/xy-container/index.js.map +0 -1
- package/containers.d.ts +0 -6
- package/containers.js +0 -4
- package/containers.js.map +0 -1
- package/core/component/config.d.ts +0 -58
- package/core/component/config.js +0 -14
- package/core/component/config.js.map +0 -1
- package/core/component/index.d.ts +0 -43
- package/core/component/index.js +0 -118
- package/core/component/index.js.map +0 -1
- package/core/component/types.d.ts +0 -2
- package/core/component/types.js +0 -2
- package/core/component/types.js.map +0 -1
- package/core/config/index.d.ts +0 -3
- package/core/config/index.js +0 -16
- package/core/config/index.js.map +0 -1
- package/core/container/config.d.ts +0 -48
- package/core/container/config.js +0 -29
- package/core/container/config.js.map +0 -1
- package/core/container/index.d.ts +0 -26
- package/core/container/index.js +0 -105
- package/core/container/index.js.map +0 -1
- package/core/xy-component/config.d.ts +0 -38
- package/core/xy-component/config.js +0 -20
- package/core/xy-component/config.js.map +0 -1
- package/core/xy-component/index.d.ts +0 -27
- package/core/xy-component/index.js +0 -74
- package/core/xy-component/index.js.map +0 -1
- package/data-models/core.d.ts +0 -6
- package/data-models/core.js +0 -14
- package/data-models/core.js.map +0 -1
- package/data-models/graph.d.ts +0 -24
- package/data-models/graph.js +0 -107
- package/data-models/graph.js.map +0 -1
- package/data-models/map-graph.d.ts +0 -21
- package/data-models/map-graph.js +0 -62
- package/data-models/map-graph.js.map +0 -1
- package/data-models/map.d.ts +0 -5
- package/data-models/map.js +0 -12
- package/data-models/map.js.map +0 -1
- package/data-models/series.d.ts +0 -6
- package/data-models/series.js +0 -19
- package/data-models/series.js.map +0 -1
- package/index.d.ts +0 -7
- package/index.js +0 -55
- package/index.js.map +0 -1
- package/maps/china-provinces.json.js +0 -140373
- package/maps/fr-regions.json.js +0 -14162
- package/maps/germany-regions.json.js +0 -35760
- package/maps/ind-regions.json.js +0 -290584
- package/maps/uk-regions.json.js +0 -96233
- package/maps/us-counties.json.js +0 -206318
- package/maps/us-states.json.js +0 -16345
- package/maps/world-110m-alpha.json.js +0 -251366
- package/maps/world-simple.json.js +0 -89428
- package/maps/world-simplest.json.js +0 -28175
- package/maps.d.ts +0 -60
- package/maps.js +0 -23
- package/styles/colors.d.ts +0 -7
- package/styles/colors.js +0 -24
- package/styles/colors.js.map +0 -1
- package/styles/index.d.ts +0 -7
- package/styles/index.js +0 -38
- package/styles/index.js.map +0 -1
- package/styles/sizes.d.ts +0 -2
- package/styles/sizes.js.map +0 -1
- package/types/accessor.d.ts +0 -5
- package/types/accessor.js +0 -2
- package/types/accessor.js.map +0 -1
- package/types/component.d.ts +0 -13
- package/types/component.js +0 -14
- package/types/component.js.map +0 -1
- package/types/curve.d.ts +0 -40
- package/types/curve.js +0 -46
- package/types/curve.js.map +0 -1
- package/types/data.d.ts +0 -7
- package/types/data.js +0 -2
- package/types/data.js.map +0 -1
- package/types/direction.d.ts +0 -6
- package/types/direction.js +0 -10
- package/types/direction.js.map +0 -1
- package/types/graph.d.ts +0 -35
- package/types/graph.js +0 -2
- package/types/graph.js.map +0 -1
- package/types/map.d.ts +0 -4
- package/types/map.js +0 -2
- package/types/map.js.map +0 -1
- package/types/misc.d.ts +0 -8
- package/types/position.d.ts +0 -20
- package/types/position.js +0 -27
- package/types/position.js.map +0 -1
- package/types/scale.d.ts +0 -23
- package/types/scale.js +0 -27
- package/types/scale.js.map +0 -1
- package/types/shape.d.ts +0 -7
- package/types/shape.js +0 -11
- package/types/shape.js.map +0 -1
- package/types/spacing.d.ts +0 -6
- package/types/spacing.js +0 -2
- package/types/spacing.js.map +0 -1
- package/types/svg.d.ts +0 -18
- package/types/svg.js +0 -22
- package/types/svg.js.map +0 -1
- package/types/symbol.d.ts +0 -18
- package/types/symbol.js +0 -24
- package/types/symbol.js.map +0 -1
- package/types/text.d.ts +0 -47
- package/types/text.js +0 -26
- package/types/text.js.map +0 -1
- package/types.d.ts +0 -27
- package/types.js +0 -30
- package/types.js.map +0 -1
- package/utils/color.d.ts +0 -10
- package/utils/color.js +0 -32
- package/utils/color.js.map +0 -1
- package/utils/d3.d.ts +0 -3
- package/utils/d3.js +0 -16
- package/utils/d3.js.map +0 -1
- package/utils/data.d.ts +0 -45
- package/utils/data.js +0 -274
- package/utils/data.js.map +0 -1
- package/utils/html.d.ts +0 -1
- package/utils/html.js +0 -16
- package/utils/html.js.map +0 -1
- package/utils/map.d.ts +0 -2
- package/utils/map.js +0 -20
- package/utils/map.js.map +0 -1
- package/utils/misc.d.ts +0 -9
- package/utils/misc.js +0 -47
- package/utils/misc.js.map +0 -1
- package/utils/path.d.ts +0 -23
- package/utils/path.js +0 -144
- package/utils/path.js.map +0 -1
- package/utils/scale.d.ts +0 -1
- package/utils/style.d.ts +0 -6
- package/utils/style.js +0 -24
- package/utils/style.js.map +0 -1
- package/utils/svg.d.ts +0 -3
- package/utils/text.d.ts +0 -139
- package/utils/text.js +0 -443
- package/utils/text.js.map +0 -1
- package/utils/type.d.ts +0 -5
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
import { min, max } from 'd3-array'
|
|
2
|
+
import { Transition } from 'd3-transition'
|
|
3
|
+
import { select, Selection, pointer } from 'd3-selection'
|
|
4
|
+
import { zoom, zoomTransform, zoomIdentity, ZoomTransform, D3ZoomEvent, ZoomBehavior } from 'd3-zoom'
|
|
5
|
+
import { drag, D3DragEvent } from 'd3-drag'
|
|
6
|
+
import { interval, Timer } from 'd3-timer'
|
|
7
|
+
|
|
8
|
+
// Core
|
|
9
|
+
import { ComponentCore } from 'core/component'
|
|
10
|
+
import { GraphDataModel } from 'data-models/graph'
|
|
11
|
+
|
|
12
|
+
// Types
|
|
13
|
+
import { GraphInputLink, GraphInputNode } from 'types/graph'
|
|
14
|
+
import { Spacing } from 'types/spacing'
|
|
15
|
+
|
|
16
|
+
// Utils
|
|
17
|
+
import { isNumber, clamp, clean, unique, shallowDiff, isFunction, getBoolean } from 'utils/data'
|
|
18
|
+
import { stringToHtmlId } from 'utils/misc'
|
|
19
|
+
import { smartTransition } from 'utils/d3'
|
|
20
|
+
|
|
21
|
+
// Local Types
|
|
22
|
+
import { GraphNode, GraphLink, GraphLayoutType, GraphLinkArrowStyle, GraphPanel } from './types'
|
|
23
|
+
|
|
24
|
+
// Config
|
|
25
|
+
import { GraphConfig, GraphConfigInterface } from './config'
|
|
26
|
+
|
|
27
|
+
// Styles
|
|
28
|
+
import * as generalSelectors from './style'
|
|
29
|
+
import * as nodeSelectors from './modules/node/style'
|
|
30
|
+
import * as linkSelectors from './modules/link/style'
|
|
31
|
+
import * as panelSelectors from './modules/panel/style'
|
|
32
|
+
|
|
33
|
+
// Modules
|
|
34
|
+
import { createNodes, updateNodes, removeNodes, zoomNodesThrottled, zoomNodes, updateSelectedNodes } from './modules/node'
|
|
35
|
+
import { getMaxNodeSize, getNodeSize, getX, getY } from './modules/node/helper'
|
|
36
|
+
import { createLinks, updateLinks, removeLinks, zoomLinksThrottled, zoomLinks, animateLinkFlow, updateSelectedLinks } from './modules/link'
|
|
37
|
+
import { LINK_MARKER_WIDTH, LINK_MARKER_HEIGHT, getDoubleArrowPath, getArrowPath, getLinkColor, getLinkArrow } from './modules/link/helper'
|
|
38
|
+
import { createPanels, updatePanels, removePanels } from './modules/panel'
|
|
39
|
+
import { setPanelForNodes, updatePanelBBoxSize, updatePanelNumNodes, initPanels } from './modules/panel/helper'
|
|
40
|
+
import { applyLayoutCircular, applyLayoutParallel, applyLayoutDagre, applyLayoutConcentric, applyLayoutForce, applyELKLayout } from './modules/layout'
|
|
41
|
+
|
|
42
|
+
export class Graph<
|
|
43
|
+
N extends GraphInputNode,
|
|
44
|
+
L extends GraphInputLink,
|
|
45
|
+
> extends ComponentCore<
|
|
46
|
+
{nodes: N[]; links?: L[]},
|
|
47
|
+
GraphConfig<N, L>,
|
|
48
|
+
GraphConfigInterface<N, L>
|
|
49
|
+
> {
|
|
50
|
+
static selectors = {
|
|
51
|
+
root: generalSelectors.root,
|
|
52
|
+
background: generalSelectors.background,
|
|
53
|
+
node: nodeSelectors.gNode,
|
|
54
|
+
nodeShape: nodeSelectors.node,
|
|
55
|
+
nodeGauge: nodeSelectors.nodeGauge,
|
|
56
|
+
nodeSideLabel: nodeSelectors.sideLabelGroup,
|
|
57
|
+
nodeLabel: nodeSelectors.label,
|
|
58
|
+
link: linkSelectors.gLink,
|
|
59
|
+
linkLine: linkSelectors.link,
|
|
60
|
+
panel: panelSelectors.gPanel,
|
|
61
|
+
panelRect: panelSelectors.panel,
|
|
62
|
+
panelSelection: panelSelectors.panelSelection,
|
|
63
|
+
panelLabel: panelSelectors.label,
|
|
64
|
+
panelLabelText: panelSelectors.labelText,
|
|
65
|
+
panelSideIcon: panelSelectors.sideIconGroup,
|
|
66
|
+
panelSideIconShape: panelSelectors.sideIconShape,
|
|
67
|
+
panelSideIconSymbol: panelSelectors.sideIconSymbol,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static nodeSelectors = nodeSelectors
|
|
71
|
+
g: Selection<SVGGElement, unknown, null, undefined>
|
|
72
|
+
config: GraphConfig<N, L> = new GraphConfig()
|
|
73
|
+
datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>> = new GraphDataModel()
|
|
74
|
+
private _selectedNode: GraphNode<N>
|
|
75
|
+
private _selectedLink: GraphLink<N, L>
|
|
76
|
+
|
|
77
|
+
private _graphGroup: Selection<SVGGElement, unknown, SVGGElement, undefined>
|
|
78
|
+
private _panelsGroup: Selection<SVGGElement, unknown, SVGGElement, undefined>
|
|
79
|
+
private _linksGroup: Selection<SVGGElement, unknown, SVGGElement, undefined>
|
|
80
|
+
private _nodesGroup: Selection<SVGGElement, unknown, SVGGElement, undefined>
|
|
81
|
+
private _timer: Timer
|
|
82
|
+
|
|
83
|
+
private _isFirstRender = true
|
|
84
|
+
private _prevWidth: number
|
|
85
|
+
private _prevHeight: number
|
|
86
|
+
private _shouldRecalculateLayout = false
|
|
87
|
+
|
|
88
|
+
private _shouldFitLayout: boolean
|
|
89
|
+
private _shouldSetPanels = false
|
|
90
|
+
private _panels: GraphPanel[]
|
|
91
|
+
|
|
92
|
+
private _defs: Selection<SVGDefsElement, unknown, SVGGElement, undefined>
|
|
93
|
+
private _backgroundRect: Selection<SVGRectElement, unknown, SVGGElement, undefined>
|
|
94
|
+
private _zoomBehavior: ZoomBehavior<SVGGElement, unknown>
|
|
95
|
+
private _isAutoFitDisabled = false
|
|
96
|
+
private _scale: number
|
|
97
|
+
private _initialTransform
|
|
98
|
+
private _isDragging = false
|
|
99
|
+
|
|
100
|
+
events = {
|
|
101
|
+
[Graph.selectors.background]: {
|
|
102
|
+
click: this._onBackgroundClick.bind(this),
|
|
103
|
+
},
|
|
104
|
+
[Graph.selectors.node]: {
|
|
105
|
+
click: this._onNodeClick.bind(this),
|
|
106
|
+
mouseover: this._onNodeMouseOver.bind(this),
|
|
107
|
+
mouseout: this._onNodeMouseOut.bind(this),
|
|
108
|
+
},
|
|
109
|
+
[Graph.selectors.link]: {
|
|
110
|
+
click: this._onLinkClick.bind(this),
|
|
111
|
+
mouseover: this._onLinkMouseOver.bind(this),
|
|
112
|
+
mouseout: this._onLinkMouseOut.bind(this),
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public get selectedNode (): GraphNode<N> {
|
|
117
|
+
return this._selectedNode
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public get selectedLink (): GraphLink<N, L> {
|
|
121
|
+
return this._selectedLink
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
constructor (config?: GraphConfigInterface<N, L>) {
|
|
125
|
+
super()
|
|
126
|
+
if (config) this.config.init(config)
|
|
127
|
+
|
|
128
|
+
this._backgroundRect = this.g.append('rect').attr('class', generalSelectors.background)
|
|
129
|
+
this._graphGroup = this.g.append('g').attr('class', generalSelectors.graphGroup)
|
|
130
|
+
|
|
131
|
+
this._zoomBehavior = zoom<SVGGElement, unknown>()
|
|
132
|
+
.scaleExtent(this.config.zoomScaleExtent)
|
|
133
|
+
.on('zoom', (e: D3ZoomEvent<SVGGElement, unknown>) => this._onZoom(e.transform, e))
|
|
134
|
+
|
|
135
|
+
this._panelsGroup = this._graphGroup.append('g').attr('class', panelSelectors.panels)
|
|
136
|
+
this._linksGroup = this._graphGroup.append('g').attr('class', linkSelectors.links)
|
|
137
|
+
this._nodesGroup = this._graphGroup.append('g').attr('class', nodeSelectors.nodes)
|
|
138
|
+
|
|
139
|
+
this._defs = this._graphGroup.append('defs')
|
|
140
|
+
|
|
141
|
+
this._getMarkerId = this._getMarkerId.bind(this)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setData (data: {nodes: N[]; links?: L[]}): void {
|
|
145
|
+
const { config } = this
|
|
146
|
+
|
|
147
|
+
this.datamodel.nodeSort = config.nodeSort
|
|
148
|
+
this.datamodel.data = data
|
|
149
|
+
this._shouldRecalculateLayout = true
|
|
150
|
+
if (config.layoutAutofit) this._shouldFitLayout = true
|
|
151
|
+
this._shouldSetPanels = true
|
|
152
|
+
|
|
153
|
+
this._addSVGDefs()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setConfig (config: GraphConfigInterface<N, L>): void {
|
|
157
|
+
this._shouldFitLayout = this._shouldFitLayout || this.config.layoutType !== config.layoutType
|
|
158
|
+
this._shouldRecalculateLayout = this._shouldRecalculateLayout || this._shouldLayoutRecalculate(config)
|
|
159
|
+
|
|
160
|
+
super.setConfig(config)
|
|
161
|
+
this._shouldSetPanels = true
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get bleed (): Spacing {
|
|
165
|
+
const extraPadding = 50 // Extra padding to take into account labels and selection outlines
|
|
166
|
+
return { top: extraPadding, bottom: extraPadding, left: extraPadding, right: extraPadding }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_render (customDuration?: number): void {
|
|
170
|
+
const { config: { disableZoom, duration, layoutAutofit, panels }, datamodel } = this
|
|
171
|
+
if (!datamodel.nodes && !datamodel.links) return
|
|
172
|
+
const animDuration = isNumber(customDuration) ? customDuration : duration
|
|
173
|
+
|
|
174
|
+
this._backgroundRect
|
|
175
|
+
.attr('width', this._width)
|
|
176
|
+
.attr('height', this._height)
|
|
177
|
+
.attr('opacity', 0)
|
|
178
|
+
|
|
179
|
+
if ((this._prevWidth !== this._width || this._prevHeight !== this._height) && layoutAutofit) {
|
|
180
|
+
// Fit layout on resize
|
|
181
|
+
this._shouldFitLayout = true
|
|
182
|
+
this._prevWidth = this._width
|
|
183
|
+
this._prevHeight = this._height
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Apply layout and render
|
|
187
|
+
this._calculateLayout().then((isFirstRender) => {
|
|
188
|
+
// If the component has been destroyed while the layout calculation
|
|
189
|
+
// was in progress, we cancel the render
|
|
190
|
+
if (this.isDestroyed()) return
|
|
191
|
+
|
|
192
|
+
if (this._shouldSetPanels) {
|
|
193
|
+
smartTransition(this._panelsGroup, duration / 2)
|
|
194
|
+
.style('opacity', panels?.length ? 1 : 0)
|
|
195
|
+
|
|
196
|
+
this._panels = initPanels(panels)
|
|
197
|
+
setPanelForNodes(this._panels, datamodel.nodes, this.config)
|
|
198
|
+
this._shouldSetPanels = false
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (isFirstRender) {
|
|
202
|
+
this._fit()
|
|
203
|
+
this._shouldFitLayout = false
|
|
204
|
+
} else if (this._shouldFitLayout && !this._isAutoFitDisabled) {
|
|
205
|
+
this._fit(duration)
|
|
206
|
+
this._shouldFitLayout = false
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Draw
|
|
210
|
+
this._drawNodes(animDuration)
|
|
211
|
+
this._drawLinks(animDuration)
|
|
212
|
+
|
|
213
|
+
// Select Links / Nodes
|
|
214
|
+
this._resetSelection()
|
|
215
|
+
if (this.config.selectedNodeId) {
|
|
216
|
+
const selectedNode = datamodel.nodes.find(node => node.id === this.config.selectedNodeId)
|
|
217
|
+
this._selectNode(selectedNode)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (this.config.selectedLinkId) {
|
|
221
|
+
const selectedLink = datamodel.links.find(link => link.id === this.config.selectedLinkId)
|
|
222
|
+
this._selectLink(selectedLink)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Link flow animation timer
|
|
226
|
+
if (!this._timer) {
|
|
227
|
+
const refreshRateMs = 35
|
|
228
|
+
this._timer = interval(this._onLinkFlowTimerFrame.bind(this), refreshRateMs)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Zoom
|
|
232
|
+
if (disableZoom) this.g.on('.zoom', null)
|
|
233
|
+
else this.g.call(this._zoomBehavior).on('dblclick.zoom', null)
|
|
234
|
+
|
|
235
|
+
if (!this._isFirstRender && !disableZoom) {
|
|
236
|
+
const transform = zoomTransform(this.g.node())
|
|
237
|
+
this._onZoom(transform)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// While the graph is animating we disable pointer events on the graph group
|
|
241
|
+
if (animDuration) { this._graphGroup.attr('pointer-events', 'none') }
|
|
242
|
+
smartTransition(this._graphGroup, animDuration)
|
|
243
|
+
.on('end interrupt', () => {
|
|
244
|
+
this._graphGroup.attr('pointer-events', null)
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
// We need to set up events and attributes again because the rendering might have been delayed by the layout
|
|
248
|
+
// calculation and they were not set up properly (see the render function of `ComponentCore`)
|
|
249
|
+
this._setUpComponentEventsThrottled()
|
|
250
|
+
this._setCustomAttributesThrottled()
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
this._isFirstRender = false
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private _drawNodes (duration: number): void {
|
|
258
|
+
const { config, datamodel } = this
|
|
259
|
+
|
|
260
|
+
const nodes: GraphNode<N>[] = datamodel.nodes
|
|
261
|
+
const nodeGroups = this._nodesGroup
|
|
262
|
+
.selectAll<SVGGElement, GraphNode<N>>(`.${nodeSelectors.gNode}:not(.${nodeSelectors.gNodeExit})`)
|
|
263
|
+
.data(nodes, d => String(d._id))
|
|
264
|
+
|
|
265
|
+
const nodeGroupsEnter = nodeGroups.enter().append('g')
|
|
266
|
+
.attr('class', nodeSelectors.gNode)
|
|
267
|
+
.call(createNodes, config, duration)
|
|
268
|
+
|
|
269
|
+
const nodeGroupsMerged = nodeGroups.merge(nodeGroupsEnter)
|
|
270
|
+
const nodeUpdateSelection = updateNodes(nodeGroupsMerged, config, duration, this._scale)
|
|
271
|
+
this._drawPanels(nodeUpdateSelection, duration)
|
|
272
|
+
|
|
273
|
+
const nodesGroupExit = nodeGroups.exit<GraphNode<N>>()
|
|
274
|
+
nodesGroupExit
|
|
275
|
+
.classed(nodeSelectors.gNodeExit, true)
|
|
276
|
+
.call(removeNodes, config, duration)
|
|
277
|
+
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
279
|
+
const thisRef = this
|
|
280
|
+
if (!config.disableDrag) {
|
|
281
|
+
const dragBehaviour = drag<SVGGElement, GraphNode<N>>()
|
|
282
|
+
.on('start', function (event, d) { thisRef._onDragStarted(d, event, select(this)) })
|
|
283
|
+
.on('drag', function (event, d) { thisRef._onDragged(d, event, nodeGroupsMerged) })
|
|
284
|
+
.on('end', function (event, d) { thisRef._onDragEnded(d, event, select(this)) })
|
|
285
|
+
nodeGroupsMerged.call(dragBehaviour)
|
|
286
|
+
} else {
|
|
287
|
+
nodeGroupsMerged.on('.drag', null)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private _drawLinks (duration: number): void {
|
|
292
|
+
const { config, datamodel: { links } } = this
|
|
293
|
+
|
|
294
|
+
const linkGroups = this._linksGroup
|
|
295
|
+
.selectAll<SVGGElement, GraphLink<N, L>>(`.${linkSelectors.gLink}`)
|
|
296
|
+
.data(links, (d: GraphLink<N, L>) => String(d._id))
|
|
297
|
+
|
|
298
|
+
const linkGroupsEnter = linkGroups.enter().append('g')
|
|
299
|
+
.attr('class', linkSelectors.gLink)
|
|
300
|
+
.call(createLinks, config, duration)
|
|
301
|
+
|
|
302
|
+
const linkGroupsMerged = linkGroups.merge(linkGroupsEnter)
|
|
303
|
+
linkGroupsMerged.call(updateLinks, config, duration, this._scale, this._getMarkerId)
|
|
304
|
+
|
|
305
|
+
const linkGroupsExit = linkGroups.exit<GraphLink<N, L>>()
|
|
306
|
+
linkGroupsExit
|
|
307
|
+
.attr('class', linkSelectors.gLinkExit)
|
|
308
|
+
.call(removeLinks, config, duration)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private _drawPanels (
|
|
312
|
+
nodeUpdateSelection: Selection<SVGGElement, GraphNode<N>, SVGGElement, unknown> | Transition<SVGGElement, GraphNode<N>, SVGGElement, unknown>,
|
|
313
|
+
duration: number
|
|
314
|
+
): void {
|
|
315
|
+
const { config } = this
|
|
316
|
+
if (!this._panels) return
|
|
317
|
+
|
|
318
|
+
const selection = ((nodeUpdateSelection as Transition<SVGGElement, GraphNode<N>, SVGGElement, unknown>).duration)
|
|
319
|
+
? (nodeUpdateSelection as Transition<SVGGElement, GraphNode<N>, SVGGElement, unknown>).selection()
|
|
320
|
+
: nodeUpdateSelection as Selection<SVGGElement, GraphNode<N>, SVGGElement, unknown>
|
|
321
|
+
|
|
322
|
+
updatePanelNumNodes(selection, this._panels, config)
|
|
323
|
+
updatePanelBBoxSize(selection, this._panels, config)
|
|
324
|
+
const panelData = this._panels.filter(p => p._numNodes)
|
|
325
|
+
const panelGroup = this._panelsGroup
|
|
326
|
+
.selectAll<SVGGElement, GraphPanel>(`.${panelSelectors.gPanel}`)
|
|
327
|
+
.data(panelData, p => p.label)
|
|
328
|
+
|
|
329
|
+
const panelGroupExit = panelGroup.exit<GraphPanel<N, L>>()
|
|
330
|
+
panelGroupExit.call(removePanels, config, duration)
|
|
331
|
+
|
|
332
|
+
const panelGroupEnter = panelGroup.enter().append('g')
|
|
333
|
+
.attr('class', panelSelectors.gPanel)
|
|
334
|
+
.call(createPanels, selection)
|
|
335
|
+
const panelGroupMerged = panelGroup.merge(panelGroupEnter)
|
|
336
|
+
|
|
337
|
+
this._updatePanels(panelGroupMerged, duration)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private _updatePanels (panelToUpdate: Selection<SVGGElement, GraphPanel, SVGGElement, unknown>, duration: number): void {
|
|
341
|
+
const { config } = this
|
|
342
|
+
if (!this._panels) return
|
|
343
|
+
|
|
344
|
+
panelToUpdate.call(updatePanels, config, duration)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private async _calculateLayout (): Promise<boolean> {
|
|
348
|
+
const { config, datamodel } = this
|
|
349
|
+
|
|
350
|
+
const firstRender = this._isFirstRender
|
|
351
|
+
if (this._shouldRecalculateLayout) {
|
|
352
|
+
switch (config.layoutType) {
|
|
353
|
+
case GraphLayoutType.Parallel:
|
|
354
|
+
applyLayoutParallel(datamodel, config, this._width, this._height)
|
|
355
|
+
break
|
|
356
|
+
case GraphLayoutType.ParallelHorizontal:
|
|
357
|
+
applyLayoutParallel(datamodel, config, this._width, this._height, 'horizontal')
|
|
358
|
+
break
|
|
359
|
+
case GraphLayoutType.Dagre:
|
|
360
|
+
await applyLayoutDagre(datamodel, config, this._width)
|
|
361
|
+
break
|
|
362
|
+
case GraphLayoutType.Force:
|
|
363
|
+
await applyLayoutForce(datamodel, config, this._width)
|
|
364
|
+
break
|
|
365
|
+
case GraphLayoutType.Concentric:
|
|
366
|
+
applyLayoutConcentric(datamodel, config, this._width, this._height)
|
|
367
|
+
break
|
|
368
|
+
case GraphLayoutType.Elk:
|
|
369
|
+
await applyELKLayout(datamodel, config, this._width)
|
|
370
|
+
break
|
|
371
|
+
case GraphLayoutType.Circular:
|
|
372
|
+
default:
|
|
373
|
+
applyLayoutCircular(datamodel, config, this._width, this._height)
|
|
374
|
+
break
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this._shouldRecalculateLayout = false
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return firstRender
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private _fit (duration = 0): void {
|
|
384
|
+
const { datamodel: { nodes } } = this
|
|
385
|
+
if (nodes?.length && this.g?.size()) {
|
|
386
|
+
const transform = this._getTransform(nodes)
|
|
387
|
+
smartTransition(this.g, duration)
|
|
388
|
+
.call(this._zoomBehavior.transform, transform)
|
|
389
|
+
this._onZoom(transform)
|
|
390
|
+
} else {
|
|
391
|
+
console.warn('Unovis | Graph: Node data is not defined. Check if the component has been initialized.')
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
private _getTransform (nodes: GraphNode<N>[]): ZoomTransform {
|
|
396
|
+
const { nodeSize, zoomScaleExtent } = this.config
|
|
397
|
+
const { left, top, right, bottom } = this.bleed
|
|
398
|
+
|
|
399
|
+
const maxNodeSize = getMaxNodeSize(nodes, nodeSize)
|
|
400
|
+
const w = this._width
|
|
401
|
+
const h = this._height
|
|
402
|
+
const xExtent = [
|
|
403
|
+
min(nodes, d => getX(d) - maxNodeSize / 2 - (max(d._panels?.map(p => p._padding.left)) || 0)),
|
|
404
|
+
max(nodes, d => getX(d) + maxNodeSize / 2 + (max(d._panels?.map(p => p._padding.right)) || 0)),
|
|
405
|
+
]
|
|
406
|
+
const yExtent = [
|
|
407
|
+
min(nodes, d => getY(d) - maxNodeSize / 2 - (max(d._panels?.map(p => p._padding.top)) || 0)),
|
|
408
|
+
max(nodes, d => getY(d) + maxNodeSize / 2 + (max(d._panels?.map(p => p._padding.bottom)) || 0)),
|
|
409
|
+
]
|
|
410
|
+
|
|
411
|
+
const xScale = w / (xExtent[1] - xExtent[0] + left + right)
|
|
412
|
+
const yScale = h / (yExtent[1] - yExtent[0] + top + bottom)
|
|
413
|
+
|
|
414
|
+
const clampedScale = clamp(min([xScale, yScale]), zoomScaleExtent[0], zoomScaleExtent[1])
|
|
415
|
+
|
|
416
|
+
const xCenter = (xExtent[1] + xExtent[0]) / 2
|
|
417
|
+
const yCenter = (yExtent[1] + yExtent[0]) / 2
|
|
418
|
+
const translateX = this._width / 2 - xCenter * clampedScale
|
|
419
|
+
const translateY = this._height / 2 - yCenter * clampedScale
|
|
420
|
+
const transform = zoomIdentity
|
|
421
|
+
.translate(translateX, translateY)
|
|
422
|
+
.scale(clampedScale)
|
|
423
|
+
|
|
424
|
+
return transform
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
private _selectNode (node: GraphNode<N>): void {
|
|
428
|
+
const { datamodel: { nodes, links } } = this
|
|
429
|
+
if (!node) console.warn('Unovis | Graph: Select Node: Not found')
|
|
430
|
+
this._selectedNode = node
|
|
431
|
+
|
|
432
|
+
// Apply grey out
|
|
433
|
+
// Grey out all nodes
|
|
434
|
+
nodes.forEach(n => {
|
|
435
|
+
n._state.selected = false
|
|
436
|
+
n._state.greyout = true
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
// Grey out all links
|
|
440
|
+
links.forEach(l => {
|
|
441
|
+
l._state.greyout = true
|
|
442
|
+
l._state.selected = false
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
// Highlight selected
|
|
446
|
+
if (node) {
|
|
447
|
+
node._state.selected = true
|
|
448
|
+
node._state.greyout = false
|
|
449
|
+
|
|
450
|
+
const connectedLinks = links.filter(l => (l.source === node) || (l.target === node))
|
|
451
|
+
connectedLinks.forEach(l => {
|
|
452
|
+
const source = l.source as GraphNode<N>
|
|
453
|
+
const target = l.target as GraphNode<N>
|
|
454
|
+
source._state.greyout = false
|
|
455
|
+
target._state.greyout = false
|
|
456
|
+
l._state.greyout = false
|
|
457
|
+
})
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
this._updateSelectedElements()
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
private _selectLink (link: GraphLink<N, L>): void {
|
|
464
|
+
const { datamodel: { nodes, links } } = this
|
|
465
|
+
if (!link) console.warn('Unovis: Graph: Select Link: Not found')
|
|
466
|
+
this._selectedLink = link
|
|
467
|
+
const selectedLinkSource = link?.source as GraphNode<N>
|
|
468
|
+
const selectedLinkTarget = link?.target as GraphNode<N>
|
|
469
|
+
|
|
470
|
+
// Apply grey out
|
|
471
|
+
nodes.forEach(n => {
|
|
472
|
+
n._state.selected = false
|
|
473
|
+
n._state.greyout = true
|
|
474
|
+
if (selectedLinkTarget?._id === n._id || selectedLinkSource?._id === n._id) {
|
|
475
|
+
link._state.greyout = false
|
|
476
|
+
}
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
links.forEach(l => {
|
|
480
|
+
l._state.greyout = true
|
|
481
|
+
const source = l.source as GraphNode<N>
|
|
482
|
+
const target = l.target as GraphNode<N>
|
|
483
|
+
if ((source._id === selectedLinkSource?._id) && (target._id === selectedLinkTarget?._id)) {
|
|
484
|
+
source._state.greyout = false
|
|
485
|
+
target._state.greyout = false
|
|
486
|
+
l._state.greyout = false
|
|
487
|
+
}
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
links.forEach(l => {
|
|
491
|
+
delete l._state.selected
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
if (link) link._state.selected = true
|
|
495
|
+
|
|
496
|
+
this._updateSelectedElements()
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
private _resetSelection (): void {
|
|
500
|
+
const { datamodel: { nodes, links } } = this
|
|
501
|
+
this._selectedNode = undefined
|
|
502
|
+
this._selectedLink = undefined
|
|
503
|
+
|
|
504
|
+
// Disable Grayout
|
|
505
|
+
nodes.forEach(n => {
|
|
506
|
+
delete n._state.selected
|
|
507
|
+
delete n._state.greyout
|
|
508
|
+
})
|
|
509
|
+
links.forEach(l => {
|
|
510
|
+
delete l._state.greyout
|
|
511
|
+
delete l._state.selected
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
this._updateSelectedElements()
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
private _updateSelectedElements (): void {
|
|
518
|
+
const { config } = this
|
|
519
|
+
|
|
520
|
+
const linkElements = this._linksGroup.selectAll<SVGGElement, GraphLink<N, L>>(`.${linkSelectors.gLink}`)
|
|
521
|
+
linkElements.call(updateSelectedLinks, config, this._scale)
|
|
522
|
+
|
|
523
|
+
const nodeElements = this._nodesGroup.selectAll<SVGGElement, GraphNode<N>>(`.${nodeSelectors.gNode}`)
|
|
524
|
+
nodeElements.call(updateSelectedNodes, config)
|
|
525
|
+
|
|
526
|
+
// this._drawPanels(nodeElements, 0)
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
private _onBackgroundClick (): void {
|
|
530
|
+
this._resetSelection()
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
534
|
+
private _onNodeClick (d: GraphNode<N>): void {
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
538
|
+
private _onNodeMouseOut (d: GraphNode<N>): void {
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
542
|
+
private _onNodeMouseOver (d: GraphNode<N>): void {
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
546
|
+
private _onLinkClick (d: GraphLink<N, L>): void {
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
private _onLinkMouseOver (d: GraphLink<N, L>): void {
|
|
550
|
+
if (this._isDragging) return
|
|
551
|
+
|
|
552
|
+
d._state.hovered = true
|
|
553
|
+
this._updateSelectedElements()
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
private _onLinkMouseOut (d: GraphLink<N, L>): void {
|
|
557
|
+
if (this._isDragging) return
|
|
558
|
+
|
|
559
|
+
delete d._state.hovered
|
|
560
|
+
this._updateSelectedElements()
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
private _onLinkFlowTimerFrame (elapsed = 0): void {
|
|
564
|
+
const { config: { linkFlow, linkFlowAnimDuration }, datamodel: { links } } = this
|
|
565
|
+
|
|
566
|
+
const hasLinksWithFlow = links.some((d, i) => getBoolean(d, linkFlow, i))
|
|
567
|
+
if (!hasLinksWithFlow) return
|
|
568
|
+
|
|
569
|
+
const t = (elapsed % linkFlowAnimDuration) / linkFlowAnimDuration
|
|
570
|
+
const linkElements = this._linksGroup.selectAll<SVGGElement, GraphLink<N, L>>(`.${linkSelectors.gLink}`)
|
|
571
|
+
|
|
572
|
+
const linksToAnimate = linkElements.filter(d => !d._state.greyout)
|
|
573
|
+
linksToAnimate.each(d => { d._state.flowAnimTime = t })
|
|
574
|
+
animateLinkFlow(linksToAnimate, this.config, this._scale)
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
private _onZoom (t: ZoomTransform, event?: D3ZoomEvent<SVGGElement, unknown>): void {
|
|
578
|
+
const { config, datamodel: { nodes } } = this
|
|
579
|
+
const transform = t || event.transform
|
|
580
|
+
this._scale = transform.k
|
|
581
|
+
this._graphGroup.attr('transform', transform.toString())
|
|
582
|
+
if (isFunction(config.onZoom)) config.onZoom(this._scale, config.zoomScaleExtent)
|
|
583
|
+
|
|
584
|
+
if (!this._initialTransform) this._initialTransform = transform
|
|
585
|
+
|
|
586
|
+
// If the event was triggered by a mouse interaction (pan or zoom) we don't
|
|
587
|
+
// refit the layout after recalculation (e.g. on container resize)
|
|
588
|
+
if (event?.sourceEvent) {
|
|
589
|
+
const diff = Object.keys(transform).reduce((acc, prop) => {
|
|
590
|
+
const val = transform[prop]
|
|
591
|
+
const dVal = Math.abs(val - this._initialTransform[prop])
|
|
592
|
+
return prop === 'k' ? 2 * dVal : dVal / 50
|
|
593
|
+
}, 0)
|
|
594
|
+
|
|
595
|
+
if (diff > config.layoutAutofitTolerance) this._isAutoFitDisabled = true
|
|
596
|
+
else this._isAutoFitDisabled = false
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
this._nodesGroup.selectAll<SVGGElement, GraphNode<N, L>>(`.${nodeSelectors.gNode}`)
|
|
600
|
+
.call(
|
|
601
|
+
(nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomNodesThrottled : zoomNodes) as typeof zoomNodes,
|
|
602
|
+
config,
|
|
603
|
+
this._scale
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
this._linksGroup.selectAll<SVGGElement, GraphLink<N, L>>(`.${linkSelectors.gLink}`)
|
|
607
|
+
.call(
|
|
608
|
+
(nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomLinksThrottled : zoomLinks) as typeof zoomLinks,
|
|
609
|
+
config,
|
|
610
|
+
this._scale,
|
|
611
|
+
this._getMarkerId
|
|
612
|
+
)
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
private _onDragStarted (
|
|
616
|
+
d: GraphNode<N>,
|
|
617
|
+
event: D3DragEvent<SVGGElement, GraphNode<N>, unknown>,
|
|
618
|
+
nodeSelection: Selection<SVGGElement, GraphNode<N>, SVGGElement, unknown>
|
|
619
|
+
): void {
|
|
620
|
+
const { config } = this
|
|
621
|
+
this._isDragging = true
|
|
622
|
+
d._state.isDragged = true
|
|
623
|
+
nodeSelection.call(updateNodes, config, 0, this._scale)
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
private _onDragged (
|
|
627
|
+
d: GraphNode<N>,
|
|
628
|
+
event: D3DragEvent<SVGGElement, GraphNode<N>, unknown>,
|
|
629
|
+
allNodesSelection: Selection<SVGGElement, GraphNode<N>, SVGGElement, unknown>
|
|
630
|
+
): void {
|
|
631
|
+
const { config } = this
|
|
632
|
+
const transform = zoomTransform(this.g.node())
|
|
633
|
+
const scale = transform.k
|
|
634
|
+
|
|
635
|
+
// Prevent the node from being dragged offscreen or outside its panel
|
|
636
|
+
const panels = this._panels?.filter(p => p.nodes.includes(d._id)) ?? []
|
|
637
|
+
const nodeSizeValue = getNodeSize(d, config.nodeSize, d._index)
|
|
638
|
+
const maxY = min([(this._height - transform.y) / scale, ...panels.map(p => p._y + p._height)]) - nodeSizeValue / 2
|
|
639
|
+
const maxX = min([(this._width - transform.x) / scale, ...panels.map(p => p._x + p._width)]) - nodeSizeValue / 2
|
|
640
|
+
const minY = max([-transform.y / scale, ...panels.map(p => p._y)]) + nodeSizeValue / 2
|
|
641
|
+
const minX = max([-transform.x / scale, ...panels.map(p => p._x)]) + nodeSizeValue / 2
|
|
642
|
+
|
|
643
|
+
let [x, y] = pointer(event, this._graphGroup.node())
|
|
644
|
+
if (y < minY) y = minY
|
|
645
|
+
else if (y > maxY) y = maxY
|
|
646
|
+
if (x < minX) x = minX
|
|
647
|
+
else if (x > maxX) x = maxX
|
|
648
|
+
|
|
649
|
+
// Snap to Layout
|
|
650
|
+
if (Math.sqrt(Math.pow(x - d.x, 2) + Math.pow(y - d.y, 2)) < 15) {
|
|
651
|
+
x = d.x
|
|
652
|
+
y = d.y
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// Assign coordinates
|
|
656
|
+
d._state.fx = x
|
|
657
|
+
d._state.fy = y
|
|
658
|
+
if (d._state.fx === d.x) delete d._state.fx
|
|
659
|
+
if (d._state.fy === d.y) delete d._state.fy
|
|
660
|
+
|
|
661
|
+
// Update affected DOM elements
|
|
662
|
+
const nodeSelection = this._nodesGroup.selectAll<SVGGElement, GraphNode<N>>(`.${nodeSelectors.gNode}`)
|
|
663
|
+
const nodeToUpdate = nodeSelection.filter((n: GraphNode<N>) => n._id === d._id)
|
|
664
|
+
nodeToUpdate.call(updateNodes, config, 0, scale)
|
|
665
|
+
|
|
666
|
+
const linkSelection = this._linksGroup.selectAll<SVGGElement, GraphLink<N, L>>(`.${linkSelectors.gLink}`)
|
|
667
|
+
const linksToUpdate = linkSelection.filter((l: L) => {
|
|
668
|
+
const source = l.source as GraphNode<N>
|
|
669
|
+
const target = l.target as GraphNode<N>
|
|
670
|
+
return source._id === d._id || target._id === d._id
|
|
671
|
+
})
|
|
672
|
+
linksToUpdate.call(updateLinks, config, 0, scale, this._getMarkerId)
|
|
673
|
+
const linksToAnimate = linksToUpdate.filter(d => d._state.greyout)
|
|
674
|
+
if (linksToAnimate.size()) animateLinkFlow(linksToAnimate, config, this._scale)
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
private _onDragEnded (
|
|
678
|
+
d: GraphNode<N>,
|
|
679
|
+
event: D3DragEvent<SVGGElement, GraphNode<N>, unknown>,
|
|
680
|
+
nodeSelection: Selection<SVGGElement, GraphNode<N>, SVGGElement, unknown>
|
|
681
|
+
): void {
|
|
682
|
+
const { config } = this
|
|
683
|
+
this._isDragging = false
|
|
684
|
+
d._state.isDragged = false
|
|
685
|
+
nodeSelection.call(updateNodes, config, 0, this._scale)
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
private _shouldLayoutRecalculate (nextConfig: GraphConfigInterface<N, L>): boolean {
|
|
689
|
+
const { config } = this
|
|
690
|
+
if (config.layoutType !== nextConfig.layoutType) return true
|
|
691
|
+
if (config.layoutNonConnectedAside !== nextConfig.layoutNonConnectedAside) return true
|
|
692
|
+
|
|
693
|
+
if (config.layoutType === GraphLayoutType.Force) {
|
|
694
|
+
const forceSettingsDiff = shallowDiff(config.forceLayoutSettings, nextConfig.forceLayoutSettings)
|
|
695
|
+
if (Object.keys(forceSettingsDiff).length) return true
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (config.layoutType === GraphLayoutType.Dagre) {
|
|
699
|
+
const dagreSettingsDiff = shallowDiff(config.dagreLayoutSettings, nextConfig.dagreLayoutSettings)
|
|
700
|
+
if (Object.keys(dagreSettingsDiff).length) return true
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (
|
|
704
|
+
config.layoutType === GraphLayoutType.Parallel ||
|
|
705
|
+
config.layoutType === GraphLayoutType.ParallelHorizontal ||
|
|
706
|
+
config.layoutType === GraphLayoutType.Concentric
|
|
707
|
+
) {
|
|
708
|
+
if (config.layoutGroupOrder !== nextConfig.layoutGroupOrder) return true
|
|
709
|
+
if (config.layoutParallelNodesPerColumn !== nextConfig.layoutParallelNodesPerColumn) return true
|
|
710
|
+
if (config.layoutParallelSortConnectionsByGroup !== nextConfig.layoutParallelSortConnectionsByGroup) return true
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return false
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
private _getMarkerId (d: GraphLink, color?: string, arrow?: GraphLinkArrowStyle): string {
|
|
717
|
+
const { config } = this
|
|
718
|
+
const c = color ?? getLinkColor(d, config)
|
|
719
|
+
const a = arrow ?? getLinkArrow(d, this._scale, config)
|
|
720
|
+
return a && c ? `${this.uid}-${stringToHtmlId(c)}-${a}` : null
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
private _addSVGDefs (): void {
|
|
724
|
+
const { datamodel: { links } } = this
|
|
725
|
+
|
|
726
|
+
// Clean up old defs
|
|
727
|
+
this._defs.selectAll('*').remove()
|
|
728
|
+
|
|
729
|
+
// Get all variations of link colors to create markers
|
|
730
|
+
const linkColors = unique(clean(
|
|
731
|
+
links.map(d => getLinkColor(d, this.config))
|
|
732
|
+
))
|
|
733
|
+
|
|
734
|
+
this._defs.selectAll('marker')
|
|
735
|
+
.data([
|
|
736
|
+
...linkColors.map(d => ({ color: d, arrow: GraphLinkArrowStyle.Single })), // Single-sided arrows
|
|
737
|
+
...linkColors.map(d => ({ color: d, arrow: GraphLinkArrowStyle.Double })), // Double-sided arrows
|
|
738
|
+
]).enter()
|
|
739
|
+
.append('marker')
|
|
740
|
+
.attr('id', d => this._getMarkerId(null, d.color, d.arrow))
|
|
741
|
+
.attr('orient', 'auto')
|
|
742
|
+
.attr('markerWidth', d => d.arrow === GraphLinkArrowStyle.Double ? LINK_MARKER_WIDTH * 2 : LINK_MARKER_WIDTH)
|
|
743
|
+
.attr('markerHeight', d => d.arrow === GraphLinkArrowStyle.Double ? LINK_MARKER_HEIGHT * 2 : LINK_MARKER_HEIGHT)
|
|
744
|
+
.attr('markerUnits', 'userSpaceOnUse')
|
|
745
|
+
.attr('refX', LINK_MARKER_WIDTH - LINK_MARKER_HEIGHT / 2)
|
|
746
|
+
.attr('refY', LINK_MARKER_HEIGHT - LINK_MARKER_HEIGHT / 2)
|
|
747
|
+
.html(d => {
|
|
748
|
+
return `
|
|
749
|
+
<path
|
|
750
|
+
d="${d.arrow === GraphLinkArrowStyle.Double ? getDoubleArrowPath() : getArrowPath()}"
|
|
751
|
+
fill="${d.color ?? null}"
|
|
752
|
+
/>
|
|
753
|
+
`
|
|
754
|
+
})
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
public zoomIn (increment = 0.3): void {
|
|
758
|
+
const scaleBy = 1 + increment
|
|
759
|
+
smartTransition(this.g, this.config.duration / 2)
|
|
760
|
+
.call(this._zoomBehavior.scaleBy, scaleBy)
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
public zoomOut (increment = 0.3): void {
|
|
764
|
+
const scaleBy = 1 - increment
|
|
765
|
+
smartTransition(this.g, this.config.duration / 2)
|
|
766
|
+
.call(this._zoomBehavior.scaleBy, scaleBy)
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
public setZoom (zoomLevel: number): void {
|
|
770
|
+
smartTransition(this.g, this.config.duration / 2)
|
|
771
|
+
.call(this._zoomBehavior.scaleTo, zoomLevel)
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
public fitView (): void {
|
|
775
|
+
this._fit(this.config.duration / 2)
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/** Enable automatic fitting to container if it was disabled due to previous zoom / pan interactions */
|
|
779
|
+
public resetAutofitState (): void {
|
|
780
|
+
this._isAutoFitDisabled = false
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/** Get current coordinates of the nodes as an array of { id: string; x: number; y: number } objects */
|
|
784
|
+
public getNodesCoordinates (): { id: string; x: number; y: number }[] {
|
|
785
|
+
const { datamodel: { nodes } } = this
|
|
786
|
+
return nodes.map(n => ({
|
|
787
|
+
id: n._id,
|
|
788
|
+
x: n.x,
|
|
789
|
+
y: n.y,
|
|
790
|
+
}))
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** Get node coordinates by id as { id: string; x: number; y: number } */
|
|
794
|
+
public getNodeCoordinatesById (id: string): { id: string; x: number; y: number } | undefined {
|
|
795
|
+
const { datamodel: { nodes } } = this
|
|
796
|
+
const node = nodes.find(n => n._id === id)
|
|
797
|
+
|
|
798
|
+
if (!node) {
|
|
799
|
+
console.warn(`Unovis | Graph: Node ${id} not found`)
|
|
800
|
+
return undefined
|
|
801
|
+
} else {
|
|
802
|
+
return {
|
|
803
|
+
id: node._id,
|
|
804
|
+
x: node.x,
|
|
805
|
+
y: node.y,
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|