@unovis/ts 1.1.1-beta.7 → 1.1.1-beta.9
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/components/area/config.d.ts +25 -0
- package/components/area/config.js +16 -0
- package/components/area/config.js.map +1 -0
- package/components/area/index.d.ts +19 -0
- package/components/area/index.js +102 -0
- package/components/area/index.js.map +1 -0
- package/components/area/style.d.ts +3 -0
- package/{src/components/area/style.ts → components/area/style.js} +10 -9
- package/components/area/style.js.map +1 -0
- package/components/area/types.d.ts +6 -0
- package/components/axis/config.d.ts +71 -0
- package/components/axis/config.js +32 -0
- package/components/axis/config.js.map +1 -0
- package/components/axis/index.d.ts +44 -0
- package/components/axis/index.js +305 -0
- package/components/axis/index.js.map +1 -0
- package/components/axis/style.d.ts +9 -0
- package/{src/components/axis/style.ts → components/axis/style.js} +22 -27
- package/components/axis/style.js.map +1 -0
- package/components/axis/types.d.ts +4 -0
- package/components/axis/types.js +8 -0
- package/components/axis/types.js.map +1 -0
- package/components/brush/config.d.ts +42 -0
- package/components/brush/config.js +24 -0
- package/components/brush/config.js.map +1 -0
- package/components/brush/index.d.ts +28 -0
- package/components/brush/index.js +199 -0
- package/components/brush/index.js.map +1 -0
- package/components/brush/style.d.ts +5 -0
- package/{src/components/brush/style.ts → components/brush/style.js} +14 -15
- package/components/brush/style.js.map +1 -0
- package/components/brush/types.d.ts +7 -0
- package/components/brush/types.js +8 -0
- package/components/brush/types.js.map +1 -0
- package/components/bullet-legend/config.d.ts +34 -0
- package/components/bullet-legend/config.js +16 -0
- package/components/bullet-legend/config.js.map +1 -0
- package/components/bullet-legend/index.d.ts +19 -0
- package/components/bullet-legend/index.js +79 -0
- package/components/bullet-legend/index.js.map +1 -0
- package/components/bullet-legend/style.d.ts +6 -0
- package/{src/components/bullet-legend/style.ts → components/bullet-legend/style.js} +16 -18
- package/components/bullet-legend/style.js.map +1 -0
- package/components/bullet-legend/types.d.ts +7 -0
- package/components/bullet-legend/types.js +2 -0
- package/components/bullet-legend/types.js.map +1 -0
- package/components/chord-diagram/config.d.ts +44 -0
- package/components/chord-diagram/config.js +25 -0
- package/components/chord-diagram/config.js.map +1 -0
- package/components/chord-diagram/index.d.ts +42 -0
- package/components/chord-diagram/index.js +305 -0
- package/components/chord-diagram/index.js.map +1 -0
- package/components/chord-diagram/modules/label.d.ts +8 -0
- package/components/chord-diagram/modules/label.js +115 -0
- package/components/chord-diagram/modules/label.js.map +1 -0
- package/components/chord-diagram/modules/link.d.ts +21 -0
- package/components/chord-diagram/modules/link.js +63 -0
- package/components/chord-diagram/modules/link.js.map +1 -0
- package/components/chord-diagram/modules/node.d.ts +17 -0
- package/components/chord-diagram/modules/node.js +52 -0
- package/components/chord-diagram/modules/node.js.map +1 -0
- package/components/chord-diagram/style.d.ts +13 -0
- package/{src/components/chord-diagram/style.ts → components/chord-diagram/style.js} +30 -39
- package/components/chord-diagram/style.js.map +1 -0
- package/components/chord-diagram/types.d.ts +58 -0
- package/components/chord-diagram/types.js +8 -0
- package/components/chord-diagram/types.js.map +1 -0
- package/components/crosshair/config.d.ts +43 -0
- package/components/crosshair/config.js +19 -0
- package/components/crosshair/config.js.map +1 -0
- package/components/crosshair/index.d.ts +35 -0
- package/components/crosshair/index.js +183 -0
- package/components/crosshair/index.js.map +1 -0
- package/components/crosshair/style.d.ts +4 -0
- package/{src/components/crosshair/style.ts → components/crosshair/style.js} +12 -12
- package/components/crosshair/style.js.map +1 -0
- package/components/crosshair/types.d.ts +13 -0
- package/components/crosshair/types.js +2 -0
- package/components/crosshair/types.js.map +1 -0
- package/components/donut/config.d.ts +59 -0
- package/components/donut/config.js +28 -0
- package/components/donut/config.js.map +1 -0
- package/components/donut/index.d.ts +21 -0
- package/components/donut/index.js +107 -0
- package/components/donut/index.js.map +1 -0
- package/components/donut/modules/arc.d.ts +10 -0
- package/components/donut/modules/arc.js +59 -0
- package/components/donut/modules/arc.js.map +1 -0
- package/components/donut/style.d.ts +7 -0
- package/{src/components/donut/style.ts → components/donut/style.js} +18 -20
- package/components/donut/style.js.map +1 -0
- package/components/donut/types.d.ts +20 -0
- package/components/flow-legend/config.d.ts +29 -0
- package/components/flow-legend/config.js +18 -0
- package/components/flow-legend/config.js.map +1 -0
- package/components/flow-legend/index.d.ts +16 -0
- package/components/flow-legend/index.js +75 -0
- package/components/flow-legend/index.js.map +1 -0
- package/components/flow-legend/style.d.ts +8 -0
- package/{src/components/flow-legend/style.ts → components/flow-legend/style.js} +21 -25
- package/components/flow-legend/style.js.map +1 -0
- package/components/flow-legend/types.d.ts +9 -0
- package/components/flow-legend/types.js +8 -0
- package/components/flow-legend/types.js.map +1 -0
- package/components/free-brush/config.d.ts +45 -0
- package/components/free-brush/config.js +24 -0
- package/components/free-brush/config.js.map +1 -0
- package/components/free-brush/index.d.ts +20 -0
- package/components/free-brush/index.js +192 -0
- package/components/free-brush/index.js.map +1 -0
- package/components/free-brush/style.d.ts +4 -0
- package/{src/components/free-brush/style.ts → components/free-brush/style.js} +12 -12
- package/components/free-brush/style.js.map +1 -0
- package/components/free-brush/types.d.ts +7 -0
- package/components/free-brush/types.js +9 -0
- package/components/free-brush/types.js.map +1 -0
- package/components/graph/config.d.ts +238 -0
- package/components/graph/config.js +84 -0
- package/components/graph/config.js.map +1 -0
- package/components/graph/index.d.ts +126 -0
- package/components/graph/index.js +656 -0
- package/components/graph/index.js.map +1 -0
- package/components/graph/modules/layout-helpers.d.ts +21 -0
- package/components/graph/modules/layout-helpers.js +69 -0
- package/components/graph/modules/layout-helpers.js.map +1 -0
- package/components/graph/modules/layout.d.ts +10 -0
- package/components/graph/modules/layout.js +399 -0
- package/components/graph/modules/layout.js.map +1 -0
- package/components/graph/modules/link/helper.d.ts +25 -0
- package/components/graph/modules/link/helper.js +74 -0
- package/components/graph/modules/link/helper.js.map +1 -0
- package/components/graph/modules/link/index.d.ts +11 -0
- package/components/graph/modules/link/index.js +212 -0
- package/components/graph/modules/link/index.js.map +1 -0
- package/components/graph/modules/link/style.d.ts +15 -0
- package/{src/components/graph/modules/link/style.ts → components/graph/modules/link/style.js} +34 -45
- package/components/graph/modules/link/style.js.map +1 -0
- package/components/graph/modules/node/helper.d.ts +21 -0
- package/components/graph/modules/node/helper.js +126 -0
- package/components/graph/modules/node/helper.js.map +1 -0
- package/components/graph/modules/node/index.d.ts +11 -0
- package/components/graph/modules/node/index.js +252 -0
- package/components/graph/modules/node/index.js.map +1 -0
- package/components/graph/modules/node/style.d.ts +24 -0
- package/{src/components/graph/modules/node/style.ts → components/graph/modules/node/style.js} +52 -72
- package/components/graph/modules/node/style.js.map +1 -0
- package/components/graph/modules/panel/helper.d.ts +18 -0
- package/components/graph/modules/panel/helper.js +111 -0
- package/components/graph/modules/panel/helper.js.map +1 -0
- package/components/graph/modules/panel/index.d.ts +7 -0
- package/components/graph/modules/panel/index.js +98 -0
- package/components/graph/modules/panel/index.js.map +1 -0
- package/components/graph/modules/panel/style.d.ts +14 -0
- package/{src/components/graph/modules/panel/style.ts → components/graph/modules/panel/style.js} +32 -42
- package/components/graph/modules/panel/style.js.map +1 -0
- package/components/graph/modules/shape.d.ts +6 -0
- package/components/graph/modules/shape.js +80 -0
- package/components/graph/modules/shape.js.map +1 -0
- package/components/graph/modules/zoom-levels.d.ts +6 -0
- package/components/graph/modules/zoom-levels.js +10 -0
- package/components/graph/modules/zoom-levels.js.map +1 -0
- package/components/graph/style.d.ts +6 -0
- package/components/graph/style.js +66 -0
- package/components/graph/style.js.map +1 -0
- package/components/graph/types.d.ts +125 -0
- package/components/graph/types.js +30 -0
- package/components/graph/types.js.map +1 -0
- package/components/grouped-bar/config.d.ts +36 -0
- package/components/grouped-bar/config.js +20 -0
- package/components/grouped-bar/config.js.map +1 -0
- package/components/grouped-bar/index.d.ts +32 -0
- package/components/grouped-bar/index.js +249 -0
- package/components/grouped-bar/index.js.map +1 -0
- package/components/grouped-bar/style.d.ts +5 -0
- package/{src/components/grouped-bar/style.ts → components/grouped-bar/style.js} +14 -15
- package/components/grouped-bar/style.js.map +1 -0
- package/components/leaflet-flow-map/config.d.ts +46 -0
- package/components/leaflet-flow-map/config.js +25 -0
- package/components/leaflet-flow-map/config.js.map +1 -0
- package/components/leaflet-flow-map/index.d.ts +52 -0
- package/components/leaflet-flow-map/index.js +220 -0
- package/components/leaflet-flow-map/index.js.map +1 -0
- package/components/leaflet-flow-map/renderer-utils.d.ts +5 -0
- package/components/leaflet-flow-map/renderer-utils.js +15 -0
- package/components/leaflet-flow-map/renderer-utils.js.map +1 -0
- package/components/leaflet-flow-map/renderer.d.ts +26 -0
- package/components/leaflet-flow-map/renderer.js +117 -0
- package/components/leaflet-flow-map/renderer.js.map +1 -0
- package/components/leaflet-flow-map/shaders.d.ts +2 -0
- package/{src/components/leaflet-flow-map/shaders.ts → components/leaflet-flow-map/shaders.js} +7 -4
- package/components/leaflet-flow-map/shaders.js.map +1 -0
- package/components/leaflet-flow-map/types.d.ts +23 -0
- package/components/leaflet-map/config.d.ts +193 -0
- package/components/leaflet-map/config.js +71 -0
- package/components/leaflet-map/config.js.map +1 -0
- package/components/leaflet-map/index.d.ts +130 -0
- package/components/leaflet-map/index.js +690 -0
- package/components/leaflet-map/index.js.map +1 -0
- package/components/leaflet-map/leaflet.css.js +5 -0
- package/components/leaflet-map/leaflet.css.js.map +1 -0
- package/components/leaflet-map/modules/clusterBackground.d.ts +5 -0
- package/components/leaflet-map/modules/clusterBackground.js +27 -0
- package/components/leaflet-map/modules/clusterBackground.js.map +1 -0
- package/components/leaflet-map/modules/donut.d.ts +3 -0
- package/components/leaflet-map/modules/donut.js +25 -0
- package/components/leaflet-map/modules/donut.js.map +1 -0
- package/components/leaflet-map/modules/map.d.ts +14 -0
- package/components/leaflet-map/modules/map.js +154 -0
- package/components/leaflet-map/modules/map.js.map +1 -0
- package/components/leaflet-map/modules/node.d.ts +9 -0
- package/components/leaflet-map/modules/node.js +162 -0
- package/components/leaflet-map/modules/node.js.map +1 -0
- package/components/leaflet-map/modules/selectionRing.d.ts +7 -0
- package/components/leaflet-map/modules/selectionRing.js +41 -0
- package/components/leaflet-map/modules/selectionRing.js.map +1 -0
- package/components/leaflet-map/modules/utils.d.ts +50 -0
- package/components/leaflet-map/modules/utils.js +210 -0
- package/components/leaflet-map/modules/utils.js.map +1 -0
- package/{src/components → components}/leaflet-map/renderer/leaflet-maplibre-gl.js +78 -76
- package/components/leaflet-map/renderer/leaflet-maplibre-gl.js.map +1 -0
- package/components/leaflet-map/renderer/map-style.d.ts +4 -0
- package/components/leaflet-map/renderer/map-style.js +15 -0
- package/components/leaflet-map/renderer/map-style.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js +40 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js +40 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js +4981 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +8 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.js +27 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +4 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.js +39 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -0
- package/{src/components → components}/leaflet-map/renderer/maplibre-gl.css.js +4 -2
- package/components/leaflet-map/renderer/maplibre-gl.css.js.map +1 -0
- package/components/leaflet-map/style.d.ts +52 -0
- package/components/leaflet-map/style.js +183 -0
- package/components/leaflet-map/style.js.map +1 -0
- package/components/leaflet-map/types.d.ts +75 -0
- package/components/leaflet-map/types.js +15 -0
- package/components/leaflet-map/types.js.map +1 -0
- package/components/line/config.d.ts +30 -0
- package/components/line/config.js +17 -0
- package/components/line/config.js.map +1 -0
- package/components/line/index.d.ts +27 -0
- package/components/line/index.js +152 -0
- package/components/line/index.js.map +1 -0
- package/components/line/style.d.ts +6 -0
- package/{src/components/line/style.ts → components/line/style.js} +16 -18
- package/components/line/style.js.map +1 -0
- package/components/line/types.d.ts +12 -0
- package/components/nested-donut/config.d.ts +59 -0
- package/components/nested-donut/config.js +19 -0
- package/components/nested-donut/config.js.map +1 -0
- package/components/nested-donut/index.d.ts +38 -0
- package/components/nested-donut/index.js +133 -0
- package/components/nested-donut/index.js.map +1 -0
- package/components/nested-donut/modules/arc.d.ts +17 -0
- package/components/nested-donut/modules/arc.js +50 -0
- package/components/nested-donut/modules/arc.js.map +1 -0
- package/components/nested-donut/modules/label.d.ts +7 -0
- package/components/nested-donut/modules/label.js +34 -0
- package/components/nested-donut/modules/label.js.map +1 -0
- package/components/nested-donut/style.d.ts +26 -0
- package/components/nested-donut/style.js +70 -0
- package/components/nested-donut/style.js.map +1 -0
- package/components/nested-donut/types.d.ts +24 -0
- package/components/nested-donut/types.js +11 -0
- package/components/nested-donut/types.js.map +1 -0
- package/components/sankey/config.d.ts +162 -0
- package/components/sankey/config.js +65 -0
- package/components/sankey/config.js.map +1 -0
- package/components/sankey/index.d.ts +59 -0
- package/components/sankey/index.js +306 -0
- package/components/sankey/index.js.map +1 -0
- package/components/sankey/modules/label.d.ts +23 -0
- package/components/sankey/modules/label.js +168 -0
- package/components/sankey/modules/label.js.map +1 -0
- package/components/sankey/modules/link.d.ts +14 -0
- package/components/sankey/modules/link.js +108 -0
- package/components/sankey/modules/link.js.map +1 -0
- package/components/sankey/modules/node.d.ts +10 -0
- package/components/sankey/modules/node.js +156 -0
- package/components/sankey/modules/node.js.map +1 -0
- package/components/sankey/style.d.ts +20 -0
- package/{src/components/sankey/style.ts → components/sankey/style.js} +44 -60
- package/components/sankey/style.js.map +1 -0
- package/components/sankey/types.d.ts +84 -0
- package/components/sankey/types.js +34 -0
- package/components/sankey/types.js.map +1 -0
- package/components/scatter/config.d.ts +44 -0
- package/components/scatter/config.js +23 -0
- package/components/scatter/config.js.map +1 -0
- package/components/scatter/index.d.ts +28 -0
- package/components/scatter/index.js +167 -0
- package/components/scatter/index.js.map +1 -0
- package/components/scatter/modules/point.d.ts +7 -0
- package/components/scatter/modules/point.js +86 -0
- package/components/scatter/modules/point.js.map +1 -0
- package/components/scatter/modules/utils.d.ts +11 -0
- package/components/scatter/modules/utils.js +112 -0
- package/components/scatter/modules/utils.js.map +1 -0
- package/components/scatter/style.d.ts +5 -0
- package/{src/components/scatter/style.ts → components/scatter/style.js} +14 -15
- package/components/scatter/style.js.map +1 -0
- package/components/scatter/types.d.ts +19 -0
- package/components/stacked-bar/config.d.ts +38 -0
- package/components/stacked-bar/config.js +20 -0
- package/components/stacked-bar/config.js.map +1 -0
- package/components/stacked-bar/index.d.ts +28 -0
- package/components/stacked-bar/index.js +208 -0
- package/components/stacked-bar/index.js.map +1 -0
- package/components/stacked-bar/style.d.ts +5 -0
- package/{src/components/stacked-bar/style.ts → components/stacked-bar/style.js} +14 -15
- package/components/stacked-bar/style.js.map +1 -0
- package/components/stacked-bar/types.d.ts +5 -0
- package/components/timeline/config.d.ts +43 -0
- package/components/timeline/config.js +24 -0
- package/components/timeline/config.js.map +1 -0
- package/components/timeline/index.d.ts +41 -0
- package/components/timeline/index.js +244 -0
- package/components/timeline/index.js.map +1 -0
- package/components/timeline/style.d.ts +13 -0
- package/{src/components/timeline/style.ts → components/timeline/style.js} +30 -39
- package/components/timeline/style.js.map +1 -0
- package/components/tooltip/config.d.ts +68 -0
- package/components/tooltip/config.js +20 -0
- package/components/tooltip/config.js.map +1 -0
- package/components/tooltip/index.d.ts +36 -0
- package/components/tooltip/index.js +184 -0
- package/components/tooltip/index.js.map +1 -0
- package/{src/components → components}/tooltip/style.js +14 -11
- package/components/tooltip/style.js.map +1 -0
- package/components/topojson-map/config.d.ts +99 -0
- package/components/topojson-map/config.js +42 -0
- package/components/topojson-map/config.js.map +1 -0
- package/components/topojson-map/index.d.ts +52 -0
- package/components/topojson-map/index.js +355 -0
- package/components/topojson-map/index.js.map +1 -0
- package/components/topojson-map/style.d.ts +11 -0
- package/{src/components/topojson-map/style.ts → components/topojson-map/style.js} +26 -33
- package/components/topojson-map/style.js.map +1 -0
- package/components/topojson-map/types.d.ts +78 -0
- package/components/topojson-map/types.js +80 -0
- package/components/topojson-map/types.js.map +1 -0
- package/components/topojson-map/utils.d.ts +3 -0
- package/components/topojson-map/utils.js +30 -0
- package/components/topojson-map/utils.js.map +1 -0
- package/components/vis-controls/config.d.ts +12 -0
- package/components/vis-controls/config.js +13 -0
- package/components/vis-controls/config.js.map +1 -0
- package/components/vis-controls/index.d.ts +14 -0
- package/components/vis-controls/index.js +52 -0
- package/components/vis-controls/index.js.map +1 -0
- package/components/vis-controls/style.d.ts +11 -0
- package/{src/components/vis-controls/style.ts → components/vis-controls/style.js} +27 -34
- package/components/vis-controls/style.js.map +1 -0
- package/components/vis-controls/types.d.ts +13 -0
- package/components/vis-controls/types.js +8 -0
- package/components/vis-controls/types.js.map +1 -0
- package/components/xy-labels/config.d.ts +48 -0
- package/components/xy-labels/config.js +25 -0
- package/components/xy-labels/config.js.map +1 -0
- package/components/xy-labels/index.d.ts +15 -0
- package/components/xy-labels/index.js +87 -0
- package/components/xy-labels/index.js.map +1 -0
- package/components/xy-labels/modules/label.d.ts +9 -0
- package/components/xy-labels/modules/label.js +107 -0
- package/components/xy-labels/modules/label.js.map +1 -0
- package/components/xy-labels/style.d.ts +5 -0
- package/{src/components/xy-labels/style.ts → components/xy-labels/style.js} +14 -15
- package/components/xy-labels/style.js.map +1 -0
- package/components/xy-labels/types.d.ts +23 -0
- package/components/xy-labels/types.js +9 -0
- package/components/xy-labels/types.js.map +1 -0
- package/components.d.ts +51 -0
- package/components.js +29 -0
- package/components.js.map +1 -0
- package/containers/single-container/config.d.ts +12 -0
- package/containers/single-container/config.js +12 -0
- package/containers/single-container/config.js.map +1 -0
- package/containers/single-container/index.d.ts +19 -0
- package/containers/single-container/index.js +128 -0
- package/containers/single-container/index.js.map +1 -0
- package/containers/xy-container/config.d.ts +99 -0
- package/containers/xy-container/config.js +30 -0
- package/containers/xy-container/config.js.map +1 -0
- package/containers/xy-container/index.d.ts +34 -0
- package/containers/xy-container/index.js +330 -0
- package/containers/xy-container/index.js.map +1 -0
- package/containers.d.ts +6 -0
- package/containers.js +4 -0
- package/containers.js.map +1 -0
- package/core/component/config.d.ts +58 -0
- package/core/component/config.js +14 -0
- package/core/component/config.js.map +1 -0
- package/core/component/index.d.ts +43 -0
- package/core/component/index.js +118 -0
- package/core/component/index.js.map +1 -0
- package/core/component/types.d.ts +2 -0
- package/core/component/types.js +2 -0
- package/core/component/types.js.map +1 -0
- package/core/config/index.d.ts +3 -0
- package/core/config/index.js +16 -0
- package/core/config/index.js.map +1 -0
- package/core/container/config.d.ts +48 -0
- package/core/container/config.js +29 -0
- package/core/container/config.js.map +1 -0
- package/core/container/index.d.ts +26 -0
- package/core/container/index.js +106 -0
- package/core/container/index.js.map +1 -0
- package/core/xy-component/config.d.ts +38 -0
- package/core/xy-component/config.js +20 -0
- package/core/xy-component/config.js.map +1 -0
- package/core/xy-component/index.d.ts +27 -0
- package/core/xy-component/index.js +74 -0
- package/core/xy-component/index.js.map +1 -0
- package/data-models/core.d.ts +6 -0
- package/data-models/core.js +14 -0
- package/data-models/core.js.map +1 -0
- package/data-models/graph.d.ts +24 -0
- package/data-models/graph.js +107 -0
- package/data-models/graph.js.map +1 -0
- package/data-models/map-graph.d.ts +21 -0
- package/data-models/map-graph.js +62 -0
- package/data-models/map-graph.js.map +1 -0
- package/data-models/map.d.ts +5 -0
- package/data-models/map.js +12 -0
- package/data-models/map.js.map +1 -0
- package/data-models/series.d.ts +6 -0
- package/data-models/series.js +19 -0
- package/data-models/series.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +55 -0
- package/index.js.map +1 -0
- package/maps/china-provinces.json.js +140373 -0
- package/maps/fr-regions.json.js +14162 -0
- package/maps/germany-regions.json.js +35760 -0
- package/maps/ind-regions.json.js +290584 -0
- package/maps/uk-regions.json.js +96233 -0
- package/maps/us-counties.json.js +206318 -0
- package/maps/us-states.json.js +16345 -0
- package/maps/world-110m-alpha.json.js +251366 -0
- package/maps/world-simple.json.js +89428 -0
- package/maps/world-simplest.json.js +28175 -0
- package/maps.d.ts +60 -0
- package/maps.js +23 -0
- package/package.json +1 -1
- package/styles/colors.d.ts +7 -0
- package/styles/colors.js +24 -0
- package/styles/colors.js.map +1 -0
- package/styles/index.d.ts +7 -0
- package/styles/index.js +38 -0
- package/styles/index.js.map +1 -0
- package/styles/sizes.d.ts +2 -0
- package/{src/styles/sizes.ts → styles/sizes.js} +8 -6
- package/styles/sizes.js.map +1 -0
- package/types/accessor.d.ts +5 -0
- package/types/accessor.js +2 -0
- package/types/accessor.js.map +1 -0
- package/types/component.d.ts +13 -0
- package/types/component.js +14 -0
- package/types/component.js.map +1 -0
- package/types/curve.d.ts +40 -0
- package/types/curve.js +46 -0
- package/types/curve.js.map +1 -0
- package/types/data.d.ts +7 -0
- package/types/data.js +2 -0
- package/types/data.js.map +1 -0
- package/types/direction.d.ts +6 -0
- package/types/direction.js +10 -0
- package/types/direction.js.map +1 -0
- package/types/graph.d.ts +35 -0
- package/types/graph.js +2 -0
- package/types/graph.js.map +1 -0
- package/types/map.d.ts +4 -0
- package/types/map.js +2 -0
- package/types/map.js.map +1 -0
- package/types/misc.d.ts +8 -0
- package/types/position.d.ts +20 -0
- package/types/position.js +27 -0
- package/types/position.js.map +1 -0
- package/types/scale.d.ts +23 -0
- package/types/scale.js +27 -0
- package/types/scale.js.map +1 -0
- package/types/shape.d.ts +7 -0
- package/types/shape.js +11 -0
- package/types/shape.js.map +1 -0
- package/types/spacing.d.ts +6 -0
- package/types/spacing.js +2 -0
- package/types/spacing.js.map +1 -0
- package/types/svg.d.ts +18 -0
- package/types/svg.js +22 -0
- package/types/svg.js.map +1 -0
- package/types/symbol.d.ts +18 -0
- package/types/symbol.js +24 -0
- package/types/symbol.js.map +1 -0
- package/types/text.d.ts +47 -0
- package/types/text.js +26 -0
- package/types/text.js.map +1 -0
- package/types.d.ts +27 -0
- package/types.js +30 -0
- package/types.js.map +1 -0
- package/utils/color.d.ts +10 -0
- package/utils/color.js +32 -0
- package/utils/color.js.map +1 -0
- package/utils/d3.d.ts +3 -0
- package/utils/d3.js +16 -0
- package/utils/d3.js.map +1 -0
- package/utils/data.d.ts +45 -0
- package/utils/data.js +274 -0
- package/utils/data.js.map +1 -0
- package/utils/html.d.ts +1 -0
- package/utils/html.js +16 -0
- package/utils/html.js.map +1 -0
- package/utils/map.d.ts +2 -0
- package/utils/map.js +20 -0
- package/utils/map.js.map +1 -0
- package/utils/misc.d.ts +9 -0
- package/utils/misc.js +47 -0
- package/utils/misc.js.map +1 -0
- package/utils/path.d.ts +23 -0
- package/utils/path.js +144 -0
- package/utils/path.js.map +1 -0
- package/utils/scale.d.ts +1 -0
- package/utils/style.d.ts +6 -0
- package/utils/style.js +24 -0
- package/utils/style.js.map +1 -0
- package/utils/svg.d.ts +3 -0
- package/utils/text.d.ts +139 -0
- package/utils/text.js +443 -0
- package/utils/text.js.map +1 -0
- package/utils/type.d.ts +5 -0
- package/declaration.d.ts +0 -1
- package/index.ts +0 -1
- package/licences.txt +0 -43
- package/maps.ts +0 -1
- package/rollup.config.js +0 -71
- package/rules/ts-getter-setter.js +0 -35
- package/src/components/area/config.ts +0 -29
- package/src/components/area/index.ts +0 -133
- package/src/components/area/types.ts +0 -2
- package/src/components/axis/config.ts +0 -76
- package/src/components/axis/index.ts +0 -363
- package/src/components/axis/types.ts +0 -4
- package/src/components/brush/config.ts +0 -51
- package/src/components/brush/index.ts +0 -233
- package/src/components/brush/types.ts +0 -8
- package/src/components/bullet-legend/config.ts +0 -38
- package/src/components/bullet-legend/index.ts +0 -104
- package/src/components/bullet-legend/types.ts +0 -7
- package/src/components/chord-diagram/config.ts +0 -53
- package/src/components/chord-diagram/index.ts +0 -401
- package/src/components/chord-diagram/modules/label.ts +0 -155
- package/src/components/chord-diagram/modules/link.ts +0 -91
- package/src/components/chord-diagram/modules/node.ts +0 -80
- package/src/components/chord-diagram/types.ts +0 -68
- package/src/components/crosshair/config.ts +0 -48
- package/src/components/crosshair/index.ts +0 -220
- package/src/components/crosshair/types.ts +0 -15
- package/src/components/donut/config.ts +0 -65
- package/src/components/donut/index.ts +0 -148
- package/src/components/donut/modules/arc.ts +0 -86
- package/src/components/donut/types.ts +0 -17
- package/src/components/flow-legend/config.ts +0 -31
- package/src/components/flow-legend/index.ts +0 -103
- package/src/components/flow-legend/types.ts +0 -10
- package/src/components/free-brush/config.ts +0 -54
- package/src/components/free-brush/index.ts +0 -207
- package/src/components/free-brush/types.ts +0 -8
- package/src/components/graph/config.ts +0 -280
- package/src/components/graph/index.ts +0 -809
- package/src/components/graph/modules/layout-helpers.ts +0 -96
- package/src/components/graph/modules/layout.ts +0 -502
- package/src/components/graph/modules/link/helper.ts +0 -105
- package/src/components/graph/modules/link/index.ts +0 -302
- package/src/components/graph/modules/node/helper.ts +0 -162
- package/src/components/graph/modules/node/index.ts +0 -343
- package/src/components/graph/modules/panel/helper.ts +0 -160
- package/src/components/graph/modules/panel/index.ts +0 -137
- package/src/components/graph/modules/shape.ts +0 -108
- package/src/components/graph/modules/zoom-levels.ts +0 -6
- package/src/components/graph/style.ts +0 -72
- package/src/components/graph/types.ts +0 -152
- package/src/components/grouped-bar/config.ts +0 -40
- package/src/components/grouped-bar/index.ts +0 -325
- package/src/components/leaflet-flow-map/config.ts +0 -60
- package/src/components/leaflet-flow-map/index.ts +0 -279
- package/src/components/leaflet-flow-map/renderer-utils.ts +0 -14
- package/src/components/leaflet-flow-map/renderer.ts +0 -146
- package/src/components/leaflet-flow-map/types.ts +0 -18
- package/src/components/leaflet-map/config.ts +0 -234
- package/src/components/leaflet-map/index.ts +0 -808
- package/src/components/leaflet-map/leaflet.css +0 -625
- package/src/components/leaflet-map/modules/clusterBackground.ts +0 -34
- package/src/components/leaflet-map/modules/donut.ts +0 -37
- package/src/components/leaflet-map/modules/map.ts +0 -178
- package/src/components/leaflet-map/modules/node.ts +0 -208
- package/src/components/leaflet-map/modules/selectionRing.ts +0 -63
- package/src/components/leaflet-map/modules/utils.ts +0 -290
- package/src/components/leaflet-map/renderer/map-style.ts +0 -24
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json +0 -35
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json +0 -35
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json +0 -2185
- package/src/components/leaflet-map/renderer/mapboxgl-layer.ts +0 -43
- package/src/components/leaflet-map/renderer/mapboxgl-utils.ts +0 -40
- package/src/components/leaflet-map/style.ts +0 -217
- package/src/components/leaflet-map/types.ts +0 -75
- package/src/components/line/config.ts +0 -34
- package/src/components/line/index.ts +0 -188
- package/src/components/line/types.ts +0 -3
- package/src/components/nested-donut/config.ts +0 -75
- package/src/components/nested-donut/index.ts +0 -176
- package/src/components/nested-donut/modules/arc.ts +0 -78
- package/src/components/nested-donut/modules/label.ts +0 -63
- package/src/components/nested-donut/style.ts +0 -82
- package/src/components/nested-donut/types.ts +0 -29
- package/src/components/sankey/config.ts +0 -195
- package/src/components/sankey/index.ts +0 -387
- package/src/components/sankey/modules/label.ts +0 -228
- package/src/components/sankey/modules/link.ts +0 -141
- package/src/components/sankey/modules/node.ts +0 -221
- package/src/components/sankey/types.ts +0 -95
- package/src/components/scatter/config.ts +0 -49
- package/src/components/scatter/index.ts +0 -220
- package/src/components/scatter/modules/point.ts +0 -123
- package/src/components/scatter/modules/utils.ts +0 -150
- package/src/components/scatter/types.ts +0 -21
- package/src/components/stacked-bar/config.ts +0 -42
- package/src/components/stacked-bar/index.ts +0 -267
- package/src/components/stacked-bar/types.ts +0 -5
- package/src/components/timeline/config.ts +0 -49
- package/src/components/timeline/index.ts +0 -302
- package/src/components/tooltip/config.ts +0 -69
- package/src/components/tooltip/index.ts +0 -220
- package/src/components/topojson-map/config.ts +0 -124
- package/src/components/topojson-map/index.ts +0 -436
- package/src/components/topojson-map/types.ts +0 -123
- package/src/components/topojson-map/utils.ts +0 -29
- package/src/components/vis-controls/config.ts +0 -16
- package/src/components/vis-controls/index.ts +0 -68
- package/src/components/vis-controls/types.ts +0 -14
- package/src/components/xy-labels/config.ts +0 -56
- package/src/components/xy-labels/index.ts +0 -109
- package/src/components/xy-labels/modules/label.ts +0 -140
- package/src/components/xy-labels/types.ts +0 -26
- package/src/components.ts +0 -56
- package/src/containers/single-container/config.ts +0 -15
- package/src/containers/single-container/index.ts +0 -150
- package/src/containers/xy-container/config.ts +0 -112
- package/src/containers/xy-container/index.ts +0 -407
- package/src/containers.ts +0 -6
- package/src/core/component/config.ts +0 -61
- package/src/core/component/index.ts +0 -154
- package/src/core/component/types.ts +0 -9
- package/src/core/config/index.ts +0 -12
- package/src/core/container/config.ts +0 -56
- package/src/core/container/index.ts +0 -136
- package/src/core/xy-component/config.ts +0 -46
- package/src/core/xy-component/index.ts +0 -90
- package/src/data-models/core.ts +0 -15
- package/src/data-models/graph.ts +0 -138
- package/src/data-models/map-graph.ts +0 -72
- package/src/data-models/map.ts +0 -18
- package/src/data-models/series.ts +0 -16
- package/src/index.ts +0 -7
- package/src/maps/china-provinces.json +0 -1
- package/src/maps/fr-regions.json +0 -1
- package/src/maps/germany-regions.json +0 -1
- package/src/maps/ind-regions.json +0 -1
- package/src/maps/uk-regions.json +0 -1
- package/src/maps/us-counties.json +0 -1
- package/src/maps/us-states.json +0 -1
- package/src/maps/world-110m-alpha.json +0 -1
- package/src/maps/world-simple.json +0 -1
- package/src/maps/world-simplest.json +0 -1
- package/src/maps.ts +0 -34
- package/src/styles/colors.ts +0 -28
- package/src/styles/index.ts +0 -38
- package/src/types/accessor.ts +0 -5
- package/src/types/component.ts +0 -15
- package/src/types/curve.ts +0 -62
- package/src/types/data.ts +0 -5
- package/src/types/direction.ts +0 -6
- package/src/types/graph.ts +0 -40
- package/src/types/map.ts +0 -5
- package/src/types/misc.ts +0 -10
- package/src/types/position.ts +0 -23
- package/src/types/scale.ts +0 -47
- package/src/types/shape.ts +0 -7
- package/src/types/spacing.ts +0 -6
- package/src/types/svg.ts +0 -32
- package/src/types/symbol.ts +0 -21
- package/src/types/text.ts +0 -71
- package/src/types.ts +0 -31
- package/src/utils/color.ts +0 -41
- package/src/utils/d3.ts +0 -15
- package/src/utils/data.ts +0 -328
- package/src/utils/html.ts +0 -13
- package/src/utils/map.ts +0 -29
- package/src/utils/misc.ts +0 -54
- package/src/utils/path.ts +0 -196
- package/src/utils/scale.ts +0 -1
- package/src/utils/style.ts +0 -37
- package/src/utils/svg.ts +0 -49
- package/src/utils/text.ts +0 -529
- package/src/utils/type.ts +0 -9
- package/tsconfig.json +0 -29
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import { select, Selection } from 'd3-selection'
|
|
2
|
-
import { sankey } from 'd3-sankey'
|
|
3
|
-
import { extent, max, sum } from 'd3-array'
|
|
4
|
-
import { scaleLinear } from 'd3-scale'
|
|
5
|
-
|
|
6
|
-
// Core
|
|
7
|
-
import { ComponentCore } from 'core/component'
|
|
8
|
-
import { GraphDataModel } from 'data-models/graph'
|
|
9
|
-
|
|
10
|
-
// Types
|
|
11
|
-
import { ExtendedSizeComponent, Sizing } from 'types/component'
|
|
12
|
-
import { Position } from 'types/position'
|
|
13
|
-
import { Spacing } from 'types/spacing'
|
|
14
|
-
import { VerticalAlign } from 'types/text'
|
|
15
|
-
|
|
16
|
-
// Utils
|
|
17
|
-
import { smartTransition } from 'utils/d3'
|
|
18
|
-
import { getNumber, getString, groupBy, isNumber } from 'utils/data'
|
|
19
|
-
import { getCSSVariableValueInPixels } from 'utils/misc'
|
|
20
|
-
|
|
21
|
-
// Config
|
|
22
|
-
import { SankeyConfig, SankeyConfigInterface } from './config'
|
|
23
|
-
|
|
24
|
-
// Styles
|
|
25
|
-
import * as s from './style'
|
|
26
|
-
|
|
27
|
-
// Local Types
|
|
28
|
-
import { SankeyInputLink, SankeyInputNode, SankeyLayout, SankeyLink, SankeyNode } from './types'
|
|
29
|
-
|
|
30
|
-
// Modules
|
|
31
|
-
import { createLinks, removeLinks, updateLinks } from './modules/link'
|
|
32
|
-
import { createNodes, onNodeMouseOut, onNodeMouseOver, removeNodes, updateNodes } from './modules/node'
|
|
33
|
-
import { getLabelOrientation, requiredLabelSpace } from './modules/label'
|
|
34
|
-
|
|
35
|
-
export class Sankey<
|
|
36
|
-
N extends SankeyInputNode,
|
|
37
|
-
L extends SankeyInputLink,
|
|
38
|
-
> extends ComponentCore<
|
|
39
|
-
{nodes: N[]; links?: L[]},
|
|
40
|
-
SankeyConfig<N, L>,
|
|
41
|
-
SankeyConfigInterface<N, L>
|
|
42
|
-
> implements ExtendedSizeComponent {
|
|
43
|
-
static selectors = s
|
|
44
|
-
config: SankeyConfig<N, L> = new SankeyConfig()
|
|
45
|
-
datamodel: GraphDataModel<N, L, SankeyNode<N, L>, SankeyLink<N, L>> = new GraphDataModel()
|
|
46
|
-
private _extendedWidth = undefined
|
|
47
|
-
private _extendedHeight = undefined
|
|
48
|
-
private _extendedHeightIncreased = undefined
|
|
49
|
-
private _linksGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>
|
|
50
|
-
private _nodesGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>
|
|
51
|
-
private _backgroundRect: Selection<SVGRectElement, unknown, SVGGElement, unknown>
|
|
52
|
-
private _sankey = sankey()
|
|
53
|
-
private _highlightTimeoutId = null
|
|
54
|
-
private _highlightActive = false
|
|
55
|
-
events = {
|
|
56
|
-
[Sankey.selectors.nodeGroup]: {
|
|
57
|
-
mouseenter: this._onNodeMouseOver.bind(this),
|
|
58
|
-
mouseleave: this._onNodeMouseOut.bind(this),
|
|
59
|
-
},
|
|
60
|
-
[Sankey.selectors.node]: {
|
|
61
|
-
mouseenter: this._onNodeRectMouseOver.bind(this),
|
|
62
|
-
mouseleave: this._onNodeRectMouseOut.bind(this),
|
|
63
|
-
},
|
|
64
|
-
[Sankey.selectors.link]: {
|
|
65
|
-
mouseenter: this._onLinkMouseOver.bind(this),
|
|
66
|
-
mouseleave: this._onLinkMouseOut.bind(this),
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
constructor (config?: SankeyConfigInterface<N, L>) {
|
|
71
|
-
super()
|
|
72
|
-
if (config) this.setConfig(config)
|
|
73
|
-
this._backgroundRect = this.g.append('rect').attr('class', s.background)
|
|
74
|
-
this._linksGroup = this.g.append('g').attr('class', s.links)
|
|
75
|
-
this._nodesGroup = this.g.append('g').attr('class', s.nodes)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get bleed (): Spacing {
|
|
79
|
-
const { config, datamodel: { nodes, links } } = this
|
|
80
|
-
const labelFontSize = config.labelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-label-font-size)', this.element)
|
|
81
|
-
const labelSize = requiredLabelSpace(config.labelMaxWidth, labelFontSize)
|
|
82
|
-
|
|
83
|
-
let left = 0
|
|
84
|
-
let right = 0
|
|
85
|
-
|
|
86
|
-
// We pre-calculate sankey layout to get information about node labels placement and calculate bleed properly
|
|
87
|
-
// Potentially it can be a performance bottleneck for large layouts, but generally rendering of such layouts is much more computationally heavy
|
|
88
|
-
if (nodes.length) {
|
|
89
|
-
const sankeyProbeSize = 1000
|
|
90
|
-
this._populateLinkAndNodeValues()
|
|
91
|
-
this._sankey.size([sankeyProbeSize, sankeyProbeSize])
|
|
92
|
-
this._sankey({ nodes, links })
|
|
93
|
-
const maxDepth = max(nodes, d => d.depth)
|
|
94
|
-
const zeroDepthNodes = nodes.filter(d => d.depth === 0)
|
|
95
|
-
const maxDepthNodes = nodes.filter(d => d.depth === maxDepth)
|
|
96
|
-
|
|
97
|
-
left = zeroDepthNodes.some(d => getLabelOrientation(d, sankeyProbeSize, config.labelPosition) === Position.Left) ? labelSize.width : 0
|
|
98
|
-
right = maxDepthNodes.some(d => getLabelOrientation(d, sankeyProbeSize, config.labelPosition) === Position.Right) ? labelSize.width : 0
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const top = config.labelVerticalAlign === VerticalAlign.Top ? 0
|
|
102
|
-
: config.labelVerticalAlign === VerticalAlign.Bottom ? labelSize.height
|
|
103
|
-
: labelSize.height / 2
|
|
104
|
-
|
|
105
|
-
const bottom = config.labelVerticalAlign === VerticalAlign.Top ? labelSize.height
|
|
106
|
-
: config.labelVerticalAlign === VerticalAlign.Bottom ? 0
|
|
107
|
-
: labelSize.height / 2
|
|
108
|
-
|
|
109
|
-
return { top, bottom, left, right }
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
setData (data: { nodes: N[]; links?: L[] }): void {
|
|
113
|
-
super.setData(data)
|
|
114
|
-
|
|
115
|
-
// Pre-calculate component size for Sizing.EXTEND
|
|
116
|
-
if ((this.sizing !== Sizing.Fit) || !this._hasLinks()) this._preCalculateComponentSize()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
setConfig (config: SankeyConfigInterface<N, L>): void {
|
|
120
|
-
super.setConfig(config)
|
|
121
|
-
|
|
122
|
-
// Pre-calculate component size for Sizing.EXTEND
|
|
123
|
-
if ((this.sizing !== Sizing.Fit) || !this._hasLinks()) this._preCalculateComponentSize()
|
|
124
|
-
|
|
125
|
-
// Using "as any" because typings are not full ("@types/d3-sankey": "^0.11.2")
|
|
126
|
-
const nodeId = ((d, i) => getString(d, this.config.id, i)) as any;
|
|
127
|
-
(this._sankey as any).linkSort(this.config.linkSort)
|
|
128
|
-
this._sankey
|
|
129
|
-
.nodeId(nodeId)
|
|
130
|
-
.nodeWidth(this.config.nodeWidth)
|
|
131
|
-
.nodePadding(this.config.nodePadding)
|
|
132
|
-
.nodeAlign(SankeyLayout[this.config.nodeAlign])
|
|
133
|
-
.nodeSort(this.config.nodeSort)
|
|
134
|
-
.iterations(this.config.iterations)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
_render (customDuration?: number): void {
|
|
138
|
-
const { config, bleed, datamodel: { nodes, links } } = this
|
|
139
|
-
const duration = isNumber(customDuration) ? customDuration : config.duration
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
(nodes.length === 0) ||
|
|
143
|
-
(nodes.length === 1 && links.length > 0) ||
|
|
144
|
-
(nodes.length === 1 && !config.showSingleNode) ||
|
|
145
|
-
(nodes.length > 1 && links.length === 0)
|
|
146
|
-
) {
|
|
147
|
-
this._linksGroup.selectAll<SVGGElement, SankeyLink<N, L>>(`.${s.link}`).call(removeLinks, duration)
|
|
148
|
-
this._nodesGroup.selectAll<SVGGElement, SankeyNode<N, L>>(`.${s.nodeGroup}`).call(removeNodes, config, duration)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Prepare Layout
|
|
152
|
-
this._prepareLayout()
|
|
153
|
-
|
|
154
|
-
// Links
|
|
155
|
-
smartTransition(this._linksGroup, duration).attr('transform', `translate(${bleed.left},${bleed.top})`)
|
|
156
|
-
const linkSelection = this._linksGroup.selectAll<SVGGElement, SankeyLink<N, L>>(`.${s.link}`)
|
|
157
|
-
.data(links, (d, i) => config.id(d, i) ?? i)
|
|
158
|
-
const linkSelectionEnter = linkSelection.enter().append('g').attr('class', s.link)
|
|
159
|
-
linkSelectionEnter.call(createLinks)
|
|
160
|
-
linkSelection.merge(linkSelectionEnter).call(updateLinks, config, duration)
|
|
161
|
-
linkSelection.exit<SankeyLink<N, L>>().call(removeLinks)
|
|
162
|
-
|
|
163
|
-
// Nodes
|
|
164
|
-
smartTransition(this._nodesGroup, duration).attr('transform', `translate(${bleed.left},${bleed.top})`)
|
|
165
|
-
|
|
166
|
-
const nodeSelection = this._nodesGroup.selectAll<SVGGElement, SankeyNode<N, L>>(`.${s.nodeGroup}`)
|
|
167
|
-
.data(nodes, (d, i) => config.id(d, i) ?? i)
|
|
168
|
-
const nodeSelectionEnter = nodeSelection.enter().append('g').attr('class', s.nodeGroup)
|
|
169
|
-
nodeSelectionEnter.call(createNodes, this.config, this._width, bleed)
|
|
170
|
-
nodeSelection.merge(nodeSelectionEnter).call(updateNodes, config, this._width, bleed, this._hasLinks(), duration)
|
|
171
|
-
nodeSelection.exit<SankeyNode<N, L>>()
|
|
172
|
-
.attr('class', s.nodeExit)
|
|
173
|
-
.call(removeNodes, config, duration)
|
|
174
|
-
|
|
175
|
-
// Background
|
|
176
|
-
this._backgroundRect
|
|
177
|
-
.attr('width', this.getWidth())
|
|
178
|
-
.attr('height', this.getHeight())
|
|
179
|
-
.attr('opacity', 0)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
private _populateLinkAndNodeValues (): void {
|
|
183
|
-
const { config, datamodel } = this
|
|
184
|
-
|
|
185
|
-
const nodes = datamodel.nodes
|
|
186
|
-
const links = datamodel.links
|
|
187
|
-
|
|
188
|
-
// For d3-sankey each link must be an object with the `value` property
|
|
189
|
-
links.forEach((link, i) => {
|
|
190
|
-
link.value = getNumber(link, d => getNumber(d, config.linkValue, i))
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
// Populating node.fixedValue for d3-sankey
|
|
194
|
-
nodes.forEach((node, i) => {
|
|
195
|
-
node.fixedValue = getNumber(node, config.nodeFixedValue, i)
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private _preCalculateComponentSize (): void {
|
|
200
|
-
const { bleed, config, datamodel } = this
|
|
201
|
-
const nodes = datamodel.nodes
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (nodes.length) {
|
|
205
|
-
this._populateLinkAndNodeValues()
|
|
206
|
-
this._sankey(datamodel)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const scaleExtent = extent(nodes, d => d.value || undefined)
|
|
210
|
-
const scaleRange = [config.nodeMinHeight, config.nodeMaxHeight]
|
|
211
|
-
const scale = scaleLinear().domain(scaleExtent).range(scaleRange).clamp(true)
|
|
212
|
-
nodes.forEach(n => { n._state.precalculatedHeight = scale(n.value) || config.nodeMinHeight })
|
|
213
|
-
|
|
214
|
-
const groupedByColumn: { [key: string]: SankeyNode<N, L>[] } = groupBy(nodes, d => d.layer)
|
|
215
|
-
const values = Object.values(groupedByColumn)
|
|
216
|
-
.map((group) =>
|
|
217
|
-
sum(group.map(n => n._state.precalculatedHeight + config.nodePadding)) - config.nodePadding
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
const height = max(values) || config.nodeMinHeight
|
|
221
|
-
this._extendedHeight = height + bleed.top + bleed.bottom
|
|
222
|
-
this._extendedWidth = Math.max(0, (config.nodeWidth + config.nodeHorizontalSpacing) * Object.keys(groupedByColumn).length - config.nodeHorizontalSpacing + bleed.left + bleed.right)
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private _prepareLayout (): void {
|
|
226
|
-
const { config, bleed, datamodel } = this
|
|
227
|
-
const isExtendedSize = this.sizing === Sizing.Extend
|
|
228
|
-
const sankeyHeight = this.sizing === Sizing.Fit ? this._height : this._extendedHeight
|
|
229
|
-
const sankeyWidth = this.sizing === Sizing.Fit ? this._width : this._extendedWidth
|
|
230
|
-
this._sankey
|
|
231
|
-
.size([
|
|
232
|
-
Math.max(sankeyWidth - bleed.left - bleed.right, 0),
|
|
233
|
-
Math.max(sankeyHeight - bleed.top - bleed.bottom, 0),
|
|
234
|
-
])
|
|
235
|
-
|
|
236
|
-
const nodes = datamodel.nodes
|
|
237
|
-
const links = datamodel.links
|
|
238
|
-
|
|
239
|
-
// If there are no links we manually calculate the visualization layout
|
|
240
|
-
if (!this._hasLinks()) {
|
|
241
|
-
let y = 0
|
|
242
|
-
const nodesTotalHeight = sum(nodes, n => n._state.precalculatedHeight || 1)
|
|
243
|
-
for (const node of nodes) {
|
|
244
|
-
const sankeyHeight = this.getHeight() - bleed.top - bleed.bottom
|
|
245
|
-
const nodeHeight = node._state.precalculatedHeight || 1
|
|
246
|
-
const h = isExtendedSize ? nodeHeight : (sankeyHeight - config.nodePadding * (nodes.length - 1)) * nodeHeight / nodesTotalHeight
|
|
247
|
-
|
|
248
|
-
node.width = Math.max(10, config.nodeWidth)
|
|
249
|
-
node.x0 = 0
|
|
250
|
-
node.x1 = node.width
|
|
251
|
-
node.y0 = y
|
|
252
|
-
node.y1 = y + Math.max(1, h)
|
|
253
|
-
node.layer = 0
|
|
254
|
-
|
|
255
|
-
y = node.y1 + config.nodePadding
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
this._extendedHeightIncreased = undefined
|
|
259
|
-
return
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Calculate sankey
|
|
263
|
-
this._populateLinkAndNodeValues()
|
|
264
|
-
this._sankey({ nodes, links })
|
|
265
|
-
|
|
266
|
-
// Setting minimum node height
|
|
267
|
-
// Default: 1px
|
|
268
|
-
// Extended size nodes that have no links: config.nodeMinHeight
|
|
269
|
-
for (const node of nodes) {
|
|
270
|
-
const singleExtendedSize = isExtendedSize && !node.sourceLinks?.length && !node.targetLinks?.length
|
|
271
|
-
const h = Math.max(singleExtendedSize ? config.nodeMinHeight : 1, node.y1 - node.y0)
|
|
272
|
-
const y = (node.y0 + node.y1) / 2
|
|
273
|
-
node.y0 = y - h / 2
|
|
274
|
-
node.y1 = y + h / 2
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (isExtendedSize) {
|
|
278
|
-
const height = max(nodes, d => d.y1)
|
|
279
|
-
this._extendedHeightIncreased = height + bleed.top + bleed.bottom
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
getWidth (): number {
|
|
284
|
-
return this.sizing === Sizing.Fit ? this._width : (this._extendedWidth || 0)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
getHeight (): number {
|
|
288
|
-
return this.sizing === Sizing.Fit ? this._height : Math.max(this._extendedHeightIncreased || 0, this._extendedHeight || 0)
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
getLayoutWidth (): number {
|
|
292
|
-
return this.sizing === Sizing.Fit ? this._width : this._extendedWidth
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
getLayoutHeight (): number {
|
|
296
|
-
return this.sizing === Sizing.Fit ? this._height : (this._extendedHeightIncreased || this._extendedHeight)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
getColumnCenters (): number[] {
|
|
300
|
-
const { datamodel } = this
|
|
301
|
-
const nodes = datamodel.nodes as SankeyNode<N, L>[]
|
|
302
|
-
const centers = nodes.reduce((pos, node) => {
|
|
303
|
-
const idx = node.layer
|
|
304
|
-
if (!isFinite(pos[idx])) {
|
|
305
|
-
pos[idx] = (node.x0 + node.x1) / 2
|
|
306
|
-
}
|
|
307
|
-
return pos
|
|
308
|
-
}, [])
|
|
309
|
-
|
|
310
|
-
return centers
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
highlightSubtree (node: SankeyNode<N, L>): void {
|
|
314
|
-
const { config, datamodel } = this
|
|
315
|
-
|
|
316
|
-
clearTimeout(this._highlightTimeoutId)
|
|
317
|
-
this._highlightTimeoutId = setTimeout(() => {
|
|
318
|
-
for (const n of datamodel.nodes) n._state.greyout = true
|
|
319
|
-
for (const l of datamodel.links) l._state.greyout = true
|
|
320
|
-
|
|
321
|
-
this.recursiveSetSubtreeState(node, 'sourceLinks', 'target', 'greyout', false)
|
|
322
|
-
this.recursiveSetSubtreeState(node, 'targetLinks', 'source', 'greyout', false)
|
|
323
|
-
this._render(config.highlightDuration)
|
|
324
|
-
this._highlightActive = true
|
|
325
|
-
}, config.highlightDelay)
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
recursiveSetSubtreeState (
|
|
329
|
-
node: SankeyNode<N, L>,
|
|
330
|
-
linksKey: 'sourceLinks' | 'targetLinks',
|
|
331
|
-
nodeKey: 'source' | 'target',
|
|
332
|
-
key: string,
|
|
333
|
-
value: unknown
|
|
334
|
-
): void {
|
|
335
|
-
node._state[key] = value
|
|
336
|
-
|
|
337
|
-
for (const l of node[linksKey]) {
|
|
338
|
-
l._state[key] = value
|
|
339
|
-
this.recursiveSetSubtreeState(l[nodeKey] as SankeyNode<N, L>, linksKey, nodeKey, key, value)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
disableHighlight (): void {
|
|
344
|
-
const { config, datamodel } = this
|
|
345
|
-
|
|
346
|
-
clearTimeout(this._highlightTimeoutId)
|
|
347
|
-
if (this._highlightActive) {
|
|
348
|
-
this._highlightActive = false
|
|
349
|
-
|
|
350
|
-
for (const n of datamodel.nodes) n._state.greyout = false
|
|
351
|
-
for (const l of datamodel.links) l._state.greyout = false
|
|
352
|
-
this._render(config.highlightDuration)
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
private _hasLinks (): boolean {
|
|
357
|
-
const { datamodel } = this
|
|
358
|
-
return datamodel.links.length > 0
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
private _onNodeMouseOver (d: SankeyNode<N, L>, event: MouseEvent): void {
|
|
362
|
-
onNodeMouseOver(d, select(event.currentTarget as SVGGElement), this.config, this._width)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
private _onNodeMouseOut (d: SankeyNode<N, L>, event: MouseEvent): void {
|
|
366
|
-
onNodeMouseOut(d, select(event.currentTarget as SVGGElement), this.config, this._width)
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
private _onNodeRectMouseOver (d: SankeyNode<N, L>): void {
|
|
370
|
-
const { config } = this
|
|
371
|
-
if (config.highlightSubtreeOnHover) this.highlightSubtree(d)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
private _onNodeRectMouseOut (d: SankeyNode<N, L>): void {
|
|
375
|
-
this.disableHighlight()
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
private _onLinkMouseOver (d: SankeyLink<N, L>, event: MouseEvent): void {
|
|
379
|
-
const { config } = this
|
|
380
|
-
|
|
381
|
-
if (config.highlightSubtreeOnHover) this.highlightSubtree(d.target as SankeyNode<N, L>)
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
private _onLinkMouseOut (d: SankeyLink<N, L>, event: MouseEvent): void {
|
|
385
|
-
this.disableHighlight()
|
|
386
|
-
}
|
|
387
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { Selection } from 'd3-selection'
|
|
2
|
-
|
|
3
|
-
// Utils
|
|
4
|
-
import { estimateTextSize, trimSVGText, wrapSVGText } from 'utils/text'
|
|
5
|
-
import { smartTransition } from 'utils/d3'
|
|
6
|
-
import { getString, getValue } from 'utils/data'
|
|
7
|
-
import { getColor } from 'utils/color'
|
|
8
|
-
import { getCSSVariableValueInPixels } from 'utils/misc'
|
|
9
|
-
|
|
10
|
-
// Types
|
|
11
|
-
import { GenericAccessor } from 'types/accessor'
|
|
12
|
-
import { FitMode, VerticalAlign } from 'types/text'
|
|
13
|
-
import { Position } from 'types/position'
|
|
14
|
-
|
|
15
|
-
// Local Types
|
|
16
|
-
import { SankeyInputLink, SankeyInputNode, SankeyNode, SankeySubLabelPlacement } from '../types'
|
|
17
|
-
|
|
18
|
-
// Config
|
|
19
|
-
import { SankeyConfig } from '../config'
|
|
20
|
-
|
|
21
|
-
// Styles
|
|
22
|
-
import * as s from '../style'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const NODE_LABEL_SPACING = 10
|
|
26
|
-
const LABEL_BLOCK_PADDING = 6.5
|
|
27
|
-
|
|
28
|
-
function getLabelBackground (
|
|
29
|
-
width: number,
|
|
30
|
-
height: number,
|
|
31
|
-
orientation: Position.Left | Position.Right,
|
|
32
|
-
arrowWidth = 5,
|
|
33
|
-
arrowHeight = 8
|
|
34
|
-
): string {
|
|
35
|
-
const halfHeight = height / 2
|
|
36
|
-
const halfArrowHeight = arrowHeight / 2
|
|
37
|
-
|
|
38
|
-
if (orientation === Position.Left) {
|
|
39
|
-
const rightArrowPos = `L 0 ${halfHeight - halfArrowHeight} L ${+arrowWidth} ${halfHeight} L 0 ${halfHeight + halfArrowHeight}`
|
|
40
|
-
return `
|
|
41
|
-
M 0 0
|
|
42
|
-
${rightArrowPos}
|
|
43
|
-
L 0 ${height}
|
|
44
|
-
L ${-width} ${height}
|
|
45
|
-
L ${-width} 0
|
|
46
|
-
L 0 0 `
|
|
47
|
-
} else {
|
|
48
|
-
const leftArrowPos = `L 0 ${halfHeight - halfArrowHeight} L ${-arrowWidth} ${halfHeight} L 0 ${halfHeight + halfArrowHeight}`
|
|
49
|
-
return `
|
|
50
|
-
M 0 0
|
|
51
|
-
${leftArrowPos}
|
|
52
|
-
L 0 ${height}
|
|
53
|
-
L ${width} ${height}
|
|
54
|
-
L ${width} 0
|
|
55
|
-
L 0 0 `
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function getLabelOrientation<N extends SankeyInputNode, L extends SankeyInputLink> (
|
|
60
|
-
d: SankeyNode<N, L>,
|
|
61
|
-
sankeyWidth: number,
|
|
62
|
-
labelPosition: GenericAccessor<Position.Auto | Position.Left | Position.Right | string, N>
|
|
63
|
-
): (Position.Left | Position.Right) {
|
|
64
|
-
let orientation = getValue(d, labelPosition)
|
|
65
|
-
if (orientation === Position.Auto || !orientation) {
|
|
66
|
-
orientation = d.x0 < sankeyWidth / 2 ? Position.Left : Position.Right
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return orientation as (Position.Left | Position.Right)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const requiredLabelSpace = (labelWidth: number, labelFontSize: number): { width: number; height: number } => {
|
|
73
|
-
return {
|
|
74
|
-
height: labelFontSize * 2.5 + 2 * LABEL_BLOCK_PADDING, // Assuming 2.5 lines per label
|
|
75
|
-
width: labelWidth + 2 * NODE_LABEL_SPACING + 2 * LABEL_BLOCK_PADDING,
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function getLabelGroupXTranslate<N extends SankeyInputNode, L extends SankeyInputLink> (
|
|
80
|
-
d: SankeyNode<N, L>,
|
|
81
|
-
config: SankeyConfig<N, L>,
|
|
82
|
-
width: number
|
|
83
|
-
): number {
|
|
84
|
-
const orientation = getLabelOrientation(d, width, config.labelPosition)
|
|
85
|
-
switch (orientation) {
|
|
86
|
-
case Position.Right: return config.nodeWidth + NODE_LABEL_SPACING
|
|
87
|
-
case Position.Left:
|
|
88
|
-
default:
|
|
89
|
-
return -NODE_LABEL_SPACING
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function getLabelGroupYTranslate<N extends SankeyInputNode, L extends SankeyInputLink> (
|
|
94
|
-
d: SankeyNode<N, L>,
|
|
95
|
-
labelGroupHeight: number,
|
|
96
|
-
config: SankeyConfig<N, L>
|
|
97
|
-
): number {
|
|
98
|
-
const nodeHeight = d.y1 - d.y0
|
|
99
|
-
if (config.labelBackground && (nodeHeight < labelGroupHeight)) return (nodeHeight - labelGroupHeight) / 2
|
|
100
|
-
|
|
101
|
-
switch (config.labelVerticalAlign) {
|
|
102
|
-
case VerticalAlign.Bottom: return nodeHeight - labelGroupHeight
|
|
103
|
-
case VerticalAlign.Middle: return nodeHeight / 2 - labelGroupHeight / 2
|
|
104
|
-
case VerticalAlign.Top:
|
|
105
|
-
default: return 0
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function getLabelTextAnchor<N extends SankeyInputNode, L extends SankeyInputLink> (
|
|
110
|
-
d: SankeyNode<N, L>,
|
|
111
|
-
config: SankeyConfig<N, L>,
|
|
112
|
-
width: number
|
|
113
|
-
): string {
|
|
114
|
-
const orientation = getLabelOrientation(d, width, config.labelPosition)
|
|
115
|
-
switch (orientation) {
|
|
116
|
-
case Position.Right: return 'start'
|
|
117
|
-
case Position.Left:
|
|
118
|
-
default:
|
|
119
|
-
return 'end'
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function getSubLabelTextAnchor<N extends SankeyInputNode, L extends SankeyInputLink> (
|
|
124
|
-
d: SankeyNode<N, L>,
|
|
125
|
-
config: SankeyConfig<N, L>,
|
|
126
|
-
width: number
|
|
127
|
-
): string {
|
|
128
|
-
const isSublabelInline = config.subLabelPlacement === SankeySubLabelPlacement.Inline
|
|
129
|
-
const orientation = getLabelOrientation(d, width, config.labelPosition)
|
|
130
|
-
switch (orientation) {
|
|
131
|
-
case Position.Right: return isSublabelInline ? 'end' : 'start'
|
|
132
|
-
case Position.Left:
|
|
133
|
-
default:
|
|
134
|
-
return isSublabelInline ? 'start' : 'end'
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function renderLabel<N extends SankeyInputNode, L extends SankeyInputLink> (
|
|
139
|
-
labelGroup: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any>,
|
|
140
|
-
d: SankeyNode<N, L>,
|
|
141
|
-
config: SankeyConfig<N, L>,
|
|
142
|
-
width: number,
|
|
143
|
-
duration: number,
|
|
144
|
-
forceExpand = false
|
|
145
|
-
): { x: number; y: number; width: number; height: number; layer: number; selection: any; hidden?: boolean } {
|
|
146
|
-
const labelTextSelection: Selection<SVGTextElement, SankeyNode<N, L>, SVGGElement, SankeyNode<N, L>> = labelGroup.select(`.${s.label}`)
|
|
147
|
-
const labelShowBackground = config.labelBackground || forceExpand
|
|
148
|
-
const sublabelTextSelection: Selection<SVGTextElement, SankeyNode<N, L>, SVGGElement, SankeyNode<N, L>> = labelGroup.select(`.${s.sublabel}`)
|
|
149
|
-
const labelPadding = labelShowBackground ? LABEL_BLOCK_PADDING : 0
|
|
150
|
-
const isSublabelInline = config.subLabelPlacement === SankeySubLabelPlacement.Inline
|
|
151
|
-
const separator = config.labelForceWordBreak ? '' : config.labelTextSeparator
|
|
152
|
-
const fastEstimatesMode = true // Fast but inaccurate
|
|
153
|
-
const fontWidthToHeightRatio = 0.52
|
|
154
|
-
const dy = 0.32
|
|
155
|
-
const labelOrientation = getLabelOrientation(d, width, config.labelPosition)
|
|
156
|
-
const labelOrientationMult = labelOrientation === Position.Left ? -1 : 1
|
|
157
|
-
const labelText = getString(d, config.label)
|
|
158
|
-
const sublabelText = getString(d, config.subLabel)
|
|
159
|
-
let wasTrimmed = false
|
|
160
|
-
|
|
161
|
-
const labelFontSize = config.labelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-node-label-font-size)', labelGroup.node())
|
|
162
|
-
const subLabelFontSize = config.subLabelFontSize ?? getCSSVariableValueInPixels('var(--vis-sankey-node-sublabel-font-size)', labelGroup.node())
|
|
163
|
-
|
|
164
|
-
// Render the main label, wrap / trim it and estimate its size
|
|
165
|
-
const labelsFontSizeDifference = sublabelText ? labelFontSize - subLabelFontSize : 0
|
|
166
|
-
const labelTranslateY = labelPadding + ((isSublabelInline && labelsFontSizeDifference < 0) ? -0.6 * labelsFontSizeDifference : 0)
|
|
167
|
-
labelTextSelection
|
|
168
|
-
.text(labelText)
|
|
169
|
-
.attr('font-size', labelFontSize)
|
|
170
|
-
.style('fill', getColor(d, config.labelColor))
|
|
171
|
-
.attr('transform', `translate(${labelOrientationMult * labelPadding},${labelTranslateY})`)
|
|
172
|
-
.style('cursor', (d: SankeyNode<N, L>) => getString(d, config.labelCursor))
|
|
173
|
-
|
|
174
|
-
const labelMaxWidth = isSublabelInline ? config.labelMaxWidth * (1 - (sublabelText ? config.subLabelToLabelInlineWidthRatio : 0)) : config.labelMaxWidth
|
|
175
|
-
if (config.labelFit === FitMode.Wrap || forceExpand) wrapSVGText(labelTextSelection, labelMaxWidth, separator)
|
|
176
|
-
else wasTrimmed = trimSVGText(labelTextSelection, labelMaxWidth, config.labelTrimMode, fastEstimatesMode, labelFontSize, fontWidthToHeightRatio)
|
|
177
|
-
|
|
178
|
-
const labelSize = estimateTextSize(labelTextSelection, labelFontSize, dy, fastEstimatesMode, fontWidthToHeightRatio)
|
|
179
|
-
|
|
180
|
-
// Render the sub-label, wrap / trim it and estimate its size
|
|
181
|
-
const sublabelTranslateX = labelOrientationMult * (labelPadding + (isSublabelInline ? config.labelMaxWidth : 0))
|
|
182
|
-
const sublabelMarginTop = 0
|
|
183
|
-
const sublabelTranslateY = labelPadding + (isSublabelInline
|
|
184
|
-
? (labelsFontSizeDifference > 0 ? 0.6 * labelsFontSizeDifference : 0)
|
|
185
|
-
: labelSize.height + sublabelMarginTop)
|
|
186
|
-
sublabelTextSelection
|
|
187
|
-
.text(sublabelText)
|
|
188
|
-
.attr('font-size', subLabelFontSize)
|
|
189
|
-
.style('fill', getColor(d, config.subLabelColor))
|
|
190
|
-
.attr('transform', `translate(${sublabelTranslateX},${sublabelTranslateY})`)
|
|
191
|
-
.style('cursor', (d: SankeyNode<N, L>) => getString(d, config.labelCursor))
|
|
192
|
-
|
|
193
|
-
const sublabelMaxWidth = isSublabelInline ? config.labelMaxWidth * config.subLabelToLabelInlineWidthRatio : config.labelMaxWidth
|
|
194
|
-
if (config.labelFit === FitMode.Wrap || forceExpand) wrapSVGText(sublabelTextSelection, sublabelMaxWidth, separator)
|
|
195
|
-
else wasTrimmed = wasTrimmed || trimSVGText(sublabelTextSelection, sublabelMaxWidth, config.labelTrimMode, fastEstimatesMode, subLabelFontSize, fontWidthToHeightRatio)
|
|
196
|
-
|
|
197
|
-
labelGroup.classed(s.labelTrimmed, wasTrimmed)
|
|
198
|
-
const sublabelSize = estimateTextSize(sublabelTextSelection, subLabelFontSize, dy, fastEstimatesMode, fontWidthToHeightRatio)
|
|
199
|
-
|
|
200
|
-
// Draw the background if needed
|
|
201
|
-
const labelGroupHeight = (isSublabelInline ? Math.max(labelSize.height, sublabelSize.height) : (labelSize.height + sublabelSize.height)) + 2 * labelPadding
|
|
202
|
-
const labelBackground = labelGroup.select(`.${s.labelBackground}`)
|
|
203
|
-
|
|
204
|
-
labelBackground
|
|
205
|
-
.attr('d', labelShowBackground ? getLabelBackground(config.labelMaxWidth + 2 * labelPadding, labelGroupHeight, labelOrientation as (Position.Left | Position.Right)) : null)
|
|
206
|
-
|
|
207
|
-
// Position the label
|
|
208
|
-
const labelTextAnchor = getLabelTextAnchor(d, config, width)
|
|
209
|
-
const sublabelTextAnchor = getSubLabelTextAnchor(d, config, width)
|
|
210
|
-
const xTranslate = getLabelGroupXTranslate(d, config, width)
|
|
211
|
-
const yTranslate = getLabelGroupYTranslate(d, labelGroupHeight, config)
|
|
212
|
-
|
|
213
|
-
labelTextSelection.attr('text-anchor', labelTextAnchor)
|
|
214
|
-
sublabelTextSelection.attr('text-anchor', sublabelTextAnchor)
|
|
215
|
-
|
|
216
|
-
const hasTransform = !!labelGroup.attr('transform')
|
|
217
|
-
smartTransition(labelGroup, hasTransform ? duration : 0)
|
|
218
|
-
.attr('transform', `translate(${xTranslate},${yTranslate})`)
|
|
219
|
-
|
|
220
|
-
return {
|
|
221
|
-
x: d.x0 + xTranslate,
|
|
222
|
-
y: d.y0 + yTranslate,
|
|
223
|
-
width: config.labelMaxWidth,
|
|
224
|
-
height: labelGroupHeight,
|
|
225
|
-
layer: d.layer,
|
|
226
|
-
selection: labelGroup,
|
|
227
|
-
}
|
|
228
|
-
}
|