@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,75 @@
|
|
|
1
|
+
import { LatLng } from 'leaflet'
|
|
2
|
+
import Supercluster, { ClusterProperties } from 'supercluster'
|
|
3
|
+
import { GenericDataRecord } from 'types/data'
|
|
4
|
+
|
|
5
|
+
export enum LeafletMapRenderer {
|
|
6
|
+
Raster = 'raster',
|
|
7
|
+
MapLibre = 'maplibre',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum LeafletMapPointShape {
|
|
11
|
+
Square = 'square',
|
|
12
|
+
Circle = 'circle',
|
|
13
|
+
Triangle = 'triangle',
|
|
14
|
+
Ring = 'ring',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type LeafletMapPieDatum = {
|
|
18
|
+
value: number;
|
|
19
|
+
name: string;
|
|
20
|
+
color: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface LeafletMapPointStyle {
|
|
25
|
+
color: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type LeafletMapPointStyles<D> = { [key in keyof D]?: LeafletMapPointStyle }
|
|
30
|
+
|
|
31
|
+
export type PointExpandedClusterProperties<D extends GenericDataRecord> = D & {
|
|
32
|
+
// Expanded cluster related data:
|
|
33
|
+
// eslint-disable-next-line no-use-before-define
|
|
34
|
+
expandedClusterPoint?: LeafletMapPoint<D>;
|
|
35
|
+
r?: number;
|
|
36
|
+
dx?: number;
|
|
37
|
+
dy?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type LeafletMapClusterDatum<D extends GenericDataRecord> = Partial<D> & ClusterProperties & {
|
|
41
|
+
clusterIndex?: Supercluster<D>;
|
|
42
|
+
clusterPoints?: D[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type LeafletMapPointDatum<D extends GenericDataRecord> = D & PointExpandedClusterProperties<D> & {
|
|
46
|
+
id: string | number;
|
|
47
|
+
shape: LeafletMapPointShape;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type LeafletMapPoint<D extends GenericDataRecord> = {
|
|
51
|
+
geometry: GeoJSON.Point;
|
|
52
|
+
bbox: { x1: number; x2: number; y1: number; y2: number };
|
|
53
|
+
radius: number;
|
|
54
|
+
path: string;
|
|
55
|
+
color: string;
|
|
56
|
+
id: number | string;
|
|
57
|
+
properties: LeafletMapPointDatum<D> | LeafletMapClusterDatum<D>;
|
|
58
|
+
donutData: LeafletMapPieDatum[];
|
|
59
|
+
isCluster: boolean;
|
|
60
|
+
clusterIndex: Supercluster<D, Supercluster.AnyProps>;
|
|
61
|
+
clusterPoints?: D[];
|
|
62
|
+
_zIndex: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type Bounds = {
|
|
66
|
+
northEast: { lat: number; lng: number };
|
|
67
|
+
southWest: { lat: number; lng: number };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type MapZoomState = {
|
|
71
|
+
mapCenter: LatLng;
|
|
72
|
+
zoomLevel: number;
|
|
73
|
+
bounds: Bounds;
|
|
74
|
+
userDriven: boolean;
|
|
75
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { XYComponentConfigInterface, XYComponentConfig } from 'core/xy-component/config'
|
|
2
|
+
|
|
3
|
+
// Types
|
|
4
|
+
import { CurveType } from 'types/curve'
|
|
5
|
+
import { GenericAccessor, StringAccessor } from 'types/accessor'
|
|
6
|
+
|
|
7
|
+
export interface LineConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {
|
|
8
|
+
/** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */
|
|
9
|
+
curveType?: CurveType;
|
|
10
|
+
/** Line width in pixels. Default: `2` */
|
|
11
|
+
lineWidth?: number;
|
|
12
|
+
/** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */
|
|
13
|
+
lineDashArray?: GenericAccessor<number[], Datum>;
|
|
14
|
+
/** When a data point has an `undefined`, `NaN`, or other no-data value, they'll be replaced with a value specified here.
|
|
15
|
+
* Setting this property to `undefined` will lead to having the line break when there's no data, and continue when
|
|
16
|
+
* the data appears again. If you set it to `null`, the values will be treated as numerical `0` values and the line
|
|
17
|
+
* won't break; however if the whole dataset consists of only `null`s, the line won't be displayed.
|
|
18
|
+
* Default: `undefined`
|
|
19
|
+
*/
|
|
20
|
+
fallbackValue?: number | undefined | null;
|
|
21
|
+
/** Highlight line on hover. Default: `false` */
|
|
22
|
+
highlightOnHover?: boolean;
|
|
23
|
+
/** Optional link cursor. Default: `null` */
|
|
24
|
+
cursor?: StringAccessor<Datum[]>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class LineConfig<Datum> extends XYComponentConfig<Datum> implements LineConfigInterface<Datum> {
|
|
28
|
+
curveType = CurveType.MonotoneX
|
|
29
|
+
lineWidth = 2
|
|
30
|
+
lineDashArray = undefined
|
|
31
|
+
fallbackValue = undefined
|
|
32
|
+
highlightOnHover = false
|
|
33
|
+
cursor = null
|
|
34
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { select } from 'd3-selection'
|
|
2
|
+
import { Transition } from 'd3-transition'
|
|
3
|
+
import { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'
|
|
4
|
+
import { interpolatePath } from 'd3-interpolate-path'
|
|
5
|
+
|
|
6
|
+
// Core
|
|
7
|
+
import { XYComponentCore } from 'core/xy-component'
|
|
8
|
+
|
|
9
|
+
// Utils
|
|
10
|
+
import { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'
|
|
11
|
+
import { smartTransition } from 'utils/d3'
|
|
12
|
+
import { getColor } from 'utils/color'
|
|
13
|
+
|
|
14
|
+
// Types
|
|
15
|
+
import { NumericAccessor } from 'types/accessor'
|
|
16
|
+
import { Spacing } from 'types/spacing'
|
|
17
|
+
import { Curve, CurveType } from 'types/curve'
|
|
18
|
+
import { Direction } from 'types/direction'
|
|
19
|
+
|
|
20
|
+
// Local Types
|
|
21
|
+
import { LineData, LineDatum } from './types'
|
|
22
|
+
|
|
23
|
+
// Config
|
|
24
|
+
import { LineConfig, LineConfigInterface } from './config'
|
|
25
|
+
|
|
26
|
+
// Styles
|
|
27
|
+
import * as s from './style'
|
|
28
|
+
|
|
29
|
+
export class Line<Datum> extends XYComponentCore<Datum, LineConfig<Datum>, LineConfigInterface<Datum>> {
|
|
30
|
+
static selectors = s
|
|
31
|
+
config: LineConfig<Datum> = new LineConfig()
|
|
32
|
+
lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>
|
|
33
|
+
curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]
|
|
34
|
+
events = {
|
|
35
|
+
[Line.selectors.line]: {
|
|
36
|
+
mouseover: this._highlight.bind(this),
|
|
37
|
+
mouseleave: this._resetHighlight.bind(this),
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor (config?: LineConfigInterface<Datum>) {
|
|
42
|
+
super()
|
|
43
|
+
if (config) this.config.init(config)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get bleed (): Spacing {
|
|
47
|
+
const { config: { lineWidth } } = this
|
|
48
|
+
const yDomain = this.yScale.domain() as [number, number]
|
|
49
|
+
const yDirection = this.yScale.range()[0] > this.yScale.range()[1]
|
|
50
|
+
? Direction.North
|
|
51
|
+
: Direction.South
|
|
52
|
+
const isYDirectionSouth = yDirection === Direction.South
|
|
53
|
+
|
|
54
|
+
const isLineThick = lineWidth > 3
|
|
55
|
+
const isLineVeryThick = lineWidth >= 10
|
|
56
|
+
return {
|
|
57
|
+
top: !isLineVeryThick && (
|
|
58
|
+
(!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))
|
|
59
|
+
) ? 0 : lineWidth / 2,
|
|
60
|
+
bottom: !isLineVeryThick && (
|
|
61
|
+
(!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))
|
|
62
|
+
) ? 0 : lineWidth / 2,
|
|
63
|
+
left: isLineThick ? lineWidth / 2 : 0,
|
|
64
|
+
right: isLineThick ? lineWidth / 2 : 0,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_render (customDuration?: number): void {
|
|
69
|
+
super._render(customDuration)
|
|
70
|
+
const { config, datamodel: { data } } = this
|
|
71
|
+
const duration = isNumber(customDuration) ? customDuration : config.duration
|
|
72
|
+
|
|
73
|
+
this.curve = Curve[config.curveType]
|
|
74
|
+
this.lineGen = line<{ x: number; y: number; defined: boolean }>()
|
|
75
|
+
.x(d => d.x)
|
|
76
|
+
.y(d => d.y)
|
|
77
|
+
.defined(d => d.defined)
|
|
78
|
+
.curve(this.curve)
|
|
79
|
+
|
|
80
|
+
const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]
|
|
81
|
+
const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))
|
|
82
|
+
const lineData: LineData[] = yAccessors.map(a => {
|
|
83
|
+
const ld: LineDatum[] = data.map((d, i) => {
|
|
84
|
+
const rawValue = getNumber(d, a, i)
|
|
85
|
+
// If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`
|
|
86
|
+
const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue
|
|
87
|
+
return {
|
|
88
|
+
x: lineDataX[i],
|
|
89
|
+
y: this.yScale(value ?? 0),
|
|
90
|
+
defined: isFinite(value),
|
|
91
|
+
value,
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const defined = ld.reduce((def, d) => (d.defined || def), false)
|
|
96
|
+
// If the line consists only of `null` values, we'll still render it but it'll be invisible.
|
|
97
|
+
// Such trick allows us to have better animated transitions.
|
|
98
|
+
const visible = defined && ld.some(d => d.value !== null)
|
|
99
|
+
return {
|
|
100
|
+
values: ld,
|
|
101
|
+
defined,
|
|
102
|
+
visible,
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const lines = this.g
|
|
107
|
+
.selectAll<SVGGElement, LineData>(`.${s.line}`)
|
|
108
|
+
.data(lineData)
|
|
109
|
+
|
|
110
|
+
const linesEnter = lines.enter().append('g')
|
|
111
|
+
.attr('class', s.line)
|
|
112
|
+
|
|
113
|
+
linesEnter
|
|
114
|
+
.append('path')
|
|
115
|
+
.attr('class', s.linePath)
|
|
116
|
+
.attr('d', this._emptyPath())
|
|
117
|
+
.attr('stroke', (d, i) => getColor(data, config.color, i))
|
|
118
|
+
.attr('stroke-opacity', 0)
|
|
119
|
+
.attr('stroke-width', config.lineWidth)
|
|
120
|
+
|
|
121
|
+
linesEnter
|
|
122
|
+
.append('path')
|
|
123
|
+
.attr('class', s.lineSelectionHelper)
|
|
124
|
+
.attr('d', this._emptyPath())
|
|
125
|
+
|
|
126
|
+
const linesMerged = linesEnter.merge(lines)
|
|
127
|
+
linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))
|
|
128
|
+
linesMerged.each((d, i, elements) => {
|
|
129
|
+
const group = select(elements[i])
|
|
130
|
+
const linePath = group.select<SVGPathElement>(`.${s.linePath}`)
|
|
131
|
+
const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)
|
|
132
|
+
|
|
133
|
+
const isLineVisible = d.visible
|
|
134
|
+
const dashArray = getValue<LineData, number[]>(d, config.lineDashArray, i)
|
|
135
|
+
const transition = smartTransition(linePath, duration)
|
|
136
|
+
.attr('stroke', getColor(data, config.color, i))
|
|
137
|
+
.attr('stroke-width', config.lineWidth)
|
|
138
|
+
.attr('stroke-opacity', isLineVisible ? 1 : 0)
|
|
139
|
+
.style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray
|
|
140
|
+
|
|
141
|
+
const hasUndefinedSegments = d.values.some(d => !d.defined)
|
|
142
|
+
const svgPathD = this.lineGen(d.values)
|
|
143
|
+
|
|
144
|
+
if (duration && !hasUndefinedSegments) {
|
|
145
|
+
const previous = linePath.attr('d') || this._emptyPath()
|
|
146
|
+
const next = svgPathD || this._emptyPath()
|
|
147
|
+
const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>
|
|
148
|
+
t.attrTween('d', () => interpolatePath(previous, next))
|
|
149
|
+
} else if (d.visible) {
|
|
150
|
+
transition.attr('d', svgPathD)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
lineSelectionHelper
|
|
154
|
+
.attr('d', svgPathD)
|
|
155
|
+
.attr('visibility', isLineVisible ? null : 'hidden')
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
smartTransition(lines.exit(), duration)
|
|
159
|
+
.style('opacity', 0)
|
|
160
|
+
.remove()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private _emptyPath (): string {
|
|
164
|
+
const xRange = this.xScale.range()
|
|
165
|
+
const yRange = this.yScale.range()
|
|
166
|
+
return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private _highlight (datum, i, els): void {
|
|
170
|
+
const { config } = this
|
|
171
|
+
|
|
172
|
+
if (config.highlightOnHover) {
|
|
173
|
+
this.g
|
|
174
|
+
.selectAll(`.${s.line}`)
|
|
175
|
+
.classed(s.dim, d => d !== datum)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private _resetHighlight (d, i, els): void {
|
|
180
|
+
const { config } = this
|
|
181
|
+
|
|
182
|
+
if (config.highlightOnHover) {
|
|
183
|
+
this.g
|
|
184
|
+
.selectAll(`.${s.line}`)
|
|
185
|
+
.classed(s.dim, false)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css, injectGlobal } from '@emotion/css'
|
|
2
2
|
|
|
3
|
-
const globalStyles = injectGlobal
|
|
3
|
+
export const globalStyles = injectGlobal`
|
|
4
4
|
:root {
|
|
5
5
|
--vis-line-cursor: default;
|
|
6
6
|
--vis-line-stroke-dasharray: none;
|
|
7
7
|
--vis-line-stroke-dashoffset: 0;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
export const root = css`
|
|
11
12
|
label: line-component;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const line = css`
|
|
14
16
|
label: line;
|
|
15
17
|
transition: opacity 200ms;
|
|
16
18
|
cursor: var(--vis-line-cursor);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
`
|
|
20
|
+
|
|
21
|
+
export const linePath = css`
|
|
19
22
|
label: linePath;
|
|
20
23
|
fill: none;
|
|
21
24
|
stroke-dasharray: var(--vis-line-stroke-dasharray);
|
|
22
25
|
stroke-dashoffset: var(--vis-line-stroke-dashoffset);
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
`
|
|
27
|
+
|
|
28
|
+
export const lineSelectionHelper = css`
|
|
25
29
|
label: lineSelectionHelper;
|
|
26
30
|
fill: none;
|
|
27
31
|
stroke: rgba(0, 0, 0, 0);
|
|
28
32
|
stroke-width: 8px;
|
|
29
|
-
|
|
30
|
-
const dim = css `
|
|
31
|
-
opacity: 0.2;
|
|
32
|
-
`;
|
|
33
|
+
`
|
|
33
34
|
|
|
34
|
-
export
|
|
35
|
-
|
|
35
|
+
export const dim = css`
|
|
36
|
+
opacity: 0.2;
|
|
37
|
+
`
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Core
|
|
2
|
+
import { ComponentConfigInterface, ComponentConfig } from 'core/component/config'
|
|
3
|
+
|
|
4
|
+
// Types
|
|
5
|
+
import { ColorAccessor, GenericAccessor, StringAccessor } from 'types/accessor'
|
|
6
|
+
import { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {
|
|
10
|
+
/** Diagram angle range. Default: `[0, 2 * Math.PI]` */
|
|
11
|
+
angleRange?: [number, number];
|
|
12
|
+
/** Direction of hierarchy flow from root to leaf.
|
|
13
|
+
* `NestedDonutDirection.INWARDS` starts from the outer most radius and works towards center
|
|
14
|
+
* `NestedDonutDirection.OUTWARDS` starts from the inner most radius the consecutive layers outward.
|
|
15
|
+
* Default: `NestedDonutDirection.INWARDS`
|
|
16
|
+
*/
|
|
17
|
+
direction?: NestedDonutDirection | string;
|
|
18
|
+
|
|
19
|
+
/** Central label text. Default: `undefined` */
|
|
20
|
+
centralLabel?: string;
|
|
21
|
+
/** Central sub-label accessor function or text. Default: `undefined` */
|
|
22
|
+
centralSubLabel?: string;
|
|
23
|
+
/** Enables wrapping for the sub-label. Default: `true` */
|
|
24
|
+
centralSubLabelWrap?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Show donut background. The color is configurable via
|
|
27
|
+
* the `--vis-nested-donut-background-color` and `--vis-dark-nested-donut-background-color` CSS variables.
|
|
28
|
+
* Default: `true`
|
|
29
|
+
*/
|
|
30
|
+
showBackground?: boolean;
|
|
31
|
+
|
|
32
|
+
// Layers
|
|
33
|
+
/** Array of accessor functions to defined the nested groups */
|
|
34
|
+
layers: StringAccessor<Datum>[];
|
|
35
|
+
/* Layer settings */
|
|
36
|
+
layerConfig?: GenericAccessor<NestedDonutLayerSettings, string>;
|
|
37
|
+
/* Space between layers */
|
|
38
|
+
layerPadding?: number;
|
|
39
|
+
|
|
40
|
+
// Segments
|
|
41
|
+
/** Color accessor function. Default: `undefined` */
|
|
42
|
+
color?: ColorAccessor<NestedDonutSegment<Datum>>;
|
|
43
|
+
/** Corner Radius. Default: `0` */
|
|
44
|
+
cornerRadius?: number;
|
|
45
|
+
/** Label accessor function. */
|
|
46
|
+
label?: StringAccessor<NestedDonutSegment<Datum>>;
|
|
47
|
+
/**
|
|
48
|
+
* When true, the component will display empty segments (the ones that have `0` values) as tiny slices.
|
|
49
|
+
* Default: `false`
|
|
50
|
+
* */
|
|
51
|
+
showEmptySegments?: boolean;
|
|
52
|
+
/** Angular size for empty segments in radians. Default: `0.5 * Math.PI / 180` */
|
|
53
|
+
emptySegmentAngle?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class NestedDonutConfig<Datum> extends ComponentConfig implements NestedDonutConfigInterface<Datum> {
|
|
57
|
+
centralLabel?: string
|
|
58
|
+
centralSubLabel?: string
|
|
59
|
+
centralSubLabelWrap?: boolean
|
|
60
|
+
showEmptySegments?: boolean
|
|
61
|
+
emptySegmentAngle?: number
|
|
62
|
+
|
|
63
|
+
color?: ColorAccessor<NestedDonutSegment<Datum>>
|
|
64
|
+
label?: StringAccessor<NestedDonutSegment<Datum>>
|
|
65
|
+
direction = NestedDonutDirection.INWARDS
|
|
66
|
+
layers: StringAccessor<Datum>[]
|
|
67
|
+
layerSettings = undefined
|
|
68
|
+
layerPadding = 0
|
|
69
|
+
angleRange = [0, 2 * Math.PI] as [number, number]
|
|
70
|
+
padAngle = 0
|
|
71
|
+
cornerRadius = 0
|
|
72
|
+
showBackground = true
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection'
|
|
2
|
+
import { arc } from 'd3-shape'
|
|
3
|
+
import { hierarchy, partition } from 'd3-hierarchy'
|
|
4
|
+
import { scaleLinear, ScaleLinear } from 'd3-scale'
|
|
5
|
+
import { group, max, min, sum } from 'd3-array'
|
|
6
|
+
|
|
7
|
+
// Core
|
|
8
|
+
import { ComponentCore } from 'core/component'
|
|
9
|
+
import { SeriesDataModel } from 'data-models/series'
|
|
10
|
+
|
|
11
|
+
// Types
|
|
12
|
+
import { VerticalAlign } from 'types/text'
|
|
13
|
+
|
|
14
|
+
// Utils
|
|
15
|
+
import { getColor, getHexValue } from 'utils/color'
|
|
16
|
+
import { getString, getValue, isNumber } from 'utils/data'
|
|
17
|
+
import { smartTransition } from 'utils/d3'
|
|
18
|
+
import { wrapSVGText } from 'utils/text'
|
|
19
|
+
|
|
20
|
+
// Local Types
|
|
21
|
+
import { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment, defaultLayerSettings } from './types'
|
|
22
|
+
|
|
23
|
+
// Config
|
|
24
|
+
import { NestedDonutConfig, NestedDonutConfigInterface } from './config'
|
|
25
|
+
|
|
26
|
+
// Modules
|
|
27
|
+
import { createArc, updateArc, removeArc } from './modules/arc'
|
|
28
|
+
import { createLabel, updateLabel, removeLabel } from './modules/label'
|
|
29
|
+
|
|
30
|
+
// Styles
|
|
31
|
+
import * as s from './style'
|
|
32
|
+
|
|
33
|
+
export class NestedDonut<Datum> extends ComponentCore<
|
|
34
|
+
Datum[],
|
|
35
|
+
NestedDonutConfig<Datum>,
|
|
36
|
+
NestedDonutConfigInterface<Datum>
|
|
37
|
+
> {
|
|
38
|
+
static selectors = s
|
|
39
|
+
static cssVariables = s.variables
|
|
40
|
+
config: NestedDonutConfig<Datum> = new NestedDonutConfig()
|
|
41
|
+
datamodel: SeriesDataModel<Datum> = new SeriesDataModel()
|
|
42
|
+
|
|
43
|
+
arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>
|
|
44
|
+
arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>
|
|
45
|
+
centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>
|
|
46
|
+
centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>
|
|
47
|
+
|
|
48
|
+
arcGen = arc<Partial<NestedDonutSegment<Datum>>>()
|
|
49
|
+
radiusScale: ScaleLinear<number, number> = scaleLinear()
|
|
50
|
+
colorScale: ScaleLinear<string, string> = scaleLinear()
|
|
51
|
+
|
|
52
|
+
events = { }
|
|
53
|
+
|
|
54
|
+
constructor (config?: NestedDonutConfigInterface<Datum>) {
|
|
55
|
+
super()
|
|
56
|
+
if (config) this.config.init(config)
|
|
57
|
+
this.arcBackground = this.g.append('path')
|
|
58
|
+
this.arcGroup = this.g.append('g')
|
|
59
|
+
this.centralLabel = this.g.append('text')
|
|
60
|
+
.attr('class', s.centralLabel)
|
|
61
|
+
this.centralSubLabel = this.g.append('text')
|
|
62
|
+
.attr('class', s.centralSubLabel)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private getHierarchyData (): NestedDonutSegment<Datum>[] {
|
|
66
|
+
const { config, datamodel } = this
|
|
67
|
+
|
|
68
|
+
const layerAccessors = config.layers?.map(layerAccessor => (d: Datum, i: number) => getString(d, layerAccessor, i))
|
|
69
|
+
const nestedData = group(datamodel.data, ...layerAccessors as [(d: Datum) => string])
|
|
70
|
+
const rootNode = hierarchy(nestedData).count()
|
|
71
|
+
const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>
|
|
72
|
+
|
|
73
|
+
partitionData.eachBefore((node, index) => {
|
|
74
|
+
const scale = this.colorScale.domain([-1, node.children?.length])
|
|
75
|
+
node._id = this.uid + index
|
|
76
|
+
node._layer = node.depth - 1
|
|
77
|
+
|
|
78
|
+
node.data = { key: node.data[0], root: node.parent?.data.root ?? node.data[0] }
|
|
79
|
+
node.children?.forEach((child, i) => {
|
|
80
|
+
child._index = i
|
|
81
|
+
child._state = {
|
|
82
|
+
fill:
|
|
83
|
+
getColor(child, config.color, i, child.depth !== 1) ??
|
|
84
|
+
scale.range(['#fff', getHexValue(node._state.fill, this.element)])(i),
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
const segments = partitionData.descendants().filter(d => d.parent && d.children && d.data.key)
|
|
89
|
+
return segments
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_render (customDuration?: number): void {
|
|
93
|
+
const { config } = this
|
|
94
|
+
const duration = isNumber(customDuration) ? customDuration : config.duration
|
|
95
|
+
|
|
96
|
+
const layers: NestedDonutLayerSettings[] = config.layers?.map((_, i) => getValue(i, config.layerSettings) ?? defaultLayerSettings)
|
|
97
|
+
const data = this.getHierarchyData()
|
|
98
|
+
|
|
99
|
+
const outerRadius = Math.min(this._width, this._height) / 2
|
|
100
|
+
const innerRadius = Math.max(0, outerRadius - sum(layers, d => d.width + config.layerPadding))
|
|
101
|
+
|
|
102
|
+
const yMin = min(data, d => d.y0)
|
|
103
|
+
const yMax = max(data, d => d.y1)
|
|
104
|
+
|
|
105
|
+
this.radiusScale
|
|
106
|
+
.domain(config.direction === NestedDonutDirection.OUTWARDS ? [yMin, yMax] : [yMax, yMin])
|
|
107
|
+
.range([innerRadius, outerRadius])
|
|
108
|
+
|
|
109
|
+
this.arcGen
|
|
110
|
+
.startAngle(d => d.x0)
|
|
111
|
+
.endAngle(d => d.x1)
|
|
112
|
+
.innerRadius(d => this.radiusScale(d.y0))
|
|
113
|
+
.outerRadius(d => this.radiusScale(d.y1))
|
|
114
|
+
.padAngle(config.padAngle)
|
|
115
|
+
.cornerRadius(config.cornerRadius)
|
|
116
|
+
|
|
117
|
+
this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
118
|
+
|
|
119
|
+
// Arcs
|
|
120
|
+
const arcs = this.arcGroup
|
|
121
|
+
.selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segment}`)
|
|
122
|
+
.data(data, d => d._id)
|
|
123
|
+
|
|
124
|
+
const arcsEnter = arcs.enter().append('path')
|
|
125
|
+
.attr('class', s.segment)
|
|
126
|
+
.call(createArc, config)
|
|
127
|
+
|
|
128
|
+
arcs.merge(arcsEnter)
|
|
129
|
+
.call(updateArc, config, this.arcGen, duration)
|
|
130
|
+
|
|
131
|
+
arcs.exit<NestedDonutSegment<Datum>>()
|
|
132
|
+
.attr('class', s.segmentExit)
|
|
133
|
+
.call(removeArc, duration)
|
|
134
|
+
|
|
135
|
+
// Segment labels
|
|
136
|
+
const arcLabels = this.arcGroup
|
|
137
|
+
.selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)
|
|
138
|
+
.data(data, d => d._id)
|
|
139
|
+
|
|
140
|
+
const arcLabelsEnter = arcLabels.enter().append('text')
|
|
141
|
+
.attr('class', s.segmentLabel)
|
|
142
|
+
.call(createLabel, config)
|
|
143
|
+
|
|
144
|
+
arcLabels.merge(arcLabelsEnter)
|
|
145
|
+
.call(updateLabel, config, this.arcGen, duration)
|
|
146
|
+
|
|
147
|
+
arcLabels.exit<NestedDonutSegment<Datum>>()
|
|
148
|
+
.call(removeLabel, duration)
|
|
149
|
+
|
|
150
|
+
// Chart labels
|
|
151
|
+
this.centralLabel
|
|
152
|
+
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
153
|
+
.attr('dy', config.centralSubLabel ? '-0.55em' : null)
|
|
154
|
+
.text(config.centralLabel ?? null)
|
|
155
|
+
|
|
156
|
+
this.centralSubLabel
|
|
157
|
+
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
158
|
+
.attr('dy', config.centralLabel ? '0.55em' : null)
|
|
159
|
+
.text(config.centralSubLabel ?? null)
|
|
160
|
+
|
|
161
|
+
if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, innerRadius * 1.9, VerticalAlign.Top)
|
|
162
|
+
|
|
163
|
+
// Background
|
|
164
|
+
this.arcBackground.attr('class', s.background)
|
|
165
|
+
.attr('visibility', config.showBackground ? null : 'hidden')
|
|
166
|
+
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
167
|
+
|
|
168
|
+
smartTransition(this.arcBackground, duration)
|
|
169
|
+
.attr('d', arc()({
|
|
170
|
+
startAngle: config.angleRange?.[0] ?? config.angleRange?.[0] ?? 0,
|
|
171
|
+
endAngle: config.angleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,
|
|
172
|
+
innerRadius,
|
|
173
|
+
outerRadius,
|
|
174
|
+
}))
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection'
|
|
2
|
+
import { Transition } from 'd3-transition'
|
|
3
|
+
import { interpolate } from 'd3-interpolate'
|
|
4
|
+
import { Arc } from 'd3-shape'
|
|
5
|
+
|
|
6
|
+
// Utils
|
|
7
|
+
import { getColor } from 'utils/color'
|
|
8
|
+
import { smartTransition } from 'utils/d3'
|
|
9
|
+
|
|
10
|
+
// Local Types
|
|
11
|
+
import { NestedDonutSegment } from '../types'
|
|
12
|
+
|
|
13
|
+
// Config
|
|
14
|
+
import { NestedDonutConfig } from '../config'
|
|
15
|
+
|
|
16
|
+
type AnimState = { x0: number; x1: number; y0: number; y1: number }
|
|
17
|
+
export interface ArcNode extends SVGElement {
|
|
18
|
+
_animState?: AnimState;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createArc<Datum> (
|
|
22
|
+
selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,
|
|
23
|
+
config: NestedDonutConfig<Datum>
|
|
24
|
+
): void {
|
|
25
|
+
selection
|
|
26
|
+
.style('fill', d => getColor(d, config.color) ?? d._state.fill)
|
|
27
|
+
.style('opacity', 0)
|
|
28
|
+
.each((d, i, els) => {
|
|
29
|
+
const arcNode: ArcNode = els[i]
|
|
30
|
+
const angleCenter = (d.x0 + d.x1) / 2
|
|
31
|
+
const angleHalfWidth = (d.x1 - d.x0) / 2
|
|
32
|
+
arcNode._animState = {
|
|
33
|
+
x0: angleCenter - angleHalfWidth,
|
|
34
|
+
x1: angleCenter + angleHalfWidth,
|
|
35
|
+
y0: d.y0,
|
|
36
|
+
y1: d.y1,
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function updateArc<Datum> (
|
|
42
|
+
selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,
|
|
43
|
+
config: NestedDonutConfig<Datum>,
|
|
44
|
+
arcGen: Arc<any, AnimState>,
|
|
45
|
+
duration: number
|
|
46
|
+
): void {
|
|
47
|
+
selection
|
|
48
|
+
.style('transition', `fill ${duration}ms`) // Animate color with CSS because we're using CSS-variables
|
|
49
|
+
.style('fill', d => getColor(d, config.color) ?? d._state.fill)
|
|
50
|
+
|
|
51
|
+
if (duration) {
|
|
52
|
+
const transition = smartTransition(selection, duration)
|
|
53
|
+
.style('opacity', 1) as Transition<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, ArcNode>
|
|
54
|
+
|
|
55
|
+
transition.attrTween('d', (d, i, els) => {
|
|
56
|
+
const arcNode: ArcNode = els[i]
|
|
57
|
+
const nextAnimState = { x0: d.x0, x1: d.x1, y0: d.y0, y1: d.y1 }
|
|
58
|
+
const datum = interpolate(arcNode._animState, nextAnimState)
|
|
59
|
+
|
|
60
|
+
return (t: number): string => {
|
|
61
|
+
arcNode._animState = datum(t)
|
|
62
|
+
return arcGen(arcNode._animState)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
} else {
|
|
66
|
+
selection.attr('d', arcGen)
|
|
67
|
+
.style('opacity', 1)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function removeArc<Datum> (
|
|
72
|
+
selection: Selection<SVGPathElement, NestedDonutSegment<Datum>, SVGGElement, unknown>,
|
|
73
|
+
duration: number
|
|
74
|
+
): void {
|
|
75
|
+
smartTransition(selection, duration)
|
|
76
|
+
.style('opacity', 0)
|
|
77
|
+
.remove()
|
|
78
|
+
}
|