@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,61 @@
|
|
|
1
|
+
/* eslint-disable no-irregular-whitespace */
|
|
2
|
+
import { Config } from 'core/config'
|
|
3
|
+
import { VisEventCallback, VisEventType } from 'core/component/types'
|
|
4
|
+
|
|
5
|
+
export interface ComponentConfigInterface {
|
|
6
|
+
/** Animation duration of the data update transitions in milliseconds. Default: `600` */
|
|
7
|
+
duration?: number;
|
|
8
|
+
/** Events configuration. An object containing properties in the following format:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* {
|
|
12
|
+
* [selectorString]: {
|
|
13
|
+
* [eventType]: callbackFunction
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* e.g.:
|
|
18
|
+
* ```
|
|
19
|
+
* {
|
|
20
|
+
* [Area.selectors.area]: {
|
|
21
|
+
* click: (d) => console.log("Clicked Area", d)
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
events?: {
|
|
27
|
+
[selector: string]: {
|
|
28
|
+
[eventType in VisEventType]?: VisEventCallback;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/** You can set every SVG and HTML visualization object to have a custom DOM attributes, which is useful
|
|
32
|
+
* when you want to do unit or end-to-end testing. Attributes configuration object has the following structure:
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
* {
|
|
36
|
+
* [selectorString]: {
|
|
37
|
+
* [attributeName]: attribute constant value or accessor function
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
* e.g.:
|
|
42
|
+
* ```
|
|
43
|
+
* {
|
|
44
|
+
* [Area.selectors.area]: {
|
|
45
|
+
* "test-value": d => d.value
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
attributes?: {
|
|
51
|
+
[selector: string]: {
|
|
52
|
+
[attr: string]: string | number | boolean | ((datum: any) => string | number | boolean);
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class ComponentConfig extends Config implements ComponentConfigInterface {
|
|
58
|
+
duration = 600
|
|
59
|
+
events = {}
|
|
60
|
+
attributes = {}
|
|
61
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { select, Selection } from 'd3-selection'
|
|
2
|
+
import { Transition } from 'd3-transition'
|
|
3
|
+
|
|
4
|
+
// Core
|
|
5
|
+
import { CoreDataModel } from 'data-models/core'
|
|
6
|
+
|
|
7
|
+
// Utils
|
|
8
|
+
import { throttle } from 'utils/data'
|
|
9
|
+
import { guid } from 'utils/misc'
|
|
10
|
+
|
|
11
|
+
// Types
|
|
12
|
+
import { ComponentType, Sizing } from 'types/component'
|
|
13
|
+
import { Spacing } from 'types/spacing'
|
|
14
|
+
|
|
15
|
+
// Local Types
|
|
16
|
+
import { VisEventCallback, VisEventType } from './types'
|
|
17
|
+
|
|
18
|
+
// Config
|
|
19
|
+
import { ComponentConfig, ComponentConfigInterface } from './config'
|
|
20
|
+
|
|
21
|
+
export class ComponentCore<
|
|
22
|
+
CoreDatum,
|
|
23
|
+
ConfigClass extends ComponentConfig = ComponentConfig,
|
|
24
|
+
ConfigInterface extends ComponentConfigInterface = ComponentConfigInterface,
|
|
25
|
+
> {
|
|
26
|
+
element: SVGGElement | HTMLElement
|
|
27
|
+
type: ComponentType = ComponentType.SVG
|
|
28
|
+
g: Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>
|
|
29
|
+
config: ConfigClass
|
|
30
|
+
prevConfig: ConfigClass
|
|
31
|
+
datamodel: CoreDataModel<CoreDatum> = new CoreDataModel()
|
|
32
|
+
sizing: Sizing | string = Sizing.Fit // Supported by SingleContainer and a subset of components only (Sankey)
|
|
33
|
+
uid: string
|
|
34
|
+
|
|
35
|
+
events: {
|
|
36
|
+
[selector: string]: {
|
|
37
|
+
[eventType in VisEventType]?: VisEventCallback;
|
|
38
|
+
};
|
|
39
|
+
} = {}
|
|
40
|
+
|
|
41
|
+
/** Component width in pixels. This property is set automatically by the container. */
|
|
42
|
+
protected _width = 400
|
|
43
|
+
/** Component height in pixels. This property is set automatically by the container. */
|
|
44
|
+
protected _height = 200
|
|
45
|
+
/** Container width in pixels. This property is set automatically by the container. */
|
|
46
|
+
protected _containerWidth: number | undefined = undefined
|
|
47
|
+
/** Container height in pixels. This property is set automatically by the container. */
|
|
48
|
+
protected _containerHeight: number | undefined = undefined
|
|
49
|
+
|
|
50
|
+
_setUpComponentEventsThrottled = throttle(this._setUpComponentEvents, 500)
|
|
51
|
+
_setCustomAttributesThrottled = throttle(this._setCustomAttributes, 500)
|
|
52
|
+
|
|
53
|
+
constructor (type = ComponentType.SVG) {
|
|
54
|
+
if (type === ComponentType.SVG) {
|
|
55
|
+
this.element = document.createElementNS('http://www.w3.org/2000/svg', 'g')
|
|
56
|
+
} else {
|
|
57
|
+
this.element = document.createElement('div')
|
|
58
|
+
}
|
|
59
|
+
this.uid = guid()
|
|
60
|
+
this.g = select(this.element) as Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>
|
|
61
|
+
|
|
62
|
+
// Setting the root class if available
|
|
63
|
+
// eslint-disable-next-line dot-notation
|
|
64
|
+
const rootClass = this.constructor?.['selectors']?.root as string
|
|
65
|
+
if (rootClass) this.g.attr('class', rootClass)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setConfig (config: ConfigInterface): void {
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
70
|
+
const ConfigModel = (this.config.constructor as typeof ComponentConfig)
|
|
71
|
+
this.prevConfig = this.config // Store the previous config instance
|
|
72
|
+
this.config = new ConfigModel().init(config) as ConfigClass
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setData (data: CoreDatum): void {
|
|
76
|
+
this.datamodel.data = data
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setSize (width: number, height: number, containerWidth: number, containerHeight: number): void {
|
|
80
|
+
if (isFinite(width)) this._width = width
|
|
81
|
+
if (isFinite(height)) this._height = height
|
|
82
|
+
if (isFinite(containerWidth)) this._containerWidth = containerWidth
|
|
83
|
+
if (isFinite(containerHeight)) this._containerHeight = containerHeight
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render (duration = this.config.duration): void {
|
|
87
|
+
this._render(duration)
|
|
88
|
+
|
|
89
|
+
// While transition is in progress, we add the 'animating' attribute to the component's SVG group
|
|
90
|
+
const ANIMATING_ATTR = 'animating'
|
|
91
|
+
if (duration) {
|
|
92
|
+
this.g.attr(ANIMATING_ATTR, '')
|
|
93
|
+
const transition = this.g
|
|
94
|
+
.transition(ANIMATING_ATTR)
|
|
95
|
+
.duration(duration) as Transition<SVGGElement | HTMLElement, unknown, null, undefined>
|
|
96
|
+
|
|
97
|
+
transition.on('end interrupt', () => {
|
|
98
|
+
this.g.attr(ANIMATING_ATTR, null)
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
this._setUpComponentEventsThrottled()
|
|
102
|
+
this._setCustomAttributesThrottled()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get bleed (): Spacing {
|
|
106
|
+
return { top: 0, bottom: 0, left: 0, right: 0 }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
110
|
+
_render (duration = this.config.duration): void {
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private _setCustomAttributes (): void {
|
|
114
|
+
const attributeMap = this.config.attributes
|
|
115
|
+
|
|
116
|
+
Object.keys(attributeMap).forEach(className => {
|
|
117
|
+
Object.keys(attributeMap[className]).forEach(attr => {
|
|
118
|
+
(this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>)
|
|
119
|
+
.selectAll(`.${className}`)
|
|
120
|
+
.attr(attr, attributeMap[className][attr])
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private _setUpComponentEvents (): void {
|
|
126
|
+
// Set up default events
|
|
127
|
+
this._bindEvents(this.events)
|
|
128
|
+
|
|
129
|
+
// Set up user-defined events
|
|
130
|
+
this._bindEvents(this.config.events, '.user')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private _bindEvents (events = this.events, suffix = ''): void {
|
|
134
|
+
Object.keys(events).forEach(className => {
|
|
135
|
+
Object.keys(events[className]).forEach(eventType => {
|
|
136
|
+
const selection = (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>).selectAll(`.${className}`)
|
|
137
|
+
selection.on(eventType + suffix, (event: Event, d) => {
|
|
138
|
+
const els = selection.nodes()
|
|
139
|
+
const i = els.indexOf(event.currentTarget as SVGGElement | HTMLElement)
|
|
140
|
+
return events[className][eventType](d, event, i, els)
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public destroy (): void {
|
|
147
|
+
this.g?.remove()
|
|
148
|
+
this.element = undefined
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public isDestroyed (): boolean {
|
|
152
|
+
return !this.element
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type VisEventType = 'touchstart' | 'touchmove' | 'touchend' | 'mouseover' | 'mousemove' | 'mousedown' | 'mouseup'
|
|
2
|
+
| 'click' | 'auxclick' | 'contextmenu' | 'dblclick' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'scroll'
|
|
3
|
+
| 'select' | 'wheel' | 'pointerdown' | 'pointerup' | 'pointerout' | 'pointermove'
|
|
4
|
+
|
|
5
|
+
export type VisEventCallback<Datum = any> =
|
|
6
|
+
((data: Datum, event: MouseEvent, i: number, els: (SVGElement | HTMLElement)[]) => void) |
|
|
7
|
+
((data: Datum, event: WheelEvent, i: number, els: (SVGElement | HTMLElement)[]) => void) |
|
|
8
|
+
((data: Datum, event: PointerEvent, i: number, els: (SVGElement | HTMLElement)[]) => void) |
|
|
9
|
+
((data: Datum, event: TouchEvent, i: number, els: (SVGElement | HTMLElement)[]) => void);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isPlainObject, merge } from 'utils/data'
|
|
2
|
+
|
|
3
|
+
export class Config {
|
|
4
|
+
init<T> (config: T): this {
|
|
5
|
+
Object.keys(config).forEach(key => {
|
|
6
|
+
if (isPlainObject(this[key]) && isPlainObject(config[key])) this[key] = merge(this[key], config[key])
|
|
7
|
+
else this[key] = config[key]
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return this
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Core
|
|
2
|
+
import { Config } from 'core/config'
|
|
3
|
+
|
|
4
|
+
// Types
|
|
5
|
+
import { Sizing } from 'types/component'
|
|
6
|
+
import { Spacing } from 'types/spacing'
|
|
7
|
+
|
|
8
|
+
export interface ContainerConfigInterface {
|
|
9
|
+
/** Animation duration of all the components within the container. Default: `undefined` */
|
|
10
|
+
duration?: number;
|
|
11
|
+
/** Margins. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */
|
|
12
|
+
margin?: Spacing;
|
|
13
|
+
/** Padding. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */
|
|
14
|
+
padding?: Spacing;
|
|
15
|
+
/** Defines whether components should fit into the container or the container should expand to fit to the component's size. Default: `Sizing.Fit` */
|
|
16
|
+
sizing?: Sizing | string;
|
|
17
|
+
/** Width in pixels or in CSS units.
|
|
18
|
+
* Percentage units `"%"` are not supported here. If you want to set `width` as a percentage, do it via `style`
|
|
19
|
+
* of the corresponding DOM element.
|
|
20
|
+
* By default, Container automatically fits to the size of the parent element.
|
|
21
|
+
* Default: `undefined`
|
|
22
|
+
*/
|
|
23
|
+
width?: number | string;
|
|
24
|
+
/** Height in pixels or in CSS units.
|
|
25
|
+
* Percentage units `"%"` are not supported here. If you want to set `height` as a percentage, do it via `style`
|
|
26
|
+
* of the corresponding DOM element.
|
|
27
|
+
* By default, Container automatically fits to the size of the parent element.
|
|
28
|
+
* Default: `undefined`
|
|
29
|
+
*/
|
|
30
|
+
height?: number | string;
|
|
31
|
+
/** Custom SVG defs available to all the components within the container. Default: `undefined`. */
|
|
32
|
+
svgDefs?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ContainerConfig extends Config implements ContainerConfigInterface {
|
|
36
|
+
duration = undefined
|
|
37
|
+
margin = {
|
|
38
|
+
top: 0,
|
|
39
|
+
bottom: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
padding = {
|
|
45
|
+
top: 0,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
right: 0,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
sizing = Sizing.Fit
|
|
52
|
+
width = undefined
|
|
53
|
+
height = undefined
|
|
54
|
+
|
|
55
|
+
svgDefs = undefined
|
|
56
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { select, Selection } from 'd3-selection'
|
|
2
|
+
import { ResizeObserver } from '@juggle/resize-observer'
|
|
3
|
+
|
|
4
|
+
// Types
|
|
5
|
+
import { Sizing } from 'types/component'
|
|
6
|
+
|
|
7
|
+
// Utils
|
|
8
|
+
import { isEqual, clamp } from 'utils/data'
|
|
9
|
+
|
|
10
|
+
// Config
|
|
11
|
+
import { ContainerConfig, ContainerConfigInterface } from './config'
|
|
12
|
+
|
|
13
|
+
export class ContainerCore {
|
|
14
|
+
svg: Selection<SVGSVGElement, unknown, null, undefined>
|
|
15
|
+
element: SVGSVGElement
|
|
16
|
+
prevConfig: ContainerConfig
|
|
17
|
+
config: ContainerConfig
|
|
18
|
+
|
|
19
|
+
protected _container: HTMLElement
|
|
20
|
+
protected _requestedAnimationFrame: number
|
|
21
|
+
private _isFirstRender = true
|
|
22
|
+
private _containerSize: { width: number; height: number }
|
|
23
|
+
private _resizeObserver: ResizeObserver | undefined
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
|
+
static DEFAULT_CONTAINER_HEIGHT = 300
|
|
27
|
+
|
|
28
|
+
constructor (element: HTMLElement) {
|
|
29
|
+
this._requestedAnimationFrame = null
|
|
30
|
+
this._container = element
|
|
31
|
+
|
|
32
|
+
// Create SVG element for visualizations
|
|
33
|
+
this.svg = select(this._container).append('svg')
|
|
34
|
+
// We set `display` to `block` because inline elements have an invisible
|
|
35
|
+
// inline space that adds 4px to the height of the container
|
|
36
|
+
.style('display', 'block')
|
|
37
|
+
.attr('xmlns', 'http://www.w3.org/2000/svg')
|
|
38
|
+
.attr('height', ContainerCore.DEFAULT_CONTAINER_HEIGHT)
|
|
39
|
+
|
|
40
|
+
this.element = this.svg.node()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
updateContainer<T extends ContainerConfigInterface> (config: T): void {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
45
|
+
const ConfigModel = (this.config.constructor as typeof ContainerConfig)
|
|
46
|
+
this.prevConfig = this.config
|
|
47
|
+
this.config = new ConfigModel().init(config)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_render (duration?: number): void {
|
|
51
|
+
if (this.config.svgDefs) {
|
|
52
|
+
this.svg.select('.svgDefs').remove()
|
|
53
|
+
this.svg.append('defs').attr('class', 'svgDefs').html(this.config.svgDefs)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this._isFirstRender = false
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render (duration = this.config.duration): void {
|
|
60
|
+
const width = this.config.width || this.containerWidth
|
|
61
|
+
const height = this.config.height || this.containerHeight
|
|
62
|
+
|
|
63
|
+
// We set SVG size in `render()` instead of `_render()`, because the size values in pixels will become
|
|
64
|
+
// available only in the next animation when being accessed via `element.clientWidth` and `element.clientHeight`,
|
|
65
|
+
// and we rely on those values when setting width and size of the components.
|
|
66
|
+
this.svg
|
|
67
|
+
.attr('width', width)
|
|
68
|
+
.attr('height', height)
|
|
69
|
+
|
|
70
|
+
// Set up Resize Observer. We do it in `render()` to capture container size change if it happened
|
|
71
|
+
// in the next animation frame after the initial `render` was called.
|
|
72
|
+
if (!this._resizeObserver) this._setUpResizeObserver()
|
|
73
|
+
|
|
74
|
+
// Schedule the actual rendering in the next frame
|
|
75
|
+
cancelAnimationFrame(this._requestedAnimationFrame)
|
|
76
|
+
this._requestedAnimationFrame = requestAnimationFrame(() => {
|
|
77
|
+
this._render(duration)
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get containerWidth (): number {
|
|
82
|
+
return this.config.width
|
|
83
|
+
? this.element.clientWidth
|
|
84
|
+
: clamp(this._container.clientWidth || this._container.getBoundingClientRect().width, 0, Number.POSITIVE_INFINITY)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get containerHeight (): number {
|
|
88
|
+
return this.config.height
|
|
89
|
+
? this.element.clientHeight
|
|
90
|
+
: clamp(this._container.clientHeight || this._container.getBoundingClientRect().height, 0, Number.POSITIVE_INFINITY)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get width (): number {
|
|
94
|
+
return clamp(this.containerWidth - this.config.margin.left - this.config.margin.right, 0, Number.POSITIVE_INFINITY)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get height (): number {
|
|
98
|
+
return clamp(this.containerHeight - this.config.margin.top - this.config.margin.bottom, 0, Number.POSITIVE_INFINITY)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
removeAllChildren (): void {
|
|
102
|
+
while (this.element.firstChild) {
|
|
103
|
+
this.element.removeChild(this.element.firstChild)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_onResize (): void {
|
|
108
|
+
const { config } = this
|
|
109
|
+
const redrawOnResize = config.sizing === Sizing.Fit || config.sizing === Sizing.FitWidth
|
|
110
|
+
if (redrawOnResize) this.render(0)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_setUpResizeObserver (): void {
|
|
114
|
+
const containerRect = this._container.getBoundingClientRect()
|
|
115
|
+
this._containerSize = { width: containerRect.width, height: containerRect.height }
|
|
116
|
+
|
|
117
|
+
this._resizeObserver = new ResizeObserver((entries, observer) => {
|
|
118
|
+
const resizedContainerRect = this._container.getBoundingClientRect()
|
|
119
|
+
const resizedContainerSize = { width: resizedContainerRect.width, height: resizedContainerRect.height }
|
|
120
|
+
const hasSizeChanged = !isEqual(this._containerSize, resizedContainerSize)
|
|
121
|
+
// Do resize only if element is attached to the DOM
|
|
122
|
+
// will come in useful when some ancestor of container becomes detached
|
|
123
|
+
if (hasSizeChanged && resizedContainerSize.width && resizedContainerSize.height) {
|
|
124
|
+
this._containerSize = resizedContainerSize
|
|
125
|
+
this._onResize()
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
this._resizeObserver.observe(this._container)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
destroy (): void {
|
|
132
|
+
cancelAnimationFrame(this._requestedAnimationFrame)
|
|
133
|
+
this._resizeObserver?.disconnect()
|
|
134
|
+
this.svg.remove()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ContinuousScale } from 'types/scale'
|
|
2
|
+
|
|
3
|
+
// Types
|
|
4
|
+
import { ColorAccessor, NumericAccessor } from 'types/accessor'
|
|
5
|
+
|
|
6
|
+
// Config
|
|
7
|
+
import { ComponentConfig, ComponentConfigInterface } from '../component/config'
|
|
8
|
+
|
|
9
|
+
export interface XYComponentConfigInterface<Datum> extends ComponentConfigInterface {
|
|
10
|
+
/** Accessor function for getting the values along the X axis. Default: `undefined` */
|
|
11
|
+
x: NumericAccessor<Datum>;
|
|
12
|
+
/** A single of multiple accessor functions for getting the values along the Y axis. Default: `undefined` */
|
|
13
|
+
y: NumericAccessor<Datum> | NumericAccessor<Datum>[];
|
|
14
|
+
/** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */
|
|
15
|
+
id?: ((d: Datum, i: number, ...any: any[]) => string);
|
|
16
|
+
/** Component color accessor function. Default: `d => d.color` */
|
|
17
|
+
color?: ColorAccessor<Datum> | ColorAccessor<Datum[]>;
|
|
18
|
+
/** Scale for X dimension, e.g. Scale.scaleLinear(). If you set xScale you'll be responsible for setting it's `domain` and `range` as well.
|
|
19
|
+
* Only continuous scales are supported.
|
|
20
|
+
* Default: `undefined`
|
|
21
|
+
*/
|
|
22
|
+
xScale?: ContinuousScale;
|
|
23
|
+
/** Scale for Y dimension, e.g. Scale.scaleLinear(). If you set yScale you'll be responsible for setting it's `domain` and `range` as well.
|
|
24
|
+
* Only continuous scales are supported.
|
|
25
|
+
* Default: `undefined`
|
|
26
|
+
*/
|
|
27
|
+
yScale?: ContinuousScale;
|
|
28
|
+
/** Identifies whether the component should be excluded from overall X and Y domain calculations or not.
|
|
29
|
+
* This property can be useful when you want pass individual data to a component and you don't want it to affect
|
|
30
|
+
* the scales of the chart.
|
|
31
|
+
* Default: `false`
|
|
32
|
+
*/
|
|
33
|
+
excludeFromDomainCalculation?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class XYComponentConfig<Datum> extends ComponentConfig implements XYComponentConfigInterface<Datum> {
|
|
37
|
+
x = undefined
|
|
38
|
+
y = undefined
|
|
39
|
+
// eslint-disable-next-line dot-notation
|
|
40
|
+
id = (d: Datum, i: number): string => d['id'] ?? `${i}`
|
|
41
|
+
// eslint-disable-next-line dot-notation
|
|
42
|
+
color = (d: Datum | Datum[]): string => d['color']
|
|
43
|
+
xScale = undefined
|
|
44
|
+
yScale = undefined
|
|
45
|
+
excludeFromDomainCalculation = false
|
|
46
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection'
|
|
2
|
+
|
|
3
|
+
// Core
|
|
4
|
+
import { ComponentCore } from 'core/component'
|
|
5
|
+
import { SeriesDataModel } from 'data-models/series'
|
|
6
|
+
|
|
7
|
+
// Utils
|
|
8
|
+
import { filterDataByRange, getExtent, isArray } from 'utils/data'
|
|
9
|
+
|
|
10
|
+
// Types
|
|
11
|
+
import { NumericAccessor } from 'types/accessor'
|
|
12
|
+
import { ContinuousScale, Scale, ScaleDimension } from 'types/scale'
|
|
13
|
+
|
|
14
|
+
// Config
|
|
15
|
+
import { XYComponentConfig, XYComponentConfigInterface } from './config'
|
|
16
|
+
|
|
17
|
+
export class XYComponentCore<
|
|
18
|
+
Datum,
|
|
19
|
+
ConfigClass extends XYComponentConfig<Datum> = XYComponentConfig<Datum>,
|
|
20
|
+
ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>,
|
|
21
|
+
> extends ComponentCore<Datum[], ConfigClass, ConfigInterface> {
|
|
22
|
+
element: SVGGraphicsElement
|
|
23
|
+
g: Selection<SVGGElement, unknown, null, undefined>
|
|
24
|
+
config: ConfigClass
|
|
25
|
+
prevConfig: ConfigClass
|
|
26
|
+
datamodel: SeriesDataModel<Datum> = new SeriesDataModel()
|
|
27
|
+
|
|
28
|
+
/** Clippable components can be affected by a clipping path (set up in the container) */
|
|
29
|
+
clippable = true
|
|
30
|
+
|
|
31
|
+
/** Identifies whether the component displayed stacked data (eg StackedBar, Area) */
|
|
32
|
+
stacked = false
|
|
33
|
+
|
|
34
|
+
private _xScale: ContinuousScale = Scale.scaleLinear()
|
|
35
|
+
private _yScale: ContinuousScale = Scale.scaleLinear()
|
|
36
|
+
|
|
37
|
+
get xScale (): ContinuousScale {
|
|
38
|
+
return this.config.xScale || this._xScale
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get yScale (): ContinuousScale {
|
|
42
|
+
return this.config.yScale || this._yScale
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setConfig (config: ConfigInterface): void {
|
|
46
|
+
// We don't allow changing scales after the component has been initialized
|
|
47
|
+
if (this.config?.xScale) config.xScale = this.config.xScale
|
|
48
|
+
if (this.config?.yScale) config.yScale = this.config.yScale
|
|
49
|
+
|
|
50
|
+
super.setConfig(config)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setScaleDomain (dimension: ScaleDimension, domain: number[]): void {
|
|
54
|
+
if (dimension === ScaleDimension.X) this._xScale?.domain(domain)
|
|
55
|
+
if (dimension === ScaleDimension.Y) this._yScale?.domain(domain)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setScaleRange (dimension: ScaleDimension, range: number[]): void {
|
|
59
|
+
if (dimension === ScaleDimension.X) this._xScale?.range(range)
|
|
60
|
+
if (dimension === ScaleDimension.Y) this._yScale?.range(range)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setScale (dimension: ScaleDimension, scale: ContinuousScale): void {
|
|
64
|
+
if (scale && (dimension === ScaleDimension.X)) this._xScale = scale
|
|
65
|
+
if (scale && (dimension === ScaleDimension.Y)) this._yScale = scale
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getDataExtent (dimension: ScaleDimension, scaleByVisibleData: boolean): number[] {
|
|
69
|
+
const { config, datamodel } = this
|
|
70
|
+
|
|
71
|
+
switch (dimension) {
|
|
72
|
+
case ScaleDimension.X: return this.getXDataExtent()
|
|
73
|
+
case ScaleDimension.Y: return this.getYDataExtent(scaleByVisibleData)
|
|
74
|
+
default: return getExtent(datamodel.data, config[dimension])
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getXDataExtent (): number[] {
|
|
79
|
+
const { config, datamodel } = this
|
|
80
|
+
return getExtent(datamodel.data, config.x)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getYDataExtent (scaleByVisibleData: boolean): number[] {
|
|
84
|
+
const { config, datamodel } = this
|
|
85
|
+
|
|
86
|
+
const data = scaleByVisibleData ? filterDataByRange(datamodel.data, this.xScale.domain() as [number, number], config.x) : datamodel.data
|
|
87
|
+
const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]
|
|
88
|
+
return getExtent(data, ...yAccessors)
|
|
89
|
+
}
|
|
90
|
+
}
|