@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,150 @@
|
|
|
1
|
+
// Global CSS variables (side effects import)
|
|
2
|
+
import 'styles/index'
|
|
3
|
+
|
|
4
|
+
// Core
|
|
5
|
+
import { ContainerCore } from 'core/container'
|
|
6
|
+
import { ComponentCore } from 'core/component'
|
|
7
|
+
import { ComponentConfigInterface } from 'core/component/config'
|
|
8
|
+
|
|
9
|
+
// Utils
|
|
10
|
+
import { smartTransition } from 'utils/d3'
|
|
11
|
+
|
|
12
|
+
// Types
|
|
13
|
+
import { Sizing, ExtendedSizeComponent } from 'types/component'
|
|
14
|
+
|
|
15
|
+
// Config
|
|
16
|
+
import { SingleContainerConfig, SingleContainerConfigInterface } from './config'
|
|
17
|
+
|
|
18
|
+
export class SingleContainer<Data> extends ContainerCore {
|
|
19
|
+
component: ComponentCore<Data>
|
|
20
|
+
config: SingleContainerConfig<Data> = new SingleContainerConfig()
|
|
21
|
+
|
|
22
|
+
constructor (element: HTMLElement, config?: SingleContainerConfigInterface<Data>, data?: Data) {
|
|
23
|
+
super(element)
|
|
24
|
+
|
|
25
|
+
if (config) {
|
|
26
|
+
this.updateContainer(config, true)
|
|
27
|
+
this.component = config.component
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (data) {
|
|
31
|
+
this.setData(data, true)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Render if component exists and has data
|
|
35
|
+
if (this.component?.datamodel.data) this.render()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public setData (data: Data, preventRender?: boolean): void {
|
|
39
|
+
const { config } = this
|
|
40
|
+
|
|
41
|
+
if (this.component) this.component.setData(data)
|
|
42
|
+
if (!preventRender) this.render()
|
|
43
|
+
config.tooltip?.hide()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public updateContainer (containerConfig: SingleContainerConfigInterface<Data>, preventRender?: boolean): void {
|
|
47
|
+
super.updateContainer(containerConfig)
|
|
48
|
+
this.removeAllChildren()
|
|
49
|
+
|
|
50
|
+
this.component = containerConfig.component
|
|
51
|
+
if (containerConfig.sizing) this.component.sizing = containerConfig.sizing
|
|
52
|
+
this.element.appendChild(this.component.element)
|
|
53
|
+
|
|
54
|
+
const tooltip = containerConfig.tooltip
|
|
55
|
+
if (tooltip) {
|
|
56
|
+
if (!tooltip.hasContainer()) tooltip.setContainer(this._container)
|
|
57
|
+
tooltip.setComponents([this.component])
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!preventRender) this.render()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public updateComponent (componentConfig: ComponentConfigInterface, preventRender?: boolean): void {
|
|
64
|
+
this.component.setConfig(componentConfig)
|
|
65
|
+
if (!preventRender) this.render()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public update (
|
|
69
|
+
containerConfig: SingleContainerConfigInterface<Data>,
|
|
70
|
+
componentConfig?: ComponentConfigInterface,
|
|
71
|
+
data?: Data
|
|
72
|
+
): void {
|
|
73
|
+
if (containerConfig) this.updateContainer(containerConfig, true)
|
|
74
|
+
if (componentConfig) this.updateComponent(componentConfig, true)
|
|
75
|
+
if (data) this.setData(data, true)
|
|
76
|
+
this.render()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public getFitWidthScale (): number {
|
|
80
|
+
const { config, component } = this
|
|
81
|
+
|
|
82
|
+
const extendedSizeComponent = component as ExtendedSizeComponent
|
|
83
|
+
if (!extendedSizeComponent.getWidth) return 1
|
|
84
|
+
|
|
85
|
+
const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right
|
|
86
|
+
return this.width / componentWidth
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_render (duration?: number): void {
|
|
90
|
+
const { config, component } = this
|
|
91
|
+
super._render(duration)
|
|
92
|
+
|
|
93
|
+
component.setSize(this.width, this.height, this.containerWidth, this.containerHeight)
|
|
94
|
+
component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`)
|
|
95
|
+
component.render(duration)
|
|
96
|
+
|
|
97
|
+
if (config.tooltip) config.tooltip.update()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)
|
|
101
|
+
// Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.
|
|
102
|
+
render (duration = this.config.duration): void {
|
|
103
|
+
const { config, component } = this
|
|
104
|
+
|
|
105
|
+
if (config.sizing === Sizing.Extend || config.sizing === Sizing.FitWidth) {
|
|
106
|
+
const fitToWidth = config.sizing === Sizing.FitWidth
|
|
107
|
+
const extendedSizeComponent = component as ExtendedSizeComponent
|
|
108
|
+
|
|
109
|
+
const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right
|
|
110
|
+
const componentHeight = extendedSizeComponent.getHeight() + config.margin.top + config.margin.bottom
|
|
111
|
+
const scale = fitToWidth ? this.getFitWidthScale() : 1
|
|
112
|
+
|
|
113
|
+
const currentWidth = this.svg.attr('width')
|
|
114
|
+
const currentHeight = this.svg.attr('height')
|
|
115
|
+
const scaledWidth = componentWidth * scale
|
|
116
|
+
const scaledHeight = componentHeight * scale
|
|
117
|
+
const animated = currentWidth || currentHeight
|
|
118
|
+
|
|
119
|
+
smartTransition(this.svg, animated ? duration : 0)
|
|
120
|
+
.attr('width', scaledWidth)
|
|
121
|
+
.attr('height', scaledHeight)
|
|
122
|
+
.attr('viewBox', `${0} ${0} ${componentWidth} ${fitToWidth ? scaledHeight : componentHeight}`)
|
|
123
|
+
.attr('preserveAspectRatio', 'xMinYMin')
|
|
124
|
+
} else {
|
|
125
|
+
this.svg
|
|
126
|
+
.attr('width', this.config.width || this.containerWidth)
|
|
127
|
+
.attr('height', this.config.height || this.containerHeight)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Schedule the actual rendering in the next frame
|
|
131
|
+
cancelAnimationFrame(this._requestedAnimationFrame)
|
|
132
|
+
this._requestedAnimationFrame = requestAnimationFrame(() => {
|
|
133
|
+
this._render(duration)
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_onResize (): void {
|
|
138
|
+
const { config } = this
|
|
139
|
+
super._onResize()
|
|
140
|
+
config.tooltip?.hide()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public destroy (): void {
|
|
144
|
+
const { component, config } = this
|
|
145
|
+
super.destroy()
|
|
146
|
+
|
|
147
|
+
component?.destroy()
|
|
148
|
+
config.tooltip?.destroy()
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Core
|
|
2
|
+
import { XYComponentCore } from 'core/xy-component'
|
|
3
|
+
import { ContainerConfig, ContainerConfigInterface } from 'core/container/config'
|
|
4
|
+
import { Tooltip } from 'components/tooltip'
|
|
5
|
+
|
|
6
|
+
// Components
|
|
7
|
+
import { Axis } from 'components/axis'
|
|
8
|
+
import { Crosshair } from 'components/crosshair'
|
|
9
|
+
|
|
10
|
+
// Types
|
|
11
|
+
import { ContinuousScale } from 'types/scale'
|
|
12
|
+
import { Direction } from 'types/direction'
|
|
13
|
+
|
|
14
|
+
export interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {
|
|
15
|
+
/** An array of visualization components. Default: `[]` */
|
|
16
|
+
components?: XYComponentCore<Datum>[];
|
|
17
|
+
|
|
18
|
+
/** Scale for X dimension, e.g. Scale.scaleLinear().
|
|
19
|
+
* If set, this value will override the components' xScale and they will have a single shared xScale instance.
|
|
20
|
+
* By default the components have their own scale instances but their `domain` and `range` values are synchronized.
|
|
21
|
+
* Default: `undefined` */
|
|
22
|
+
xScale?: ContinuousScale;
|
|
23
|
+
/** Scale domain (data extent) for X dimension. By default this value is calculated automatically based on data. */
|
|
24
|
+
xDomain?: [number | undefined, number | undefined];
|
|
25
|
+
/** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.
|
|
26
|
+
* For example, imagine that you have a chart with dynamic data that has negative values. When values are small
|
|
27
|
+
* (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can
|
|
28
|
+
* be achieved by setting `xDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the
|
|
29
|
+
* values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`
|
|
30
|
+
* Default: `undefined` */
|
|
31
|
+
xDomainMinConstraint?: [number | undefined, number | undefined];
|
|
32
|
+
/** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.
|
|
33
|
+
* For example, imagine that you have a chart with dynamic data. When values are small
|
|
34
|
+
* (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can
|
|
35
|
+
* be achieved by setting `xDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the
|
|
36
|
+
* values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`
|
|
37
|
+
* Default: `undefined` */
|
|
38
|
+
xDomainMaxConstraint?: [number | undefined, number | undefined];
|
|
39
|
+
/** Force set the X scale range (in the screen space). By default the range is calculated automatically based on the
|
|
40
|
+
* chart's set up */
|
|
41
|
+
xRange?: [number, number];
|
|
42
|
+
|
|
43
|
+
/** Scale for Y dimension, e.g. Scale.scaleLinear().
|
|
44
|
+
* If set, this value will override the components' yScale and they will have a single shared yScale instance.
|
|
45
|
+
* By default the components have their own scale instances but their `domain` and `range` values are synchronized.
|
|
46
|
+
* Default: `undefined` */
|
|
47
|
+
yScale?: ContinuousScale;
|
|
48
|
+
/** Scale domain (data extent) for Y dimension. By default this value is calculated automatically based on data. */
|
|
49
|
+
yDomain?: [number | undefined, number | undefined];
|
|
50
|
+
/** Constraint the minimum value of the Y scale domain.
|
|
51
|
+
* For example, imagine that you have a chart with dynamic data that has negative values. When values are small
|
|
52
|
+
* (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can
|
|
53
|
+
* be achieved by setting `yDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the
|
|
54
|
+
* values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`
|
|
55
|
+
* Default: `undefined` */
|
|
56
|
+
yDomainMinConstraint?: [number | undefined, number | undefined];
|
|
57
|
+
/** Constraint the minimum value of the Y scale domain.
|
|
58
|
+
* For example, imagine that you have a chart with dynamic data. When values are small
|
|
59
|
+
* (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can
|
|
60
|
+
* be achieved by setting `yDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the
|
|
61
|
+
* values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`
|
|
62
|
+
* Default: `undefined` */
|
|
63
|
+
yDomainMaxConstraint?: [number | undefined, number | undefined];
|
|
64
|
+
/** Force set the Y scale range (in the screen space). By default the range is calculated automatically based on the
|
|
65
|
+
* chart's set up */
|
|
66
|
+
yRange?: [number, number];
|
|
67
|
+
/** Y Axis direction. Default: `Direction.North` */
|
|
68
|
+
yDirection?: Direction.South | Direction.North | string;
|
|
69
|
+
|
|
70
|
+
/** X Axis component instance. Default: `undefined` */
|
|
71
|
+
xAxis?: Axis<Datum>;
|
|
72
|
+
/** Y Axis component instance. Default: `undefined` */
|
|
73
|
+
yAxis?: Axis<Datum>;
|
|
74
|
+
/** Enables automatic calculation of chart margins based on the size of the axes. Default: `true` */
|
|
75
|
+
autoMargin?: boolean;
|
|
76
|
+
/** Tooltip component. Default: `undefined` */
|
|
77
|
+
tooltip?: Tooltip | undefined;
|
|
78
|
+
/** Crosshair component. Default: `undefined` */
|
|
79
|
+
crosshair?: Crosshair<Datum> | undefined;
|
|
80
|
+
/** Prevents the chart domain from being empty (when domain's min and max values are equal).
|
|
81
|
+
* That usually happens when all the data values are the same.
|
|
82
|
+
* Setting to `true` will automatically extend the domain by `+1` when needed.
|
|
83
|
+
* Default: `true` */
|
|
84
|
+
preventEmptyDomain?: boolean;
|
|
85
|
+
/** Sets the Y scale domain based on the current X scale domain (not the whole dataset). Default: `false` */
|
|
86
|
+
scaleByDomain?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class XYContainerConfig<Datum> extends ContainerConfig implements XYContainerConfigInterface<Datum> {
|
|
90
|
+
components = []
|
|
91
|
+
tooltip: Tooltip = undefined
|
|
92
|
+
crosshair: Crosshair<Datum> = undefined
|
|
93
|
+
xAxis: Axis<Datum> = undefined
|
|
94
|
+
yAxis: Axis<Datum> = undefined
|
|
95
|
+
autoMargin = true
|
|
96
|
+
|
|
97
|
+
xScale = undefined
|
|
98
|
+
xDomain = undefined
|
|
99
|
+
xDomainMinConstraint = undefined
|
|
100
|
+
xDomainMaxConstraint = undefined
|
|
101
|
+
xRange = undefined
|
|
102
|
+
|
|
103
|
+
yScale = undefined
|
|
104
|
+
yDomain = undefined
|
|
105
|
+
yDomainMinConstraint = undefined
|
|
106
|
+
yDomainMaxConstraint = undefined
|
|
107
|
+
yRange = undefined
|
|
108
|
+
yDirection = Direction.North
|
|
109
|
+
|
|
110
|
+
preventEmptyDomain = true
|
|
111
|
+
scaleByDomain = false
|
|
112
|
+
}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { css } from '@emotion/css'
|
|
2
|
+
import { extent, merge as mergeArrays } from 'd3-array'
|
|
3
|
+
import { Selection } from 'd3-selection'
|
|
4
|
+
|
|
5
|
+
// Global CSS variables (side effects import)
|
|
6
|
+
import 'styles/index'
|
|
7
|
+
|
|
8
|
+
// Core
|
|
9
|
+
import { ContainerCore } from 'core/container'
|
|
10
|
+
import { XYComponentCore } from 'core/xy-component'
|
|
11
|
+
import { XYComponentConfigInterface } from 'core/xy-component/config'
|
|
12
|
+
|
|
13
|
+
// Data Model
|
|
14
|
+
import { CoreDataModel } from 'data-models/core'
|
|
15
|
+
|
|
16
|
+
// Types
|
|
17
|
+
import { Spacing } from 'types/spacing'
|
|
18
|
+
import { AxisType } from 'components/axis/types'
|
|
19
|
+
import { ScaleDimension } from 'types/scale'
|
|
20
|
+
import { Direction } from 'types/direction'
|
|
21
|
+
|
|
22
|
+
// Utils
|
|
23
|
+
import { clamp, clean, flatten } from 'utils/data'
|
|
24
|
+
import { guid } from 'utils/misc'
|
|
25
|
+
|
|
26
|
+
// Config
|
|
27
|
+
import { XYContainerConfig, XYContainerConfigInterface } from './config'
|
|
28
|
+
import {
|
|
29
|
+
AreaConfigInterface,
|
|
30
|
+
BrushConfigInterface,
|
|
31
|
+
LineConfigInterface,
|
|
32
|
+
ScatterConfigInterface,
|
|
33
|
+
StackedBarConfigInterface,
|
|
34
|
+
TimelineConfigInterface,
|
|
35
|
+
} from '../../components'
|
|
36
|
+
|
|
37
|
+
export type XYConfigInterface<Datum> = XYComponentConfigInterface<Datum>
|
|
38
|
+
| StackedBarConfigInterface<Datum>
|
|
39
|
+
| LineConfigInterface<Datum>
|
|
40
|
+
| ScatterConfigInterface<Datum>
|
|
41
|
+
| BrushConfigInterface<Datum>
|
|
42
|
+
| TimelineConfigInterface<Datum>
|
|
43
|
+
| AreaConfigInterface<Datum>
|
|
44
|
+
|
|
45
|
+
export class XYContainer<Datum> extends ContainerCore {
|
|
46
|
+
config: XYContainerConfig<Datum> = new XYContainerConfig()
|
|
47
|
+
datamodel: CoreDataModel<Datum[]> = new CoreDataModel()
|
|
48
|
+
private _svgDefs: Selection<SVGDefsElement, unknown, null, undefined>
|
|
49
|
+
private _clipPath: Selection<SVGClipPathElement, unknown, null, undefined>
|
|
50
|
+
private _clipPathId = guid()
|
|
51
|
+
private _axisMargin: Spacing = { top: 0, bottom: 0, left: 0, right: 0 }
|
|
52
|
+
private _firstRender = true
|
|
53
|
+
|
|
54
|
+
constructor (element: HTMLElement, config?: XYContainerConfigInterface<Datum>, data?: Datum[]) {
|
|
55
|
+
super(element)
|
|
56
|
+
|
|
57
|
+
this._clipPath = this.svg.append('clipPath')
|
|
58
|
+
.attr('id', this._clipPathId)
|
|
59
|
+
this._clipPath.append('rect')
|
|
60
|
+
|
|
61
|
+
// When the base tag is specified on the HTML head,
|
|
62
|
+
// Safari fails to find the corresponding filter URL.
|
|
63
|
+
// We have to provide tull url in order to fix that
|
|
64
|
+
const highlightFilterId = 'saturate'
|
|
65
|
+
const baseUrl = window.location.href.replace(window.location.hash, '')
|
|
66
|
+
this.svg.attr('class', css`
|
|
67
|
+
--highlight-filter-id: url(${baseUrl}#${highlightFilterId}); // defining a css variable
|
|
68
|
+
`)
|
|
69
|
+
|
|
70
|
+
this._svgDefs = this.svg.append('defs')
|
|
71
|
+
this._svgDefs.append('filter')
|
|
72
|
+
.attr('id', highlightFilterId)
|
|
73
|
+
.attr('filterUnits', 'objectBoundingBox')
|
|
74
|
+
.html('<feColorMatrix type="saturate" in="SourceGraphic" values="1.35"/>')
|
|
75
|
+
|
|
76
|
+
if (config) {
|
|
77
|
+
this.updateContainer(config, true)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (data) {
|
|
81
|
+
this.setData(data, true)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Render if components are present and have data
|
|
85
|
+
if (this.components?.some(c => c.datamodel.data)) {
|
|
86
|
+
this.render()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Force re-render axes when fonts are loaded
|
|
90
|
+
(document as any).fonts?.ready.then(() => {
|
|
91
|
+
if (!this._firstRender) this._renderAxes(0)
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get components (): XYComponentCore<Datum>[] {
|
|
96
|
+
return this.config.components
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Overriding ContainerCore default get width method to work with axis auto margin
|
|
100
|
+
get width (): number {
|
|
101
|
+
const margin = this._getMargin()
|
|
102
|
+
return clamp(this.containerWidth - margin.left - margin.right, 0, Number.POSITIVE_INFINITY)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Overriding ContainerCore default get height method to work with axis auto margin
|
|
106
|
+
get height (): number {
|
|
107
|
+
const margin = this._getMargin()
|
|
108
|
+
|
|
109
|
+
return clamp(this.containerHeight - margin.top - margin.bottom, 0, Number.POSITIVE_INFINITY)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setData (data: Datum[], preventRender?: boolean): void {
|
|
113
|
+
const { components, config } = this
|
|
114
|
+
if (!data) return
|
|
115
|
+
this.datamodel.data = data
|
|
116
|
+
|
|
117
|
+
components.forEach((c) => {
|
|
118
|
+
c.setData(data)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
config.crosshair?.setData(data)
|
|
122
|
+
config.xAxis?.setData(data)
|
|
123
|
+
config.yAxis?.setData(data)
|
|
124
|
+
config.tooltip?.hide()
|
|
125
|
+
if (!preventRender) this.render()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
updateContainer (containerConfig: XYContainerConfigInterface<Datum>, preventRender?: boolean): void {
|
|
129
|
+
super.updateContainer(containerConfig)
|
|
130
|
+
this.removeAllChildren()
|
|
131
|
+
|
|
132
|
+
// If there were any new components added we need to pass them data
|
|
133
|
+
this.setData(this.datamodel.data, true)
|
|
134
|
+
|
|
135
|
+
// Set up the axes
|
|
136
|
+
if (containerConfig.xAxis) {
|
|
137
|
+
this.config.xAxis.config.type = AxisType.X
|
|
138
|
+
this.element.appendChild(containerConfig.xAxis.element)
|
|
139
|
+
}
|
|
140
|
+
if (containerConfig.yAxis) {
|
|
141
|
+
this.config.yAxis.config.type = AxisType.Y
|
|
142
|
+
this.element.appendChild(containerConfig.yAxis.element)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Re-insert elements to the DOM
|
|
146
|
+
for (const c of this.components) {
|
|
147
|
+
this.element.appendChild(c.element)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Set up the tooltip
|
|
151
|
+
const tooltip = containerConfig.tooltip
|
|
152
|
+
if (tooltip) {
|
|
153
|
+
if (!tooltip.hasContainer()) tooltip.setContainer(this._container)
|
|
154
|
+
tooltip.setComponents(this.components)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Set up the crosshair
|
|
158
|
+
const crosshair = containerConfig.crosshair
|
|
159
|
+
if (crosshair) {
|
|
160
|
+
crosshair.setContainer(this.svg)
|
|
161
|
+
crosshair.tooltip = tooltip
|
|
162
|
+
|
|
163
|
+
this.element.appendChild(crosshair.element)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Clipping path
|
|
167
|
+
this.element.appendChild(this._clipPath.node())
|
|
168
|
+
|
|
169
|
+
// Defs
|
|
170
|
+
this.element.appendChild(this._svgDefs.node())
|
|
171
|
+
|
|
172
|
+
// Rendering
|
|
173
|
+
if (!preventRender) this.render()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
updateComponents (componentConfigs: XYConfigInterface<Datum>[], preventRender?: boolean): void {
|
|
177
|
+
const { config } = this
|
|
178
|
+
|
|
179
|
+
this.components.forEach((c, i) => {
|
|
180
|
+
const componentConfig = componentConfigs[i]
|
|
181
|
+
if (componentConfig) {
|
|
182
|
+
c.setConfig(componentConfigs[i])
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
this.updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair)
|
|
187
|
+
if (!preventRender) this.render()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
update (containerConfig: XYContainerConfigInterface<Datum>, componentConfigs?: XYComponentConfigInterface<Datum>[], data?: Datum[]): void {
|
|
191
|
+
if (data) this.datamodel.data = data // Just updating the data model because the `updateContainer` method has the `setData` step inside
|
|
192
|
+
if (containerConfig) this.updateContainer(containerConfig, true)
|
|
193
|
+
if (componentConfigs) this.updateComponents(componentConfigs, true)
|
|
194
|
+
this.render()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_render (customDuration?: number): void {
|
|
198
|
+
const { config } = this
|
|
199
|
+
super._render()
|
|
200
|
+
|
|
201
|
+
// Calculate extra margin required to fit the axes
|
|
202
|
+
if (config.autoMargin) {
|
|
203
|
+
this._setAutoMargin()
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Get chart total margin after auto margin calculations
|
|
207
|
+
const margin = this._getMargin()
|
|
208
|
+
|
|
209
|
+
// Update Scales of all the components at once to calculate required paddings and sync them
|
|
210
|
+
this.updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair)
|
|
211
|
+
|
|
212
|
+
// Render components
|
|
213
|
+
for (const c of this.components) {
|
|
214
|
+
c.g.attr('transform', `translate(${margin.left},${margin.top})`)
|
|
215
|
+
.style('clip-path', c.clippable ? `url(#${this._clipPathId})` : null)
|
|
216
|
+
.style('-webkit-clip-path', c.clippable ? `url(#${this._clipPathId})` : null)
|
|
217
|
+
|
|
218
|
+
c.render(customDuration)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
this._renderAxes(this._firstRender ? 0 : customDuration)
|
|
222
|
+
|
|
223
|
+
// Clip Rect
|
|
224
|
+
// Extending the clipping path to allow small overflow (e.g. Line will looks better that way when it touches the edges)
|
|
225
|
+
const clipPathExtension = 2
|
|
226
|
+
this._clipPath.select('rect')
|
|
227
|
+
.attr('x', -clipPathExtension)
|
|
228
|
+
.attr('y', -clipPathExtension)
|
|
229
|
+
.attr('width', this.width + 2 * clipPathExtension)
|
|
230
|
+
.attr('height', this.height + 2 * clipPathExtension)
|
|
231
|
+
|
|
232
|
+
// Tooltip
|
|
233
|
+
config.tooltip?.update() // Re-bind events
|
|
234
|
+
|
|
235
|
+
// Crosshair
|
|
236
|
+
const crosshair = config.crosshair
|
|
237
|
+
if (crosshair) {
|
|
238
|
+
// Pass accessors
|
|
239
|
+
const yAccessors = this.components.filter(c => !c.stacked).map(c => c.config.y)
|
|
240
|
+
const yStackedAccessors = this.components.filter(c => c.stacked).map(c => c.config.y)
|
|
241
|
+
// eslint-disable-next-line dot-notation
|
|
242
|
+
const baselineAccessor = this.components.find(c => c.config['baseline'])?.config['baseline']
|
|
243
|
+
|
|
244
|
+
crosshair.accessors = {
|
|
245
|
+
x: this.components[0]?.config.x,
|
|
246
|
+
y: flatten(yAccessors),
|
|
247
|
+
yStacked: flatten(yStackedAccessors),
|
|
248
|
+
baseline: baselineAccessor,
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
crosshair.g.attr('transform', `translate(${margin.left},${margin.top})`)
|
|
252
|
+
.style('clip-path', `url(#${this._clipPathId})`)
|
|
253
|
+
.style('-webkit-clip-path', `url(#${this._clipPathId})`)
|
|
254
|
+
crosshair.hide()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this._firstRender = false
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
updateScales<T extends XYComponentCore<Datum>> (...components: T[]): void {
|
|
261
|
+
const c = clean(components || this.components)
|
|
262
|
+
this._setScales(...c)
|
|
263
|
+
this._updateScalesDomain(...c)
|
|
264
|
+
this._updateScalesRange(...c)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
_setScales<T extends XYComponentCore<Datum>> (...components: T[]): void {
|
|
268
|
+
const { config } = this
|
|
269
|
+
if (!components) return
|
|
270
|
+
|
|
271
|
+
// Set the X and Y scales
|
|
272
|
+
if (config.xScale) components.forEach(c => c.setScale(ScaleDimension.X, config.xScale))
|
|
273
|
+
if (config.yScale) components.forEach(c => c.setScale(ScaleDimension.Y, config.yScale))
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
_updateScalesDomain<T extends XYComponentCore<Datum>> (...components: T[]): void {
|
|
277
|
+
const { config } = this
|
|
278
|
+
if (!components) return
|
|
279
|
+
|
|
280
|
+
// Loop over all the dimensions
|
|
281
|
+
Object.values(ScaleDimension).forEach((dimension: ScaleDimension) => {
|
|
282
|
+
const [min, max] = extent(
|
|
283
|
+
mergeArrays(
|
|
284
|
+
components
|
|
285
|
+
.filter(c => !c.config.excludeFromDomainCalculation)
|
|
286
|
+
.map(c => c.getDataExtent(dimension, config.scaleByDomain))
|
|
287
|
+
) as number[]
|
|
288
|
+
) // Components with undefined dimension accessors will return [undefined, undefined] but d3.extent will take care of that
|
|
289
|
+
|
|
290
|
+
const configuredDomain = dimension === ScaleDimension.Y ? config.yDomain : config.xDomain
|
|
291
|
+
const configuredDomainMinConstraint = dimension === ScaleDimension.Y ? config.yDomainMinConstraint : config.xDomainMinConstraint
|
|
292
|
+
const configuredDomainMaxConstraint = dimension === ScaleDimension.Y ? config.yDomainMaxConstraint : config.xDomainMaxConstraint
|
|
293
|
+
const domainMin = configuredDomain?.[0] ?? min ?? 0
|
|
294
|
+
const domainMax = configuredDomain?.[1] ?? max ?? 1
|
|
295
|
+
const domain = [
|
|
296
|
+
clamp(domainMin, configuredDomainMinConstraint?.[0] ?? Number.NEGATIVE_INFINITY, configuredDomainMinConstraint?.[1] ?? Number.POSITIVE_INFINITY),
|
|
297
|
+
clamp(domainMax, configuredDomainMaxConstraint?.[0] ?? Number.NEGATIVE_INFINITY, configuredDomainMaxConstraint?.[1] ?? Number.POSITIVE_INFINITY),
|
|
298
|
+
]
|
|
299
|
+
|
|
300
|
+
if (config.preventEmptyDomain && (domain[0] === domain[1]) && isFinite(domain[0])) {
|
|
301
|
+
domain[1] = domain[0] + 1
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
components.forEach(c => c.setScaleDomain(dimension, domain))
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
_updateScalesRange<T extends XYComponentCore<Datum>> (...components: T[]): void {
|
|
309
|
+
const { config } = this
|
|
310
|
+
if (!components) return
|
|
311
|
+
|
|
312
|
+
// Set initial scale range
|
|
313
|
+
const isYDirectionSouth = config.yDirection === Direction.South
|
|
314
|
+
const xRange: [number, number] = [config.padding.left ?? 0, this.width - config.padding.right ?? 0]
|
|
315
|
+
const yRange: [number, number] = [this.height - config.padding.bottom ?? 0, config.padding.top ?? 0]
|
|
316
|
+
if (isYDirectionSouth) yRange.reverse()
|
|
317
|
+
|
|
318
|
+
for (const c of components) {
|
|
319
|
+
c.setSize(this.width, this.height, this.containerWidth, this.containerHeight)
|
|
320
|
+
c.setScaleRange(ScaleDimension.X, config.xRange ?? xRange)
|
|
321
|
+
c.setScaleRange(ScaleDimension.Y, config.yRange ?? yRange)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Get and combine bleed
|
|
325
|
+
const bleed = components.map(c => c.bleed).reduce((bleed, b) => {
|
|
326
|
+
for (const key of Object.keys(bleed)) {
|
|
327
|
+
if (bleed[key] < b[key]) bleed[key] = b[key]
|
|
328
|
+
}
|
|
329
|
+
return bleed
|
|
330
|
+
}, { top: 0, bottom: 0, left: 0, right: 0 })
|
|
331
|
+
|
|
332
|
+
// Update scale range
|
|
333
|
+
for (const c of components) {
|
|
334
|
+
c.setScaleRange(ScaleDimension.X, [xRange[0] + bleed.left, xRange[1] - bleed.right])
|
|
335
|
+
c.setScaleRange(
|
|
336
|
+
ScaleDimension.Y,
|
|
337
|
+
isYDirectionSouth
|
|
338
|
+
? [yRange[0] + bleed.top, yRange[1] - bleed.bottom] // if Y axis is directed downwards
|
|
339
|
+
: [yRange[0] - bleed.bottom, yRange[1] + bleed.top] // if Y axis is directed upwards
|
|
340
|
+
)
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
_renderAxes (duration: number): void {
|
|
345
|
+
const { config: { xAxis, yAxis } } = this
|
|
346
|
+
const margin = this._getMargin()
|
|
347
|
+
|
|
348
|
+
const axes = clean([xAxis, yAxis])
|
|
349
|
+
axes.forEach(axis => {
|
|
350
|
+
const offset = axis.getOffset(margin)
|
|
351
|
+
axis.g.attr('transform', `translate(${offset.left},${offset.top})`)
|
|
352
|
+
axis.render(duration)
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
_setAutoMargin (): void {
|
|
357
|
+
const { config: { xAxis, yAxis } } = this
|
|
358
|
+
|
|
359
|
+
// At first we need to set the domain to the scales
|
|
360
|
+
const components = clean([...this.components, xAxis, yAxis])
|
|
361
|
+
this._updateScalesDomain(...components)
|
|
362
|
+
|
|
363
|
+
// Calculate margin required by the axes
|
|
364
|
+
// We do two iterations on the first render, because the amount and size of ticks can change
|
|
365
|
+
// after new margin are calculated and applied (axes dimensions will change).
|
|
366
|
+
// That's needed for correct label placement.
|
|
367
|
+
const numIterations = this._firstRender ? 2 : 1
|
|
368
|
+
for (let i = 0; i < numIterations; i += 1) {
|
|
369
|
+
const axisMargin: Spacing = { top: 0, bottom: 0, left: 0, right: 0 }
|
|
370
|
+
this._updateScalesRange(...components)
|
|
371
|
+
const axes = clean([xAxis, yAxis])
|
|
372
|
+
axes.forEach(axis => {
|
|
373
|
+
axis.preRender()
|
|
374
|
+
|
|
375
|
+
const m = axis.getRequiredMargin()
|
|
376
|
+
if (axisMargin.top < m.top) axisMargin.top = m.top
|
|
377
|
+
if (axisMargin.bottom < m.bottom) axisMargin.bottom = m.bottom
|
|
378
|
+
if (axisMargin.left < m.left) axisMargin.left = m.left
|
|
379
|
+
if (axisMargin.right < m.right) axisMargin.right = m.right
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
this._axisMargin = axisMargin
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private _getMargin (): Spacing {
|
|
387
|
+
const { config: { margin } } = this
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
top: margin.top + this._axisMargin.top,
|
|
391
|
+
bottom: margin.bottom + this._axisMargin.bottom,
|
|
392
|
+
left: margin.left + this._axisMargin.left,
|
|
393
|
+
right: margin.right + this._axisMargin.right,
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
public destroy (): void {
|
|
398
|
+
const { components, config: { tooltip, crosshair, xAxis, yAxis } } = this
|
|
399
|
+
super.destroy()
|
|
400
|
+
|
|
401
|
+
for (const c of components) c?.destroy()
|
|
402
|
+
tooltip?.destroy()
|
|
403
|
+
crosshair?.destroy()
|
|
404
|
+
xAxis?.destroy()
|
|
405
|
+
yAxis?.destroy()
|
|
406
|
+
}
|
|
407
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ContainerCore } from './core/container'
|
|
2
|
+
export type { ContainerConfigInterface } from './core/container/config'
|
|
3
|
+
export { SingleContainer } from './containers/single-container'
|
|
4
|
+
export type { SingleContainerConfigInterface } from './containers/single-container/config'
|
|
5
|
+
export { XYContainer } from './containers/xy-container'
|
|
6
|
+
export type { XYContainerConfigInterface } from './containers/xy-container/config'
|