@unovis/ts 1.3.0-beta.3 → 1.3.1
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 +6 -10
- package/components/area/config.js +3 -12
- package/components/area/config.js.map +1 -1
- package/components/area/index.d.ts +5 -6
- package/components/area/index.js +10 -9
- package/components/area/index.js.map +1 -1
- package/components/axis/config.d.ts +3 -27
- package/components/axis/config.js +3 -30
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +4 -3
- package/components/axis/index.js +8 -5
- package/components/axis/index.js.map +1 -1
- package/components/brush/config.d.ts +2 -12
- package/components/brush/config.js +11 -20
- package/components/brush/config.js.map +1 -1
- package/components/brush/index.d.ts +4 -3
- package/components/brush/index.js +4 -3
- package/components/brush/index.js.map +1 -1
- package/components/bullet-legend/config.d.ts +1 -10
- package/components/bullet-legend/config.js +11 -14
- package/components/bullet-legend/config.js.map +1 -1
- package/components/bullet-legend/index.d.ts +4 -3
- package/components/bullet-legend/index.js +5 -2
- package/components/bullet-legend/index.js.map +1 -1
- package/components/chord-diagram/config.d.ts +7 -23
- package/components/chord-diagram/config.js +4 -23
- package/components/chord-diagram/config.js.map +1 -1
- package/components/chord-diagram/index.d.ts +4 -3
- package/components/chord-diagram/index.js +8 -7
- package/components/chord-diagram/index.js.map +1 -1
- package/components/chord-diagram/modules/label.d.ts +3 -3
- package/components/chord-diagram/modules/label.js +1 -1
- package/components/chord-diagram/modules/label.js.map +1 -1
- package/components/chord-diagram/modules/link.d.ts +2 -2
- package/components/chord-diagram/modules/link.js.map +1 -1
- package/components/chord-diagram/modules/node.d.ts +2 -2
- package/components/chord-diagram/modules/node.js.map +1 -1
- package/components/chord-diagram/types.d.ts +3 -2
- package/components/chord-diagram/types.js.map +1 -1
- package/components/crosshair/config.d.ts +4 -14
- package/components/crosshair/config.js +3 -16
- package/components/crosshair/config.js.map +1 -1
- package/components/crosshair/index.d.ts +4 -3
- package/components/crosshair/index.js +4 -3
- package/components/crosshair/index.js.map +1 -1
- package/components/donut/config.d.ts +3 -20
- package/components/donut/config.js +3 -24
- package/components/donut/config.js.map +1 -1
- package/components/donut/index.d.ts +4 -3
- package/components/donut/index.js +5 -4
- package/components/donut/index.js.map +1 -1
- package/components/donut/modules/arc.d.ts +3 -3
- package/components/donut/modules/arc.js.map +1 -1
- package/components/flow-legend/config.d.ts +1 -11
- package/components/flow-legend/config.js +11 -16
- package/components/flow-legend/config.js.map +1 -1
- package/components/flow-legend/index.d.ts +4 -3
- package/components/flow-legend/index.js +5 -2
- package/components/flow-legend/index.js.map +1 -1
- package/components/free-brush/config.d.ts +2 -12
- package/components/free-brush/config.js +11 -20
- package/components/free-brush/config.js.map +1 -1
- package/components/free-brush/index.d.ts +4 -3
- package/components/free-brush/index.js +13 -12
- package/components/free-brush/index.js.map +1 -1
- package/components/graph/config.d.ts +3 -75
- package/components/graph/config.js +13 -79
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +8 -7
- package/components/graph/index.js +7 -5
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.d.ts +7 -7
- package/components/graph/modules/layout.js +7 -2
- package/components/graph/modules/layout.js.map +1 -1
- package/components/graph/modules/link/helper.d.ts +5 -5
- package/components/graph/modules/link/helper.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +6 -6
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/node/helper.d.ts +1 -1
- package/components/graph/modules/node/helper.js.map +1 -1
- package/components/graph/modules/node/index.d.ts +9 -6
- package/components/graph/modules/node/index.js +7 -9
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/panel/helper.d.ts +4 -4
- package/components/graph/modules/panel/helper.js.map +1 -1
- package/components/graph/modules/panel/index.d.ts +3 -3
- package/components/graph/modules/panel/index.js.map +1 -1
- package/components/graph/modules/shape.js +2 -2
- package/components/graph/modules/shape.js.map +1 -1
- package/components/grouped-bar/config.d.ts +5 -13
- package/components/grouped-bar/config.js +3 -16
- package/components/grouped-bar/config.js.map +1 -1
- package/components/grouped-bar/index.d.ts +5 -9
- package/components/grouped-bar/index.js +5 -15
- package/components/grouped-bar/index.js.map +1 -1
- package/components/leaflet-flow-map/config.d.ts +2 -16
- package/components/leaflet-flow-map/config.js +3 -21
- package/components/leaflet-flow-map/config.js.map +1 -1
- package/components/leaflet-flow-map/index.d.ts +4 -3
- package/components/leaflet-flow-map/index.js +3 -2
- package/components/leaflet-flow-map/index.js.map +1 -1
- package/components/leaflet-map/config.d.ts +4 -59
- package/components/leaflet-map/config.js +24 -68
- package/components/leaflet-map/config.js.map +1 -1
- package/components/leaflet-map/index.d.ts +5 -4
- package/components/leaflet-map/index.js +4 -3
- package/components/leaflet-map/index.js.map +1 -1
- package/components/leaflet-map/modules/clusterBackground.d.ts +4 -2
- package/components/leaflet-map/modules/clusterBackground.js.map +1 -1
- package/components/leaflet-map/modules/map.d.ts +4 -4
- package/components/leaflet-map/modules/map.js +6 -6
- package/components/leaflet-map/modules/map.js.map +1 -1
- package/components/leaflet-map/modules/node.d.ts +3 -0
- package/components/leaflet-map/modules/node.js +8 -12
- package/components/leaflet-map/modules/node.js.map +1 -1
- package/components/leaflet-map/modules/utils.d.ts +4 -4
- package/components/leaflet-map/modules/utils.js +6 -2
- package/components/leaflet-map/modules/utils.js.map +1 -1
- package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +2 -2
- package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -1
- package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +5 -1
- package/components/leaflet-map/renderer/mapboxgl-utils.js +3 -3
- package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -1
- package/components/leaflet-map/style.js.map +1 -1
- package/components/leaflet-map/types.d.ts +5 -1
- package/components/leaflet-map/types.js.map +1 -1
- package/components/line/config.d.ts +6 -11
- package/components/line/config.js +3 -13
- package/components/line/config.js.map +1 -1
- package/components/line/index.d.ts +6 -5
- package/components/line/index.js +7 -6
- package/components/line/index.js.map +1 -1
- package/components/nested-donut/config.d.ts +2 -21
- package/components/nested-donut/config.js +3 -24
- package/components/nested-donut/config.js.map +1 -1
- package/components/nested-donut/index.d.ts +4 -3
- package/components/nested-donut/index.js +18 -8
- package/components/nested-donut/index.js.map +1 -1
- package/components/nested-donut/modules/arc.d.ts +3 -3
- package/components/nested-donut/modules/arc.js.map +1 -1
- package/components/nested-donut/modules/label.d.ts +2 -2
- package/components/nested-donut/modules/label.js.map +1 -1
- package/components/nested-donut/style.js.map +1 -1
- package/components/sankey/config.d.ts +3 -48
- package/components/sankey/config.js +11 -58
- package/components/sankey/config.js.map +1 -1
- package/components/sankey/index.d.ts +4 -3
- package/components/sankey/index.js +3 -2
- package/components/sankey/index.js.map +1 -1
- package/components/sankey/modules/label.d.ts +7 -7
- package/components/sankey/modules/label.js.map +1 -1
- package/components/sankey/modules/link.d.ts +12 -2
- package/components/sankey/modules/link.js +4 -8
- package/components/sankey/modules/link.js.map +1 -1
- package/components/sankey/modules/node.d.ts +7 -7
- package/components/sankey/modules/node.js +1 -1
- package/components/sankey/modules/node.js.map +1 -1
- package/components/scatter/config.d.ts +5 -17
- package/components/scatter/config.js +3 -19
- package/components/scatter/config.js.map +1 -1
- package/components/scatter/index.d.ts +4 -3
- package/components/scatter/index.js +8 -8
- package/components/scatter/index.js.map +1 -1
- package/components/scatter/modules/point.d.ts +2 -2
- package/components/scatter/modules/point.js.map +1 -1
- package/components/scatter/modules/utils.d.ts +2 -2
- package/components/scatter/modules/utils.js.map +1 -1
- package/components/stacked-bar/config.d.ts +5 -13
- package/components/stacked-bar/config.js +3 -16
- package/components/stacked-bar/config.js.map +1 -1
- package/components/stacked-bar/index.d.ts +4 -3
- package/components/stacked-bar/index.js +4 -3
- package/components/stacked-bar/index.js.map +1 -1
- package/components/timeline/config.d.ts +5 -16
- package/components/timeline/config.js +3 -21
- package/components/timeline/config.js.map +1 -1
- package/components/timeline/index.d.ts +4 -3
- package/components/timeline/index.js +4 -3
- package/components/timeline/index.js.map +1 -1
- package/components/tooltip/config.d.ts +1 -15
- package/components/tooltip/config.js +12 -16
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.d.ts +6 -4
- package/components/tooltip/index.js +15 -6
- package/components/tooltip/index.js.map +1 -1
- package/components/tooltip/style.d.ts +6 -0
- package/components/tooltip/style.js +13 -14
- package/components/tooltip/style.js.map +1 -1
- package/components/topojson-map/config.d.ts +4 -36
- package/components/topojson-map/config.js +3 -38
- package/components/topojson-map/config.js.map +1 -1
- package/components/topojson-map/index.d.ts +4 -3
- package/components/topojson-map/index.js +4 -5
- package/components/topojson-map/index.js.map +1 -1
- package/components/vis-controls/config.d.ts +1 -5
- package/components/vis-controls/config.js +6 -9
- package/components/vis-controls/config.js.map +1 -1
- package/components/vis-controls/index.d.ts +3 -2
- package/components/vis-controls/index.js +5 -2
- package/components/vis-controls/index.js.map +1 -1
- package/components/xy-labels/config.d.ts +4 -16
- package/components/xy-labels/config.js +3 -20
- package/components/xy-labels/config.js.map +1 -1
- package/components/xy-labels/index.d.ts +4 -3
- package/components/xy-labels/index.js +3 -2
- package/components/xy-labels/index.js.map +1 -1
- package/components/xy-labels/modules/label.d.ts +3 -3
- package/components/xy-labels/modules/label.js +1 -1
- package/components/xy-labels/modules/label.js.map +1 -1
- package/containers/single-container/config.d.ts +2 -4
- package/containers/single-container/config.js +3 -8
- package/containers/single-container/config.js.map +1 -1
- package/containers/single-container/index.d.ts +4 -3
- package/containers/single-container/index.js +2 -2
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +2 -22
- package/containers/xy-container/config.js +3 -26
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.d.ts +5 -2
- package/containers/xy-container/index.js +7 -6
- package/containers/xy-container/index.js.map +1 -1
- package/core/component/config.d.ts +1 -6
- package/core/component/config.js +6 -12
- package/core/component/config.js.map +1 -1
- package/core/component/index.d.ts +7 -5
- package/core/component/index.js +14 -9
- package/core/component/index.js.map +1 -1
- package/core/container/config.d.ts +1 -21
- package/core/container/config.js +21 -25
- package/core/container/config.js.map +1 -1
- package/core/container/index.d.ts +5 -4
- package/core/container/index.js +4 -3
- package/core/container/index.js.map +1 -1
- package/core/xy-component/config.d.ts +2 -10
- package/core/xy-component/config.js +3 -16
- package/core/xy-component/config.js.map +1 -1
- package/core/xy-component/index.d.ts +5 -4
- package/core/xy-component/index.js +2 -0
- package/core/xy-component/index.js.map +1 -1
- package/data-models/map-graph.d.ts +1 -1
- package/data-models/map-graph.js +4 -7
- package/data-models/map-graph.js.map +1 -1
- package/package.json +3 -1
- package/styles/colors.d.ts +2 -2
- package/styles/index.d.ts +1 -1
- package/styles/patterns.js +2 -1
- package/styles/patterns.js.map +1 -1
- package/types/accessor.d.ts +5 -5
- package/types/component.js +2 -0
- package/types/component.js.map +1 -1
- package/utils/d3.d.ts +10 -1
- package/utils/d3.js.map +1 -1
- package/utils/data.d.ts +7 -7
- package/utils/data.js +2 -1
- package/utils/data.js.map +1 -1
- package/utils/text.js +2 -2
- package/utils/text.js.map +1 -1
- package/core/config/index.d.ts +0 -3
- package/core/config/index.js +0 -16
- package/core/config/index.js.map +0 -1
|
@@ -3,7 +3,7 @@ import Supercluster, { ClusterFeature, PointFeature } from 'supercluster';
|
|
|
3
3
|
import { NumericAccessor, StringAccessor } from "../../../types/accessor";
|
|
4
4
|
import { GenericDataRecord } from "../../../types/data";
|
|
5
5
|
import { LeafletMapPoint, LeafletMapPointShape, LeafletMapPieDatum, LeafletMapPointStyles, PointExpandedClusterProperties, LeafletMapPointDatum, LeafletMapClusterDatum } from '../types';
|
|
6
|
-
import {
|
|
6
|
+
import { LeafletMapConfigInterface } from '../config';
|
|
7
7
|
export declare function bBoxMerge(bBoxArray: ({
|
|
8
8
|
x1: number;
|
|
9
9
|
x2: number;
|
|
@@ -20,20 +20,20 @@ export declare function projectPoint<D extends GenericDataRecord>(geoJSONPoint:
|
|
|
20
20
|
x: number;
|
|
21
21
|
y: number;
|
|
22
22
|
};
|
|
23
|
-
export declare function getPointRadius<D extends GenericDataRecord>(geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>> | PointFeature<PointExpandedClusterProperties<D>>, pointRadius: NumericAccessor<D
|
|
23
|
+
export declare function getPointRadius<D extends GenericDataRecord>(geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>> | PointFeature<PointExpandedClusterProperties<D>>, pointRadius: NumericAccessor<LeafletMapPointDatum<D>> | NumericAccessor<LeafletMapClusterDatum<D>>, zoomLevel: number): number;
|
|
24
24
|
export declare function getPointPos<D extends GenericDataRecord>(point: LeafletMapPoint<D> | ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>, leafletMap: L.Map): {
|
|
25
25
|
x: number;
|
|
26
26
|
y: number;
|
|
27
27
|
};
|
|
28
28
|
export declare function getPointDisplayOrder<D extends GenericDataRecord>(d: LeafletMapPoint<D>, pointStatus: StringAccessor<LeafletMapPointDatum<D> | LeafletMapClusterDatum<D>>, colorMap: LeafletMapPointStyles<D>): number;
|
|
29
29
|
export declare function toGeoJSONPoint<D extends GenericDataRecord>(d: D, i: number, pointLatitude: NumericAccessor<D>, pointLongitude: NumericAccessor<D>): PointFeature<D>;
|
|
30
|
-
export declare function calculateClusterIndex<D extends GenericDataRecord>(data: D[], config:
|
|
30
|
+
export declare function calculateClusterIndex<D extends GenericDataRecord>(data: D[], config: LeafletMapConfigInterface<D>, maxClusterZoomLevel?: number): Supercluster<D>;
|
|
31
31
|
export declare function getNodePathData({ x, y }: {
|
|
32
32
|
x: number;
|
|
33
33
|
y: number;
|
|
34
34
|
}, radius: number, shape: LeafletMapPointShape): string;
|
|
35
35
|
export declare function getDonutData<D extends GenericDataRecord>(d: LeafletMapClusterDatum<D> | LeafletMapPointDatum<D>, colorMap: LeafletMapPointStyles<D>): LeafletMapPieDatum[];
|
|
36
|
-
export declare function geoJsonPointToScreenPoint<D extends GenericDataRecord>(geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>, i: number, leafletMap: L.Map, config:
|
|
36
|
+
export declare function geoJsonPointToScreenPoint<D extends GenericDataRecord>(geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>, i: number, leafletMap: L.Map, config: LeafletMapConfigInterface<D>): LeafletMapPoint<D>;
|
|
37
37
|
export declare function shouldClusterExpand<D extends GenericDataRecord>(cluster: LeafletMapPoint<D>, zoomLevel: number, midLevel?: number, maxLevel?: number, maxClusterZoomLevel?: number): boolean;
|
|
38
38
|
export declare function findPointAndClusterByPointId<D extends GenericDataRecord>(points: LeafletMapPoint<D>[], id: string, pointId: StringAccessor<D>): {
|
|
39
39
|
point: PointFeature<D> | undefined;
|
|
@@ -39,7 +39,10 @@ function projectPoint(geoJSONPoint, leafletMap) {
|
|
|
39
39
|
}
|
|
40
40
|
function getPointRadius(geoPoint, pointRadius, zoomLevel) {
|
|
41
41
|
const isDynamic = !pointRadius;
|
|
42
|
-
const radius = isDynamic
|
|
42
|
+
const radius = isDynamic
|
|
43
|
+
? 1 + 2 * Math.pow(zoomLevel, 0.80)
|
|
44
|
+
// Todo: Needs a better typings handling
|
|
45
|
+
: getNumber(geoPoint.properties, pointRadius);
|
|
43
46
|
const isCluster = geoPoint.properties.cluster;
|
|
44
47
|
return (isCluster && isDynamic)
|
|
45
48
|
? clamp(Math.pow(geoPoint.properties.point_count, 0.35) * radius, radius * 1.1, radius * 3)
|
|
@@ -127,7 +130,8 @@ function geoJsonPointToScreenPoint(geoPoint, i, leafletMap, config) {
|
|
|
127
130
|
const clusterPoints = isCluster ? clusterIndex.getLeaves(geoPoint.properties.cluster_id, Infinity).map(d => d.properties) : undefined;
|
|
128
131
|
const { x, y } = getPointPos(geoPoint, leafletMap);
|
|
129
132
|
const id = isCluster ? `cluster-${geoPoint.id}` : ((_a = getString(geoPoint.properties, config.pointId)) !== null && _a !== void 0 ? _a : geoPoint.geometry.coordinates.join(''));
|
|
130
|
-
|
|
133
|
+
// Todo: Needs a better typings handling
|
|
134
|
+
const pointColor = getColor(geoPoint.properties, (isCluster ? config.clusterColor : config.pointColor));
|
|
131
135
|
const radius = getPointRadius(geoPoint, isCluster ? config.clusterRadius : config.pointRadius, zoomLevel);
|
|
132
136
|
const shape = isCluster ? LeafletMapPointShape.Circle : getString(geoPoint.properties, config.pointShape);
|
|
133
137
|
const isRing = shape === LeafletMapPointShape.Ring;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/components/leaflet-map/modules/utils.ts"],"sourcesContent":["import type L from 'leaflet'\nimport { min, max } from 'd3-array'\nimport Supercluster, { ClusterFeature, PointFeature } from 'supercluster'\n\n// Utils\nimport { clamp, getString, getNumber } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { polygon, circlePath } from 'utils/path'\nimport { getHTMLTransform } from 'utils/html'\n\n// Types\nimport { NumericAccessor, StringAccessor } from 'types/accessor'\nimport { GenericDataRecord } from 'types/data'\n\n// Local Types\nimport {\n LeafletMapPoint,\n LeafletMapPointShape,\n LeafletMapPieDatum,\n LeafletMapPointStyles,\n PointExpandedClusterProperties,\n LeafletMapPointDatum,\n LeafletMapClusterDatum,\n} from '../types'\n\n// Config\nimport { LeafletMapConfig } from '../config'\n\nexport function bBoxMerge (\n bBoxArray: ({x1: number; x2: number; y1: number; y2: number})[]):\n { x: number; y: number; width: number; height: number } {\n let box = { x1: 0, x2: 0, y1: 0, y2: 0 }\n bBoxArray.forEach(coords => {\n if (!box) {\n box = { ...coords }\n } else {\n if (box.x1 > coords.x1) box.x1 = coords.x1\n if (box.y1 > coords.y1) box.y1 = coords.y1\n if (box.x2 < coords.x2) box.x2 = coords.x2\n if (box.y2 < coords.y2) box.y2 = coords.y2\n }\n })\n\n return {\n x: box.x1,\n y: box.y1,\n width: box.x2 - box.x1,\n height: box.y2 - box.y1,\n }\n}\n\nexport const getNextZoomLevelOnClusterClick = (level: number): number => clamp(1 + level * 1.5, level, 12)\n\nexport function projectPoint<D extends GenericDataRecord> (\n geoJSONPoint: LeafletMapPoint<D> | ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>,\n leafletMap: L.Map\n): { x: number; y: number } {\n const lat = geoJSONPoint.geometry.coordinates[1]\n const lon = geoJSONPoint.geometry.coordinates[0]\n const projected = leafletMap.latLngToLayerPoint([lat, lon])\n return projected\n}\n\nexport function getPointRadius<D extends GenericDataRecord> (\n geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>> | PointFeature<PointExpandedClusterProperties<D>>,\n pointRadius: NumericAccessor<D>,\n zoomLevel: number\n): number {\n const isDynamic = !pointRadius\n const radius = isDynamic ? 1 + 2 * Math.pow(zoomLevel, 0.80) : getNumber((geoPoint.properties as LeafletMapPointDatum<D>), pointRadius)\n\n const isCluster = (geoPoint as ClusterFeature<D>).properties.cluster\n return (isCluster && isDynamic)\n ? clamp(Math.pow((geoPoint as ClusterFeature<D>).properties.point_count, 0.35) * radius, radius * 1.1, radius * 3)\n : radius\n}\n\nexport function getPointPos<D extends GenericDataRecord> (point: LeafletMapPoint<D> | ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>, leafletMap: L.Map): { x: number; y: number } {\n const properties = point.properties as LeafletMapPointDatum<D>\n const isFromCluster = !!(properties).expandedClusterPoint\n\n if (isFromCluster) {\n const { x, y } = projectPoint(properties.expandedClusterPoint, leafletMap)\n return {\n x: x + properties.dx,\n y: y + properties.dy,\n }\n } else {\n return projectPoint(point, leafletMap)\n }\n}\n\nexport function getPointDisplayOrder<D extends GenericDataRecord> (\n d: LeafletMapPoint<D>,\n pointStatus: StringAccessor<LeafletMapPointDatum<D> | LeafletMapClusterDatum<D>>,\n colorMap: LeafletMapPointStyles<D>\n): number {\n const status = getString(d.properties, pointStatus)\n const statusList = Object.keys(colorMap)\n return Object.keys(statusList).indexOf(status)\n}\n\nexport function toGeoJSONPoint<D extends GenericDataRecord> (d: D, i: number, pointLatitude: NumericAccessor<D>, pointLongitude: NumericAccessor<D>): PointFeature<D> {\n const lat = getNumber(d, pointLatitude) as number\n const lon = getNumber(d, pointLongitude) as number\n\n return {\n type: 'Feature',\n properties: {\n ...d,\n _index: i,\n },\n geometry: {\n type: 'Point',\n coordinates: [lon, lat],\n },\n }\n}\n\nexport function calculateClusterIndex<D extends GenericDataRecord> (data: D[], config: LeafletMapConfig<D>, maxClusterZoomLevel = 23): Supercluster<D> {\n const { colorMap, pointShape, pointLatitude, pointLongitude, clusteringDistance } = config\n return new Supercluster<D, Supercluster.AnyProps>({\n radius: clusteringDistance,\n maxZoom: maxClusterZoomLevel,\n map: (d): Supercluster.AnyProps => {\n const shape = getString(d, pointShape)\n\n const clusterPoint = { shape }\n for (const key of Object.keys(colorMap)) {\n clusterPoint[key] = d[key] || 0\n }\n\n return clusterPoint\n },\n reduce: (acc, clusterPoint): void => {\n acc.shape = acc.shape === clusterPoint.shape ? acc.shape : LeafletMapPointShape.Circle\n acc.value = (acc.value ?? 0) + (clusterPoint.value ?? 0)\n\n for (const key of Object.keys(colorMap)) {\n acc[key] += clusterPoint[key]\n }\n },\n }).load(data.map((d, i) => toGeoJSONPoint(d, i, pointLatitude, pointLongitude)))\n}\n\nexport function getNodePathData ({ x, y }: { x: number; y: number }, radius: number, shape: LeafletMapPointShape): string {\n switch (shape) {\n case LeafletMapPointShape.Triangle:\n return polygon(radius * 2, 3)\n case LeafletMapPointShape.Square:\n return polygon(radius * 2, 4)\n case LeafletMapPointShape.Circle:\n case LeafletMapPointShape.Ring:\n default:\n return circlePath(x, y, radius)\n }\n}\n\nexport function getDonutData<D extends GenericDataRecord> (\n d: LeafletMapClusterDatum<D> | LeafletMapPointDatum<D>,\n colorMap: LeafletMapPointStyles<D>\n): LeafletMapPieDatum[] {\n return Object.keys(colorMap).map(key => ({\n name: key,\n value: d[key] as number,\n color: colorMap[key].color,\n className: colorMap[key].className,\n }))\n}\n\nexport function geoJsonPointToScreenPoint<D extends GenericDataRecord> (\n geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>,\n i: number,\n leafletMap: L.Map,\n config: LeafletMapConfig<D>\n): LeafletMapPoint<D> {\n const zoomLevel = leafletMap.getZoom()\n const isCluster = (geoPoint.properties as LeafletMapClusterDatum<D>).cluster\n const clusterIndex = (geoPoint.properties as LeafletMapClusterDatum<D>).clusterIndex\n const clusterPoints = isCluster ? clusterIndex.getLeaves((geoPoint.properties as LeafletMapClusterDatum<D>).cluster_id as number, Infinity).map(d => d.properties) : undefined\n const { x, y } = getPointPos(geoPoint, leafletMap)\n\n const id = isCluster ? `cluster-${geoPoint.id}` : (getString(geoPoint.properties as LeafletMapPointDatum<D>, config.pointId) ?? geoPoint.geometry.coordinates.join(''))\n const pointColor = getColor(geoPoint.properties, isCluster ? config.clusterColor : config.pointColor)\n const radius = getPointRadius(geoPoint, isCluster ? config.clusterRadius : config.pointRadius, zoomLevel)\n const shape = isCluster ? LeafletMapPointShape.Circle : getString(geoPoint.properties as LeafletMapPointDatum<D>, config.pointShape) as LeafletMapPointShape\n const isRing = shape === LeafletMapPointShape.Ring\n\n const donutData = getDonutData(geoPoint.properties, config.colorMap)\n const maxValue = max(donutData, d => d.value)\n const maxValueIndex = donutData.map(d => d.value).indexOf(maxValue)\n const biggestDatum = donutData[maxValueIndex ?? 0]\n\n const color = isCluster ? pointColor\n : (isRing ? null : (pointColor ?? biggestDatum?.color))\n const bbox = { x1: x - radius, y1: y - radius, x2: x + radius, y2: y + radius }\n const path = getNodePathData({ x: 0, y: 0 }, radius, shape)\n const _zIndex = 0\n\n const screenPoint: LeafletMapPoint<D> = {\n ...geoPoint,\n id,\n bbox,\n radius,\n donutData,\n path,\n color,\n isCluster,\n clusterIndex,\n clusterPoints,\n _zIndex,\n }\n\n return screenPoint\n}\n\nexport function shouldClusterExpand<D extends GenericDataRecord> (\n cluster: LeafletMapPoint<D>,\n zoomLevel: number,\n midLevel = 4,\n maxLevel = 8,\n maxClusterZoomLevel = 23\n): boolean {\n if (!cluster) return false\n\n const clusterExpansionZoomLevel = cluster.clusterIndex.getClusterExpansionZoom(cluster.properties.cluster_id as number)\n return zoomLevel >= maxLevel ||\n (zoomLevel >= midLevel && (cluster.properties.point_count < 20 || clusterExpansionZoomLevel >= maxClusterZoomLevel))\n}\n\nexport function findPointAndClusterByPointId<D extends GenericDataRecord> (\n points: LeafletMapPoint<D>[],\n id: string,\n pointId: StringAccessor<D>\n): {\n point: PointFeature<D> | undefined;\n cluster: LeafletMapPoint<D> | undefined;\n } {\n let point\n let cluster\n points.forEach(p => {\n if (p.isCluster) {\n const leaves = p.clusterIndex.getLeaves((p.properties as LeafletMapClusterDatum<D>).cluster_id as number, Infinity) ?? []\n const foundPoint = leaves.find(d => getString(d.properties, pointId) === id)\n if (foundPoint) {\n point = foundPoint\n cluster = p\n }\n }\n })\n return { point, cluster }\n}\n\nexport function getNodeRelativePosition<D extends GenericDataRecord> (d: LeafletMapPoint<D>, leafletMap: L.Map): { x: number; y: number } {\n const paneTransform = getHTMLTransform(leafletMap.getPane('mapPane'))\n const { x, y } = getPointPos(d, leafletMap)\n return { x: x + paneTransform[0], y: y + paneTransform[1] }\n}\n\nexport function getClusterRadius<D extends GenericDataRecord> (cluster: { points: PointFeature<PointExpandedClusterProperties<D>>[]; cluster: LeafletMapPoint<D> }): number {\n const { points } = cluster\n const minX = min<number>(points.map(d => d.properties.dx - d.properties.r))\n const maxX = max<number>(points.map(d => d.properties.dx + d.properties.r))\n const minY = min<number>(points.map(d => d.properties.dy - d.properties.r))\n const maxY = max<number>(points.map(d => d.properties.dy + d.properties.r))\n return Math.sqrt((maxX - minX) ** 2 + (maxY - minY) ** 2) * 0.5\n}\n\nexport function getClustersAndPoints<D extends GenericDataRecord> (\n clusterIndex: Supercluster<D>,\n leafletMap: L.Map,\n customBounds?: [number, number, number, number]\n): (ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<D>)[] {\n const leafletBounds = leafletMap.getBounds()\n const southWest = leafletBounds.getSouthWest()\n const northEast = leafletBounds.getNorthEast()\n const bounds = customBounds || [southWest.lng, southWest.lat, northEast.lng, northEast.lat]\n const zoom = Math.round(leafletMap.getZoom())\n const points = clusterIndex.getClusters(bounds, zoom) // as ClusterFeature<LeafletMapPointDatum<D>>[]\n\n for (const p of points) {\n const point = p as ClusterFeature<LeafletMapClusterDatum<D>>\n const isCluster = point.properties.cluster\n if (isCluster) {\n point.properties.clusterIndex = clusterIndex\n point.properties.clusterPoints = clusterIndex.getLeaves(point.properties.cluster_id, Infinity).map(d => d.properties)\n }\n }\n\n return points as (ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<D>)[]\n}\n"],"names":[],"mappings":";;;;;;;;AA4BM,SAAU,SAAS,CACvB,SAA+D,EAAA;AAE/D,IAAA,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAA;AACxC,IAAA,SAAS,CAAC,OAAO,CAAC,MAAM,IAAG;QACzB,IAAI,CAAC,GAAG,EAAE;YACR,GAAG,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,MAAM,CAAE,CAAA;AACpB,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;AAAE,gBAAA,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;AAC1C,YAAA,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;AAAE,gBAAA,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;AAC1C,YAAA,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;AAAE,gBAAA,GAAG,CAAC,EAAE,GAAG,MAAM,C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,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAA;AACtH,SAAA;AACF,KAAA;AAED,IAAA,OAAO,MAAyE,CAAA;AAClF;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/leaflet-map/modules/utils.ts"],"sourcesContent":["import type L from 'leaflet'\nimport { min, max } from 'd3-array'\nimport Supercluster, { ClusterFeature, PointFeature } from 'supercluster'\n\n// Utils\nimport { clamp, getString, getNumber } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { polygon, circlePath } from 'utils/path'\nimport { getHTMLTransform } from 'utils/html'\n\n// Types\nimport { ColorAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { GenericDataRecord } from 'types/data'\n\n// Local Types\nimport {\n LeafletMapPoint,\n LeafletMapPointShape,\n LeafletMapPieDatum,\n LeafletMapPointStyles,\n PointExpandedClusterProperties,\n LeafletMapPointDatum,\n LeafletMapClusterDatum,\n} from '../types'\n\n// Config\nimport { LeafletMapConfigInterface } from '../config'\n\nexport function bBoxMerge (\n bBoxArray: ({x1: number; x2: number; y1: number; y2: number})[]):\n { x: number; y: number; width: number; height: number } {\n let box = { x1: 0, x2: 0, y1: 0, y2: 0 }\n bBoxArray.forEach(coords => {\n if (!box) {\n box = { ...coords }\n } else {\n if (box.x1 > coords.x1) box.x1 = coords.x1\n if (box.y1 > coords.y1) box.y1 = coords.y1\n if (box.x2 < coords.x2) box.x2 = coords.x2\n if (box.y2 < coords.y2) box.y2 = coords.y2\n }\n })\n\n return {\n x: box.x1,\n y: box.y1,\n width: box.x2 - box.x1,\n height: box.y2 - box.y1,\n }\n}\n\nexport const getNextZoomLevelOnClusterClick = (level: number): number => clamp(1 + level * 1.5, level, 12)\n\nexport function projectPoint<D extends GenericDataRecord> (\n geoJSONPoint: LeafletMapPoint<D> | ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>,\n leafletMap: L.Map\n): { x: number; y: number } {\n const lat = geoJSONPoint.geometry.coordinates[1]\n const lon = geoJSONPoint.geometry.coordinates[0]\n const projected = leafletMap.latLngToLayerPoint([lat, lon])\n return projected\n}\n\nexport function getPointRadius<D extends GenericDataRecord> (\n geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>> | PointFeature<PointExpandedClusterProperties<D>>,\n pointRadius: NumericAccessor<LeafletMapPointDatum<D>> | NumericAccessor<LeafletMapClusterDatum<D>>,\n zoomLevel: number\n): number {\n const isDynamic = !pointRadius\n const radius = isDynamic\n ? 1 + 2 * Math.pow(zoomLevel, 0.80)\n // Todo: Needs a better typings handling\n : getNumber((geoPoint.properties as LeafletMapPointDatum<D>), pointRadius as NumericAccessor<LeafletMapPointDatum<D>>)\n\n const isCluster = (geoPoint as ClusterFeature<D>).properties.cluster\n return (isCluster && isDynamic)\n ? clamp(Math.pow((geoPoint as ClusterFeature<D>).properties.point_count, 0.35) * radius, radius * 1.1, radius * 3)\n : radius\n}\n\nexport function getPointPos<D extends GenericDataRecord> (point: LeafletMapPoint<D> | ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>, leafletMap: L.Map): { x: number; y: number } {\n const properties = point.properties as LeafletMapPointDatum<D>\n const isFromCluster = !!(properties).expandedClusterPoint\n\n if (isFromCluster) {\n const { x, y } = projectPoint(properties.expandedClusterPoint, leafletMap)\n return {\n x: x + properties.dx,\n y: y + properties.dy,\n }\n } else {\n return projectPoint(point, leafletMap)\n }\n}\n\nexport function getPointDisplayOrder<D extends GenericDataRecord> (\n d: LeafletMapPoint<D>,\n pointStatus: StringAccessor<LeafletMapPointDatum<D> | LeafletMapClusterDatum<D>>,\n colorMap: LeafletMapPointStyles<D>\n): number {\n const status = getString(d.properties, pointStatus)\n const statusList = Object.keys(colorMap)\n return Object.keys(statusList).indexOf(status)\n}\n\nexport function toGeoJSONPoint<D extends GenericDataRecord> (d: D, i: number, pointLatitude: NumericAccessor<D>, pointLongitude: NumericAccessor<D>): PointFeature<D> {\n const lat = getNumber(d, pointLatitude) as number\n const lon = getNumber(d, pointLongitude) as number\n\n return {\n type: 'Feature',\n properties: {\n ...d,\n _index: i,\n },\n geometry: {\n type: 'Point',\n coordinates: [lon, lat],\n },\n }\n}\n\nexport function calculateClusterIndex<D extends GenericDataRecord> (data: D[], config: LeafletMapConfigInterface<D>, maxClusterZoomLevel = 23): Supercluster<D> {\n const { colorMap, pointShape, pointLatitude, pointLongitude, clusteringDistance } = config\n return new Supercluster<D, Supercluster.AnyProps>({\n radius: clusteringDistance,\n maxZoom: maxClusterZoomLevel,\n map: (d): Supercluster.AnyProps => {\n const shape = getString(d, pointShape)\n\n const clusterPoint = { shape } as Supercluster.AnyProps\n for (const key of Object.keys(colorMap)) {\n clusterPoint[key] = d[key] || 0\n }\n\n return clusterPoint\n },\n reduce: (acc, clusterPoint): void => {\n acc.shape = acc.shape === clusterPoint.shape ? acc.shape : LeafletMapPointShape.Circle\n acc.value = (acc.value ?? 0) + (clusterPoint.value ?? 0)\n\n for (const key of Object.keys(colorMap)) {\n acc[key] += clusterPoint[key]\n }\n },\n }).load(data.map((d, i) => toGeoJSONPoint(d, i, pointLatitude, pointLongitude)))\n}\n\nexport function getNodePathData ({ x, y }: { x: number; y: number }, radius: number, shape: LeafletMapPointShape): string {\n switch (shape) {\n case LeafletMapPointShape.Triangle:\n return polygon(radius * 2, 3)\n case LeafletMapPointShape.Square:\n return polygon(radius * 2, 4)\n case LeafletMapPointShape.Circle:\n case LeafletMapPointShape.Ring:\n default:\n return circlePath(x, y, radius)\n }\n}\n\nexport function getDonutData<D extends GenericDataRecord> (\n d: LeafletMapClusterDatum<D> | LeafletMapPointDatum<D>,\n colorMap: LeafletMapPointStyles<D>\n): LeafletMapPieDatum[] {\n return Object.keys(colorMap).map(key => ({\n name: key,\n value: d[key] as number,\n color: colorMap[key].color,\n className: colorMap[key].className,\n }))\n}\n\nexport function geoJsonPointToScreenPoint<D extends GenericDataRecord> (\n geoPoint: ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<LeafletMapPointDatum<D>>,\n i: number,\n leafletMap: L.Map,\n config: LeafletMapConfigInterface<D>\n): LeafletMapPoint<D> {\n const zoomLevel = leafletMap.getZoom()\n const isCluster = (geoPoint.properties as LeafletMapClusterDatum<D>).cluster\n const clusterIndex = (geoPoint.properties as LeafletMapClusterDatum<D>).clusterIndex\n const clusterPoints = isCluster ? clusterIndex.getLeaves((geoPoint.properties as LeafletMapClusterDatum<D>).cluster_id as number, Infinity).map(d => d.properties) : undefined\n const { x, y } = getPointPos(geoPoint, leafletMap)\n\n const id = isCluster ? `cluster-${geoPoint.id}` : (getString(geoPoint.properties as LeafletMapPointDatum<D>, config.pointId) ?? geoPoint.geometry.coordinates.join(''))\n // Todo: Needs a better typings handling\n const pointColor = getColor(geoPoint.properties as LeafletMapPointDatum<D>, (isCluster ? config.clusterColor : config.pointColor) as ColorAccessor<LeafletMapPointDatum<D>>)\n const radius = getPointRadius(geoPoint, isCluster ? config.clusterRadius : config.pointRadius, zoomLevel)\n const shape = isCluster ? LeafletMapPointShape.Circle : getString(geoPoint.properties as LeafletMapPointDatum<D>, config.pointShape) as LeafletMapPointShape\n const isRing = shape === LeafletMapPointShape.Ring\n\n const donutData = getDonutData(geoPoint.properties, config.colorMap)\n const maxValue = max(donutData, d => d.value)\n const maxValueIndex = donutData.map(d => d.value).indexOf(maxValue)\n const biggestDatum = donutData[maxValueIndex ?? 0]\n\n const color = isCluster ? pointColor\n : (isRing ? null : (pointColor ?? biggestDatum?.color))\n const bbox = { x1: x - radius, y1: y - radius, x2: x + radius, y2: y + radius }\n const path = getNodePathData({ x: 0, y: 0 }, radius, shape)\n const _zIndex = 0\n\n const screenPoint: LeafletMapPoint<D> = {\n ...geoPoint,\n id,\n bbox,\n radius,\n donutData,\n path,\n color,\n isCluster,\n clusterIndex,\n clusterPoints,\n _zIndex,\n }\n\n return screenPoint\n}\n\nexport function shouldClusterExpand<D extends GenericDataRecord> (\n cluster: LeafletMapPoint<D>,\n zoomLevel: number,\n midLevel = 4,\n maxLevel = 8,\n maxClusterZoomLevel = 23\n): boolean {\n if (!cluster) return false\n\n const clusterExpansionZoomLevel = cluster.clusterIndex.getClusterExpansionZoom(cluster.properties.cluster_id as number)\n return zoomLevel >= maxLevel ||\n (zoomLevel >= midLevel && (cluster.properties.point_count < 20 || clusterExpansionZoomLevel >= maxClusterZoomLevel))\n}\n\nexport function findPointAndClusterByPointId<D extends GenericDataRecord> (\n points: LeafletMapPoint<D>[],\n id: string,\n pointId: StringAccessor<D>\n): {\n point: PointFeature<D> | undefined;\n cluster: LeafletMapPoint<D> | undefined;\n } {\n let point\n let cluster\n points.forEach(p => {\n if (p.isCluster) {\n const leaves = p.clusterIndex.getLeaves((p.properties as LeafletMapClusterDatum<D>).cluster_id as number, Infinity) ?? []\n const foundPoint = leaves.find(d => getString(d.properties, pointId) === id)\n if (foundPoint) {\n point = foundPoint\n cluster = p\n }\n }\n })\n return { point, cluster }\n}\n\nexport function getNodeRelativePosition<D extends GenericDataRecord> (d: LeafletMapPoint<D>, leafletMap: L.Map): { x: number; y: number } {\n const paneTransform = getHTMLTransform(leafletMap.getPane('mapPane'))\n const { x, y } = getPointPos(d, leafletMap)\n return { x: x + paneTransform[0], y: y + paneTransform[1] }\n}\n\nexport function getClusterRadius<D extends GenericDataRecord> (cluster: { points: PointFeature<PointExpandedClusterProperties<D>>[]; cluster: LeafletMapPoint<D> }): number {\n const { points } = cluster\n const minX = min<number>(points.map(d => d.properties.dx - d.properties.r))\n const maxX = max<number>(points.map(d => d.properties.dx + d.properties.r))\n const minY = min<number>(points.map(d => d.properties.dy - d.properties.r))\n const maxY = max<number>(points.map(d => d.properties.dy + d.properties.r))\n return Math.sqrt((maxX - minX) ** 2 + (maxY - minY) ** 2) * 0.5\n}\n\nexport function getClustersAndPoints<D extends GenericDataRecord> (\n clusterIndex: Supercluster<D>,\n leafletMap: L.Map,\n customBounds?: [number, number, number, number]\n): (ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<D>)[] {\n const leafletBounds = leafletMap.getBounds()\n const southWest = leafletBounds.getSouthWest()\n const northEast = leafletBounds.getNorthEast()\n const bounds = customBounds || [southWest.lng, southWest.lat, northEast.lng, northEast.lat]\n const zoom = Math.round(leafletMap.getZoom())\n const points = clusterIndex.getClusters(bounds, zoom) // as ClusterFeature<LeafletMapPointDatum<D>>[]\n\n for (const p of points) {\n const point = p as ClusterFeature<LeafletMapClusterDatum<D>>\n const isCluster = point.properties.cluster\n if (isCluster) {\n point.properties.clusterIndex = clusterIndex\n point.properties.clusterPoints = clusterIndex.getLeaves(point.properties.cluster_id, Infinity).map(d => d.properties)\n }\n }\n\n return points as (ClusterFeature<LeafletMapClusterDatum<D>> | PointFeature<D>)[]\n}\n"],"names":[],"mappings":";;;;;;;;AA4BM,SAAU,SAAS,CACvB,SAA+D,EAAA;AAE/D,IAAA,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAA;AACxC,IAAA,SAAS,CAAC,OAAO,CAAC,MAAM,IAAG;QACzB,IAAI,CAAC,GAAG,EAAE;YACR,GAAG,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,MAAM,CAAE,CAAA;AACpB,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;AAAE,gBAAA,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;AAC1C,YAAA,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;AAAE,gBAAA,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;AAC1C,YAAA,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;A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AAK,CAAC,UAAU,CAAC,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAA;AACtH,SAAA;AACF,KAAA;AAED,IAAA,OAAO,MAAyE,CAAA;AAClF;;;;"}
|
|
@@ -2,7 +2,7 @@ import type L from 'leaflet';
|
|
|
2
2
|
import type Maplibre from 'maplibre-gl';
|
|
3
3
|
import type { Map } from 'maplibre-gl';
|
|
4
4
|
import { GenericDataRecord } from "../../../types/data";
|
|
5
|
-
import {
|
|
6
|
-
export declare function getMaplibreGLLayer<Datum extends GenericDataRecord>(config:
|
|
5
|
+
import { LeafletMapConfigInterface } from '../config';
|
|
6
|
+
export declare function getMaplibreGLLayer<Datum extends GenericDataRecord>(config: LeafletMapConfigInterface<Datum>, leaflet: typeof L, maplibre: typeof Maplibre): L.Layer & {
|
|
7
7
|
getMaplibreMap(): Map;
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxgl-layer.js","sources":["../../../../src/components/leaflet-map/renderer/mapboxgl-layer.ts"],"sourcesContent":["import type L from 'leaflet'\nimport type Maplibre from 'maplibre-gl'\nimport type { Map } from 'maplibre-gl'\n\nimport { injectGlobal } from '@emotion/css'\n\n// Utils\nimport { isObject } from 'utils/data'\n\n// Types\nimport { GenericDataRecord } from 'types/data'\n\n// Config\nimport {
|
|
1
|
+
{"version":3,"file":"mapboxgl-layer.js","sources":["../../../../src/components/leaflet-map/renderer/mapboxgl-layer.ts"],"sourcesContent":["import type L from 'leaflet'\nimport type Maplibre from 'maplibre-gl'\nimport type { Map } from 'maplibre-gl'\n\nimport { injectGlobal } from '@emotion/css'\n\n// Utils\nimport { isObject } from 'utils/data'\n\n// Types\nimport { GenericDataRecord } from 'types/data'\n\n// Config\nimport { LeafletMapConfigInterface } from '../config'\nimport { MapLibreStyleSpecs } from './map-style'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { MaplibreGLLayer } from './leaflet-maplibre-gl'\n\n// Inject MapLibreGL global style\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport mapLibreStyles from './maplibre-gl.css.js'\ninjectGlobal(mapLibreStyles)\n\nexport function getMaplibreGLLayer<Datum extends GenericDataRecord> (\n config: LeafletMapConfigInterface<Datum>,\n leaflet: typeof L,\n maplibre: typeof Maplibre\n): L.Layer & { getMaplibreMap(): Map } {\n const { accessToken, style } = config\n\n if (isObject(style) && !(style as MapLibreStyleSpecs).glyphs) {\n console.warn('Unovis | Leaflet Map: Glyphs URL is required in order to show the map. Set `mapboxglGlyphs` URL in the style settings')\n return\n }\n\n if (isObject(style) && !(style as MapLibreStyleSpecs).sources) {\n console.warn('Unovis | Leaflet Map: Sources settings are required in order to show map. Set the `sources` property in the style settings')\n return\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const layer = MaplibreGLLayer(leaflet, maplibre, {\n style: style,\n accessToken: accessToken || 'not-needed',\n })\n\n return layer\n}\n"],"names":[],"mappings":";;;;;AAuBA,YAAY,CAAC,cAAc,CAAC,CAAA;SAEZ,kBAAkB,CAChC,MAAwC,EACxC,OAAiB,EACjB,QAAyB,EAAA;AAEzB,IAAA,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAErC,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAE,KAA4B,CAAC,MAAM,EAAE;AAC5D,QAAA,OAAO,CAAC,IAAI,CAAC,uHAAuH,CAAC,CAAA;QACrI,OAAM;AACP,KAAA;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAE,KAA4B,CAAC,OAAO,EAAE;AAC7D,QAAA,OAAO,CAAC,IAAI,CAAC,4HAA4H,CAAC,CAAA;QAC1I,OAAM;AACP,KAAA;;;AAID,IAAA,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE;AAC/C,QAAA,KAAK,EAAE,KAAK;QACZ,WAAW,EAAE,WAAW,IAAI,YAAY;AACzC,KAAA,CAAC,CAAA;AAEF,IAAA,OAAO,KAAK,CAAA;AACd;;;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import type L from 'leaflet';
|
|
2
|
+
import type { Map } from 'maplibre-gl';
|
|
1
3
|
export declare function constraintMapView(map: L.Map, latMin?: number, latMax?: number): void;
|
|
2
|
-
export declare function mapboxglWheelEvent(map:
|
|
4
|
+
export declare function mapboxglWheelEvent(map: L.Map, layer: L.Layer & {
|
|
5
|
+
getMaplibreMap(): Map;
|
|
6
|
+
}, event: WheelEvent): void;
|
|
3
7
|
export declare const mapboxglWheelEventThrottled: import("throttle-debounce").throttle<typeof mapboxglWheelEvent>;
|
|
4
8
|
export declare const constraintMapViewThrottled: import("throttle-debounce").throttle<typeof constraintMapView>;
|
|
@@ -13,11 +13,11 @@ function constraintMapView(map, latMin = -75, latMax = 85) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
function mapboxglWheelEvent(map, layer, event) {
|
|
16
|
-
const {
|
|
16
|
+
const { deltaY } = event;
|
|
17
17
|
if (!layer || !layer.getMaplibreMap)
|
|
18
18
|
return;
|
|
19
19
|
const mapboxmap = layer.getMaplibreMap();
|
|
20
|
-
const delta =
|
|
20
|
+
const delta = deltaY * -1;
|
|
21
21
|
// Prevent Map from being zoomed-out too far away
|
|
22
22
|
const bounds = map.getBounds();
|
|
23
23
|
const northEast = bounds.getNorthEast();
|
|
@@ -30,7 +30,7 @@ function mapboxglWheelEvent(map, layer, event) {
|
|
|
30
30
|
}
|
|
31
31
|
const zoom = mapboxmap.getZoom() + delta * 0.001;
|
|
32
32
|
const xy = map.mouseEventToLayerPoint(event);
|
|
33
|
-
map.setZoomAround(xy, zoom + 1, { animate: false
|
|
33
|
+
map.setZoomAround(xy, zoom + 1, { animate: false });
|
|
34
34
|
}
|
|
35
35
|
const mapboxglWheelEventThrottled = throttle(mapboxglWheelEvent, 32);
|
|
36
36
|
const constraintMapViewThrottled = throttle(constraintMapView, 1000);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxgl-utils.js","sources":["../../../../src/components/leaflet-map/renderer/mapboxgl-utils.ts"],"sourcesContent":["// Utils\nimport { throttle } from 'utils/data'\n\nexport function constraintMapView (map: L.Map, latMin = -75, latMax = 85): void {\n const bounds = map.getBounds()\n const northEast = bounds.getNorthEast()\n const southWest = bounds.getSouthWest()\n\n if (northEast.lat > latMax && southWest.lat < latMin) {\n map.fitBounds([\n [latMin, 0],\n [latMax, 0],\n ])\n }\n}\n\nexport function mapboxglWheelEvent (map
|
|
1
|
+
{"version":3,"file":"mapboxgl-utils.js","sources":["../../../../src/components/leaflet-map/renderer/mapboxgl-utils.ts"],"sourcesContent":["import type L from 'leaflet'\nimport type { Map } from 'maplibre-gl'\n\n// Utils\nimport { throttle } from 'utils/data'\n\nexport function constraintMapView (map: L.Map, latMin = -75, latMax = 85): void {\n const bounds = map.getBounds()\n const northEast = bounds.getNorthEast()\n const southWest = bounds.getSouthWest()\n\n if (northEast.lat > latMax && southWest.lat < latMin) {\n map.fitBounds([\n [latMin, 0],\n [latMax, 0],\n ])\n }\n}\n\nexport function mapboxglWheelEvent (\n map: L.Map,\n layer: L.Layer & { getMaplibreMap(): Map },\n event: WheelEvent\n): void {\n const { deltaY } = event\n if (!layer || !layer.getMaplibreMap) return\n const mapboxmap = layer.getMaplibreMap()\n const delta = deltaY * -1\n\n // Prevent Map from being zoomed-out too far away\n const bounds = map.getBounds()\n const northEast = bounds.getNorthEast()\n const southWest = bounds.getSouthWest()\n const latMin = -70\n const latMax = 80\n if (delta < 0 && northEast.lat > latMax && southWest.lat < latMin) {\n constraintMapView(map)\n return\n }\n\n const zoom = mapboxmap.getZoom() + delta * 0.001\n const xy = map.mouseEventToLayerPoint(event)\n map.setZoomAround(xy, zoom + 1, { animate: false })\n}\n\nexport const mapboxglWheelEventThrottled = throttle(mapboxglWheelEvent, 32)\nexport const constraintMapViewThrottled = throttle(constraintMapView, 1000)\n"],"names":[],"mappings":";;AAGA;AAGgB,SAAA,iBAAiB,CAAE,GAAU,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,EAAA;AACtE,IAAA,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAA;AAC9B,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAA;AACvC,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAA;IAEvC,IAAI,SAAS,CAAC,GAAG,GAAG,MAAM,IAAI,SAAS,CAAC,GAAG,GAAG,MAAM,EAAE;QACpD,GAAG,CAAC,SAAS,CAAC;YACZ,CAAC,MAAM,EAAE,CAAC,CAAC;YACX,CAAC,MAAM,EAAE,CAAC,CAAC;AACZ,SAAA,CAAC,CAAA;AACH,KAAA;AACH,CAAC;SAEe,kBAAkB,CAChC,GAAU,EACV,KAA0C,EAC1C,KAAiB,EAAA;AAEjB,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;AACxB,IAAA,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,cAAc;QAAE,OAAM;AAC3C,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,EAAE,CAAA;AACxC,IAAA,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,CAAA;;AAGzB,IAAA,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAA;AAC9B,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAA;AACvC,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAA;AACvC,IAAA,MAAM,MAAM,GAAG,CAAC,EAAE,CAAA;IAClB,MAAM,MAAM,GAAG,EAAE,CAAA;AACjB,IAAA,IAAI,KAAK,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,GAAG,MAAM,IAAI,SAAS,CAAC,GAAG,GAAG,MAAM,EAAE;QACjE,iBAAiB,CAAC,GAAG,CAAC,CAAA;QACtB,OAAM;AACP,KAAA;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,KAAK,CAAA;IAChD,MAAM,EAAE,GAAG,GAAG,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAA;AAC5C,IAAA,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,IAAI,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;AACrD,CAAC;AAEY,MAAA,2BAA2B,GAAG,QAAQ,CAAC,kBAAkB,EAAE,EAAE,EAAC;AAC9D,MAAA,0BAA0B,GAAG,QAAQ,CAAC,iBAAiB,EAAE,IAAI;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/leaflet-map/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\n// Inject Leaflet global style\n// eslint-disable-next-line\nimport leafletCSS from './leaflet.css'\ninjectGlobal(leafletCSS)\n\nconst cssVarDefaults = {\n '--vis-map-container-background-color': '#dfe5eb',\n /* Undefined by default to allow proper fallback to var(--vis-font-family) */\n '--vis-map-label-font-family': undefined,\n\n '--vis-map-point-default-fill-color': '#B9BEC3',\n '--vis-map-point-ring-fill-color': '#ffffff',\n '--vis-map-point-default-stroke-color': '#959da3',\n '--vis-map-point-default-stroke-width': '0px',\n '--vis-map-point-default-cursor': 'default',\n\n '--vis-map-cluster-default-fill-color': '#fff',\n '--vis-map-cluster-default-stroke-color': '#B9BEC3',\n '--vis-map-cluster-default-stroke-width': '1.5px',\n '--vis-map-cluster-donut-fill-color': '#959da3',\n\n '--vis-map-cluster-inner-label-text-color-dark': '#5b5f6d',\n '--vis-map-cluster-inner-label-text-color-light': '#fff',\n\n '--vis-map-point-inner-label-text-color-dark': '#5b5f6d',\n '--vis-map-point-inner-label-text-color-light': '#fff',\n\n '--vis-map-point-bottom-label-text-color': '#5b5f6d',\n '--vis-map-point-bottom-label-font-size': '10px',\n\n '--vis-map-cluster-expanded-background-fill-color': '#fff',\n\n /* Dark Theme */\n '--vis-dark-map-container-background-color': '#dfe5eb',\n '--vis-dark-map-point-default-fill-color': '#B9BEC3',\n '--vis-dark-map-point-default-stroke-color': '#959da3',\n '--vis-dark-map-point-ring-fill-color': '#5b5f6d',\n\n '--vis-dark-map-cluster-default-fill-color': '#5b5f6d',\n '--vis-dark-map-cluster-default-stroke-color': '#B9BEC3',\n '--vis-dark-map-cluster-donut-fill-color': '#959da3',\n\n '--vis-dark-map-cluster-inner-label-text-color-dark': '#5b5f6d',\n '--vis-dark-map-cluster-inner-label-text-color-light': '#fff',\n\n '--vis-dark-map-point-inner-label-text-color-dark': '#5b5f6d',\n '--vis-dark-map-point-inner-label-text-color-light': '#fff',\n\n '--vis-dark-map-point-bottom-label-text-color': '#5b5f6d',\n\n '--vis-dark-map-cluster-expanded-background-fill-color': '#fff',\n}\n\nexport const root = css`\n label: leaflet-map-component;\n\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: var(--vis-map-container-background-color);\n\n canvas {\n pointer-events: all;\n }\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const background = `${root} canvas`\n\nexport const points = css`\n label: g-points;\n`\n\nexport const point = css`\n label: g-point;\n`\n\nexport const pointPath = css`\n label: point-path;\n\n stroke-opacity: 1;\n fill-opacity: 1.0;\n fill: var(${variables.mapPointDefaultFillColor});\n stroke: var(${variables.mapPointDefaultStrokeColor});\n stroke-width: var(${variables.mapPointDefaultStrokeWidth});\n pointer-events: fill !important;\n transition: .2s stroke-width, .3s transform;\n cursor: var(${variables.mapPointDefaultCursor});\n\n &:hover {\n stroke-width: 2;\n fill-opacity: 1;\n animation: none;\n transform: scale(1.1);\n }\n`\n\nexport const pointPathRing = css`\n label: point-path-ring;\n fill: var(${variables.mapPointRingFillColor});\n`\n\nexport const pointPathCluster = css`\n label: point-path-cluster;\n fill-opacity: 0.9;\n stroke: none;\n animation: none;\n fill: var(${variables.mapClusterDefaultFillColor});\n stroke: var(${variables.mapClusterDefaultStrokeColor});\n stroke-width: var(${variables.mapClusterDefaultStrokeWidth});\n`\n\nexport const pointSelectionRing = css`\n label: point-selection-ring;\n stroke: var(${variables.mapPointDefaultFillColor});\n`\n\nexport const pointSelection = css`\n label: point-selection;\n\n opacity: 0;\n transform: scale(1);\n\n &.active {\n transition: all 400ms cubic-bezier(0.230, 1.000, 0.320, 1.000);\n opacity: 1;\n transform: scale(1.25);\n }\n`\n\nexport const innerLabel = css`\n label: inner-label;\n\n text-anchor: middle;\n fill: var(${variables.mapPointInnerLabelTextColorDark});\n font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const innerLabelCluster = css`\n label: inner-label-cluster;\n fill: var(${variables.mapPointInnerLabelTextColorDark});\n`\n\nexport const bottomLabel = css`\n label: bottom-label;\n\n text-anchor: middle;\n fill: var(${variables.mapPointBottomLabelTextColor});\n font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const donutCluster = css`\n label: donut-cluster;\n\n transform: scale(1);\n transition: .3s transform;\n path {\n fill: var(${variables.mapClusterDonutFillColor});\n stroke-width: 0.5;\n }\n\n &:hover {\n transform: scale(1.1);\n }\n`\n\nexport const svgOverlay = css`\n label: svg-overlay;\n position: absolute;\n pointer-events: none;\n`\n\nexport const backgroundRect = css`\n label: background-rect;\n\n opacity: 0;\n`\n\nexport const clusterBackground = css`\n label: cluster-background;\n\n fill: var(${variables.mapClusterExpandedBackgroundFillColor});\n opacity: 0.6;\n visibility: hidden;\n\n &.active {\n visibility: visible;\n }\n`\n\nexport const onFeatureHover = css`\n label: feature-hovered;\n`\n\nexport const mapboxglCanvas = css`\n pointer-events: all;\n cursor: grab;\n\n &${`.${onFeatureHover}`} {\n cursor: default;\n }\n`\n\nexport const map = css`\n label: map;\n`\n"],"names":["leafletCSS"],"mappings":";;;;AAQA,YAAY,CAACA,QAAU,CAAC,CAAA;AAExB,MAAM,cAAc,GAAG;AACrB,IAAA,sCAAsC,EAAE,SAAS;;AAEjD,IAAA,6BAA6B,EAAE,
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/leaflet-map/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\n// Inject Leaflet global style\n// eslint-disable-next-line\nimport leafletCSS from './leaflet.css'\ninjectGlobal(leafletCSS)\n\nconst cssVarDefaults = {\n '--vis-map-container-background-color': '#dfe5eb',\n /* Undefined by default to allow proper fallback to var(--vis-font-family) */\n '--vis-map-label-font-family': undefined as undefined,\n\n '--vis-map-point-default-fill-color': '#B9BEC3',\n '--vis-map-point-ring-fill-color': '#ffffff',\n '--vis-map-point-default-stroke-color': '#959da3',\n '--vis-map-point-default-stroke-width': '0px',\n '--vis-map-point-default-cursor': 'default',\n\n '--vis-map-cluster-default-fill-color': '#fff',\n '--vis-map-cluster-default-stroke-color': '#B9BEC3',\n '--vis-map-cluster-default-stroke-width': '1.5px',\n '--vis-map-cluster-donut-fill-color': '#959da3',\n\n '--vis-map-cluster-inner-label-text-color-dark': '#5b5f6d',\n '--vis-map-cluster-inner-label-text-color-light': '#fff',\n\n '--vis-map-point-inner-label-text-color-dark': '#5b5f6d',\n '--vis-map-point-inner-label-text-color-light': '#fff',\n\n '--vis-map-point-bottom-label-text-color': '#5b5f6d',\n '--vis-map-point-bottom-label-font-size': '10px',\n\n '--vis-map-cluster-expanded-background-fill-color': '#fff',\n\n /* Dark Theme */\n '--vis-dark-map-container-background-color': '#dfe5eb',\n '--vis-dark-map-point-default-fill-color': '#B9BEC3',\n '--vis-dark-map-point-default-stroke-color': '#959da3',\n '--vis-dark-map-point-ring-fill-color': '#5b5f6d',\n\n '--vis-dark-map-cluster-default-fill-color': '#5b5f6d',\n '--vis-dark-map-cluster-default-stroke-color': '#B9BEC3',\n '--vis-dark-map-cluster-donut-fill-color': '#959da3',\n\n '--vis-dark-map-cluster-inner-label-text-color-dark': '#5b5f6d',\n '--vis-dark-map-cluster-inner-label-text-color-light': '#fff',\n\n '--vis-dark-map-point-inner-label-text-color-dark': '#5b5f6d',\n '--vis-dark-map-point-inner-label-text-color-light': '#fff',\n\n '--vis-dark-map-point-bottom-label-text-color': '#5b5f6d',\n\n '--vis-dark-map-cluster-expanded-background-fill-color': '#fff',\n}\n\nexport const root = css`\n label: leaflet-map-component;\n\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: var(--vis-map-container-background-color);\n\n canvas {\n pointer-events: all;\n }\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const background = `${root} canvas`\n\nexport const points = css`\n label: g-points;\n`\n\nexport const point = css`\n label: g-point;\n`\n\nexport const pointPath = css`\n label: point-path;\n\n stroke-opacity: 1;\n fill-opacity: 1.0;\n fill: var(${variables.mapPointDefaultFillColor});\n stroke: var(${variables.mapPointDefaultStrokeColor});\n stroke-width: var(${variables.mapPointDefaultStrokeWidth});\n pointer-events: fill !important;\n transition: .2s stroke-width, .3s transform;\n cursor: var(${variables.mapPointDefaultCursor});\n\n &:hover {\n stroke-width: 2;\n fill-opacity: 1;\n animation: none;\n transform: scale(1.1);\n }\n`\n\nexport const pointPathRing = css`\n label: point-path-ring;\n fill: var(${variables.mapPointRingFillColor});\n`\n\nexport const pointPathCluster = css`\n label: point-path-cluster;\n fill-opacity: 0.9;\n stroke: none;\n animation: none;\n fill: var(${variables.mapClusterDefaultFillColor});\n stroke: var(${variables.mapClusterDefaultStrokeColor});\n stroke-width: var(${variables.mapClusterDefaultStrokeWidth});\n`\n\nexport const pointSelectionRing = css`\n label: point-selection-ring;\n stroke: var(${variables.mapPointDefaultFillColor});\n`\n\nexport const pointSelection = css`\n label: point-selection;\n\n opacity: 0;\n transform: scale(1);\n\n &.active {\n transition: all 400ms cubic-bezier(0.230, 1.000, 0.320, 1.000);\n opacity: 1;\n transform: scale(1.25);\n }\n`\n\nexport const innerLabel = css`\n label: inner-label;\n\n text-anchor: middle;\n fill: var(${variables.mapPointInnerLabelTextColorDark});\n font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const innerLabelCluster = css`\n label: inner-label-cluster;\n fill: var(${variables.mapPointInnerLabelTextColorDark});\n`\n\nexport const bottomLabel = css`\n label: bottom-label;\n\n text-anchor: middle;\n fill: var(${variables.mapPointBottomLabelTextColor});\n font-family: var(${variables.mapLabelFontFamily}, var(--vis-font-family));\n pointer-events: none;\n font-weight: 600;\n`\n\nexport const donutCluster = css`\n label: donut-cluster;\n\n transform: scale(1);\n transition: .3s transform;\n path {\n fill: var(${variables.mapClusterDonutFillColor});\n stroke-width: 0.5;\n }\n\n &:hover {\n transform: scale(1.1);\n }\n`\n\nexport const svgOverlay = css`\n label: svg-overlay;\n position: absolute;\n pointer-events: none;\n`\n\nexport const backgroundRect = css`\n label: background-rect;\n\n opacity: 0;\n`\n\nexport const clusterBackground = css`\n label: cluster-background;\n\n fill: var(${variables.mapClusterExpandedBackgroundFillColor});\n opacity: 0.6;\n visibility: hidden;\n\n &.active {\n visibility: visible;\n }\n`\n\nexport const onFeatureHover = css`\n label: feature-hovered;\n`\n\nexport const mapboxglCanvas = css`\n pointer-events: all;\n cursor: grab;\n\n &${`.${onFeatureHover}`} {\n cursor: default;\n }\n`\n\nexport const map = css`\n label: map;\n`\n"],"names":["leafletCSS"],"mappings":";;;;AAQA,YAAY,CAACA,QAAU,CAAC,CAAA;AAExB,MAAM,cAAc,GAAG;AACr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,CAAA;;;;;;AAMf,cAAA,EAAA,SAAS,CAAC,wBAAwB,CAAA;;;;;;;EAOjD;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;EAI5B;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;;;EAIhC;AAEM,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAA;;;AAGtB,YAAA,EAAA,SAAS,CAAC,qCAAqC,CAAA;;;;;;;EAO5D;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;EAEhC;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;;;AAI5B,GAAA,EAAA,CAAA,CAAA,EAAI,cAAc,CAAE,CAAA,CAAA;;;EAGxB;AAEM,MAAM,GAAG,GAAG,GAAG,CAAA,CAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LatLng } from 'leaflet';
|
|
2
|
-
import Supercluster, { ClusterProperties } from 'supercluster';
|
|
2
|
+
import Supercluster, { ClusterProperties, PointFeature } from 'supercluster';
|
|
3
3
|
import { GenericDataRecord } from "../../types/data";
|
|
4
4
|
export declare enum LeafletMapRenderer {
|
|
5
5
|
Raster = "raster",
|
|
@@ -74,3 +74,7 @@ export declare type MapZoomState = {
|
|
|
74
74
|
bounds: Bounds;
|
|
75
75
|
userDriven: boolean;
|
|
76
76
|
};
|
|
77
|
+
export declare type LeafletMapExpandedCluster<Datum extends GenericDataRecord> = {
|
|
78
|
+
points: PointFeature<PointExpandedClusterProperties<Datum>>[];
|
|
79
|
+
cluster: LeafletMapPoint<Datum>;
|
|
80
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/components/leaflet-map/types.ts"],"sourcesContent":["import { LatLng } from 'leaflet'\nimport Supercluster, { ClusterProperties } from 'supercluster'\nimport { GenericDataRecord } from 'types/data'\n\nexport enum LeafletMapRenderer {\n Raster = 'raster',\n MapLibre = 'maplibre',\n}\n\nexport enum LeafletMapPointShape {\n Square = 'square',\n Circle = 'circle',\n Triangle = 'triangle',\n Ring = 'ring',\n}\n\nexport type LeafletMapPieDatum = {\n value: number;\n name: string;\n color: string;\n className?: string;\n}\n\nexport interface LeafletMapPointStyle {\n color: string;\n className?: string;\n}\n\nexport type LeafletMapPointStyles<D> = { [key in keyof D]?: LeafletMapPointStyle }\n\nexport type PointExpandedClusterProperties<D extends GenericDataRecord> = D & {\n // Expanded cluster related data:\n // eslint-disable-next-line no-use-before-define\n expandedClusterPoint?: LeafletMapPoint<D>;\n r?: number;\n dx?: number;\n dy?: number;\n}\n\nexport type LeafletMapClusterDatum<D extends GenericDataRecord> = Partial<D> & ClusterProperties & {\n clusterIndex?: Supercluster<D>;\n clusterPoints?: D[];\n}\n\nexport type LeafletMapPointDatum<D extends GenericDataRecord> = D & PointExpandedClusterProperties<D> & {\n id: string | number;\n shape: LeafletMapPointShape;\n _index: number;\n};\n\nexport type LeafletMapPoint<D extends GenericDataRecord> = {\n geometry: GeoJSON.Point;\n bbox: { x1: number; x2: number; y1: number; y2: number };\n radius: number;\n path: string;\n color: string;\n id: number | string;\n properties: LeafletMapPointDatum<D> | LeafletMapClusterDatum<D>;\n donutData: LeafletMapPieDatum[];\n isCluster: boolean;\n clusterIndex: Supercluster<D, Supercluster.AnyProps>;\n clusterPoints?: D[];\n _zIndex: number;\n}\n\nexport type Bounds = {\n northEast: { lat: number; lng: number };\n southWest: { lat: number; lng: number };\n}\n\nexport type MapZoomState = {\n mapCenter: LatLng;\n zoomLevel: number;\n bounds: Bounds;\n userDriven: boolean;\n}\n"],"names":[],"mappings":"IAIY,mBAGX;AAHD,CAAA,UAAY,kBAAkB,EAAA;AAC5B,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAG7B,EAAA,CAAA,CAAA,CAAA;IAEW,qBAKX;AALD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,oBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,oBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EALW,oBAAoB,KAApB,oBAAoB,GAK/B,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/components/leaflet-map/types.ts"],"sourcesContent":["import { LatLng } from 'leaflet'\nimport Supercluster, { ClusterProperties, PointFeature } from 'supercluster'\nimport { GenericDataRecord } from 'types/data'\n\nexport enum LeafletMapRenderer {\n Raster = 'raster',\n MapLibre = 'maplibre',\n}\n\nexport enum LeafletMapPointShape {\n Square = 'square',\n Circle = 'circle',\n Triangle = 'triangle',\n Ring = 'ring',\n}\n\nexport type LeafletMapPieDatum = {\n value: number;\n name: string;\n color: string;\n className?: string;\n}\n\nexport interface LeafletMapPointStyle {\n color: string;\n className?: string;\n}\n\nexport type LeafletMapPointStyles<D> = { [key in keyof D]?: LeafletMapPointStyle }\n\nexport type PointExpandedClusterProperties<D extends GenericDataRecord> = D & {\n // Expanded cluster related data:\n // eslint-disable-next-line no-use-before-define\n expandedClusterPoint?: LeafletMapPoint<D>;\n r?: number;\n dx?: number;\n dy?: number;\n}\n\nexport type LeafletMapClusterDatum<D extends GenericDataRecord> = Partial<D> & ClusterProperties & {\n clusterIndex?: Supercluster<D>;\n clusterPoints?: D[];\n}\n\nexport type LeafletMapPointDatum<D extends GenericDataRecord> = D & PointExpandedClusterProperties<D> & {\n id: string | number;\n shape: LeafletMapPointShape;\n _index: number;\n};\n\nexport type LeafletMapPoint<D extends GenericDataRecord> = {\n geometry: GeoJSON.Point;\n bbox: { x1: number; x2: number; y1: number; y2: number };\n radius: number;\n path: string;\n color: string;\n id: number | string;\n properties: LeafletMapPointDatum<D> | LeafletMapClusterDatum<D>;\n donutData: LeafletMapPieDatum[];\n isCluster: boolean;\n clusterIndex: Supercluster<D, Supercluster.AnyProps>;\n clusterPoints?: D[];\n _zIndex: number;\n}\n\nexport type Bounds = {\n northEast: { lat: number; lng: number };\n southWest: { lat: number; lng: number };\n}\n\nexport type MapZoomState = {\n mapCenter: LatLng;\n zoomLevel: number;\n bounds: Bounds;\n userDriven: boolean;\n}\n\nexport type LeafletMapExpandedCluster<Datum extends GenericDataRecord> = {\n points: PointFeature<PointExpandedClusterProperties<Datum>>[];\n cluster: LeafletMapPoint<Datum>;\n}\n"],"names":[],"mappings":"IAIY,mBAGX;AAHD,CAAA,UAAY,kBAAkB,EAAA;AAC5B,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAG7B,EAAA,CAAA,CAAA,CAAA;IAEW,qBAKX;AALD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,oBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,oBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EALW,oBAAoB,KAApB,oBAAoB,GAK/B,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { XYComponentConfigInterface
|
|
1
|
+
import { XYComponentConfigInterface } from "../../core/xy-component/config";
|
|
2
2
|
import { CurveType } from "../../types/curve";
|
|
3
|
-
import { GenericAccessor, StringAccessor } from "../../types/accessor";
|
|
3
|
+
import { ColorAccessor, GenericAccessor, StringAccessor } from "../../types/accessor";
|
|
4
4
|
export interface LineConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {
|
|
5
|
+
/** Line color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */
|
|
6
|
+
color?: ColorAccessor<Datum[]>;
|
|
5
7
|
/** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */
|
|
6
8
|
curveType?: CurveType;
|
|
7
9
|
/** Line width in pixels. Default: `2` */
|
|
8
10
|
lineWidth?: number;
|
|
9
11
|
/** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */
|
|
10
|
-
lineDashArray?: GenericAccessor<number[], Datum>;
|
|
12
|
+
lineDashArray?: GenericAccessor<number[], Datum[]>;
|
|
11
13
|
/** When a data point has an `undefined`, `NaN`, or other no-data value, they'll be replaced with a value specified here.
|
|
12
14
|
* Setting this property to `undefined` will lead to having the line break when there's no data, and continue when
|
|
13
15
|
* the data appears again. If you set it to `null`, the values will be treated as numerical `0` values and the line
|
|
@@ -20,11 +22,4 @@ export interface LineConfigInterface<Datum> extends XYComponentConfigInterface<D
|
|
|
20
22
|
/** Optional link cursor. Default: `null` */
|
|
21
23
|
cursor?: StringAccessor<Datum[]>;
|
|
22
24
|
}
|
|
23
|
-
export declare
|
|
24
|
-
curveType: CurveType;
|
|
25
|
-
lineWidth: number;
|
|
26
|
-
lineDashArray: any;
|
|
27
|
-
fallbackValue: any;
|
|
28
|
-
highlightOnHover: boolean;
|
|
29
|
-
cursor: any;
|
|
30
|
-
}
|
|
25
|
+
export declare const LineDefaultConfig: LineConfigInterface<unknown>;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XYComponentDefaultConfig } from '../../core/xy-component/config.js';
|
|
2
2
|
import { CurveType } from '../../types/curve.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.curveType = CurveType.MonotoneX;
|
|
8
|
-
this.lineWidth = 2;
|
|
9
|
-
this.lineDashArray = undefined;
|
|
10
|
-
this.fallbackValue = undefined;
|
|
11
|
-
this.highlightOnHover = false;
|
|
12
|
-
this.cursor = null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
4
|
+
const LineDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { curveType: CurveType.MonotoneX, lineWidth: 2, lineDashArray: undefined, fallbackValue: undefined, highlightOnHover: false, cursor: null });
|
|
15
5
|
|
|
16
|
-
export {
|
|
6
|
+
export { LineDefaultConfig };
|
|
17
7
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/line/config.ts"],"sourcesContent":["import { XYComponentConfigInterface,
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/line/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, GenericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface LineConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Line color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType;\n /** Line width in pixels. Default: `2` */\n lineWidth?: number;\n /** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */\n lineDashArray?: GenericAccessor<number[], Datum[]>;\n /** When a data point has an `undefined`, `NaN`, or other no-data value, they'll be replaced with a value specified here.\n * Setting this property to `undefined` will lead to having the line break when there's no data, and continue when\n * the data appears again. If you set it to `null`, the values will be treated as numerical `0` values and the line\n * won't break; however if the whole dataset consists of only `null`s, the line won't be displayed.\n * Default: `undefined`\n */\n fallbackValue?: number | undefined | null;\n /** Highlight line on hover. Default: `false` */\n highlightOnHover?: boolean;\n /** Optional link cursor. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n}\n\nexport const LineDefaultConfig: LineConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n curveType: CurveType.MonotoneX,\n lineWidth: 2,\n lineDashArray: undefined,\n fallbackValue: undefined,\n highlightOnHover: false,\n cursor: null,\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,iBAAiB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACzB,wBAAwB,CAC3B,EAAA,EAAA,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,SAAS,EAAE,CAAC,EACZ,aAAa,EAAE,SAAS,EACxB,aAAa,EAAE,SAAS,EACxB,gBAAgB,EAAE,KAAK,EACvB,MAAM,EAAE,IAAI;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CurveFactoryLineOnly, Line as LineGenInterface } from 'd3-shape';
|
|
2
2
|
import { XYComponentCore } from "../../core/xy-component";
|
|
3
3
|
import { Spacing } from "../../types/spacing";
|
|
4
|
-
import {
|
|
4
|
+
import { LineConfigInterface } from './config';
|
|
5
5
|
import * as s from './style';
|
|
6
|
-
export declare class Line<Datum> extends XYComponentCore<Datum,
|
|
6
|
+
export declare class Line<Datum> extends XYComponentCore<Datum, LineConfigInterface<Datum>> {
|
|
7
7
|
static selectors: typeof s;
|
|
8
|
-
|
|
8
|
+
protected _defaultConfig: LineConfigInterface<Datum>;
|
|
9
|
+
config: LineConfigInterface<Datum>;
|
|
9
10
|
lineGen: LineGenInterface<{
|
|
10
11
|
x: number;
|
|
11
12
|
y: number;
|
|
@@ -14,8 +15,8 @@ export declare class Line<Datum> extends XYComponentCore<Datum, LineConfig<Datum
|
|
|
14
15
|
curve: CurveFactoryLineOnly;
|
|
15
16
|
events: {
|
|
16
17
|
[x: string]: {
|
|
17
|
-
mouseover: (datum:
|
|
18
|
-
mouseleave: (
|
|
18
|
+
mouseover: (datum: Datum) => void;
|
|
19
|
+
mouseleave: () => void;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
constructor(config?: LineConfigInterface<Datum>);
|
package/components/line/index.js
CHANGED
|
@@ -7,14 +7,15 @@ import { smartTransition } from '../../utils/d3.js';
|
|
|
7
7
|
import { getColor } from '../../utils/color.js';
|
|
8
8
|
import { Curve, CurveType } from '../../types/curve.js';
|
|
9
9
|
import { Direction } from '../../types/direction.js';
|
|
10
|
-
import {
|
|
10
|
+
import { LineDefaultConfig } from './config.js';
|
|
11
11
|
import * as style from './style.js';
|
|
12
12
|
import { line as line$1, linePath, lineSelectionHelper, dim } from './style.js';
|
|
13
13
|
|
|
14
14
|
class Line extends XYComponentCore {
|
|
15
15
|
constructor(config) {
|
|
16
16
|
super();
|
|
17
|
-
this.
|
|
17
|
+
this._defaultConfig = LineDefaultConfig;
|
|
18
|
+
this.config = this._defaultConfig;
|
|
18
19
|
this.curve = Curve[CurveType.MonotoneX];
|
|
19
20
|
this.events = {
|
|
20
21
|
[Line.selectors.line]: {
|
|
@@ -23,7 +24,7 @@ class Line extends XYComponentCore {
|
|
|
23
24
|
},
|
|
24
25
|
};
|
|
25
26
|
if (config)
|
|
26
|
-
this.
|
|
27
|
+
this.setConfig(config);
|
|
27
28
|
}
|
|
28
29
|
get bleed() {
|
|
29
30
|
const { config: { lineWidth } } = this;
|
|
@@ -98,7 +99,7 @@ class Line extends XYComponentCore {
|
|
|
98
99
|
const linePath$1 = group.select(`.${linePath}`);
|
|
99
100
|
const lineSelectionHelper$1 = group.select(`.${lineSelectionHelper}`);
|
|
100
101
|
const isLineVisible = d.visible;
|
|
101
|
-
const dashArray = getValue(
|
|
102
|
+
const dashArray = getValue(data, config.lineDashArray, i);
|
|
102
103
|
const transition = smartTransition(linePath$1, duration)
|
|
103
104
|
.attr('stroke', getColor(data, config.color, i))
|
|
104
105
|
.attr('stroke-width', config.lineWidth)
|
|
@@ -128,7 +129,7 @@ class Line extends XYComponentCore {
|
|
|
128
129
|
const yRange = this.yScale.range();
|
|
129
130
|
return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`;
|
|
130
131
|
}
|
|
131
|
-
_highlight(datum
|
|
132
|
+
_highlight(datum) {
|
|
132
133
|
const { config } = this;
|
|
133
134
|
if (config.highlightOnHover) {
|
|
134
135
|
this.g
|
|
@@ -136,7 +137,7 @@ class Line extends XYComponentCore {
|
|
|
136
137
|
.classed(dim, d => d !== datum);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
_resetHighlight(
|
|
140
|
+
_resetHighlight() {
|
|
140
141
|
const { config } = this;
|
|
141
142
|
if (config.highlightOnHover) {
|
|
142
143
|
this.g
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/line/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Curve, CurveType } from 'types/curve'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { LineData, LineDatum } from './types'\n\n// Config\nimport { LineConfig, LineConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Line<Datum> extends XYComponentCore<Datum, LineConfig<Datum>, LineConfigInterface<Datum>> {\n static selectors = s\n config: LineConfig<Datum> = new LineConfig()\n lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>\n curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]\n events = {\n [Line.selectors.line]: {\n mouseover: this._highlight.bind(this),\n mouseleave: this._resetHighlight.bind(this),\n },\n }\n\n constructor (config?: LineConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n }\n\n get bleed (): Spacing {\n const { config: { lineWidth } } = this\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n this.curve = Curve[config.curveType]\n this.lineGen = line<{ x: number; y: number; defined: boolean }>()\n .x(d => d.x)\n .y(d => d.y)\n .defined(d => d.defined)\n .curve(this.curve)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n const lineData: LineData[] = yAccessors.map(a => {\n const ld: LineDatum[] = data.map((d, i) => {\n const rawValue = getNumber(d, a, i)\n // If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`\n const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue\n return {\n x: lineDataX[i],\n y: this.yScale(value ?? 0),\n defined: isFinite(value),\n value,\n }\n })\n\n const defined = ld.reduce((def, d) => (d.defined || def), false)\n // If the line consists only of `null` values, we'll still render it but it'll be invisible.\n // Such trick allows us to have better animated transitions.\n const visible = defined && ld.some(d => d.value !== null)\n return {\n values: ld,\n defined,\n visible,\n }\n })\n\n const lines = this.g\n .selectAll<SVGGElement, LineData>(`.${s.line}`)\n .data(lineData)\n\n const linesEnter = lines.enter().append('g')\n .attr('class', s.line)\n\n linesEnter\n .append('path')\n .attr('class', s.linePath)\n .attr('stroke', (d, i) => getColor(data, config.color, i))\n .attr('stroke-opacity', 0)\n .attr('stroke-width', config.lineWidth)\n\n linesEnter\n .append('path')\n .attr('class', s.lineSelectionHelper)\n .attr('d', this._emptyPath())\n\n const linesMerged = linesEnter.merge(lines)\n linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))\n linesMerged.each((d, i, elements) => {\n const group = select(elements[i])\n const linePath = group.select<SVGPathElement>(`.${s.linePath}`)\n const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)\n\n const isLineVisible = d.visible\n const dashArray = getValue<LineData, number[]>(d, config.lineDashArray, i)\n const transition = smartTransition(linePath, duration)\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', isLineVisible ? 1 : 0)\n .style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray\n\n const hasUndefinedSegments = d.values.some(d => !d.defined)\n const svgPathD = this.lineGen(d.values)\n\n if (duration && !hasUndefinedSegments) {\n const previous = linePath.attr('d') || this._emptyPath()\n const next = svgPathD || this._emptyPath()\n const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>\n t.attrTween('d', () => interpolatePath(previous, next))\n } else if (d.visible) {\n transition.attr('d', svgPathD)\n }\n\n lineSelectionHelper\n .attr('d', svgPathD)\n .attr('visibility', isLineVisible ? null : 'hidden')\n })\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n private _emptyPath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n\n private _highlight (datum, i, els): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, d => d !== datum)\n }\n }\n\n private _resetHighlight (d, i, els): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, false)\n }\n }\n}\n"],"names":["s.line","s.linePath","s.lineSelectionHelper","linePath","lineSelectionHelper","s.dim","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAqE,CAAA;AAYpG,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;AAXT,QAAA,IAAA,CAAA,MAAM,GAAsB,IAAI,UAAU,EAAE,CAAA;AAE5C,QAAA,IAAA,CAAA,KAAK,GAAyB,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG;gBACrB,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBACrC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5C,aAAA;SACF,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KACrC;AAED,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,CAAA;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,CAAA;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;cAC9D,SAAS,CAAC,KAAK;AACjB,cAAE,SAAS,CAAC,KAAK,CAAA;AACnB,QAAA,MAAM,iBAAiB,GAAG,UAAU,KAAK,SAAS,CAAC,KAAK,CAAA;AAExD,QAAA,MAAM,WAAW,GAA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AM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAJ,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAA;AACpC,SAAA;KACF;AAEO,IAAA,eAAe,CAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAA;AAChC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAL,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AA5JM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/line/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { CurveFactoryLineOnly, Line as LineGenInterface, line } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, getValue, isArray, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Curve, CurveType } from 'types/curve'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { LineData, LineDatum } from './types'\n\n// Config\nimport { LineDefaultConfig, LineConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Line<Datum> extends XYComponentCore<Datum, LineConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = LineDefaultConfig as LineConfigInterface<Datum>\n public config: LineConfigInterface<Datum> = this._defaultConfig\n lineGen: LineGenInterface<{ x: number; y: number; defined: boolean }>\n curve: CurveFactoryLineOnly = Curve[CurveType.MonotoneX]\n events = {\n [Line.selectors.line]: {\n mouseover: this._highlight.bind(this),\n mouseleave: this._resetHighlight.bind(this),\n },\n }\n\n constructor (config?: LineConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n get bleed (): Spacing {\n const { config: { lineWidth } } = this\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n this.curve = Curve[config.curveType]\n this.lineGen = line<{ x: number; y: number; defined: boolean }>()\n .x(d => d.x)\n .y(d => d.y)\n .defined(d => d.defined)\n .curve(this.curve)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const lineDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n const lineData: LineData[] = yAccessors.map(a => {\n const ld: LineDatum[] = data.map((d, i) => {\n const rawValue = getNumber(d, a, i)\n // If `rawValue` is not numerical or if it's not finite (`NaN`, `undefined`, ...), we replace it with `config.fallbackValue`\n const value = (isNumber(rawValue) || (rawValue === null)) && isFinite(rawValue) ? rawValue : config.fallbackValue\n return {\n x: lineDataX[i],\n y: this.yScale(value ?? 0),\n defined: isFinite(value),\n value,\n }\n })\n\n const defined = ld.reduce((def, d) => (d.defined || def), false)\n // If the line consists only of `null` values, we'll still render it but it'll be invisible.\n // Such trick allows us to have better animated transitions.\n const visible = defined && ld.some(d => d.value !== null)\n return {\n values: ld,\n defined,\n visible,\n }\n })\n\n const lines = this.g\n .selectAll<SVGGElement, LineData>(`.${s.line}`)\n .data(lineData)\n\n const linesEnter = lines.enter().append('g')\n .attr('class', s.line)\n\n linesEnter\n .append('path')\n .attr('class', s.linePath)\n .attr('stroke', (d, i) => getColor(data, config.color, i))\n .attr('stroke-opacity', 0)\n .attr('stroke-width', config.lineWidth)\n\n linesEnter\n .append('path')\n .attr('class', s.lineSelectionHelper)\n .attr('d', this._emptyPath())\n\n const linesMerged = linesEnter.merge(lines)\n linesMerged.style('cursor', (d, i) => getString(data, config.cursor, i))\n linesMerged.each((d, i, elements) => {\n const group = select(elements[i])\n const linePath = group.select<SVGPathElement>(`.${s.linePath}`)\n const lineSelectionHelper = group.select(`.${s.lineSelectionHelper}`)\n\n const isLineVisible = d.visible\n const dashArray = getValue<Datum[], number[]>(data, config.lineDashArray, i)\n const transition = smartTransition(linePath, duration)\n .attr('stroke', getColor(data, config.color, i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', isLineVisible ? 1 : 0)\n .style('stroke-dasharray', dashArray?.join(' ') ?? null) // We use `.style` because there's also a default CSS-variable for stroke-dasharray\n\n const hasUndefinedSegments = d.values.some(d => !d.defined)\n const svgPathD = this.lineGen(d.values)\n\n if (duration && !hasUndefinedSegments) {\n const previous = linePath.attr('d') || this._emptyPath()\n const next = svgPathD || this._emptyPath()\n const t = transition as Transition<SVGPathElement, LineData, SVGGElement, LineData>\n t.attrTween('d', () => interpolatePath(previous, next))\n } else if (d.visible) {\n transition.attr('d', svgPathD)\n }\n\n lineSelectionHelper\n .attr('d', svgPathD)\n .attr('visibility', isLineVisible ? null : 'hidden')\n })\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n private _emptyPath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n\n private _highlight (datum: Datum): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, d => d !== datum)\n }\n }\n\n private _resetHighlight (): void {\n const { config } = this\n\n if (config.highlightOnHover) {\n this.g\n .selectAll(`.${s.line}`)\n .classed(s.dim, false)\n }\n }\n}\n"],"names":["s.line","s.linePath","s.lineSelectionHelper","linePath","lineSelectionHelper","s.dim","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAajF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAZC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;AAE/D,QAAA,IAAA,CAAA,KAAK,GAAyB,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACxD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG;gBACrB,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBACrC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5C,aAAA;SACF,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,CAAA;QACtC,MAAM,OAAO,GAAG,IAAI,C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C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,OAAO,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA;KAC/D;AAEO,IAAA,UAAU,CAAE,KAAY,EAAA;AAC9B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAJ,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAA;AACpC,SAAA;KACF;IAEO,eAAe,GAAA;AACrB,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEvB,IAAI,MAAM,CAAC,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC;AACH,iBAAA,SAAS,CAAC,CAAI,CAAA,EAAAL,MAAM,EAAE,CAAC;AACvB,iBAAA,OAAO,CAACK,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AA7JM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentConfigInterface
|
|
1
|
+
import { ComponentConfigInterface } from "../../core/component/config";
|
|
2
2
|
import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
|
|
3
3
|
import { NestedDonutDirection, NestedDonutLayerSettings, NestedDonutSegment } from './types';
|
|
4
4
|
export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterface {
|
|
@@ -46,23 +46,4 @@ export interface NestedDonutConfigInterface<Datum> extends ComponentConfigInterf
|
|
|
46
46
|
*/
|
|
47
47
|
showEmptySegments?: boolean;
|
|
48
48
|
}
|
|
49
|
-
export declare
|
|
50
|
-
angleRange: [number, number];
|
|
51
|
-
centralLabel: any;
|
|
52
|
-
centralSubLabel: any;
|
|
53
|
-
centralSubLabelWrap: boolean;
|
|
54
|
-
cornerRadius: number;
|
|
55
|
-
direction: NestedDonutDirection;
|
|
56
|
-
emptySegmentAngle: number;
|
|
57
|
-
hideOverflowingSegmentLabels: boolean;
|
|
58
|
-
layers: StringAccessor<Datum>[];
|
|
59
|
-
layerPadding: number;
|
|
60
|
-
layerSettings: any;
|
|
61
|
-
segmentColor: any;
|
|
62
|
-
segmentLabel: any;
|
|
63
|
-
segmentLabelColor: any;
|
|
64
|
-
showBackground: boolean;
|
|
65
|
-
showEmptySegments: boolean;
|
|
66
|
-
sort: any;
|
|
67
|
-
value: any;
|
|
68
|
-
}
|
|
49
|
+
export declare const NestedDonutDefaultConfig: NestedDonutConfigInterface<unknown>;
|