@unovis/ts 1.1.1-beta.7 → 1.1.1-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/area/config.d.ts +25 -0
- package/components/area/config.js +16 -0
- package/components/area/config.js.map +1 -0
- package/components/area/index.d.ts +19 -0
- package/components/area/index.js +102 -0
- package/components/area/index.js.map +1 -0
- package/components/area/style.d.ts +3 -0
- package/{src/components/area/style.ts → components/area/style.js} +10 -9
- package/components/area/style.js.map +1 -0
- package/components/area/types.d.ts +6 -0
- package/components/axis/config.d.ts +71 -0
- package/components/axis/config.js +32 -0
- package/components/axis/config.js.map +1 -0
- package/components/axis/index.d.ts +44 -0
- package/components/axis/index.js +305 -0
- package/components/axis/index.js.map +1 -0
- package/components/axis/style.d.ts +9 -0
- package/{src/components/axis/style.ts → components/axis/style.js} +22 -27
- package/components/axis/style.js.map +1 -0
- package/components/axis/types.d.ts +4 -0
- package/components/axis/types.js +8 -0
- package/components/axis/types.js.map +1 -0
- package/components/brush/config.d.ts +42 -0
- package/components/brush/config.js +24 -0
- package/components/brush/config.js.map +1 -0
- package/components/brush/index.d.ts +28 -0
- package/components/brush/index.js +199 -0
- package/components/brush/index.js.map +1 -0
- package/components/brush/style.d.ts +5 -0
- package/{src/components/brush/style.ts → components/brush/style.js} +14 -15
- package/components/brush/style.js.map +1 -0
- package/components/brush/types.d.ts +7 -0
- package/components/brush/types.js +8 -0
- package/components/brush/types.js.map +1 -0
- package/components/bullet-legend/config.d.ts +34 -0
- package/components/bullet-legend/config.js +16 -0
- package/components/bullet-legend/config.js.map +1 -0
- package/components/bullet-legend/index.d.ts +19 -0
- package/components/bullet-legend/index.js +79 -0
- package/components/bullet-legend/index.js.map +1 -0
- package/components/bullet-legend/style.d.ts +6 -0
- package/{src/components/bullet-legend/style.ts → components/bullet-legend/style.js} +16 -18
- package/components/bullet-legend/style.js.map +1 -0
- package/components/bullet-legend/types.d.ts +7 -0
- package/components/bullet-legend/types.js +2 -0
- package/components/bullet-legend/types.js.map +1 -0
- package/components/chord-diagram/config.d.ts +44 -0
- package/components/chord-diagram/config.js +25 -0
- package/components/chord-diagram/config.js.map +1 -0
- package/components/chord-diagram/index.d.ts +42 -0
- package/components/chord-diagram/index.js +305 -0
- package/components/chord-diagram/index.js.map +1 -0
- package/components/chord-diagram/modules/label.d.ts +8 -0
- package/components/chord-diagram/modules/label.js +115 -0
- package/components/chord-diagram/modules/label.js.map +1 -0
- package/components/chord-diagram/modules/link.d.ts +21 -0
- package/components/chord-diagram/modules/link.js +63 -0
- package/components/chord-diagram/modules/link.js.map +1 -0
- package/components/chord-diagram/modules/node.d.ts +17 -0
- package/components/chord-diagram/modules/node.js +52 -0
- package/components/chord-diagram/modules/node.js.map +1 -0
- package/components/chord-diagram/style.d.ts +13 -0
- package/{src/components/chord-diagram/style.ts → components/chord-diagram/style.js} +30 -39
- package/components/chord-diagram/style.js.map +1 -0
- package/components/chord-diagram/types.d.ts +58 -0
- package/components/chord-diagram/types.js +8 -0
- package/components/chord-diagram/types.js.map +1 -0
- package/components/crosshair/config.d.ts +43 -0
- package/components/crosshair/config.js +19 -0
- package/components/crosshair/config.js.map +1 -0
- package/components/crosshair/index.d.ts +35 -0
- package/components/crosshair/index.js +183 -0
- package/components/crosshair/index.js.map +1 -0
- package/components/crosshair/style.d.ts +4 -0
- package/{src/components/crosshair/style.ts → components/crosshair/style.js} +12 -12
- package/components/crosshair/style.js.map +1 -0
- package/components/crosshair/types.d.ts +13 -0
- package/components/crosshair/types.js +2 -0
- package/components/crosshair/types.js.map +1 -0
- package/components/donut/config.d.ts +59 -0
- package/components/donut/config.js +28 -0
- package/components/donut/config.js.map +1 -0
- package/components/donut/index.d.ts +21 -0
- package/components/donut/index.js +107 -0
- package/components/donut/index.js.map +1 -0
- package/components/donut/modules/arc.d.ts +10 -0
- package/components/donut/modules/arc.js +59 -0
- package/components/donut/modules/arc.js.map +1 -0
- package/components/donut/style.d.ts +7 -0
- package/{src/components/donut/style.ts → components/donut/style.js} +18 -20
- package/components/donut/style.js.map +1 -0
- package/components/donut/types.d.ts +20 -0
- package/components/flow-legend/config.d.ts +29 -0
- package/components/flow-legend/config.js +18 -0
- package/components/flow-legend/config.js.map +1 -0
- package/components/flow-legend/index.d.ts +16 -0
- package/components/flow-legend/index.js +75 -0
- package/components/flow-legend/index.js.map +1 -0
- package/components/flow-legend/style.d.ts +8 -0
- package/{src/components/flow-legend/style.ts → components/flow-legend/style.js} +21 -25
- package/components/flow-legend/style.js.map +1 -0
- package/components/flow-legend/types.d.ts +9 -0
- package/components/flow-legend/types.js +8 -0
- package/components/flow-legend/types.js.map +1 -0
- package/components/free-brush/config.d.ts +45 -0
- package/components/free-brush/config.js +24 -0
- package/components/free-brush/config.js.map +1 -0
- package/components/free-brush/index.d.ts +20 -0
- package/components/free-brush/index.js +192 -0
- package/components/free-brush/index.js.map +1 -0
- package/components/free-brush/style.d.ts +4 -0
- package/{src/components/free-brush/style.ts → components/free-brush/style.js} +12 -12
- package/components/free-brush/style.js.map +1 -0
- package/components/free-brush/types.d.ts +7 -0
- package/components/free-brush/types.js +9 -0
- package/components/free-brush/types.js.map +1 -0
- package/components/graph/config.d.ts +238 -0
- package/components/graph/config.js +84 -0
- package/components/graph/config.js.map +1 -0
- package/components/graph/index.d.ts +126 -0
- package/components/graph/index.js +656 -0
- package/components/graph/index.js.map +1 -0
- package/components/graph/modules/layout-helpers.d.ts +21 -0
- package/components/graph/modules/layout-helpers.js +69 -0
- package/components/graph/modules/layout-helpers.js.map +1 -0
- package/components/graph/modules/layout.d.ts +10 -0
- package/components/graph/modules/layout.js +399 -0
- package/components/graph/modules/layout.js.map +1 -0
- package/components/graph/modules/link/helper.d.ts +25 -0
- package/components/graph/modules/link/helper.js +74 -0
- package/components/graph/modules/link/helper.js.map +1 -0
- package/components/graph/modules/link/index.d.ts +11 -0
- package/components/graph/modules/link/index.js +212 -0
- package/components/graph/modules/link/index.js.map +1 -0
- package/components/graph/modules/link/style.d.ts +15 -0
- package/{src/components/graph/modules/link/style.ts → components/graph/modules/link/style.js} +34 -45
- package/components/graph/modules/link/style.js.map +1 -0
- package/components/graph/modules/node/helper.d.ts +21 -0
- package/components/graph/modules/node/helper.js +126 -0
- package/components/graph/modules/node/helper.js.map +1 -0
- package/components/graph/modules/node/index.d.ts +11 -0
- package/components/graph/modules/node/index.js +252 -0
- package/components/graph/modules/node/index.js.map +1 -0
- package/components/graph/modules/node/style.d.ts +24 -0
- package/{src/components/graph/modules/node/style.ts → components/graph/modules/node/style.js} +52 -72
- package/components/graph/modules/node/style.js.map +1 -0
- package/components/graph/modules/panel/helper.d.ts +18 -0
- package/components/graph/modules/panel/helper.js +111 -0
- package/components/graph/modules/panel/helper.js.map +1 -0
- package/components/graph/modules/panel/index.d.ts +7 -0
- package/components/graph/modules/panel/index.js +98 -0
- package/components/graph/modules/panel/index.js.map +1 -0
- package/components/graph/modules/panel/style.d.ts +14 -0
- package/{src/components/graph/modules/panel/style.ts → components/graph/modules/panel/style.js} +32 -42
- package/components/graph/modules/panel/style.js.map +1 -0
- package/components/graph/modules/shape.d.ts +6 -0
- package/components/graph/modules/shape.js +80 -0
- package/components/graph/modules/shape.js.map +1 -0
- package/components/graph/modules/zoom-levels.d.ts +6 -0
- package/components/graph/modules/zoom-levels.js +10 -0
- package/components/graph/modules/zoom-levels.js.map +1 -0
- package/components/graph/style.d.ts +6 -0
- package/components/graph/style.js +66 -0
- package/components/graph/style.js.map +1 -0
- package/components/graph/types.d.ts +125 -0
- package/components/graph/types.js +30 -0
- package/components/graph/types.js.map +1 -0
- package/components/grouped-bar/config.d.ts +36 -0
- package/components/grouped-bar/config.js +20 -0
- package/components/grouped-bar/config.js.map +1 -0
- package/components/grouped-bar/index.d.ts +32 -0
- package/components/grouped-bar/index.js +249 -0
- package/components/grouped-bar/index.js.map +1 -0
- package/components/grouped-bar/style.d.ts +5 -0
- package/{src/components/grouped-bar/style.ts → components/grouped-bar/style.js} +14 -15
- package/components/grouped-bar/style.js.map +1 -0
- package/components/leaflet-flow-map/config.d.ts +46 -0
- package/components/leaflet-flow-map/config.js +25 -0
- package/components/leaflet-flow-map/config.js.map +1 -0
- package/components/leaflet-flow-map/index.d.ts +52 -0
- package/components/leaflet-flow-map/index.js +220 -0
- package/components/leaflet-flow-map/index.js.map +1 -0
- package/components/leaflet-flow-map/renderer-utils.d.ts +5 -0
- package/components/leaflet-flow-map/renderer-utils.js +15 -0
- package/components/leaflet-flow-map/renderer-utils.js.map +1 -0
- package/components/leaflet-flow-map/renderer.d.ts +26 -0
- package/components/leaflet-flow-map/renderer.js +117 -0
- package/components/leaflet-flow-map/renderer.js.map +1 -0
- package/components/leaflet-flow-map/shaders.d.ts +2 -0
- package/{src/components/leaflet-flow-map/shaders.ts → components/leaflet-flow-map/shaders.js} +7 -4
- package/components/leaflet-flow-map/shaders.js.map +1 -0
- package/components/leaflet-flow-map/types.d.ts +23 -0
- package/components/leaflet-map/config.d.ts +193 -0
- package/components/leaflet-map/config.js +71 -0
- package/components/leaflet-map/config.js.map +1 -0
- package/components/leaflet-map/index.d.ts +130 -0
- package/components/leaflet-map/index.js +690 -0
- package/components/leaflet-map/index.js.map +1 -0
- package/components/leaflet-map/leaflet.css.js +5 -0
- package/components/leaflet-map/leaflet.css.js.map +1 -0
- package/components/leaflet-map/modules/clusterBackground.d.ts +5 -0
- package/components/leaflet-map/modules/clusterBackground.js +27 -0
- package/components/leaflet-map/modules/clusterBackground.js.map +1 -0
- package/components/leaflet-map/modules/donut.d.ts +3 -0
- package/components/leaflet-map/modules/donut.js +25 -0
- package/components/leaflet-map/modules/donut.js.map +1 -0
- package/components/leaflet-map/modules/map.d.ts +14 -0
- package/components/leaflet-map/modules/map.js +154 -0
- package/components/leaflet-map/modules/map.js.map +1 -0
- package/components/leaflet-map/modules/node.d.ts +9 -0
- package/components/leaflet-map/modules/node.js +162 -0
- package/components/leaflet-map/modules/node.js.map +1 -0
- package/components/leaflet-map/modules/selectionRing.d.ts +7 -0
- package/components/leaflet-map/modules/selectionRing.js +41 -0
- package/components/leaflet-map/modules/selectionRing.js.map +1 -0
- package/components/leaflet-map/modules/utils.d.ts +50 -0
- package/components/leaflet-map/modules/utils.js +210 -0
- package/components/leaflet-map/modules/utils.js.map +1 -0
- package/{src/components → components}/leaflet-map/renderer/leaflet-maplibre-gl.js +78 -76
- package/components/leaflet-map/renderer/leaflet-maplibre-gl.js.map +1 -0
- package/components/leaflet-map/renderer/map-style.d.ts +4 -0
- package/components/leaflet-map/renderer/map-style.js +15 -0
- package/components/leaflet-map/renderer/map-style.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js +40 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js +40 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js +4981 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +8 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.js +27 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +4 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.js +39 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -0
- package/{src/components → components}/leaflet-map/renderer/maplibre-gl.css.js +4 -2
- package/components/leaflet-map/renderer/maplibre-gl.css.js.map +1 -0
- package/components/leaflet-map/style.d.ts +52 -0
- package/components/leaflet-map/style.js +183 -0
- package/components/leaflet-map/style.js.map +1 -0
- package/components/leaflet-map/types.d.ts +75 -0
- package/components/leaflet-map/types.js +15 -0
- package/components/leaflet-map/types.js.map +1 -0
- package/components/line/config.d.ts +30 -0
- package/components/line/config.js +17 -0
- package/components/line/config.js.map +1 -0
- package/components/line/index.d.ts +27 -0
- package/components/line/index.js +152 -0
- package/components/line/index.js.map +1 -0
- package/components/line/style.d.ts +6 -0
- package/{src/components/line/style.ts → components/line/style.js} +16 -18
- package/components/line/style.js.map +1 -0
- package/components/line/types.d.ts +12 -0
- package/components/nested-donut/config.d.ts +59 -0
- package/components/nested-donut/config.js +19 -0
- package/components/nested-donut/config.js.map +1 -0
- package/components/nested-donut/index.d.ts +38 -0
- package/components/nested-donut/index.js +133 -0
- package/components/nested-donut/index.js.map +1 -0
- package/components/nested-donut/modules/arc.d.ts +17 -0
- package/components/nested-donut/modules/arc.js +50 -0
- package/components/nested-donut/modules/arc.js.map +1 -0
- package/components/nested-donut/modules/label.d.ts +7 -0
- package/components/nested-donut/modules/label.js +34 -0
- package/components/nested-donut/modules/label.js.map +1 -0
- package/components/nested-donut/style.d.ts +26 -0
- package/components/nested-donut/style.js +70 -0
- package/components/nested-donut/style.js.map +1 -0
- package/components/nested-donut/types.d.ts +24 -0
- package/components/nested-donut/types.js +11 -0
- package/components/nested-donut/types.js.map +1 -0
- package/components/sankey/config.d.ts +162 -0
- package/components/sankey/config.js +65 -0
- package/components/sankey/config.js.map +1 -0
- package/components/sankey/index.d.ts +59 -0
- package/components/sankey/index.js +306 -0
- package/components/sankey/index.js.map +1 -0
- package/components/sankey/modules/label.d.ts +23 -0
- package/components/sankey/modules/label.js +168 -0
- package/components/sankey/modules/label.js.map +1 -0
- package/components/sankey/modules/link.d.ts +14 -0
- package/components/sankey/modules/link.js +108 -0
- package/components/sankey/modules/link.js.map +1 -0
- package/components/sankey/modules/node.d.ts +10 -0
- package/components/sankey/modules/node.js +156 -0
- package/components/sankey/modules/node.js.map +1 -0
- package/components/sankey/style.d.ts +20 -0
- package/{src/components/sankey/style.ts → components/sankey/style.js} +44 -60
- package/components/sankey/style.js.map +1 -0
- package/components/sankey/types.d.ts +84 -0
- package/components/sankey/types.js +34 -0
- package/components/sankey/types.js.map +1 -0
- package/components/scatter/config.d.ts +44 -0
- package/components/scatter/config.js +23 -0
- package/components/scatter/config.js.map +1 -0
- package/components/scatter/index.d.ts +28 -0
- package/components/scatter/index.js +167 -0
- package/components/scatter/index.js.map +1 -0
- package/components/scatter/modules/point.d.ts +7 -0
- package/components/scatter/modules/point.js +86 -0
- package/components/scatter/modules/point.js.map +1 -0
- package/components/scatter/modules/utils.d.ts +11 -0
- package/components/scatter/modules/utils.js +112 -0
- package/components/scatter/modules/utils.js.map +1 -0
- package/components/scatter/style.d.ts +5 -0
- package/{src/components/scatter/style.ts → components/scatter/style.js} +14 -15
- package/components/scatter/style.js.map +1 -0
- package/components/scatter/types.d.ts +19 -0
- package/components/stacked-bar/config.d.ts +38 -0
- package/components/stacked-bar/config.js +20 -0
- package/components/stacked-bar/config.js.map +1 -0
- package/components/stacked-bar/index.d.ts +28 -0
- package/components/stacked-bar/index.js +208 -0
- package/components/stacked-bar/index.js.map +1 -0
- package/components/stacked-bar/style.d.ts +5 -0
- package/{src/components/stacked-bar/style.ts → components/stacked-bar/style.js} +14 -15
- package/components/stacked-bar/style.js.map +1 -0
- package/components/stacked-bar/types.d.ts +5 -0
- package/components/timeline/config.d.ts +43 -0
- package/components/timeline/config.js +24 -0
- package/components/timeline/config.js.map +1 -0
- package/components/timeline/index.d.ts +41 -0
- package/components/timeline/index.js +244 -0
- package/components/timeline/index.js.map +1 -0
- package/components/timeline/style.d.ts +13 -0
- package/{src/components/timeline/style.ts → components/timeline/style.js} +30 -39
- package/components/timeline/style.js.map +1 -0
- package/components/tooltip/config.d.ts +68 -0
- package/components/tooltip/config.js +20 -0
- package/components/tooltip/config.js.map +1 -0
- package/components/tooltip/index.d.ts +36 -0
- package/components/tooltip/index.js +184 -0
- package/components/tooltip/index.js.map +1 -0
- package/{src/components → components}/tooltip/style.js +14 -11
- package/components/tooltip/style.js.map +1 -0
- package/components/topojson-map/config.d.ts +99 -0
- package/components/topojson-map/config.js +42 -0
- package/components/topojson-map/config.js.map +1 -0
- package/components/topojson-map/index.d.ts +52 -0
- package/components/topojson-map/index.js +355 -0
- package/components/topojson-map/index.js.map +1 -0
- package/components/topojson-map/style.d.ts +11 -0
- package/{src/components/topojson-map/style.ts → components/topojson-map/style.js} +26 -33
- package/components/topojson-map/style.js.map +1 -0
- package/components/topojson-map/types.d.ts +78 -0
- package/components/topojson-map/types.js +80 -0
- package/components/topojson-map/types.js.map +1 -0
- package/components/topojson-map/utils.d.ts +3 -0
- package/components/topojson-map/utils.js +30 -0
- package/components/topojson-map/utils.js.map +1 -0
- package/components/vis-controls/config.d.ts +12 -0
- package/components/vis-controls/config.js +13 -0
- package/components/vis-controls/config.js.map +1 -0
- package/components/vis-controls/index.d.ts +14 -0
- package/components/vis-controls/index.js +52 -0
- package/components/vis-controls/index.js.map +1 -0
- package/components/vis-controls/style.d.ts +11 -0
- package/{src/components/vis-controls/style.ts → components/vis-controls/style.js} +27 -34
- package/components/vis-controls/style.js.map +1 -0
- package/components/vis-controls/types.d.ts +13 -0
- package/components/vis-controls/types.js +8 -0
- package/components/vis-controls/types.js.map +1 -0
- package/components/xy-labels/config.d.ts +48 -0
- package/components/xy-labels/config.js +25 -0
- package/components/xy-labels/config.js.map +1 -0
- package/components/xy-labels/index.d.ts +15 -0
- package/components/xy-labels/index.js +87 -0
- package/components/xy-labels/index.js.map +1 -0
- package/components/xy-labels/modules/label.d.ts +9 -0
- package/components/xy-labels/modules/label.js +107 -0
- package/components/xy-labels/modules/label.js.map +1 -0
- package/components/xy-labels/style.d.ts +5 -0
- package/{src/components/xy-labels/style.ts → components/xy-labels/style.js} +14 -15
- package/components/xy-labels/style.js.map +1 -0
- package/components/xy-labels/types.d.ts +23 -0
- package/components/xy-labels/types.js +9 -0
- package/components/xy-labels/types.js.map +1 -0
- package/components.d.ts +51 -0
- package/components.js +29 -0
- package/components.js.map +1 -0
- package/containers/single-container/config.d.ts +12 -0
- package/containers/single-container/config.js +12 -0
- package/containers/single-container/config.js.map +1 -0
- package/containers/single-container/index.d.ts +19 -0
- package/containers/single-container/index.js +128 -0
- package/containers/single-container/index.js.map +1 -0
- package/containers/xy-container/config.d.ts +99 -0
- package/containers/xy-container/config.js +30 -0
- package/containers/xy-container/config.js.map +1 -0
- package/containers/xy-container/index.d.ts +34 -0
- package/containers/xy-container/index.js +330 -0
- package/containers/xy-container/index.js.map +1 -0
- package/containers.d.ts +6 -0
- package/containers.js +4 -0
- package/containers.js.map +1 -0
- package/core/component/config.d.ts +58 -0
- package/core/component/config.js +14 -0
- package/core/component/config.js.map +1 -0
- package/core/component/index.d.ts +43 -0
- package/core/component/index.js +118 -0
- package/core/component/index.js.map +1 -0
- package/core/component/types.d.ts +2 -0
- package/core/component/types.js +2 -0
- package/core/component/types.js.map +1 -0
- package/core/config/index.d.ts +3 -0
- package/core/config/index.js +16 -0
- package/core/config/index.js.map +1 -0
- package/core/container/config.d.ts +48 -0
- package/core/container/config.js +29 -0
- package/core/container/config.js.map +1 -0
- package/core/container/index.d.ts +26 -0
- package/core/container/index.js +106 -0
- package/core/container/index.js.map +1 -0
- package/core/xy-component/config.d.ts +38 -0
- package/core/xy-component/config.js +20 -0
- package/core/xy-component/config.js.map +1 -0
- package/core/xy-component/index.d.ts +27 -0
- package/core/xy-component/index.js +74 -0
- package/core/xy-component/index.js.map +1 -0
- package/data-models/core.d.ts +6 -0
- package/data-models/core.js +14 -0
- package/data-models/core.js.map +1 -0
- package/data-models/graph.d.ts +24 -0
- package/data-models/graph.js +107 -0
- package/data-models/graph.js.map +1 -0
- package/data-models/map-graph.d.ts +21 -0
- package/data-models/map-graph.js +62 -0
- package/data-models/map-graph.js.map +1 -0
- package/data-models/map.d.ts +5 -0
- package/data-models/map.js +12 -0
- package/data-models/map.js.map +1 -0
- package/data-models/series.d.ts +6 -0
- package/data-models/series.js +19 -0
- package/data-models/series.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +55 -0
- package/index.js.map +1 -0
- package/maps/china-provinces.json.js +140373 -0
- package/maps/fr-regions.json.js +14162 -0
- package/maps/germany-regions.json.js +35760 -0
- package/maps/ind-regions.json.js +290584 -0
- package/maps/uk-regions.json.js +96233 -0
- package/maps/us-counties.json.js +206318 -0
- package/maps/us-states.json.js +16345 -0
- package/maps/world-110m-alpha.json.js +251366 -0
- package/maps/world-simple.json.js +89428 -0
- package/maps/world-simplest.json.js +28175 -0
- package/maps.d.ts +60 -0
- package/maps.js +23 -0
- package/package.json +1 -1
- package/styles/colors.d.ts +7 -0
- package/styles/colors.js +24 -0
- package/styles/colors.js.map +1 -0
- package/styles/index.d.ts +7 -0
- package/styles/index.js +38 -0
- package/styles/index.js.map +1 -0
- package/styles/sizes.d.ts +2 -0
- package/{src/styles/sizes.ts → styles/sizes.js} +8 -6
- package/styles/sizes.js.map +1 -0
- package/types/accessor.d.ts +5 -0
- package/types/accessor.js +2 -0
- package/types/accessor.js.map +1 -0
- package/types/component.d.ts +13 -0
- package/types/component.js +14 -0
- package/types/component.js.map +1 -0
- package/types/curve.d.ts +40 -0
- package/types/curve.js +46 -0
- package/types/curve.js.map +1 -0
- package/types/data.d.ts +7 -0
- package/types/data.js +2 -0
- package/types/data.js.map +1 -0
- package/types/direction.d.ts +6 -0
- package/types/direction.js +10 -0
- package/types/direction.js.map +1 -0
- package/types/graph.d.ts +35 -0
- package/types/graph.js +2 -0
- package/types/graph.js.map +1 -0
- package/types/map.d.ts +4 -0
- package/types/map.js +2 -0
- package/types/map.js.map +1 -0
- package/types/misc.d.ts +8 -0
- package/types/position.d.ts +20 -0
- package/types/position.js +27 -0
- package/types/position.js.map +1 -0
- package/types/scale.d.ts +23 -0
- package/types/scale.js +27 -0
- package/types/scale.js.map +1 -0
- package/types/shape.d.ts +7 -0
- package/types/shape.js +11 -0
- package/types/shape.js.map +1 -0
- package/types/spacing.d.ts +6 -0
- package/types/spacing.js +2 -0
- package/types/spacing.js.map +1 -0
- package/types/svg.d.ts +18 -0
- package/types/svg.js +22 -0
- package/types/svg.js.map +1 -0
- package/types/symbol.d.ts +18 -0
- package/types/symbol.js +24 -0
- package/types/symbol.js.map +1 -0
- package/types/text.d.ts +47 -0
- package/types/text.js +26 -0
- package/types/text.js.map +1 -0
- package/types.d.ts +27 -0
- package/types.js +30 -0
- package/types.js.map +1 -0
- package/utils/color.d.ts +10 -0
- package/utils/color.js +32 -0
- package/utils/color.js.map +1 -0
- package/utils/d3.d.ts +3 -0
- package/utils/d3.js +16 -0
- package/utils/d3.js.map +1 -0
- package/utils/data.d.ts +45 -0
- package/utils/data.js +274 -0
- package/utils/data.js.map +1 -0
- package/utils/html.d.ts +1 -0
- package/utils/html.js +16 -0
- package/utils/html.js.map +1 -0
- package/utils/map.d.ts +2 -0
- package/utils/map.js +20 -0
- package/utils/map.js.map +1 -0
- package/utils/misc.d.ts +9 -0
- package/utils/misc.js +47 -0
- package/utils/misc.js.map +1 -0
- package/utils/path.d.ts +23 -0
- package/utils/path.js +144 -0
- package/utils/path.js.map +1 -0
- package/utils/scale.d.ts +1 -0
- package/utils/style.d.ts +6 -0
- package/utils/style.js +24 -0
- package/utils/style.js.map +1 -0
- package/utils/svg.d.ts +3 -0
- package/utils/text.d.ts +139 -0
- package/utils/text.js +443 -0
- package/utils/text.js.map +1 -0
- package/utils/type.d.ts +5 -0
- package/declaration.d.ts +0 -1
- package/index.ts +0 -1
- package/licences.txt +0 -43
- package/maps.ts +0 -1
- package/rollup.config.js +0 -71
- package/rules/ts-getter-setter.js +0 -35
- package/src/components/area/config.ts +0 -29
- package/src/components/area/index.ts +0 -133
- package/src/components/area/types.ts +0 -2
- package/src/components/axis/config.ts +0 -76
- package/src/components/axis/index.ts +0 -363
- package/src/components/axis/types.ts +0 -4
- package/src/components/brush/config.ts +0 -51
- package/src/components/brush/index.ts +0 -233
- package/src/components/brush/types.ts +0 -8
- package/src/components/bullet-legend/config.ts +0 -38
- package/src/components/bullet-legend/index.ts +0 -104
- package/src/components/bullet-legend/types.ts +0 -7
- package/src/components/chord-diagram/config.ts +0 -53
- package/src/components/chord-diagram/index.ts +0 -401
- package/src/components/chord-diagram/modules/label.ts +0 -155
- package/src/components/chord-diagram/modules/link.ts +0 -91
- package/src/components/chord-diagram/modules/node.ts +0 -80
- package/src/components/chord-diagram/types.ts +0 -68
- package/src/components/crosshair/config.ts +0 -48
- package/src/components/crosshair/index.ts +0 -220
- package/src/components/crosshair/types.ts +0 -15
- package/src/components/donut/config.ts +0 -65
- package/src/components/donut/index.ts +0 -148
- package/src/components/donut/modules/arc.ts +0 -86
- package/src/components/donut/types.ts +0 -17
- package/src/components/flow-legend/config.ts +0 -31
- package/src/components/flow-legend/index.ts +0 -103
- package/src/components/flow-legend/types.ts +0 -10
- package/src/components/free-brush/config.ts +0 -54
- package/src/components/free-brush/index.ts +0 -207
- package/src/components/free-brush/types.ts +0 -8
- package/src/components/graph/config.ts +0 -280
- package/src/components/graph/index.ts +0 -809
- package/src/components/graph/modules/layout-helpers.ts +0 -96
- package/src/components/graph/modules/layout.ts +0 -502
- package/src/components/graph/modules/link/helper.ts +0 -105
- package/src/components/graph/modules/link/index.ts +0 -302
- package/src/components/graph/modules/node/helper.ts +0 -162
- package/src/components/graph/modules/node/index.ts +0 -343
- package/src/components/graph/modules/panel/helper.ts +0 -160
- package/src/components/graph/modules/panel/index.ts +0 -137
- package/src/components/graph/modules/shape.ts +0 -108
- package/src/components/graph/modules/zoom-levels.ts +0 -6
- package/src/components/graph/style.ts +0 -72
- package/src/components/graph/types.ts +0 -152
- package/src/components/grouped-bar/config.ts +0 -40
- package/src/components/grouped-bar/index.ts +0 -325
- package/src/components/leaflet-flow-map/config.ts +0 -60
- package/src/components/leaflet-flow-map/index.ts +0 -279
- package/src/components/leaflet-flow-map/renderer-utils.ts +0 -14
- package/src/components/leaflet-flow-map/renderer.ts +0 -146
- package/src/components/leaflet-flow-map/types.ts +0 -18
- package/src/components/leaflet-map/config.ts +0 -234
- package/src/components/leaflet-map/index.ts +0 -808
- package/src/components/leaflet-map/leaflet.css +0 -625
- package/src/components/leaflet-map/modules/clusterBackground.ts +0 -34
- package/src/components/leaflet-map/modules/donut.ts +0 -37
- package/src/components/leaflet-map/modules/map.ts +0 -178
- package/src/components/leaflet-map/modules/node.ts +0 -208
- package/src/components/leaflet-map/modules/selectionRing.ts +0 -63
- package/src/components/leaflet-map/modules/utils.ts +0 -290
- package/src/components/leaflet-map/renderer/map-style.ts +0 -24
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json +0 -35
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json +0 -35
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json +0 -2185
- package/src/components/leaflet-map/renderer/mapboxgl-layer.ts +0 -43
- package/src/components/leaflet-map/renderer/mapboxgl-utils.ts +0 -40
- package/src/components/leaflet-map/style.ts +0 -217
- package/src/components/leaflet-map/types.ts +0 -75
- package/src/components/line/config.ts +0 -34
- package/src/components/line/index.ts +0 -188
- package/src/components/line/types.ts +0 -3
- package/src/components/nested-donut/config.ts +0 -75
- package/src/components/nested-donut/index.ts +0 -176
- package/src/components/nested-donut/modules/arc.ts +0 -78
- package/src/components/nested-donut/modules/label.ts +0 -63
- package/src/components/nested-donut/style.ts +0 -82
- package/src/components/nested-donut/types.ts +0 -29
- package/src/components/sankey/config.ts +0 -195
- package/src/components/sankey/index.ts +0 -387
- package/src/components/sankey/modules/label.ts +0 -228
- package/src/components/sankey/modules/link.ts +0 -141
- package/src/components/sankey/modules/node.ts +0 -221
- package/src/components/sankey/types.ts +0 -95
- package/src/components/scatter/config.ts +0 -49
- package/src/components/scatter/index.ts +0 -220
- package/src/components/scatter/modules/point.ts +0 -123
- package/src/components/scatter/modules/utils.ts +0 -150
- package/src/components/scatter/types.ts +0 -21
- package/src/components/stacked-bar/config.ts +0 -42
- package/src/components/stacked-bar/index.ts +0 -267
- package/src/components/stacked-bar/types.ts +0 -5
- package/src/components/timeline/config.ts +0 -49
- package/src/components/timeline/index.ts +0 -302
- package/src/components/tooltip/config.ts +0 -69
- package/src/components/tooltip/index.ts +0 -220
- package/src/components/topojson-map/config.ts +0 -124
- package/src/components/topojson-map/index.ts +0 -436
- package/src/components/topojson-map/types.ts +0 -123
- package/src/components/topojson-map/utils.ts +0 -29
- package/src/components/vis-controls/config.ts +0 -16
- package/src/components/vis-controls/index.ts +0 -68
- package/src/components/vis-controls/types.ts +0 -14
- package/src/components/xy-labels/config.ts +0 -56
- package/src/components/xy-labels/index.ts +0 -109
- package/src/components/xy-labels/modules/label.ts +0 -140
- package/src/components/xy-labels/types.ts +0 -26
- package/src/components.ts +0 -56
- package/src/containers/single-container/config.ts +0 -15
- package/src/containers/single-container/index.ts +0 -150
- package/src/containers/xy-container/config.ts +0 -112
- package/src/containers/xy-container/index.ts +0 -407
- package/src/containers.ts +0 -6
- package/src/core/component/config.ts +0 -61
- package/src/core/component/index.ts +0 -154
- package/src/core/component/types.ts +0 -9
- package/src/core/config/index.ts +0 -12
- package/src/core/container/config.ts +0 -56
- package/src/core/container/index.ts +0 -136
- package/src/core/xy-component/config.ts +0 -46
- package/src/core/xy-component/index.ts +0 -90
- package/src/data-models/core.ts +0 -15
- package/src/data-models/graph.ts +0 -138
- package/src/data-models/map-graph.ts +0 -72
- package/src/data-models/map.ts +0 -18
- package/src/data-models/series.ts +0 -16
- package/src/index.ts +0 -7
- package/src/maps/china-provinces.json +0 -1
- package/src/maps/fr-regions.json +0 -1
- package/src/maps/germany-regions.json +0 -1
- package/src/maps/ind-regions.json +0 -1
- package/src/maps/uk-regions.json +0 -1
- package/src/maps/us-counties.json +0 -1
- package/src/maps/us-states.json +0 -1
- package/src/maps/world-110m-alpha.json +0 -1
- package/src/maps/world-simple.json +0 -1
- package/src/maps/world-simplest.json +0 -1
- package/src/maps.ts +0 -34
- package/src/styles/colors.ts +0 -28
- package/src/styles/index.ts +0 -38
- package/src/types/accessor.ts +0 -5
- package/src/types/component.ts +0 -15
- package/src/types/curve.ts +0 -62
- package/src/types/data.ts +0 -5
- package/src/types/direction.ts +0 -6
- package/src/types/graph.ts +0 -40
- package/src/types/map.ts +0 -5
- package/src/types/misc.ts +0 -10
- package/src/types/position.ts +0 -23
- package/src/types/scale.ts +0 -47
- package/src/types/shape.ts +0 -7
- package/src/types/spacing.ts +0 -6
- package/src/types/svg.ts +0 -32
- package/src/types/symbol.ts +0 -21
- package/src/types/text.ts +0 -71
- package/src/types.ts +0 -31
- package/src/utils/color.ts +0 -41
- package/src/utils/d3.ts +0 -15
- package/src/utils/data.ts +0 -328
- package/src/utils/html.ts +0 -13
- package/src/utils/map.ts +0 -29
- package/src/utils/misc.ts +0 -54
- package/src/utils/path.ts +0 -196
- package/src/utils/scale.ts +0 -1
- package/src/utils/style.ts +0 -37
- package/src/utils/svg.ts +0 -49
- package/src/utils/text.ts +0 -529
- package/src/utils/type.ts +0 -9
- package/tsconfig.json +0 -29
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { brushX } from 'd3-brush';
|
|
2
|
+
import { XYComponentCore } from '../../core/xy-component/index.js';
|
|
3
|
+
import { isNumber, clamp } from '../../utils/data.js';
|
|
4
|
+
import { smartTransition } from '../../utils/d3.js';
|
|
5
|
+
import { Arrangement } from '../../types/position.js';
|
|
6
|
+
import { BrushConfig } from './config.js';
|
|
7
|
+
import { BrushDirection } from './types.js';
|
|
8
|
+
import * as style from './style.js';
|
|
9
|
+
import { brush, unselected, handleLine } from './style.js';
|
|
10
|
+
|
|
11
|
+
class Brush extends XYComponentCore {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
super();
|
|
14
|
+
this.clippable = false; // Don't apply clipping path to this component. See XYContainer
|
|
15
|
+
this.config = new BrushConfig();
|
|
16
|
+
this.brushBehaviour = brushX();
|
|
17
|
+
this.events = {
|
|
18
|
+
[Brush.selectors.brush]: {},
|
|
19
|
+
};
|
|
20
|
+
this._selection = null;
|
|
21
|
+
this._firstRender = true;
|
|
22
|
+
if (config)
|
|
23
|
+
this.config.init(config);
|
|
24
|
+
this.brush = this.g
|
|
25
|
+
.append('g')
|
|
26
|
+
.attr('class', brush);
|
|
27
|
+
const directions = [{ type: BrushDirection.West }, { type: BrushDirection.East }];
|
|
28
|
+
this.unselectedRange = this.g
|
|
29
|
+
.selectAll(`.${unselected}`)
|
|
30
|
+
.data(directions)
|
|
31
|
+
.enter().append('rect')
|
|
32
|
+
.attr('class', unselected);
|
|
33
|
+
this.handleLines = this.g
|
|
34
|
+
.selectAll(`.${handleLine}`)
|
|
35
|
+
.data(directions)
|
|
36
|
+
.enter().append('line')
|
|
37
|
+
.attr('class', handleLine);
|
|
38
|
+
}
|
|
39
|
+
_render(customDuration) {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
const { brushBehaviour, config } = this;
|
|
42
|
+
const duration = isNumber(customDuration) ? customDuration : config.duration;
|
|
43
|
+
const xScale = this.xScale;
|
|
44
|
+
brushBehaviour
|
|
45
|
+
.extent([[0, 0], [this._width, this._height]])
|
|
46
|
+
.on('start', this._onBrushStart.bind(this))
|
|
47
|
+
.on('brush', this._onBrushMove.bind(this))
|
|
48
|
+
.on('end', this._onBrushEnd.bind(this));
|
|
49
|
+
this.brush
|
|
50
|
+
.call(brushBehaviour)
|
|
51
|
+
.classed('non-draggable', !config.draggable);
|
|
52
|
+
const yRange = [this._height, 0];
|
|
53
|
+
const h = yRange[0] - yRange[1];
|
|
54
|
+
this.g.selectAll('.handle')
|
|
55
|
+
.attr('y', yRange[1])
|
|
56
|
+
.attr('height', h);
|
|
57
|
+
this.unselectedRange
|
|
58
|
+
.attr('y', yRange[1])
|
|
59
|
+
.attr('height', h);
|
|
60
|
+
this.handleLines
|
|
61
|
+
.attr('y1', yRange[1] + 10)
|
|
62
|
+
.attr('y2', yRange[1] + h - 10);
|
|
63
|
+
// We save the X scale range and set it to the available horizontal space to calculate the selection range in pixels correctly
|
|
64
|
+
const xRange = [0, this._width];
|
|
65
|
+
const xScaleRange = xScale.range();
|
|
66
|
+
xScale.range(xRange);
|
|
67
|
+
const selectionMin = clamp((_b = xScale((_a = (config.selection || this._selection)) === null || _a === void 0 ? void 0 : _a[0])) !== null && _b !== void 0 ? _b : 0, xRange[0], xRange[1]);
|
|
68
|
+
const selectionMax = clamp((_d = xScale((_c = (config.selection || this._selection)) === null || _c === void 0 ? void 0 : _c[1])) !== null && _d !== void 0 ? _d : 0, xRange[0], xRange[1]);
|
|
69
|
+
xScale.range(xScaleRange); // Restore the X scale range
|
|
70
|
+
const selectionLength = selectionMax - selectionMin;
|
|
71
|
+
const brushRange = (selectionLength ? [selectionMin, selectionMax] : xRange);
|
|
72
|
+
this._positionHandles(brushRange);
|
|
73
|
+
smartTransition(this.brush, duration)
|
|
74
|
+
.call(brushBehaviour.move, brushRange) // Sets up the brush and calls brush events
|
|
75
|
+
.on('end interrupt', () => { this._firstRender = false; });
|
|
76
|
+
// We track the first render to not trigger user events on component initialization
|
|
77
|
+
if (!duration)
|
|
78
|
+
this._firstRender = false;
|
|
79
|
+
}
|
|
80
|
+
_updateSelection(s) {
|
|
81
|
+
const xRange = [0, this._width];
|
|
82
|
+
this.unselectedRange
|
|
83
|
+
.attr('x', d => d.type === BrushDirection.West ? xRange[0] : s[1])
|
|
84
|
+
.attr('width', d => {
|
|
85
|
+
const length = d.type === BrushDirection.West ? s[0] - xRange[0] : xRange[1] - s[1];
|
|
86
|
+
const lengthClamped = clamp(length, 0, xRange[1] - xRange[0]);
|
|
87
|
+
return lengthClamped;
|
|
88
|
+
});
|
|
89
|
+
this._positionHandles(s);
|
|
90
|
+
// D3 sets brush handle height to be too long, so we need to update it
|
|
91
|
+
const yRange = [this._height, 0];
|
|
92
|
+
const h = yRange[0] - yRange[1];
|
|
93
|
+
this.g.selectAll('.handle')
|
|
94
|
+
.attr('y', yRange[1])
|
|
95
|
+
.attr('height', h);
|
|
96
|
+
}
|
|
97
|
+
_positionHandles(s) {
|
|
98
|
+
const { config } = this;
|
|
99
|
+
this.brush.selectAll('.handle')
|
|
100
|
+
.attr('width', config.handleWidth)
|
|
101
|
+
.attr('x', d => {
|
|
102
|
+
if (!s)
|
|
103
|
+
return 0;
|
|
104
|
+
const west = d.type === BrushDirection.West;
|
|
105
|
+
const inside = config.handlePosition === Arrangement.Inside;
|
|
106
|
+
if (west)
|
|
107
|
+
return s[0] + (inside ? 0 : -config.handleWidth);
|
|
108
|
+
else
|
|
109
|
+
return s[1] + (inside ? -config.handleWidth : 0);
|
|
110
|
+
});
|
|
111
|
+
this.handleLines
|
|
112
|
+
.attr('transform', d => {
|
|
113
|
+
if (!s)
|
|
114
|
+
return null;
|
|
115
|
+
const west = d.type === BrushDirection.West;
|
|
116
|
+
const inside = config.handlePosition === Arrangement.Inside;
|
|
117
|
+
return `translate(${west
|
|
118
|
+
? s[0] - Math.pow((-1), Number(inside)) * config.handleWidth / 2
|
|
119
|
+
: s[1] + Math.pow((-1), Number(inside)) * config.handleWidth / 2},0)`;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
_onBrush(event) {
|
|
123
|
+
var _a;
|
|
124
|
+
const { config } = this;
|
|
125
|
+
const xScale = this.xScale;
|
|
126
|
+
const xRange = [0, this._width];
|
|
127
|
+
const s = ((event === null || event === void 0 ? void 0 : event.selection) || xRange);
|
|
128
|
+
const userDriven = !!(event === null || event === void 0 ? void 0 : event.sourceEvent);
|
|
129
|
+
// Handle edge cases:
|
|
130
|
+
// (event?.selection === null) happens when user clicks to reset the selection
|
|
131
|
+
// (s?.[0] === s?.[1]) happens when user drags the selection out of range
|
|
132
|
+
if (userDriven && (((event === null || event === void 0 ? void 0 : event.selection) === null) || // happens when user clicks to reset the selection
|
|
133
|
+
((s === null || s === void 0 ? void 0 : s[0]) === (s === null || s === void 0 ? void 0 : s[1])) || // happens when user drags the selection out of range
|
|
134
|
+
((s === null || s === void 0 ? void 0 : s[0]) < xRange[0]) || //
|
|
135
|
+
((s === null || s === void 0 ? void 0 : s[0]) > xRange[1]) || // happens when you drag the brush and the domain updates
|
|
136
|
+
((s === null || s === void 0 ? void 0 : s[1]) < xRange[0]) || // to a smaller one and brush goes out of range
|
|
137
|
+
((s === null || s === void 0 ? void 0 : s[1]) > xRange[1]) //
|
|
138
|
+
)) {
|
|
139
|
+
this.brush.call(this.brushBehaviour.move, xRange); // Will trigger the 'brush end' callback with `range`
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// When you reset selection by clicking on a non-selected brush area, D3 triggers the brush event twice.
|
|
143
|
+
// The first call will have equal selection coordinates (e.g. [441, 441]), the second call will have the full range (e.g. [0, 700]).
|
|
144
|
+
// To avoid unnecessary render from the first call we skip it
|
|
145
|
+
if (s[0] !== s[1] && isNumber(s[0]) && isNumber(s[1])) {
|
|
146
|
+
// We save the X scale range and set it to the available horizontal space to invert the selection correctly
|
|
147
|
+
const xScaleRange = xScale.range();
|
|
148
|
+
xScale.range(xRange);
|
|
149
|
+
const selectedDomain = s.map(n => +xScale.invert(n));
|
|
150
|
+
if (userDriven) {
|
|
151
|
+
// Constraint the selection if configured
|
|
152
|
+
const xDomain = xScale.domain();
|
|
153
|
+
const xDomainLength = Math.abs(xDomain[1] - xDomain[0]);
|
|
154
|
+
const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0]);
|
|
155
|
+
if (config.selectionMinLength >= xDomainLength) {
|
|
156
|
+
console.warn('Unovis | Brush: Configured `selectionMinLength` is bigger than the brush domain');
|
|
157
|
+
}
|
|
158
|
+
if ((selectionLength < config.selectionMinLength) && (config.selectionMinLength < xDomainLength)) {
|
|
159
|
+
const selection = (_a = config.selection) !== null && _a !== void 0 ? _a : this._selection;
|
|
160
|
+
const range = [xScale(selection[0]), xScale(selection[1])];
|
|
161
|
+
this.brush.call(this.brushBehaviour.move, range); // Will trigger the 'brush end' callback with `range`
|
|
162
|
+
// Restore the X scale range
|
|
163
|
+
xScale.range(xScaleRange);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this._selection = selectedDomain;
|
|
168
|
+
// Restore the X scale range
|
|
169
|
+
xScale.range(xScaleRange);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
this._updateSelection(s);
|
|
173
|
+
if (!this._firstRender)
|
|
174
|
+
config.onBrush(selectedDomain, event, userDriven);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_onBrushStart(event) {
|
|
178
|
+
const { config } = this;
|
|
179
|
+
this._onBrush(event);
|
|
180
|
+
if (!this._firstRender)
|
|
181
|
+
config.onBrushStart(this._selection, event, !!(event === null || event === void 0 ? void 0 : event.sourceEvent));
|
|
182
|
+
}
|
|
183
|
+
_onBrushMove(event) {
|
|
184
|
+
const { config } = this;
|
|
185
|
+
this._onBrush(event);
|
|
186
|
+
if (!this._firstRender)
|
|
187
|
+
config.onBrushMove(this._selection, event, !!(event === null || event === void 0 ? void 0 : event.sourceEvent));
|
|
188
|
+
}
|
|
189
|
+
_onBrushEnd(event) {
|
|
190
|
+
const { config } = this;
|
|
191
|
+
this._onBrush(event);
|
|
192
|
+
if (!this._firstRender)
|
|
193
|
+
config.onBrushEnd(this._selection, event, !!(event === null || event === void 0 ? void 0 : event.sourceEvent));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
Brush.selectors = style;
|
|
197
|
+
|
|
198
|
+
export { Brush };
|
|
199
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/brush/index.ts"],"sourcesContent":["import { BrushBehavior, brushX, D3BrushEvent } from 'd3-brush'\nimport { Selection } from 'd3-selection'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, clamp } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// Config\nimport { BrushConfig, BrushConfigInterface } from './config'\n\n// Local Types\nimport { BrushDirection, BrushHandleType } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class Brush<Datum> extends XYComponentCore<Datum, BrushConfig<Datum>, BrushConfigInterface<Datum>> {\n static selectors = s\n clippable = false // Don't apply clipping path to this component. See XYContainer\n config: BrushConfig<Datum> = new BrushConfig()\n brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n unselectedRange: Selection<SVGRectElement, BrushHandleType, SVGGElement, unknown>\n handleLines: Selection<SVGLineElement, BrushHandleType, SVGGElement, unknown>\n brushBehaviour: BrushBehavior<unknown> = brushX()\n events = {\n [Brush.selectors.brush]: {},\n }\n\n private _selection: [number, number] | null = null\n private _firstRender = true\n\n constructor (config?: BrushConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n\n const directions: BrushHandleType[] = [{ type: BrushDirection.West }, { type: BrushDirection.East }]\n this.unselectedRange = this.g\n .selectAll(`.${s.unselected}`)\n .data(directions)\n .enter().append('rect')\n .attr('class', s.unselected)\n\n this.handleLines = this.g\n .selectAll(`.${s.handleLine}`)\n .data(directions)\n .enter().append('line')\n .attr('class', s.handleLine)\n }\n\n _render (customDuration?: number): void {\n const { brushBehaviour, config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const xScale = this.xScale\n\n brushBehaviour\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(brushBehaviour)\n .classed('non-draggable', !config.draggable)\n\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.unselectedRange\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.handleLines\n .attr('y1', yRange[1] + 10)\n .attr('y2', yRange[1] + h - 10)\n\n // We save the X scale range and set it to the available horizontal space to calculate the selection range in pixels correctly\n const xRange = [0, this._width]\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectionMin = clamp(xScale((config.selection || this._selection)?.[0]) ?? 0, xRange[0], xRange[1])\n const selectionMax = clamp(xScale((config.selection || this._selection)?.[1]) ?? 0, xRange[0], xRange[1])\n xScale.range(xScaleRange) // Restore the X scale range\n\n const selectionLength = selectionMax - selectionMin\n const brushRange = (selectionLength ? [selectionMin, selectionMax] : xRange) as [number, number]\n this._positionHandles(brushRange)\n\n smartTransition(this.brush, duration)\n .call(brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n // We track the first render to not trigger user events on component initialization\n if (!duration) this._firstRender = false\n }\n\n _updateSelection (s: [number, number]): void {\n const xRange = [0, this._width]\n this.unselectedRange\n .attr('x', d => d.type === BrushDirection.West ? xRange[0] : s[1])\n .attr('width', d => {\n const length = d.type === BrushDirection.West ? s[0] - xRange[0] : xRange[1] - s[1]\n const lengthClamped = clamp(length, 0, xRange[1] - xRange[0])\n return lengthClamped\n })\n\n this._positionHandles(s)\n\n // D3 sets brush handle height to be too long, so we need to update it\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n }\n\n private _positionHandles (s: [number, number]): void {\n const { config } = this\n\n this.brush.selectAll<SVGRectElement, BrushHandleType>('.handle')\n .attr('width', config.handleWidth)\n .attr('x', d => {\n if (!s) return 0\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n\n if (west) return s[0] + (inside ? 0 : -config.handleWidth)\n else return s[1] + (inside ? -config.handleWidth : 0)\n })\n\n this.handleLines\n .attr('transform', d => {\n if (!s) return null\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n return `translate(${west\n ? s[0] - (-1) ** Number(inside) * config.handleWidth / 2\n : s[1] + (-1) ** Number(inside) * config.handleWidth / 2},0)`\n })\n }\n\n _onBrush (event: D3BrushEvent<Datum>): void {\n const { config } = this\n const xScale = this.xScale\n const xRange = [0, this._width]\n const s = (event?.selection || xRange) as [number, number]\n const userDriven = !!event?.sourceEvent\n // Handle edge cases:\n // (event?.selection === null) happens when user clicks to reset the selection\n // (s?.[0] === s?.[1]) happens when user drags the selection out of range\n if (userDriven && (\n (event?.selection === null) || // happens when user clicks to reset the selection\n (s?.[0] === s?.[1]) || // happens when user drags the selection out of range\n (s?.[0] < xRange[0]) || //\n (s?.[0] > xRange[1]) || // happens when you drag the brush and the domain updates\n (s?.[1] < xRange[0]) || // to a smaller one and brush goes out of range\n (s?.[1] > xRange[1]) //\n )) {\n this.brush.call(this.brushBehaviour.move, xRange) // Will trigger the 'brush end' callback with `range`\n return\n }\n\n // When you reset selection by clicking on a non-selected brush area, D3 triggers the brush event twice.\n // The first call will have equal selection coordinates (e.g. [441, 441]), the second call will have the full range (e.g. [0, 700]).\n // To avoid unnecessary render from the first call we skip it\n if (s[0] !== s[1] && isNumber(s[0]) && isNumber(s[1])) {\n // We save the X scale range and set it to the available horizontal space to invert the selection correctly\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectedDomain = s.map(n => +xScale.invert(n)) as [number, number]\n\n if (userDriven) {\n // Constraint the selection if configured\n const xDomain = xScale.domain() as [number, number]\n const xDomainLength = Math.abs(xDomain[1] - xDomain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (config.selectionMinLength >= xDomainLength) {\n console.warn('Unovis | Brush: Configured `selectionMinLength` is bigger than the brush domain')\n }\n\n if ((selectionLength < config.selectionMinLength) && (config.selectionMinLength < xDomainLength)) {\n const selection = config.selection ?? this._selection\n const range = [xScale(selection[0]), xScale(selection[1])] as [number, number]\n this.brush.call(this.brushBehaviour.move, range) // Will trigger the 'brush end' callback with `range`\n // Restore the X scale range\n xScale.range(xScaleRange)\n return\n } else {\n this._selection = selectedDomain\n // Restore the X scale range\n xScale.range(xScaleRange)\n }\n }\n\n this._updateSelection(s)\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n }\n\n _onBrushStart (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushStart(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushMove (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushEnd (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushEnd(this._selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.unselected","s.handleLine","s"],"mappings":";;;;;;;;;;AAsBM,MAAO,KAAa,SAAQ,eAAuE,CAAA;AAevG,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAA;AACjB,QAAA,IAAA,CAAA,MAAM,GAAuB,IAAI,WAAW,EAAE,CAAA;QAI9C,IAAc,CAAA,cAAA,GAA2B,MAAM,EAAE,CAAA;AACjD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE;SAC5B,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,IAAI,CAAA;QAC1C,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;AAIzB,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEpC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;aAChB,MAAM,CAAC,GAAG,CAAC;AACX,aAAA,IAAI,CAAC,OAAO,EAAEA,KAAO,CAAC,CAAA;AAEzB,QAAA,MAAM,UAAU,GAAsB,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAA;AACpG,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;AAC1B,aAAA,SAAS,CAAC,CAAI,CAAA,EAAAC,UAAY,EAAE,CA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AC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACzF;AAED,IAAA,WAAW,CAAE,KAA0B,EAAA;AACrC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACxF;;AAhNM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { css, injectGlobal } from '@emotion/css'
|
|
1
|
+
import { css, injectGlobal } from '@emotion/css';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const root = css `
|
|
4
4
|
label: brush-component;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const variables = injectGlobal`
|
|
5
|
+
`;
|
|
6
|
+
const variables = injectGlobal `
|
|
8
7
|
:root {
|
|
9
8
|
--vis-brush-selection-fill-color: #0b1640;
|
|
10
9
|
--vis-brush-selection-stroke-color: #acb2b9;
|
|
@@ -23,9 +22,8 @@ export const variables = injectGlobal`
|
|
|
23
22
|
--vis-brush-handle-fill-color: var(--vis-dark-brush-handle-fill-color);
|
|
24
23
|
--vis-brush-handle-stroke-color: var(--vis-dark-brush-handle-stroke-color);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export const brush = css`
|
|
25
|
+
`;
|
|
26
|
+
const brush = css `
|
|
29
27
|
label: brush;
|
|
30
28
|
fill: none;
|
|
31
29
|
stroke: none;
|
|
@@ -46,19 +44,20 @@ export const brush = css`
|
|
|
46
44
|
pointer-events: none;
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export const unselected = css`
|
|
47
|
+
`;
|
|
48
|
+
const unselected = css `
|
|
52
49
|
label: unselected;
|
|
53
50
|
fill: var(--vis-brush-selection-fill-color);
|
|
54
51
|
opacity: 0.4;
|
|
55
52
|
pointer-events: none;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export const handleLine = css`
|
|
53
|
+
`;
|
|
54
|
+
const handleLine = css `
|
|
59
55
|
label: handle-line;
|
|
60
56
|
stroke: var(--vis-brush-handle-stroke-color);
|
|
61
57
|
stroke-width: 1;
|
|
62
58
|
fill: none;
|
|
63
59
|
pointer-events: none;
|
|
64
|
-
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
export { brush, handleLine, root, unselected, variables };
|
|
63
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/brush/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: brush-component;\n`\n\nexport const variables = injectGlobal`\n :root {\n --vis-brush-selection-fill-color: #0b1640;\n --vis-brush-selection-stroke-color: #acb2b9;\n --vis-brush-handle-fill-color: #6d778c;\n --vis-brush-handle-stroke-color: #eee;\n\n --vis-dark-brush-selection-fill-color:#acb2b9;\n --vis-dark-brush-selection-stroke-color: #0b1640;\n --vis-dark-brush-handle-fill-color: #acb2b9;\n --vis-dark-brush-handle-stroke-color: var(--vis-color-grey);\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-brush-selection-fill-color: var(--vis-dark-brush-selection-fill-color);\n --vis-brush-selection-stroke-color: var(--vis-dark-brush-selection-stroke-color);\n --vis-brush-handle-fill-color: var(--vis-dark-brush-handle-fill-color);\n --vis-brush-handle-stroke-color: var(--vis-dark-brush-handle-stroke-color);\n }\n`\n\nexport const brush = css`\n label: brush;\n fill: none;\n stroke: none;\n\n .selection {\n fill: none;\n stroke: var(--vis-brush-selection-stroke-color);\n stroke-width: 0;\n stroke-opacity: 0;\n }\n\n .handle {\n fill: var(--vis-brush-handle-fill-color);\n }\n\n &.non-draggable {\n .selection, .overlay {\n pointer-events: none;\n }\n }\n`\n\nexport const unselected = css`\n label: unselected;\n fill: var(--vis-brush-selection-fill-color);\n opacity: 0.4;\n pointer-events: none;\n`\n\nexport const handleLine = css`\n label: handle-line;\n stroke: var(--vis-brush-handle-stroke-color);\n stroke-width: 1;\n fill: none;\n pointer-events: none;\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;AAajB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;;;EAM7B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;EAqBvB;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;;EAK5B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/components/brush/types.ts"],"sourcesContent":["export type BrushHandleType = {\n type: BrushDirection;\n}\n\nexport enum BrushDirection {\n West = 'w', // D3 defines brush directions as 'w', 'e', ...\n East = 'e',\n}\n"],"names":[],"mappings":"IAIY,eAGX;AAHD,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACZ,CAAC,EAHW,cAAc,KAAd,cAAc,GAGzB,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Config } from "../../core/config";
|
|
2
|
+
import { BulletLegendItemInterface } from './types';
|
|
3
|
+
export interface BulletLegendConfigInterface {
|
|
4
|
+
/** Legend items. Array of `BulletLegendItemInterface`:
|
|
5
|
+
* ```
|
|
6
|
+
* {
|
|
7
|
+
* name: string | number;
|
|
8
|
+
* color?: string;
|
|
9
|
+
* inactive?: boolean;
|
|
10
|
+
* hidden?: boolean;
|
|
11
|
+
* pointer?: boolean;
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
* Default: `[]` */
|
|
15
|
+
items: BulletLegendItemInterface[];
|
|
16
|
+
/** Apply a specific class to the labels. Default: `''` */
|
|
17
|
+
labelClassName?: string;
|
|
18
|
+
/** Callback function for the legend item click. Default: `undefined` */
|
|
19
|
+
onLegendItemClick?: ((d: BulletLegendItemInterface, i: number) => void);
|
|
20
|
+
/** Label text (<span> element) font-size CSS. Default: `null` */
|
|
21
|
+
labelFontSize?: string | null;
|
|
22
|
+
/** Label text (<span> element) max-width CSS property. Default: `null` */
|
|
23
|
+
labelMaxWidth?: string | null;
|
|
24
|
+
/** Bullet circle size, mapped to the width and height CSS properties. Default: `null` */
|
|
25
|
+
bulletSize?: string | null;
|
|
26
|
+
}
|
|
27
|
+
export declare class BulletLegendConfig extends Config implements BulletLegendConfigInterface {
|
|
28
|
+
items: BulletLegendItemInterface[];
|
|
29
|
+
labelClassName: string;
|
|
30
|
+
onLegendItemClick: any;
|
|
31
|
+
labelFontSize: any;
|
|
32
|
+
labelMaxWidth: any;
|
|
33
|
+
bulletSize: any;
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Config } from '../../core/config/index.js';
|
|
2
|
+
|
|
3
|
+
class BulletLegendConfig extends Config {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.items = [];
|
|
7
|
+
this.labelClassName = '';
|
|
8
|
+
this.onLegendItemClick = undefined;
|
|
9
|
+
this.labelFontSize = null;
|
|
10
|
+
this.labelMaxWidth = null;
|
|
11
|
+
this.bulletSize = null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { BulletLegendConfig };
|
|
16
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/bullet-legend/config.ts"],"sourcesContent":["import { Config } from 'core/config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\nexport interface BulletLegendConfigInterface {\n /** Legend items. Array of `BulletLegendItemInterface`:\n * ```\n * {\n * name: string | number;\n * color?: string;\n * inactive?: boolean;\n * hidden?: boolean;\n * pointer?: boolean;\n * }\n * ```\n * Default: `[]` */\n items: BulletLegendItemInterface[];\n /** Apply a specific class to the labels. Default: `''` */\n labelClassName?: string;\n /** Callback function for the legend item click. Default: `undefined` */\n onLegendItemClick?: ((d: BulletLegendItemInterface, i: number) => void);\n /** Label text (<span> element) font-size CSS. Default: `null` */\n labelFontSize?: string | null;\n /** Label text (<span> element) max-width CSS property. Default: `null` */\n labelMaxWidth?: string | null;\n /** Bullet circle size, mapped to the width and height CSS properties. Default: `null` */\n bulletSize?: string | null;\n}\n\nexport class BulletLegendConfig extends Config implements BulletLegendConfigInterface {\n items: BulletLegendItemInterface[] = []\n labelClassName = ''\n onLegendItemClick = undefined\n labelFontSize = null\n labelMaxWidth = null\n bulletSize = null\n}\n"],"names":[],"mappings":";;AA8BM,MAAO,kBAAmB,SAAQ,MAAM,CAAA;AAA9C,IAAA,WAAA,GAAA;;QACE,IAAK,CAAA,KAAA,GAAgC,EAAE,CAAA;QACvC,IAAc,CAAA,cAAA,GAAG,EAAE,CAAA;QACnB,IAAiB,CAAA,iBAAA,GAAG,SAAS,CAAA;QAC7B,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAa,CAAA,aAAA,GAAG,IAAI,CAAA;QACpB,IAAU,CAAA,UAAA,GAAG,IAAI,CAAA;KAClB;AAAA;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
import { BulletLegendConfig, BulletLegendConfigInterface } from './config';
|
|
3
|
+
import { BulletLegendItemInterface } from './types';
|
|
4
|
+
import * as s from './style';
|
|
5
|
+
export declare class BulletLegend {
|
|
6
|
+
static selectors: typeof s;
|
|
7
|
+
div: Selection<HTMLDivElement, unknown, null, undefined>;
|
|
8
|
+
element: HTMLElement;
|
|
9
|
+
prevConfig: BulletLegendConfig;
|
|
10
|
+
config: BulletLegendConfig;
|
|
11
|
+
protected _container: HTMLElement;
|
|
12
|
+
private _colorAccessor;
|
|
13
|
+
constructor(element: HTMLElement, config?: BulletLegendConfigInterface);
|
|
14
|
+
update(config: BulletLegendConfigInterface): void;
|
|
15
|
+
render(): void;
|
|
16
|
+
_isItemClickable(item: BulletLegendItemInterface): boolean;
|
|
17
|
+
_onItemClick(event: MouseEvent, d: BulletLegendItemInterface): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { select } from 'd3-selection';
|
|
2
|
+
import { color } from 'd3-color';
|
|
3
|
+
import { getColor } from '../../utils/color.js';
|
|
4
|
+
import { BulletLegendConfig } from './config.js';
|
|
5
|
+
import * as style from './style.js';
|
|
6
|
+
import { root, item, bullet, label, clickable } from './style.js';
|
|
7
|
+
|
|
8
|
+
class BulletLegend {
|
|
9
|
+
constructor(element, config) {
|
|
10
|
+
this._colorAccessor = (d) => d.color;
|
|
11
|
+
this._container = element;
|
|
12
|
+
// Create SVG element for visualizations
|
|
13
|
+
this.div = select(this._container)
|
|
14
|
+
.append('div')
|
|
15
|
+
.attr('class', root);
|
|
16
|
+
this.element = this.div.node();
|
|
17
|
+
if (config)
|
|
18
|
+
this.update(config);
|
|
19
|
+
}
|
|
20
|
+
update(config) {
|
|
21
|
+
this.prevConfig = this.config;
|
|
22
|
+
this.config = new BulletLegendConfig().init(config);
|
|
23
|
+
this.render();
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const { config } = this;
|
|
27
|
+
const legendItems = this.div.selectAll(`.${item}`)
|
|
28
|
+
.data(config.items);
|
|
29
|
+
const legendItemsEnter = legendItems.enter()
|
|
30
|
+
.append('div')
|
|
31
|
+
.attr('class', item)
|
|
32
|
+
.on('click', this._onItemClick.bind(this));
|
|
33
|
+
legendItemsEnter.append('span')
|
|
34
|
+
.attr('class', bullet)
|
|
35
|
+
.style('width', config.bulletSize)
|
|
36
|
+
.style('height', config.bulletSize);
|
|
37
|
+
legendItemsEnter.append('span')
|
|
38
|
+
.attr('class', label)
|
|
39
|
+
.classed(config.labelClassName, true)
|
|
40
|
+
.style('max-width', config.labelMaxWidth)
|
|
41
|
+
.style('font-size', config.labelFontSize);
|
|
42
|
+
const legendItemsMerged = legendItemsEnter.merge(legendItems);
|
|
43
|
+
legendItemsMerged
|
|
44
|
+
.classed(clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))
|
|
45
|
+
.style('display', (d) => d.hidden ? 'none' : null);
|
|
46
|
+
const legendBulletsToUpdate = legendItemsMerged.select(`.${bullet}`);
|
|
47
|
+
legendBulletsToUpdate.style('background-color', (d, i) => getColor(d, this._colorAccessor, i))
|
|
48
|
+
.style('border-color', (d, i) => getColor(d, this._colorAccessor, i));
|
|
49
|
+
legendBulletsToUpdate.each((d, i, elements) => {
|
|
50
|
+
if (d.inactive) {
|
|
51
|
+
const bulletColor = window.getComputedStyle(elements[i]).getPropertyValue('background-color');
|
|
52
|
+
const transparentColor = color(bulletColor);
|
|
53
|
+
transparentColor.opacity = 0.4;
|
|
54
|
+
select(elements[i])
|
|
55
|
+
.style('background-color', transparentColor.toString());
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
legendItemsMerged.select(`.${label}`)
|
|
59
|
+
.text((d) => d.name);
|
|
60
|
+
legendItems.exit().remove();
|
|
61
|
+
}
|
|
62
|
+
_isItemClickable(item) {
|
|
63
|
+
return item.pointer === undefined ? true : item.pointer;
|
|
64
|
+
}
|
|
65
|
+
_onItemClick(event, d) {
|
|
66
|
+
const { config: { onLegendItemClick } } = this;
|
|
67
|
+
const legendItems = this.div.selectAll(`.${item}`).nodes();
|
|
68
|
+
const index = legendItems.indexOf(event.currentTarget);
|
|
69
|
+
if (onLegendItemClick)
|
|
70
|
+
onLegendItemClick(d, index);
|
|
71
|
+
}
|
|
72
|
+
destroy() {
|
|
73
|
+
this.div.remove();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
BulletLegend.selectors = style;
|
|
77
|
+
|
|
78
|
+
export { BulletLegend };
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/bullet-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { color } from 'd3-color'\n\n// Utils\nimport { getColor } from 'utils/color'\n\n// Config\nimport { BulletLegendConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class BulletLegend {\n static selectors = s\n div: Selection<HTMLDivElement, unknown, null, undefined>\n element: HTMLElement\n prevConfig: BulletLegendConfig\n config: BulletLegendConfig\n protected _container: HTMLElement\n\n private _colorAccessor = (d: BulletLegendItemInterface): string => d.color\n\n constructor (element: HTMLElement, config?: BulletLegendConfigInterface) {\n this._container = element\n\n // Create SVG element for visualizations\n this.div = select(this._container)\n .append('div')\n .attr('class', s.root)\n\n this.element = this.div.node()\n\n if (config) this.update(config)\n }\n\n update (config: BulletLegendConfigInterface): void {\n this.prevConfig = this.config\n this.config = new BulletLegendConfig().init(config)\n this.render()\n }\n\n render (): void {\n const { config } = this\n const legendItems = this.div.selectAll<HTMLDivElement, unknown>(`.${s.item}`)\n .data(config.items)\n\n const legendItemsEnter = legendItems.enter()\n .append('div')\n .attr('class', s.item)\n .on('click', this._onItemClick.bind(this))\n\n legendItemsEnter.append('span')\n .attr('class', s.bullet)\n .style('width', config.bulletSize)\n .style('height', config.bulletSize)\n\n legendItemsEnter.append('span')\n .attr('class', s.label)\n .classed(config.labelClassName, true)\n .style('max-width', config.labelMaxWidth)\n .style('font-size', config.labelFontSize)\n\n const legendItemsMerged = legendItemsEnter.merge(legendItems)\n legendItemsMerged\n .classed(s.clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))\n .style('display', (d: BulletLegendItemInterface) => d.hidden ? 'none' : null)\n const legendBulletsToUpdate = legendItemsMerged.select(`.${s.bullet}`)\n legendBulletsToUpdate.style('background-color', (d: BulletLegendItemInterface, i) => getColor(d, this._colorAccessor, i))\n .style('border-color', (d: BulletLegendItemInterface, i) => getColor(d, this._colorAccessor, i))\n legendBulletsToUpdate.each((d, i, elements) => {\n if (d.inactive) {\n const bulletColor = window.getComputedStyle(elements[i] as Element).getPropertyValue('background-color')\n const transparentColor = color(bulletColor)\n transparentColor.opacity = 0.4\n select(elements[i])\n .style('background-color', transparentColor.toString())\n }\n })\n\n legendItemsMerged.select(`.${s.label}`)\n .text((d: BulletLegendItemInterface) => d.name)\n\n legendItems.exit().remove()\n }\n\n _isItemClickable (item: BulletLegendItemInterface): boolean {\n return item.pointer === undefined ? true : item.pointer\n }\n\n _onItemClick (event: MouseEvent, d: BulletLegendItemInterface): void {\n const { config: { onLegendItemClick } } = this\n\n const legendItems = this.div.selectAll(`.${s.item}`).nodes() as HTMLElement[]\n const index = legendItems.indexOf(event.currentTarget as HTMLElement)\n if (onLegendItemClick) onLegendItemClick(d, index)\n }\n\n public destroy (): void {\n this.div.remove()\n }\n}\n"],"names":["s.root","s.item","s.bullet","s.label","s.clickable","s"],"mappings":";;;;;;;MAea,YAAY,CAAA;IAUvB,WAAa,CAAA,OAAoB,EAAE,MAAoC,EAAA;QAF/D,IAAc,CAAA,cAAA,GAAG,CAAC,CAA4B,KAAa,CAAC,CAAC,KAAK,CAAA;AAGxE,QAAA,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA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'@emotion/css'
|
|
1
|
+
import { css, injectGlobal } from '@emotion/css';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const root = css `
|
|
4
4
|
label: bullet-legend-component;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const variables = injectGlobal`
|
|
5
|
+
`;
|
|
6
|
+
const variables = injectGlobal `
|
|
8
7
|
:root {
|
|
9
8
|
// Undefined by default to allow proper fallback to var(--vis-font-family)
|
|
10
9
|
/* --vis-legend-font-family: */
|
|
@@ -25,9 +24,8 @@ export const variables = injectGlobal`
|
|
|
25
24
|
--vis-legend-label-color: var(--vis-dark-legend-label-color);
|
|
26
25
|
--vis-legend-bullet-inactive-color: var(--vis-dark-legend-bullet-inactive-color);
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const item = css`
|
|
27
|
+
`;
|
|
28
|
+
const item = css `
|
|
31
29
|
label: legendItem;
|
|
32
30
|
display: inline;
|
|
33
31
|
font-family: var(--vis-legend-font-family, var(--vis-font-family));
|
|
@@ -35,13 +33,11 @@ export const item = css`
|
|
|
35
33
|
white-space: nowrap;
|
|
36
34
|
cursor: default;
|
|
37
35
|
user-select: none;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export const clickable = css`
|
|
36
|
+
`;
|
|
37
|
+
const clickable = css `
|
|
41
38
|
cursor: pointer;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export const label = css`
|
|
39
|
+
`;
|
|
40
|
+
const label = css `
|
|
45
41
|
label: legendItemLabel;
|
|
46
42
|
font-size: var(--vis-legend-label-font-size);
|
|
47
43
|
display: inline-block;
|
|
@@ -51,9 +47,8 @@ export const label = css`
|
|
|
51
47
|
text-overflow: ellipsis;
|
|
52
48
|
overflow: hidden;
|
|
53
49
|
white-space: nowrap;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export const bullet = css`
|
|
50
|
+
`;
|
|
51
|
+
const bullet = css `
|
|
57
52
|
label: legendItemBullet;
|
|
58
53
|
border-radius: 100%;
|
|
59
54
|
background-color: var(--vis-legend-bullet-inactive-color);
|
|
@@ -67,4 +62,7 @@ export const bullet = css`
|
|
|
67
62
|
.inactive {
|
|
68
63
|
|
|
69
64
|
}
|
|
70
|
-
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
export { bullet, clickable, item, label, root, variables };
|
|
68
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/bullet-legend/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: bullet-legend-component;\n`\n\nexport const variables = injectGlobal`\n :root {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-legend-font-family: */\n\n --vis-legend-label-color: #6c778c;\n --vis-legend-label-max-width: 300px;\n --vis-legend-label-font-size: 12px;\n --vis-legend-bullet-size: 9px;\n --vis-legend-bullet-inactive-color: #eee;\n --vis-legend-item-spacing: 20px;\n --vis-legend-bullet-label-spacing: 8px;\n\n --vis-dark-legend-label-color: #eee;\n --vis-dark-legend-bullet-inactive-color: #6c778c;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-legend-label-color: var(--vis-dark-legend-label-color);\n --vis-legend-bullet-inactive-color: var(--vis-dark-legend-bullet-inactive-color);\n }\n`\n\nexport const item = css`\n label: legendItem;\n display: inline;\n font-family: var(--vis-legend-font-family, var(--vis-font-family));\n margin-right: var(--vis-legend-item-spacing);\n white-space: nowrap;\n cursor: default;\n user-select: none;\n`\n\nexport const clickable = css`\n cursor: pointer;\n`\n\nexport const label = css`\n label: legendItemLabel;\n font-size: var(--vis-legend-label-font-size);\n display: inline-block;\n vertical-align: middle;\n color: var(--vis-legend-label-color);\n max-width: var(--vis-legend-label-max-width);\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n`\n\nexport const bullet = css`\n label: legendItemBullet;\n border-radius: 100%;\n background-color: var(--vis-legend-bullet-inactive-color);\n border: 1px solid;\n display: inline-block;\n margin-right: var(--vis-legend-bullet-label-spacing);\n width: var(--vis-legend-bullet-size);\n height: var(--vis-legend-bullet-size);\n vertical-align: middle;\n\n .inactive {\n\n }\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;AAiBjB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;EAI7B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;EAQtB;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA,CAAA;;EAE3B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;EAUvB;AAEM,MAAM,MAAM,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|