@unovis/ts 1.3.0-beta.2 → 1.3.0

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.
Files changed (113) hide show
  1. package/components/axis/config.d.ts +1 -1
  2. package/components/axis/config.js.map +1 -1
  3. package/components/axis/index.js +1 -1
  4. package/components/axis/index.js.map +1 -1
  5. package/components/chord-diagram/config.js +2 -2
  6. package/components/chord-diagram/config.js.map +1 -1
  7. package/components/chord-diagram/index.js +1 -1
  8. package/components/chord-diagram/index.js.map +1 -1
  9. package/components/donut/config.d.ts +1 -1
  10. package/components/donut/config.js +1 -3
  11. package/components/donut/config.js.map +1 -1
  12. package/components/free-brush/index.js +9 -9
  13. package/components/free-brush/index.js.map +1 -1
  14. package/components/graph/config.js +3 -3
  15. package/components/graph/config.js.map +1 -1
  16. package/components/graph/index.js +3 -2
  17. package/components/graph/index.js.map +1 -1
  18. package/components/graph/modules/layout.js +7 -2
  19. package/components/graph/modules/layout.js.map +1 -1
  20. package/components/graph/modules/link/index.js.map +1 -1
  21. package/components/graph/modules/node/helper.d.ts +1 -1
  22. package/components/graph/modules/node/helper.js.map +1 -1
  23. package/components/graph/modules/node/index.d.ts +3 -0
  24. package/components/graph/modules/node/index.js +5 -7
  25. package/components/graph/modules/node/index.js.map +1 -1
  26. package/components/graph/modules/shape.js +2 -2
  27. package/components/graph/modules/shape.js.map +1 -1
  28. package/components/grouped-bar/config.js +1 -3
  29. package/components/grouped-bar/config.js.map +1 -1
  30. package/components/grouped-bar/index.d.ts +1 -6
  31. package/components/grouped-bar/index.js +1 -12
  32. package/components/grouped-bar/index.js.map +1 -1
  33. package/components/leaflet-flow-map/config.js +1 -1
  34. package/components/leaflet-flow-map/config.js.map +1 -1
  35. package/components/leaflet-map/config.js +2 -2
  36. package/components/leaflet-map/config.js.map +1 -1
  37. package/components/leaflet-map/index.d.ts +1 -1
  38. package/components/leaflet-map/index.js.map +1 -1
  39. package/components/leaflet-map/modules/clusterBackground.d.ts +4 -2
  40. package/components/leaflet-map/modules/clusterBackground.js.map +1 -1
  41. package/components/leaflet-map/modules/map.d.ts +1 -1
  42. package/components/leaflet-map/modules/map.js +6 -6
  43. package/components/leaflet-map/modules/map.js.map +1 -1
  44. package/components/leaflet-map/modules/node.d.ts +3 -0
  45. package/components/leaflet-map/modules/node.js +8 -12
  46. package/components/leaflet-map/modules/node.js.map +1 -1
  47. package/components/leaflet-map/modules/utils.js.map +1 -1
  48. package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -1
  49. package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +5 -1
  50. package/components/leaflet-map/renderer/mapboxgl-utils.js +3 -3
  51. package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -1
  52. package/components/leaflet-map/style.js.map +1 -1
  53. package/components/leaflet-map/types.d.ts +5 -1
  54. package/components/leaflet-map/types.js.map +1 -1
  55. package/components/line/index.d.ts +2 -2
  56. package/components/line/index.js +2 -2
  57. package/components/line/index.js.map +1 -1
  58. package/components/nested-donut/index.js +14 -5
  59. package/components/nested-donut/index.js.map +1 -1
  60. package/components/nested-donut/style.js.map +1 -1
  61. package/components/sankey/config.d.ts +1 -1
  62. package/components/sankey/config.js +2 -2
  63. package/components/sankey/config.js.map +1 -1
  64. package/components/sankey/index.js.map +1 -1
  65. package/components/sankey/modules/link.d.ts +10 -0
  66. package/components/sankey/modules/link.js +4 -8
  67. package/components/sankey/modules/link.js.map +1 -1
  68. package/components/scatter/config.d.ts +1 -1
  69. package/components/scatter/config.js +1 -3
  70. package/components/scatter/config.js.map +1 -1
  71. package/components/scatter/index.js +3 -3
  72. package/components/scatter/index.js.map +1 -1
  73. package/components/scatter/modules/point.js.map +1 -1
  74. package/components/stacked-bar/config.js +1 -3
  75. package/components/stacked-bar/config.js.map +1 -1
  76. package/components/timeline/config.js +1 -7
  77. package/components/timeline/config.js.map +1 -1
  78. package/components/tooltip/index.d.ts +2 -1
  79. package/components/tooltip/index.js +10 -3
  80. package/components/tooltip/index.js.map +1 -1
  81. package/components/tooltip/style.d.ts +6 -0
  82. package/components/tooltip/style.js +13 -14
  83. package/components/tooltip/style.js.map +1 -1
  84. package/components/topojson-map/config.js +1 -1
  85. package/components/topojson-map/config.js.map +1 -1
  86. package/components/topojson-map/index.js +0 -1
  87. package/components/topojson-map/index.js.map +1 -1
  88. package/components/xy-labels/config.js +1 -3
  89. package/components/xy-labels/config.js.map +1 -1
  90. package/containers/xy-container/config.js.map +1 -1
  91. package/containers/xy-container/index.js +7 -6
  92. package/containers/xy-container/index.js.map +1 -1
  93. package/core/component/index.js +6 -2
  94. package/core/component/index.js.map +1 -1
  95. package/core/xy-component/config.js +1 -5
  96. package/core/xy-component/config.js.map +1 -1
  97. package/data-models/map-graph.js +3 -6
  98. package/data-models/map-graph.js.map +1 -1
  99. package/package.json +3 -1
  100. package/styles/colors.d.ts +2 -2
  101. package/styles/index.d.ts +1 -1
  102. package/styles/patterns.js +2 -1
  103. package/styles/patterns.js.map +1 -1
  104. package/types/accessor.d.ts +5 -5
  105. package/types/component.js +2 -0
  106. package/types/component.js.map +1 -1
  107. package/utils/d3.d.ts +10 -1
  108. package/utils/d3.js.map +1 -1
  109. package/utils/data.d.ts +6 -6
  110. package/utils/data.js +2 -1
  111. package/utils/data.js.map +1 -1
  112. package/utils/text.js +2 -2
  113. package/utils/text.js.map +1 -1
@@ -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 { 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 }\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":";;;;;;;;AA4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,YAAY,EAAE,CAAA;AAC9C,IAAA,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAA;IAC9C,MAAM,MAAM,GAAG,YAAY,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;IAC3F,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAErD,IAAA,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE;QACtB,MAAM,KAAK,GAAG,CAA8C,CAAA;AAC5D,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAA;AAC1C,QAAA,IAAI,SAAS,EAAE;AACb,YAAA,KAAK,CAAC,UAAU,CAAC,YAAY,GAAG,YAAY,CAAA;AAC5C,YAAA,KAAK,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;;;;"}
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>> | Point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A;AAC5C,IAAA,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAA;AAC9C,IAAA,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAA;IAC9C,MAAM,MAAM,GAAG,YAAY,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;IAC3F,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAErD,IAAA,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE;QACtB,MAAM,KAAK,GAAG,CAA8C,CAAA;AAC5D,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAA;AAC1C,QAAA,IAAI,SAAS,EAAE;AACb,YAAA,KAAK,CAAC,UAAU,CAAC,YAAY,GAAG,YAAY,CAAA;AAC5C,YAAA,KAAK,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;;;;"}
@@ -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 { LeafletMapConfigInterface } from '../config'\nimport { MapLibreStyleSpecs } from './map-style'\nimport { MaplibreGLLayer } from './leaflet-maplibre-gl'\n\n// Inject MapLibreGL global style\nimport mapLibreStyles from './maplibre-gl.css.js'\ninjectGlobal(mapLibreStyles)\n\nexport function getMaplibreGLLayer<Datum extends GenericDataRecord> (config: LeafletMapConfigInterface<Datum>, leaflet: typeof L, maplibre: typeof Maplibre): 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":";;;;;AAmBA,YAAY,CAAC,cAAc,CAAC,CAAA;SAEZ,kBAAkB,CAAmC,MAAwC,EAAE,OAAiB,EAAE,QAAyB,EAAA;AACzJ,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
+ {"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: any, layer: any, event: any): void;
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 { wheelDelta, deltaY } = event;
16
+ const { deltaY } = event;
17
17
  if (!layer || !layer.getMaplibreMap)
18
18
  return;
19
19
  const mapboxmap = layer.getMaplibreMap();
20
- const delta = wheelDelta || deltaY * -1; // We use deltaY for Firefox because wheelDelta is not implemented there
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, duration: 0 });
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, layer, event): void {\n const { wheelDelta, deltaY } = event\n if (!layer || !layer.getMaplibreMap) return\n const mapboxmap = layer.getMaplibreMap()\n const delta = wheelDelta || deltaY * -1 // We use deltaY for Firefox because wheelDelta is not implemented there\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, duration: 0 })\n}\n\nexport const mapboxglWheelEventThrottled = throttle(mapboxglWheelEvent, 32)\nexport const constraintMapViewThrottled = throttle(constraintMapView, 1000)\n"],"names":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jE,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,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAA;AAClE,CAAC;AAEY,MAAA,2BAA2B,GAAG,QAAQ,CAAC,kBAAkB,EAAE,EAAE,EAAC;AAC9D,MAAA,0BAA0B,GAAG,QAAQ,CAAC,iBAAiB,EAAE,IAAI;;;;"}
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,SAAS;AAExC,IAAA,oCAAoC,EAAE,SAAS;AAC/C,IAAA,iCAAiC,EAAE,SAAS;AAC5C,IAAA,sCAAsC,EAAE,SAAS;AACjD,IAAA,sCAAsC,EAAE,KAAK;AAC7C,IAAA,gCAAgC,EAAE,SAAS;AAE3C,IAAA,sCAAsC,EAAE,MAAM;AAC9C,IAAA,wCAAwC,EAAE,SAAS;AACnD,IAAA,wCAAwC,EAAE,OAAO;AACjD,IAAA,oCAAoC,EAAE,SAAS;AAE/C,IAAA,+CAA+C,EAAE,SAAS;AAC1D,IAAA,gDAAgD,EAAE,MAAM;AAExD,IAAA,6CAA6C,EAAE,SAAS;AACxD,IAAA,8CAA8C,EAAE,MAAM;AAEtD,IAAA,yCAAyC,EAAE,SAAS;AACpD,IAAA,wCAAwC,EAAE,MAAM;AAEhD,IAAA,kDAAkD,EAAE,MAAM;;AAG1D,IAAA,2CAA2C,EAAE,SAAS;AACtD,IAAA,yCAAyC,EAAE,SAAS;AACpD,IAAA,2CAA2C,EAAE,SAAS;AACtD,IAAA,sCAAsC,EAAE,SAAS;AAEjD,IAAA,2CAA2C,EAAE,SAAS;AACtD,IAAA,6CAA6C,EAAE,SAAS;AACxD,IAAA,yCAAyC,EAAE,SAAS;AAEpD,IAAA,oDAAoD,EAAE,SAAS;AAC/D,IAAA,qDAAqD,EAAE,MAAM;AAE7D,IAAA,kDAAkD,EAAE,SAAS;AAC7D,IAAA,mDAAmD,EAAE,MAAM;AAE3D,IAAA,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AG,GAAG,CAAA,CAAA;;AAEtB,YAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;EACtD;AAEM,MAAM,WAAW,GAAG,GAAG,CAAA,CAAA;;;;AAIhB,YAAA,EAAA,SAAS,CAAC,4BAA4B,CAAA;AAC/B,mBAAA,EAAA,SAAS,CAAC,kBAAkB,CAAA;;;EAGhD;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,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
+ {"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;AACrB,IAAA,sCAAsC,EAAE,SAAS;;AAEjD,IAAA,6BAA6B,EAAE,SAAsB;AAErD,IAAA,oCAAoC,EAAE,SAAS;AAC/C,IAAA,iCAAiC,EAAE,SAAS;AAC5C,IAAA,sCAAsC,EAAE,SAAS;AACjD,IAAA,sCAAsC,EAAE,KAAK;AAC7C,IAAA,gCAAgC,EAAE,SAAS;AAE3C,IAAA,sCAAsC,EAAE,MAAM;AAC9C,IAAA,wCAAwC,EAAE,SAAS;AACnD,IAAA,wCAAwC,EAAE,OAAO;AACjD,IAAA,oCAAoC,EAAE,SAAS;AAE/C,IAAA,+CAA+C,EAAE,SAAS;AAC1D,IAAA,gDAAgD,EAAE,MAAM;AAExD,IAAA,6CAA6C,EAAE,SAAS;AACxD,IAAA,8CAA8C,EAAE,MAAM;AAEtD,IAAA,yCAAyC,EAAE,SAAS;AACpD,IAAA,wCAAwC,EAAE,MAAM;AAEhD,IAAA,kDAAkD,EAAE,MAAM;;AAG1D,IAAA,2CAA2C,EAAE,SAAS;AACtD,IAAA,yCAAyC,EAAE,SAAS;AACpD,IAAA,2CAA2C,EAAE,SAAS;AACtD,IAAA,sCAAsC,EAAE,SAAS;AAEjD,IAAA,2CAA2C,EAAE,SAAS;AACtD,IAAA,6CAA6C,EAAE,SAAS;AACxD,IA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hC;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;AAIf,YAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;AAClC,mBAAA,EAAA,SAAS,CAAC,kBAAkB,CAAA;;;EAGhD;AAEM,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAA;;AAEtB,YAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;EACtD;AAEM,MAAM,WAAW,GAAG,GAAG,CAAA,CAAA;;;;AAIhB,YAAA,EAAA,SAAS,CAAC,4BAA4B,CAAA;AAC/B,mBAAA,EAAA,SAAS,CAAC,kBAAkB,CAAA;;;EAGhD;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,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;;;;"}
@@ -15,8 +15,8 @@ export declare class Line<Datum> extends XYComponentCore<Datum, LineConfigInterf
15
15
  curve: CurveFactoryLineOnly;
16
16
  events: {
17
17
  [x: string]: {
18
- mouseover: (datum: any, i: any, els: any) => void;
19
- mouseleave: (d: any, i: any, els: any) => void;
18
+ mouseover: (datum: Datum) => void;
19
+ mouseleave: () => void;
20
20
  };
21
21
  };
22
22
  constructor(config?: LineConfigInterface<Datum>);
@@ -129,7 +129,7 @@ class Line extends XYComponentCore {
129
129
  const yRange = this.yScale.range();
130
130
  return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`;
131
131
  }
132
- _highlight(datum, i, els) {
132
+ _highlight(datum) {
133
133
  const { config } = this;
134
134
  if (config.highlightOnHover) {
135
135
  this.g
@@ -137,7 +137,7 @@ class Line extends XYComponentCore {
137
137
  .classed(dim, d => d !== datum);
138
138
  }
139
139
  }
140
- _resetHighlight(d, i, els) {
140
+ _resetHighlight() {
141
141
  const { config } = this;
142
142
  if (config.highlightOnHover) {
143
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 { 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, 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,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,GAA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AAE,CAAA;KACZ;IAEO,UAAU,GAAA;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,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,KAAK,EAAE,CAAC,EAAE,GAAG,EAAA;AAC/B,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;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;;AA7JM,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,GAA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AACK,GAAK,EAAE,KAAK,CAAC,CAAA;AACzB,SAAA;KACF;;AA7JM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -132,10 +132,12 @@ class NestedDonut extends ComponentCore {
132
132
  partitionData
133
133
  .each(node => {
134
134
  var _a, _b, _c;
135
+ // Starting with the root, we transform the original data returned from d3.hierarchy
136
+ const n = node;
135
137
  node.data = {
136
- key: node.data[0],
137
- values: ((_a = (node.data[1])) === null || _a === void 0 ? void 0 : _a.length) ? node.data[1].map((index) => data[index]) : [],
138
- root: (_c = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.data.root) !== null && _c !== void 0 ? _c : node.data[0],
138
+ key: n.data[0],
139
+ values: Array.isArray(n.data[1]) ? n.data[1].map(i => data[i]) : [],
140
+ root: (_c = (_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.root) !== null && _c !== void 0 ? _c : n.data[0],
139
141
  };
140
142
  node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`;
141
143
  if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {
@@ -144,9 +146,10 @@ class NestedDonut extends ComponentCore {
144
146
  node.y1 = node._layer._outerRadius;
145
147
  }
146
148
  })
147
- .eachAfter(node => { var _a; return (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(ch => node.data.values.push(...ch.data.values)); })
148
- .eachBefore(node => {
149
+ .eachBefore((node) => {
149
150
  var _a, _b, _c, _d;
151
+ // Once ancestors have been visited, children properties that are
152
+ // dependent on the parent's data are populated here
150
153
  if (!node.children || node.depth === rootNode.height - 1)
151
154
  return;
152
155
  const positions = pie()
@@ -170,6 +173,12 @@ class NestedDonut extends ComponentCore {
170
173
  fillOpacity: color === null ? opacity(positions[i].index) : null,
171
174
  };
172
175
  });
176
+ })
177
+ .eachAfter(node => {
178
+ var _a;
179
+ // Once hierarchy has been traversed, we append children data the parent
180
+ // parent.data serves as a reference to all the original data it represents
181
+ (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(ch => node.data.values.push(...ch.data.values));
173
182
  });
174
183
  const segments = partitionData.descendants().filter(d => { var _a; return ((_a = d.parent) === null || _a === void 0 ? void 0 : _a.value) && d.data.key; });
175
184
  return segments;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc, pie } from 'd3-shape'\nimport { hierarchy, partition } from 'd3-hierarchy'\nimport { scaleLinear, ScaleLinear } from 'd3-scale'\nimport { group } from 'd3-array'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Types\nimport { VerticalAlign } from 'types/text'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getNumber, getString, getValue, isNumber, isNumberWithinRange, merge } from 'utils/data'\nimport { getPixelValue } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutSegment, NestedDonutLayer, NestedDonutSegmentLabelAlignment } from './types'\n\n// Config\nimport { NestedDonutDefaultConfig, NestedDonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\nimport { createLabel, updateLabel, removeLabel } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class NestedDonut<Datum> extends ComponentCore<\nDatum[],\nNestedDonutConfigInterface<Datum>\n> {\n static selectors = s\n static cssVariables = s.variables\n protected _defaultConfig = NestedDonutDefaultConfig as NestedDonutConfigInterface<Datum>\n public config: NestedDonutConfigInterface<Datum> = this._defaultConfig\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n\n arcGen = arc<Partial<NestedDonutSegment<Datum>>>()\n colorScale: ScaleLinear<string, string> = scaleLinear()\n\n events = { }\n\n constructor (config?: NestedDonutConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.arcBackground = this.g.append('g')\n this.arcGroup = this.g.append('g')\n .attr('class', s.segmentsGroup)\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const layers = this._getLayerSettings()\n const data = this._getHierarchyData(layers)\n\n this.arcGen\n .startAngle(d => d.x0)\n .endAngle(d => d.x1)\n .innerRadius(d => d.y0)\n .outerRadius(d => d.y1)\n .cornerRadius(config.cornerRadius)\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.arcBackground.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralSubLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n // Layer backgrounds\n const backgrounds = this.arcBackground\n .selectAll<SVGPathElement, NestedDonutLayer>(`.${s.background}`)\n .data(layers, d => d._id)\n\n const backgroundsEnter = backgrounds.enter().append('path')\n .attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n\n const backgroundsMerged = backgrounds.merge(backgroundsEnter)\n .style('transition', `fill ${duration}ms`)\n .style('fill', d => d.backgroundColor)\n\n smartTransition(backgroundsMerged, duration)\n .attr('d', d => this.arcGen({\n x0: config.angleRange?.[0] ?? 0,\n x1: config.angleRange?.[1] ?? 2 * Math.PI,\n y0: d._innerRadius,\n y1: d._outerRadius,\n }))\n\n smartTransition(backgrounds.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n // Segments\n const segments = this.arcGroup.selectAll<SVGGElement, NestedDonutSegment<Datum>>(`${s.segment}`)\n .data(data, d => d._id)\n\n const segmentsEnter = segments.enter()\n .append('g')\n .attr('class', s.segment)\n\n segments.merge(segmentsEnter)\n smartTransition(segments.exit(), duration)\n .attr('class', s.segmentExit)\n .style('opacity', 0)\n .remove()\n\n // Segment arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segmentArc}`)\n .data(data, d => d._id)\n\n const arcsEnter = segmentsEnter.append('path')\n .attr('class', s.segmentArc)\n .call(createArc, config)\n\n arcs.merge(arcsEnter)\n .call(updateArc, config, this.arcGen, duration)\n\n arcs.exit<NestedDonutSegment<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Segment labels\n const labels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const labelsEnter = segmentsEnter.append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, this.arcGen)\n\n labels.merge(labelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n labels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top)\n }\n\n private _getHierarchyData (layers: NestedDonutLayer[]): NestedDonutSegment<Datum>[] {\n const { config, datamodel: { data } } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (i: number) => getString(data[i], layerAccessor, i))\n const nestedData = group(data.keys(), ...layerAccessors as [(i: number) => string])\n\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData\n .each(node => {\n node.data = {\n key: node.data[0] as string,\n values: (node.data[1])?.length ? node.data[1].map((index: number) => data[index]) : [],\n root: node.parent?.data.root ?? node.data[0],\n }\n node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._layer = layers[node.depth - 1]\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n })\n .eachAfter(node => node.children?.forEach(ch => node.data.values.push(...ch.data.values)))\n .eachBefore(node => {\n if (!node.children || node.depth === rootNode.height - 1) return\n\n const positions = pie<NestedDonutSegment<Datum>>()\n .startAngle(node.parent ? node.x0 : config.angleRange?.[0])\n .endAngle(node.parent ? node.x1 : config.angleRange?.[1])\n .value(d => config.showEmptySegments && d.value === 0\n ? config.emptySegmentAngle\n : (d.x1 - d.x0))\n .sort(config.sort)(node.children)\n\n const opacity = scaleLinear()\n .domain([-1, node.children.length])\n .range([node._state?.fillOpacity ?? 1, 0])\n\n node.children.forEach((child, i) => {\n child._index = i\n child.x0 = positions[i].startAngle\n child.x1 = positions[i].endAngle\n\n // Default to parent's fill if segmentColor accessor is not provided\n const color = getColor(child, config.segmentColor, positions[i].index, child.depth !== 1)\n child._state = {\n fill: color ?? node._state.fill,\n fillOpacity: color === null ? opacity(positions[i].index) : null,\n }\n })\n })\n\n const segments = partitionData.descendants().filter(d => d.parent?.value && d.data.key)\n return segments\n }\n\n private _getLayerSettings (): NestedDonutLayer[] {\n const { direction, layers, layerPadding, layerSettings } = this.config\n\n const outerRadius = Math.min(this._width, this._height) / 2\n\n const defaultLayerSettings = {\n backgroundColor: cssvar(s.variables.nestedDonutBackgroundColor),\n labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,\n width: outerRadius * 0.75 / layers.length,\n }\n const layerItems = layers.reduceRight((arr, _, i) => {\n const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length\n const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings))\n const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius\n const layerWidth = getPixelValue(layerConfig.width)\n if (layerWidth === null) {\n console.warn(`Unovis | Nested Donut: Could not parse width ${layerConfig.width}. Setting to default.`)\n }\n arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - (layerWidth ?? defaultLayerSettings.width),\n })\n return arr\n }, new Array<NestedDonutLayer>())\n\n return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems\n }\n}\n"],"names":["s.segmentsGroup","s.centralLabel","s.centralSubLabel","s.background","s.segment","s.segmentExit","s.segmentArc","s.segmentLabel","s.variables","s"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCM,MAAO,WAAmB,SAAQ,aAGvC,CAAA;AAiBC,IAAA,WAAA,CAAa,MAA0C,EAAA;AACrD,QAAA,KAAK,EAAE,CAAA;QAfC,IAAc,CAAA,cAAA,GAAG,wBAA6D,CAAA;AACjF,QAAA,IAAA,CAAA,MAAM,GAAsC,IAAI,CAAC,cAAc,CAAA;AACtE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAOzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAsC,CAAA;QAClD,IAAU,CAAA,UAAA,GAAgC,WAAW,EAAE,CAAA;QAEvD,IAAM,CAAA,MAAA,GAAG,EAAG,CAAA;AAIV,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAC/B,aAAA,IAAI,CAAC,OAAO,EAAEA,aAAe,CAAC,CAAA;QACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC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AW,CAAC,KAAK,CAAC,CAAA;YACnD,IAAI,UAAU,KAAK,IAAI,EAAE;gBACvB,OAAO,CAAC,IAAI,CAAC,CAAA,6CAAA,EAAgD,WAAW,CAAC,KAAK,CAAuB,qBAAA,CAAA,CAAC,CAAA;AACvG,aAAA;AACD,YAAA,GAAG,CAAC,OAAO,CACN,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,WAAW,CACd,EAAA,EAAA,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,IAAI,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAV,UAAU,GAAI,oBAAoB,CAAC,KAAK,CAAC,IACjE,CAAA;AACF,YAAA,OAAO,GAAG,CAAA;AACZ,SAAC,EAAE,IAAI,KAAK,EAAoB,CAAC,CAAA;AAEjC,QAAA,OAAO,SAAS,KAAK,oBAAoB,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,UAAU,CAAA;KACtF;;AAzNM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGD,SAAW;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/nested-donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { arc, pie } from 'd3-shape'\nimport { hierarchy, HierarchyNode, partition } from 'd3-hierarchy'\nimport { scaleLinear, ScaleLinear } from 'd3-scale'\nimport { group } from 'd3-array'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Types\nimport { VerticalAlign } from 'types/text'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getNumber, getString, getValue, isNumber, isNumberWithinRange, merge } from 'utils/data'\nimport { getPixelValue } from 'utils/misc'\nimport { cssvar } from 'utils/style'\nimport { wrapSVGText } from 'utils/text'\n\n// Local Types\nimport { NestedDonutDirection, NestedDonutSegment, NestedDonutLayer, NestedDonutSegmentLabelAlignment } from './types'\n\n// Config\nimport { NestedDonutDefaultConfig, NestedDonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\nimport { createLabel, updateLabel, removeLabel } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class NestedDonut<Datum> extends ComponentCore<\nDatum[],\nNestedDonutConfigInterface<Datum>\n> {\n static selectors = s\n static cssVariables = s.variables\n protected _defaultConfig = NestedDonutDefaultConfig as NestedDonutConfigInterface<Datum>\n public config: NestedDonutConfigInterface<Datum> = this._defaultConfig\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGGElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n\n arcGen = arc<Partial<NestedDonutSegment<Datum>>>()\n colorScale: ScaleLinear<string, string> = scaleLinear()\n\n events = { }\n\n constructor (config?: NestedDonutConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.arcBackground = this.g.append('g')\n this.arcGroup = this.g.append('g')\n .attr('class', s.segmentsGroup)\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const layers = this._getLayerSettings()\n const data = this._getHierarchyData(layers)\n\n this.arcGen\n .startAngle(d => d.x0)\n .endAngle(d => d.x1)\n .innerRadius(d => d.y0)\n .outerRadius(d => d.y1)\n .cornerRadius(config.cornerRadius)\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.arcBackground.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n this.centralSubLabel.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n // Layer backgrounds\n const backgrounds = this.arcBackground\n .selectAll<SVGPathElement, NestedDonutLayer>(`.${s.background}`)\n .data(layers, d => d._id)\n\n const backgroundsEnter = backgrounds.enter().append('path')\n .attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n\n const backgroundsMerged = backgrounds.merge(backgroundsEnter)\n .style('transition', `fill ${duration}ms`)\n .style('fill', d => d.backgroundColor)\n\n smartTransition(backgroundsMerged, duration)\n .attr('d', d => this.arcGen({\n x0: config.angleRange?.[0] ?? 0,\n x1: config.angleRange?.[1] ?? 2 * Math.PI,\n y0: d._innerRadius,\n y1: d._outerRadius,\n }))\n\n smartTransition(backgrounds.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n // Segments\n const segments = this.arcGroup.selectAll<SVGGElement, NestedDonutSegment<Datum>>(`${s.segment}`)\n .data(data, d => d._id)\n\n const segmentsEnter = segments.enter()\n .append('g')\n .attr('class', s.segment)\n\n segments.merge(segmentsEnter)\n smartTransition(segments.exit(), duration)\n .attr('class', s.segmentExit)\n .style('opacity', 0)\n .remove()\n\n // Segment arcs\n const arcs = this.arcGroup\n .selectAll<SVGPathElement, NestedDonutSegment<Datum>>(`.${s.segmentArc}`)\n .data(data, d => d._id)\n\n const arcsEnter = segmentsEnter.append('path')\n .attr('class', s.segmentArc)\n .call(createArc, config)\n\n arcs.merge(arcsEnter)\n .call(updateArc, config, this.arcGen, duration)\n\n arcs.exit<NestedDonutSegment<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Segment labels\n const labels = this.arcGroup\n .selectAll<SVGTextElement, NestedDonutSegment<Datum>>(`.${s.segmentLabel}`)\n .data(data, d => d._id)\n\n const labelsEnter = segmentsEnter.append('text')\n .attr('class', s.segmentLabel)\n .call(createLabel, this.arcGen)\n\n labels.merge(labelsEnter)\n .call(updateLabel, config, this.arcGen, duration)\n\n labels.exit<NestedDonutSegment<Datum>>()\n .call(removeLabel, duration)\n\n // Chart labels\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, layers[0]._innerRadius * 1.9, VerticalAlign.Top)\n }\n\n private _getHierarchyData (layers: NestedDonutLayer[]): NestedDonutSegment<Datum>[] {\n const { config, datamodel: { data } } = this\n\n const layerAccessors = config.layers?.map(layerAccessor => (i: number) => getString(data[i], layerAccessor, i))\n const nestedData = group(data.keys(), ...layerAccessors as [(i: number) => string])\n\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const partitionData = partition().size([config.angleRange[1], 1])(rootNode) as NestedDonutSegment<Datum>\n\n partitionData\n .each(node => {\n // Starting with the root, we transform the original data returned from d3.hierarchy\n const n = node as unknown as HierarchyNode<[string, number[]]>\n node.data = {\n key: n.data[0],\n values: Array.isArray(n.data[1]) ? (n.data[1] as number[]).map(i => data[i]) : [],\n root: node.parent?.data?.root ?? n.data[0],\n }\n node._id = `root${partitionData.path(node).map(d => d.data.key).join('->')}`\n if (isNumberWithinRange(node.depth - 1, [0, layers.length - 1])) {\n node._layer = layers[node.depth - 1]\n node.y0 = node._layer._innerRadius\n node.y1 = node._layer._outerRadius\n }\n })\n .eachBefore((node) => {\n // Once ancestors have been visited, children properties that are\n // dependent on the parent's data are populated here\n if (!node.children || node.depth === rootNode.height - 1) return\n\n const positions = pie<NestedDonutSegment<Datum>>()\n .startAngle(node.parent ? node.x0 : config.angleRange?.[0])\n .endAngle(node.parent ? node.x1 : config.angleRange?.[1])\n .value(d => config.showEmptySegments && d.value === 0\n ? config.emptySegmentAngle\n : (d.x1 - d.x0))\n .sort(config.sort)(node.children)\n\n const opacity = scaleLinear()\n .domain([-1, node.children.length])\n .range([node._state?.fillOpacity ?? 1, 0])\n\n node.children.forEach((child, i) => {\n child._index = i\n child.x0 = positions[i].startAngle\n child.x1 = positions[i].endAngle\n\n // Default to parent's fill if segmentColor accessor is not provided\n const color = getColor(child, config.segmentColor, positions[i].index, child.depth !== 1)\n child._state = {\n fill: color ?? node._state.fill,\n fillOpacity: color === null ? opacity(positions[i].index) : null,\n }\n })\n })\n .eachAfter(node => {\n // Once hierarchy has been traversed, we append children data the parent\n // parent.data serves as a reference to all the original data it represents\n node.children?.forEach(ch => node.data.values.push(...ch.data.values))\n })\n\n const segments = partitionData.descendants().filter(d => d.parent?.value && d.data.key)\n return segments\n }\n\n private _getLayerSettings (): NestedDonutLayer[] {\n const { direction, layers, layerPadding, layerSettings } = this.config\n\n const outerRadius = Math.min(this._width, this._height) / 2\n\n const defaultLayerSettings = {\n backgroundColor: cssvar(s.variables.nestedDonutBackgroundColor),\n labelAlignment: NestedDonutSegmentLabelAlignment.Perpendicular,\n width: outerRadius * 0.75 / layers.length,\n }\n const layerItems = layers.reduceRight((arr, _, i) => {\n const layerId = direction === NestedDonutDirection.Outwards ? i : arr.length\n const layerConfig = merge(defaultLayerSettings, getValue(layerId, layerSettings))\n const radius = arr.length ? arr[0]._innerRadius - layerPadding : outerRadius\n const layerWidth = getPixelValue(layerConfig.width)\n if (layerWidth === null) {\n console.warn(`Unovis | Nested Donut: Could not parse width ${layerConfig.width}. Setting to default.`)\n }\n arr.unshift({\n ...layerConfig,\n _id: layerId,\n _outerRadius: radius,\n _innerRadius: radius - (layerWidth ?? defaultLayerSettings.width),\n })\n return arr\n }, new Array<NestedDonutLayer>())\n\n return direction === NestedDonutDirection.Inwards ? layerItems.reverse() : layerItems\n }\n}\n"],"names":["s.segmentsGroup","s.centralLabel","s.centralSubLabel","s.background","s.segment","s.segmentExit","s.segmentArc","s.segmentLabel","s.variables","s"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCM,MAA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UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAV,UAAU,GAAI,oBAAoB,CAAC,KAAK,CAAC,IACjE,CAAA;AACF,YAAA,OAAO,GAAG,CAAA;AACZ,SAAC,EAAE,IAAI,KAAK,EAAoB,CAAC,CAAA;AAEjC,QAAA,OAAO,SAAS,KAAK,oBAAoB,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,UAAU,CAAA;KACtF;;AAjOM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGD,SAAW;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../../src/components/nested-donut/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n '--vis-nested-donut-font-family': undefined,\n\n // Background\n '--vis-nested-donut-background-color': '#E7E9F3',\n\n // Central label\n '--vis-nested-donut-central-label-font-size': '16px',\n '--vis-nested-donut-central-label-font-weight': 600,\n '--vis-nested-donut-central-label-text-color': '#5b5f6d',\n\n // Central sub-label\n '--vis-nested-donut-central-sublabel-font-size': '12px;',\n '--vis-nested-donut-central-sublabel-font-weight': 500,\n '--vis-nested-donut-central-sublabel-text-color': '#5b5f6d',\n\n // Segments\n '--vis-nested-donut-segment-stroke-width': '1px',\n '--vis-nested-donut-segment-stroke-color': 'var(--vis-nested-donut-background-color)',\n '--vis-nested-donut-segment-label-text-color-light': '#5b5f6d',\n '--vis-nested-donut-segment-label-text-color-dark': '#fff',\n '--vis-nested-donut-segment-label-font-size': '1em',\n\n /* Dark theme */\n '--vis-dark-nested-donut-background-color': '#18160C',\n '--vis-dark-nested-donut-central-label-text-color': '#fff',\n '--vis-dark-nested-donut-central-sublabel-text-color': '#fff',\n}\n\nexport const root = css`\n label: nested-donut-component;\n`\n\nexport const segmentsGroup = css`\n label: nested-donut-segments-group;\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const background = css`\n label: background;\n fill: var(--vis-nested-donut-background-color);\n stroke-width: var(--vis-nested-donut-segment-stroke-width);\n stroke: var(--vis-nested-donut-segment-stroke-color);\n`\n\nexport const segment = css`\n label: segment;\n `\n\nexport const segmentExit = css`\n label: segment-exit;\n`\n\nexport const segmentArc = css`\n label: segment-arc;\n stroke-width: var(--vis-nested-donut-segment-stroke-width);\n stroke: var(--vis-nested-donut-segment-stroke-color);\n`\n\nexport const segmentLabel = css`\n label: segment-label;\n text-anchor: middle;\n dominant-baseline: middle;\n user-select: none;\n font-size: var(--vis-nested-donut-segment-label-font-size);\n`\n\nexport const centralLabel = css`\n label: central-label;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: var(--vis-nested-donut-central-label-font-size);\n font-family: var(--vis-nested-donut-central-label-font-family, var(--vis-font-family));\n font-weight: var(--vis-nested-donut-central-label-font-weight);\n fill: var(--vis-nested-donut-central-label-text-color);\n`\n\nexport const centralSubLabel = css`\n label: central-sub-label;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: var(--vis-nested-donut-central-sublabel-font-size);\n font-family: var(--vis-nested-donut-central-sublabel-font-family, var(--vis-font-family));\n font-weight: var(--vis-nested-donut-central-sublabel-font-weight);\n fill: var(--vis-nested-donut-central-sublabel-text-color);\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;;AAErB,IAAA,gCAAgC,EAAE,SAAS;;AAG3C,IAAA,qCAAqC,EAAE,SAAS;;AAGhD,IAAA,4CAA4C,EAAE,MAAM;AACpD,IAAA,8CAA8C,EAAE,GAAG;AACnD,IAAA,6CAA6C,EAAE,SAAS;;AAGxD,IAAA,+CAA+C,EAAE,OAAO;AACxD,IAAA,iDAAiD,EAAE,GAAG;AACtD,IAAA,gDAAgD,EAAE,SAAS;;AAG3D,IAAA,yCAAyC,EAAE,KAAK;AAChD,IAAA,yCAAyC,EAAE,0CAA0C;AACrF,IAAA,mDAAmD,EAAE,SAAS;AAC9D,IAAA,kDAAkD,EAAE,MAAM;AAC1D,IAAA,4CAA4C,EAAE,KAAK;;AAGnD,IAAA,0CAA0C,EAAE,SAAS;AACrD,IAAA,kDAAkD,EAAE,MAAM;AAC1D,IAAA,qDAAqD,EAAE,MAAM;CAC9D,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,aAAa,GAAG,GAAG,CAAA,CAAA;;EAE/B;MAEY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;;EAK5B;AAEM,MAAM,OAAO,GAAG,GAAG,CAAA,CAAA;;GAExB;AAEK,MAAM,WAAW,GAAG,GAAG,CAAA,CAAA;;EAE7B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;EAI5B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;EAM9B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;;;EAQ9B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;"}
1
+ {"version":3,"file":"style.js","sources":["../../../src/components/nested-donut/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n '--vis-nested-donut-font-family': undefined as undefined,\n\n // Background\n '--vis-nested-donut-background-color': '#E7E9F3',\n\n // Central label\n '--vis-nested-donut-central-label-font-size': '16px',\n '--vis-nested-donut-central-label-font-weight': 600,\n '--vis-nested-donut-central-label-text-color': '#5b5f6d',\n\n // Central sub-label\n '--vis-nested-donut-central-sublabel-font-size': '12px;',\n '--vis-nested-donut-central-sublabel-font-weight': 500,\n '--vis-nested-donut-central-sublabel-text-color': '#5b5f6d',\n\n // Segments\n '--vis-nested-donut-segment-stroke-width': '1px',\n '--vis-nested-donut-segment-stroke-color': 'var(--vis-nested-donut-background-color)',\n '--vis-nested-donut-segment-label-text-color-light': '#5b5f6d',\n '--vis-nested-donut-segment-label-text-color-dark': '#fff',\n '--vis-nested-donut-segment-label-font-size': '1em',\n\n /* Dark theme */\n '--vis-dark-nested-donut-background-color': '#18160C',\n '--vis-dark-nested-donut-central-label-text-color': '#fff',\n '--vis-dark-nested-donut-central-sublabel-text-color': '#fff',\n}\n\nexport const root = css`\n label: nested-donut-component;\n`\n\nexport const segmentsGroup = css`\n label: nested-donut-segments-group;\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const background = css`\n label: background;\n fill: var(--vis-nested-donut-background-color);\n stroke-width: var(--vis-nested-donut-segment-stroke-width);\n stroke: var(--vis-nested-donut-segment-stroke-color);\n`\n\nexport const segment = css`\n label: segment;\n `\n\nexport const segmentExit = css`\n label: segment-exit;\n`\n\nexport const segmentArc = css`\n label: segment-arc;\n stroke-width: var(--vis-nested-donut-segment-stroke-width);\n stroke: var(--vis-nested-donut-segment-stroke-color);\n`\n\nexport const segmentLabel = css`\n label: segment-label;\n text-anchor: middle;\n dominant-baseline: middle;\n user-select: none;\n font-size: var(--vis-nested-donut-segment-label-font-size);\n`\n\nexport const centralLabel = css`\n label: central-label;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: var(--vis-nested-donut-central-label-font-size);\n font-family: var(--vis-nested-donut-central-label-font-family, var(--vis-font-family));\n font-weight: var(--vis-nested-donut-central-label-font-weight);\n fill: var(--vis-nested-donut-central-label-text-color);\n`\n\nexport const centralSubLabel = css`\n label: central-sub-label;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: var(--vis-nested-donut-central-sublabel-font-size);\n font-family: var(--vis-nested-donut-central-sublabel-font-family, var(--vis-font-family));\n font-weight: var(--vis-nested-donut-central-sublabel-font-weight);\n fill: var(--vis-nested-donut-central-sublabel-text-color);\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;;AAErB,IAAA,gCAAgC,EAAE,SAAsB;;AAGxD,IAAA,qCAAqC,EAAE,SAAS;;AAGhD,IAAA,4CAA4C,EAAE,MAAM;AACpD,IAAA,8CAA8C,EAAE,GAAG;AACnD,IAAA,6CAA6C,EAAE,SAAS;;AAGxD,IAAA,+CAA+C,EAAE,OAAO;AACxD,IAAA,iDAAiD,EAAE,GAAG;AACtD,IAAA,gDAAgD,EAAE,SAAS;;AAG3D,IAAA,yCAAyC,EAAE,KAAK;AAChD,IAAA,yCAAyC,EAAE,0CAA0C;AACrF,IAAA,mDAAmD,EAAE,SAAS;AAC9D,IAAA,kDAAkD,EAAE,MAAM;AAC1D,IAAA,4CAA4C,EAAE,KAAK;;AAGnD,IAAA,0CAA0C,EAAE,SAAS;AACrD,IAAA,kDAAkD,EAAE,MAAM;AAC1D,IAAA,qDAAqD,EAAE,MAAM;CAC9D,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,aAAa,GAAG,GAAG,CAAA,CAAA;;EAE/B;MAEY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;;EAK5B;AAEM,MAAM,OAAO,GAAG,GAAG,CAAA,CAAA;;GAExB;AAEK,MAAM,WAAW,GAAG,GAAG,CAAA,CAAA;;EAE7B;AAEM,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;;;EAI5B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;EAM9B;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;;;EAQ9B;AAEM,MAAM,eAAe,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ import { Position } from "../../types/position";
5
5
  import { SankeyInputLink, SankeyInputNode, SankeyNodeAlign, SankeySubLabelPlacement, SankeyExitTransitionType, SankeyEnterTransitionType, SankeyLink, SankeyNode } from './types';
6
6
  export interface SankeyConfigInterface<N extends SankeyInputNode, L extends SankeyInputLink> extends ComponentConfigInterface {
7
7
  /** Node / Link id accessor function. Used for mapping of data updates to corresponding SVG objects. Default: `(d, i) => d.id ?? i.toString()` */
8
- id?: (d: SankeyInputNode | SankeyInputLink, i: number, ...any: any[]) => string;
8
+ id?: (d: SankeyInputNode | SankeyInputLink, i: number, ...any: unknown[]) => string;
9
9
  /** Coefficient to scale the height of the diagram when the amount of links is low: `C * links.length`, clamped to `[height / 2, height]`. Default: `1/16` */
10
10
  heightNormalizationCoeff?: number;
11
11
  /** Type of animation on removing nodes. Default: `ExitTransitionType.Default` */
@@ -4,8 +4,8 @@ import { VerticalAlign, FitMode, TrimMode } from '../../types/text.js';
4
4
  import { Position } from '../../types/position.js';
5
5
  import { SankeyExitTransitionType, SankeyEnterTransitionType, SankeyNodeAlign, SankeySubLabelPlacement } from './types.js';
6
6
 
7
- /* eslint-disable dot-notation */
8
- const SankeyDefaultConfig = (Object.assign(Object.assign({}, ComponentDefaultConfig), { heightNormalizationCoeff: 1 / 16, exitTransitionType: SankeyExitTransitionType.Default, enterTransitionType: SankeyEnterTransitionType.Default, id: (d, i) => { var _a; return (_a = d['_id']) !== null && _a !== void 0 ? _a : `${i}`; }, highlightSubtreeOnHover: false, highlightDuration: 300, highlightDelay: 1000, iterations: 32, nodeSort: undefined, nodeWidth: 25, nodeAlign: SankeyNodeAlign.Justify, nodeHorizontalSpacing: 150, nodeMinHeight: 20, nodeMaxHeight: 100, nodePadding: 2, nodeColor: d => d['color'], nodeFixedValue: d => d['fixedValue'], showSingleNode: true, nodeCursor: undefined, nodeIcon: undefined, nodeIconColor: undefined, label: d => d['label'], labelPosition: Position.Auto, labelVerticalAlign: VerticalAlign.Middle, labelBackground: false, labelTextSeparator: [' ', '-'], labelFit: FitMode.Trim, labelTrimMode: TrimMode.Middle, labelForceWordBreak: true, labelFontSize: undefined, labelCursor: undefined, labelColor: undefined, labelMaxWidth: 70, labelExpandTrimmedOnHover: true, labelVisibility: undefined, subLabel: undefined, subLabelFontSize: undefined, subLabelColor: undefined, subLabelPlacement: SankeySubLabelPlacement.Below, subLabelToLabelInlineWidthRatio: 0.4, linkValue: d => d['value'], linkColor: d => d['color'], linkCursor: undefined,
7
+ // Config
8
+ const SankeyDefaultConfig = (Object.assign(Object.assign({}, ComponentDefaultConfig), { heightNormalizationCoeff: 1 / 16, exitTransitionType: SankeyExitTransitionType.Default, enterTransitionType: SankeyEnterTransitionType.Default, id: (d, i) => { var _a; return (_a = d._id) !== null && _a !== void 0 ? _a : `${i}`; }, highlightSubtreeOnHover: false, highlightDuration: 300, highlightDelay: 1000, iterations: 32, nodeSort: undefined, nodeWidth: 25, nodeAlign: SankeyNodeAlign.Justify, nodeHorizontalSpacing: 150, nodeMinHeight: 20, nodeMaxHeight: 100, nodePadding: 2, nodeColor: (d) => d.color, nodeFixedValue: (d) => d.fixedValue, showSingleNode: true, nodeCursor: undefined, nodeIcon: undefined, nodeIconColor: undefined, label: (d) => d.label, labelPosition: Position.Auto, labelVerticalAlign: VerticalAlign.Middle, labelBackground: false, labelTextSeparator: [' ', '-'], labelFit: FitMode.Trim, labelTrimMode: TrimMode.Middle, labelForceWordBreak: true, labelFontSize: undefined, labelCursor: undefined, labelColor: undefined, labelMaxWidth: 70, labelExpandTrimmedOnHover: true, labelVisibility: undefined, subLabel: undefined, subLabelFontSize: undefined, subLabelColor: undefined, subLabelPlacement: SankeySubLabelPlacement.Below, subLabelToLabelInlineWidthRatio: 0.4, linkValue: (d) => d.value, linkColor: (d) => d.color, linkCursor: undefined,
9
9
  // https://stackoverflow.com/a/21648197/2040291
10
10
  init: function () {
11
11
  this.linkSort =