@mui/x-charts-premium 9.7.0 → 9.9.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 (230) hide show
  1. package/BarChartPremium/BarChartPremium.d.mts +1 -1
  2. package/BarChartPremium/BarChartPremium.d.ts +1 -1
  3. package/BarChartPremium/BarChartPremium.js +14 -3
  4. package/BarChartPremium/BarChartPremium.mjs +14 -3
  5. package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.mts +2 -1
  6. package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.ts +2 -1
  7. package/BarChartPremium/RangeBar/FocusedRangeBar.d.mts +1 -1
  8. package/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +1 -1
  9. package/BarChartPremium/RangeBar/seriesConfig/index.js +2 -2
  10. package/BarChartPremium/RangeBar/seriesConfig/index.mjs +2 -2
  11. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.mts +2 -3
  12. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.ts +2 -3
  13. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +12 -15
  14. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.mjs +11 -14
  15. package/BarChartPremium/webgl/BarWebGLProgram.d.mts +4 -5
  16. package/BarChartPremium/webgl/BarWebGLProgram.d.ts +4 -5
  17. package/BarChartPremium/webgl/BarWebGLProgram.js +24 -65
  18. package/BarChartPremium/webgl/BarWebGLProgram.mjs +24 -65
  19. package/BarChartPremium/webgl/shaders.d.mts +1 -1
  20. package/BarChartPremium/webgl/shaders.d.ts +1 -1
  21. package/BarChartPremium/webgl/shaders.js +2 -15
  22. package/BarChartPremium/webgl/shaders.mjs +3 -15
  23. package/CHANGELOG.md +249 -1
  24. package/CandlestickChart/CandlestickPlot.d.mts +2 -1
  25. package/CandlestickChart/CandlestickPlot.d.ts +2 -1
  26. package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.mts +2 -1
  27. package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.ts +2 -1
  28. package/CandlestickChart/seriesConfig/index.js +2 -2
  29. package/CandlestickChart/seriesConfig/index.mjs +2 -2
  30. package/CandlestickChart/seriesConfig/tooltipPosition.d.mts +2 -3
  31. package/CandlestickChart/seriesConfig/tooltipPosition.d.ts +2 -3
  32. package/CandlestickChart/seriesConfig/tooltipPosition.js +10 -14
  33. package/CandlestickChart/seriesConfig/tooltipPosition.mjs +10 -14
  34. package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.mts +1 -1
  35. package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.ts +1 -1
  36. package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
  37. package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
  38. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.mts +1 -1
  39. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.ts +1 -1
  40. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +2 -2
  41. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +2 -2
  42. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.mts +4 -3
  43. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.ts +4 -3
  44. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.js +2 -1
  45. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.mjs +2 -1
  46. package/ChartsGeoDataProviderPremium/index.d.mts +2 -1
  47. package/ChartsGeoDataProviderPremium/index.d.ts +2 -1
  48. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.mts +2 -1
  49. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.ts +2 -1
  50. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
  51. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
  52. package/ChartsRenderer/components/PaletteOption.d.mts +1 -1
  53. package/ChartsRenderer/components/PaletteOption.d.ts +1 -1
  54. package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.mts +2 -1
  55. package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.ts +2 -1
  56. package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.mts +1 -1
  57. package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.ts +1 -1
  58. package/HeatmapPremium/HeatmapPlotPremium.d.mts +1 -1
  59. package/HeatmapPremium/HeatmapPlotPremium.d.ts +1 -1
  60. package/HeatmapPremium/webgl/HeatmapWebGLProgram.js +12 -37
  61. package/HeatmapPremium/webgl/HeatmapWebGLProgram.mjs +12 -37
  62. package/HeatmapPremium/webgl/shaders.d.mts +3 -3
  63. package/HeatmapPremium/webgl/shaders.d.ts +3 -3
  64. package/HeatmapPremium/webgl/shaders.js +12 -15
  65. package/HeatmapPremium/webgl/shaders.mjs +13 -15
  66. package/HeatmapPremium/webgl/useHeatmapPlotData.js +3 -8
  67. package/HeatmapPremium/webgl/useHeatmapPlotData.mjs +3 -8
  68. package/Map/FocusedMapShape.d.mts +2 -1
  69. package/Map/FocusedMapShape.d.ts +2 -1
  70. package/Map/FocusedMapShape.js +5 -1
  71. package/Map/FocusedMapShape.mjs +5 -1
  72. package/Map/GeoDataPlot.d.mts +1 -1
  73. package/Map/GeoDataPlot.d.ts +1 -1
  74. package/Map/Graticule.d.mts +1 -1
  75. package/Map/Graticule.d.ts +1 -1
  76. package/Map/MapImagePlot.d.mts +39 -0
  77. package/Map/MapImagePlot.d.ts +39 -0
  78. package/Map/MapImagePlot.js +138 -0
  79. package/Map/MapImagePlot.mjs +132 -0
  80. package/Map/MapShape.d.mts +2 -2
  81. package/Map/MapShape.d.ts +2 -2
  82. package/Map/MapShape.js +6 -6
  83. package/Map/MapShape.mjs +6 -6
  84. package/Map/MapShapePlot.d.mts +9 -1
  85. package/Map/MapShapePlot.d.ts +9 -1
  86. package/Map/MapShapePlot.js +17 -5
  87. package/Map/MapShapePlot.mjs +17 -5
  88. package/Map/index.d.mts +2 -3
  89. package/Map/index.d.ts +2 -3
  90. package/Map/index.js +11 -0
  91. package/Map/index.mjs +1 -0
  92. package/Map/reprojectEquirectangularImage.d.mts +60 -0
  93. package/Map/reprojectEquirectangularImage.d.ts +60 -0
  94. package/Map/reprojectEquirectangularImage.js +116 -0
  95. package/Map/reprojectEquirectangularImage.mjs +110 -0
  96. package/Map/seriesConfig/descriptionGetter.js +5 -1
  97. package/Map/seriesConfig/descriptionGetter.mjs +5 -1
  98. package/Map/seriesConfig/getColor.js +18 -6
  99. package/Map/seriesConfig/getColor.mjs +18 -6
  100. package/Map/seriesConfig/highlight.d.mts +10 -0
  101. package/Map/seriesConfig/highlight.d.ts +10 -0
  102. package/Map/seriesConfig/highlight.js +52 -0
  103. package/Map/seriesConfig/highlight.mjs +45 -0
  104. package/Map/seriesConfig/identifierCleaner.d.mts +3 -0
  105. package/Map/seriesConfig/identifierCleaner.d.ts +3 -0
  106. package/Map/seriesConfig/identifierCleaner.js +14 -0
  107. package/Map/seriesConfig/identifierCleaner.mjs +8 -0
  108. package/Map/seriesConfig/identifierSerializer.d.mts +3 -0
  109. package/Map/seriesConfig/identifierSerializer.d.ts +3 -0
  110. package/Map/seriesConfig/identifierSerializer.js +12 -0
  111. package/Map/seriesConfig/identifierSerializer.mjs +6 -0
  112. package/Map/seriesConfig/index.js +8 -6
  113. package/Map/seriesConfig/index.mjs +7 -5
  114. package/Map/seriesConfig/keyboardFocusHandler.d.mts +0 -6
  115. package/Map/seriesConfig/keyboardFocusHandler.d.ts +0 -6
  116. package/Map/seriesConfig/keyboardFocusHandler.js +40 -7
  117. package/Map/seriesConfig/keyboardFocusHandler.mjs +41 -8
  118. package/Map/seriesConfig/seriesProcessor.js +11 -2
  119. package/Map/seriesConfig/seriesProcessor.mjs +11 -2
  120. package/Map/seriesConfig/tooltip.js +8 -4
  121. package/Map/seriesConfig/tooltip.mjs +8 -4
  122. package/Map/seriesConfig/tooltipPosition.d.mts +8 -3
  123. package/Map/seriesConfig/tooltipPosition.d.ts +8 -3
  124. package/Map/seriesConfig/tooltipPosition.js +15 -27
  125. package/Map/seriesConfig/tooltipPosition.mjs +16 -27
  126. package/RadialBarChart/RadialBarElement.d.mts +1 -1
  127. package/RadialBarChart/RadialBarElement.d.ts +1 -1
  128. package/RadialBarChart/seriesConfig/index.js +2 -2
  129. package/RadialBarChart/seriesConfig/index.mjs +2 -2
  130. package/RadialBarChart/seriesConfig/tooltipPosition.d.mts +2 -3
  131. package/RadialBarChart/seriesConfig/tooltipPosition.d.ts +2 -3
  132. package/RadialBarChart/seriesConfig/tooltipPosition.js +4 -6
  133. package/RadialBarChart/seriesConfig/tooltipPosition.mjs +2 -5
  134. package/RadialLineChart/RadialArea.d.mts +2 -1
  135. package/RadialLineChart/RadialArea.d.ts +2 -1
  136. package/RadialLineChart/RadialAreaPlot.d.mts +1 -1
  137. package/RadialLineChart/RadialAreaPlot.d.ts +1 -1
  138. package/RadialLineChart/RadialLine.d.mts +1 -1
  139. package/RadialLineChart/RadialLine.d.ts +1 -1
  140. package/RadialLineChart/RadialLineHighlightElement.d.mts +1 -1
  141. package/RadialLineChart/RadialLineHighlightElement.d.ts +1 -1
  142. package/RadialLineChart/RadialLineHighlightPlot.d.mts +1 -1
  143. package/RadialLineChart/RadialLineHighlightPlot.d.ts +1 -1
  144. package/RadialLineChart/RadialLinePlot.d.mts +1 -1
  145. package/RadialLineChart/RadialLinePlot.d.ts +1 -1
  146. package/RadialLineChart/RadialMarkPlot.d.mts +1 -1
  147. package/RadialLineChart/RadialMarkPlot.d.ts +1 -1
  148. package/RadialLineChart/seriesConfig/index.js +2 -2
  149. package/RadialLineChart/seriesConfig/index.mjs +2 -2
  150. package/RadialLineChart/seriesConfig/tooltipPosition.d.mts +2 -3
  151. package/RadialLineChart/seriesConfig/tooltipPosition.d.ts +2 -3
  152. package/RadialLineChart/seriesConfig/tooltipPosition.js +4 -6
  153. package/RadialLineChart/seriesConfig/tooltipPosition.mjs +2 -5
  154. package/ScatterChartPremium/ScatterPlotPremium.d.mts +2 -1
  155. package/ScatterChartPremium/ScatterPlotPremium.d.ts +2 -1
  156. package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.mts +2 -1
  157. package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.ts +2 -1
  158. package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.mts +0 -2
  159. package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.ts +0 -2
  160. package/ScatterChartPremium/webgl/ScatterWebGLProgram.js +23 -81
  161. package/ScatterChartPremium/webgl/ScatterWebGLProgram.mjs +23 -81
  162. package/index.js +1 -1
  163. package/index.mjs +1 -1
  164. package/internals/createGetVisibleCoordinate.d.mts +14 -0
  165. package/internals/createGetVisibleCoordinate.d.ts +14 -0
  166. package/internals/createGetVisibleCoordinate.js +66 -0
  167. package/internals/createGetVisibleCoordinate.mjs +60 -0
  168. package/internals/plugins/useGeoProjection/factories.d.mts +3 -0
  169. package/internals/plugins/useGeoProjection/factories.d.ts +3 -0
  170. package/internals/plugins/useGeoProjection/factories.js +29 -0
  171. package/internals/plugins/useGeoProjection/factories.mjs +23 -0
  172. package/internals/plugins/useGeoProjection/projection.utils.d.mts +17 -0
  173. package/internals/plugins/useGeoProjection/projection.utils.d.ts +17 -0
  174. package/internals/plugins/useGeoProjection/projection.utils.js +67 -0
  175. package/internals/plugins/useGeoProjection/projection.utils.mjs +59 -0
  176. package/internals/plugins/useGeoProjection/useGeoProjection.js +7 -40
  177. package/internals/plugins/useGeoProjection/useGeoProjection.mjs +7 -40
  178. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.mts +47 -11
  179. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.ts +47 -11
  180. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.js +118 -8
  181. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.mjs +117 -8
  182. package/internals/plugins/useGeoProjection/useGeoProjection.types.d.mts +63 -2
  183. package/internals/plugins/useGeoProjection/useGeoProjection.types.d.ts +63 -2
  184. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.mts +11 -0
  185. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.ts +11 -0
  186. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.js +65 -0
  187. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.mjs +58 -0
  188. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.mts +13 -0
  189. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.ts +13 -0
  190. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.js +62 -0
  191. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.mjs +56 -0
  192. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.mts +13 -0
  193. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.ts +13 -0
  194. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.js +64 -0
  195. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.mjs +58 -0
  196. package/internals/plugins/useGeoProjectionZoom/index.d.mts +2 -0
  197. package/internals/plugins/useGeoProjectionZoom/index.d.ts +2 -0
  198. package/internals/plugins/useGeoProjectionZoom/index.js +12 -0
  199. package/internals/plugins/useGeoProjectionZoom/index.mjs +1 -0
  200. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.mts +31 -0
  201. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.ts +31 -0
  202. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.js +187 -0
  203. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.mjs +177 -0
  204. package/internals/plugins/useGeoProjectionZoom/rotationMath.d.mts +23 -0
  205. package/internals/plugins/useGeoProjectionZoom/rotationMath.d.ts +23 -0
  206. package/internals/plugins/useGeoProjectionZoom/rotationMath.js +190 -0
  207. package/internals/plugins/useGeoProjectionZoom/rotationMath.mjs +182 -0
  208. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.mts +3 -0
  209. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.ts +3 -0
  210. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.js +174 -0
  211. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.mjs +166 -0
  212. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.mts +152 -0
  213. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.ts +152 -0
  214. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.js +5 -0
  215. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.mjs +1 -0
  216. package/models/seriesType/mapShape.d.mts +2 -1
  217. package/models/seriesType/mapShape.d.ts +2 -1
  218. package/package.json +6 -6
  219. package/utils/webgl/glsl.d.mts +15 -0
  220. package/utils/webgl/glsl.d.ts +15 -0
  221. package/utils/webgl/glsl.js +34 -0
  222. package/utils/webgl/glsl.mjs +28 -0
  223. package/utils/webgl/instancedAttribute.d.mts +28 -0
  224. package/utils/webgl/instancedAttribute.d.ts +28 -0
  225. package/utils/webgl/instancedAttribute.js +57 -0
  226. package/utils/webgl/instancedAttribute.mjs +50 -0
  227. package/utils/webgl/utils.d.mts +21 -2
  228. package/utils/webgl/utils.d.ts +21 -2
  229. package/utils/webgl/utils.js +44 -8
  230. package/utils/webgl/utils.mjs +41 -7
@@ -3,12 +3,122 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorChartRawScale = exports.selectorChartRawProjection = exports.selectorChartProjection = exports.selectorChartGeoProjectionState = exports.selectorChartGeoPath = exports.selectorChartGeoFeatureIndexesByName = exports.selectorChartGeoData = void 0;
6
+ exports.selectorGeoTooltipPosition = exports.selectorFitScale = exports.selectorChartZoomLevel = exports.selectorChartRawProjection = exports.selectorChartProjection = exports.selectorChartGeoProjectionState = exports.selectorChartGeoPath = exports.selectorChartGeoFeatureKey = exports.selectorChartGeoFeatureIndexesByName = exports.selectorChartGeoData = void 0;
7
+ var _store = require("@mui/x-internals/store");
8
+ var _d3Geo = require("@mui/x-charts-vendor/d3-geo");
7
9
  var _internals = require("@mui/x-charts/internals");
8
- const selectorChartGeoFeatureIndexesByName = exports.selectorChartGeoFeatureIndexesByName = _internals.useGeoProjectionSelectors.selectorChartGeoFeatureIndexesByName;
9
- const selectorChartGeoProjectionState = exports.selectorChartGeoProjectionState = _internals.useGeoProjectionSelectors.selectorChartGeoProjectionState;
10
- const selectorChartGeoData = exports.selectorChartGeoData = _internals.useGeoProjectionSelectors.selectorChartGeoData;
11
- const selectorChartRawProjection = exports.selectorChartRawProjection = _internals.useGeoProjectionSelectors.selectorChartRawProjection;
12
- const selectorChartRawScale = exports.selectorChartRawScale = _internals.useGeoProjectionSelectors.selectorChartRawScale;
13
- const selectorChartProjection = exports.selectorChartProjection = _internals.useGeoProjectionSelectors.selectorChartProjection;
14
- const selectorChartGeoPath = exports.selectorChartGeoPath = _internals.useGeoProjectionSelectors.selectorChartGeoPath;
10
+ var _projection = require("./projection.utils");
11
+ const ZERO_COORDINATES = [0, 0];
12
+ const selectorChartGeoProjectionState = state => state.geoProjection;
13
+ exports.selectorChartGeoProjectionState = selectorChartGeoProjectionState;
14
+ const selectorChartGeoProjectionZoomState = state => state.geoProjectionZoom;
15
+ const selectorChartGeoData = exports.selectorChartGeoData = (0, _store.createSelector)(selectorChartGeoProjectionState, geoProjection => geoProjection?.geoData ?? null);
16
+ const selectorChartGeoFeatureKey = exports.selectorChartGeoFeatureKey = (0, _store.createSelector)(selectorChartGeoProjectionState, geoProjection => geoProjection?.geoFeatureKey ?? 'name');
17
+ const selectorChartRawProjection = exports.selectorChartRawProjection = (0, _store.createSelector)(selectorChartGeoProjectionState, geoProjection => geoProjection?.projection ?? null);
18
+ const selectorChartZoomLevel = exports.selectorChartZoomLevel = (0, _store.createSelector)(selectorChartGeoProjectionZoomState, function selectorChartZoomLevel(geoProjectionZoom) {
19
+ return geoProjectionZoom?.zoomLevel ?? 1;
20
+ });
21
+ const selectorChartCenter = (0, _store.createSelectorMemoized)(selectorChartGeoProjectionZoomState, function selectorChartCenter(geoProjectionZoom) {
22
+ return geoProjectionZoom?.center ?? ZERO_COORDINATES;
23
+ });
24
+ const selectorChartTranslation = (0, _store.createSelectorMemoized)(selectorChartGeoProjectionZoomState, function selectorChartTranslation(geoProjectionZoom) {
25
+ return geoProjectionZoom?.translation ?? null;
26
+ });
27
+ const selectorChartRoll = (0, _store.createSelector)(selectorChartGeoProjectionZoomState, function selectorChartRoll(geoProjectionZoom) {
28
+ return geoProjectionZoom?.roll ?? 0;
29
+ });
30
+ const selectorChartInitialCenter = (0, _store.createSelectorMemoized)(selectorChartGeoProjectionZoomState, function selectorChartInitialCenter(geoProjectionZoom) {
31
+ return geoProjectionZoom?.initialCenter ?? ZERO_COORDINATES;
32
+ });
33
+ const selectorChartParallels = (0, _store.createSelectorMemoized)(selectorChartGeoProjectionState, function selectorChartParallels(geoProjection) {
34
+ return (0, _projection.getParallels)(geoProjection?.parallels);
35
+ });
36
+
37
+ /**
38
+ * Map a feature's `properties.name` to its index in `geoData.features`,
39
+ * for fast lookup by name when joining series rows to features.
40
+ *
41
+ * Features without a string `properties.name` are skipped; on duplicates,
42
+ * the first occurrence wins.
43
+ */
44
+ const selectorChartGeoFeatureIndexesByName = exports.selectorChartGeoFeatureIndexesByName = (0, _store.createSelectorMemoized)(selectorChartGeoData, selectorChartGeoFeatureKey, (geoData, geoFeatureKey) => {
45
+ const map = new Map();
46
+ if (!geoData) {
47
+ return map;
48
+ }
49
+ geoData.features.forEach((feature, index) => {
50
+ const name = typeof geoFeatureKey === 'function' ? geoFeatureKey(feature) : feature.properties?.[geoFeatureKey];
51
+ if (typeof name !== 'string') {
52
+ return;
53
+ }
54
+ if (map.has(name)) {
55
+ map.get(name).push(index);
56
+ return;
57
+ }
58
+ map.set(name, [index]);
59
+ });
60
+ return map;
61
+ });
62
+ const selectorFitScale = exports.selectorFitScale = (0, _store.createSelector)(selectorChartRawProjection, selectorChartParallels, selectorChartInitialCenter, selectorChartGeoData, _internals.selectorChartDrawingArea, function selectorFitScale(projectionInput, parallels, initialCenter, geoData, drawingArea) {
63
+ if (!geoData || projectionInput === null || initialCenter === null) {
64
+ return null;
65
+ }
66
+ const projection = (0, _projection.resolveProjectionInstance)(projectionInput, parallels);
67
+ if (projection === null) {
68
+ return null;
69
+ }
70
+ projection.rotate?.([-initialCenter[0], -initialCenter[1]]);
71
+ const [[x0, y0], [x1, y1]] = (0, _d3Geo.geoPath)(projection).bounds(geoData);
72
+ const currentScale = projection.scale();
73
+ return Math.min(currentScale * (drawingArea.width / (x1 - x0)), currentScale * (drawingArea.height / (y1 - y0)));
74
+ });
75
+
76
+ /**
77
+ * Resolves the raw `projection` input into a ready-to-use `GeoProjection` instance,
78
+ * fitted to the chart's drawing area then zoomed/panned according to the current view.
79
+ *
80
+ * - String inputs (e.g. `'mercator'`) are mapped to the matching d3-geo factory.
81
+ * - `GeoProjection` instances are used as-is, then fitted.
82
+ * - The projection is first fitted to the data (the `zoomLevel === 1` baseline), then its
83
+ * scale is multiplied by `zoomLevel` and its translation is offset so `center` lands at the
84
+ * center of the drawing area. Keeping the view as `{ zoomLevel, center }` means the absolute
85
+ * scale/translation are derived here, never stored — so they stay correct across resizes.
86
+ * - Returns `null` when no projection is registered or the name is unknown.
87
+ */
88
+ const selectorChartProjection = exports.selectorChartProjection = (0, _store.createSelectorMemoized)(selectorChartRawProjection, selectorChartParallels, selectorChartGeoData, selectorChartCenter, selectorChartTranslation, selectorChartRoll, selectorChartZoomLevel, _internals.selectorChartDrawingArea, selectorFitScale, (projectionInput, parallels, geoData, center, translation, roll, zoomLevel, drawingArea, fitScale) => {
89
+ const projection = (0, _projection.resolveProjectionInstance)(projectionInput, parallels);
90
+ if (!projection) {
91
+ return null;
92
+ }
93
+ if (!geoData || fitScale == null) {
94
+ return projection;
95
+ }
96
+ projection.rotate?.([-center[0], -center[1], roll]);
97
+ // Edge case with conic conformal and albers:
98
+ // rotate impacts the center of the projection, so we need to reset it.
99
+ projection.center?.([0, 0]);
100
+
101
+ // `fitScale` is the `zoomLevel === 1` reference scale, computed independently in
102
+ // `selectorFitScale` so it stays stable across pan/zoom transforms.
103
+ projection.scale(zoomLevel != null && zoomLevel !== 1 ? fitScale * zoomLevel : fitScale);
104
+ projection.translate([drawingArea.left + drawingArea.width / 2 + (translation?.[0] ?? 0) * drawingArea.width, drawingArea.top + drawingArea.height / 2 + (translation?.[1] ?? 0) * drawingArea.height]);
105
+ return projection;
106
+ });
107
+
108
+ /**
109
+ * Resolves the raw `projection` input into a ready-to-use `GeoPath` instance
110
+ * fitted to the chart's drawing area.
111
+ */
112
+ const selectorChartGeoPath = exports.selectorChartGeoPath = (0, _store.createSelectorMemoized)(selectorChartProjection, projection => {
113
+ if (!projection) {
114
+ return null;
115
+ }
116
+ return (0, _d3Geo.geoPath)(projection);
117
+ });
118
+ const selectorGeoTooltipPosition = exports.selectorGeoTooltipPosition = (0, _store.createSelectorMemoized)(selectorChartGeoData, selectorChartProjection, selectorChartGeoFeatureIndexesByName, function selectorGeoTooltipPosition(geoData, projection, featureIndexesByName) {
119
+ return {
120
+ geoData,
121
+ projection,
122
+ featureIndexesByName
123
+ };
124
+ });
@@ -1,8 +1,117 @@
1
- import { useGeoProjectionSelectors } from '@mui/x-charts/internals';
2
- export const selectorChartGeoFeatureIndexesByName = useGeoProjectionSelectors.selectorChartGeoFeatureIndexesByName;
3
- export const selectorChartGeoProjectionState = useGeoProjectionSelectors.selectorChartGeoProjectionState;
4
- export const selectorChartGeoData = useGeoProjectionSelectors.selectorChartGeoData;
5
- export const selectorChartRawProjection = useGeoProjectionSelectors.selectorChartRawProjection;
6
- export const selectorChartRawScale = useGeoProjectionSelectors.selectorChartRawScale;
7
- export const selectorChartProjection = useGeoProjectionSelectors.selectorChartProjection;
8
- export const selectorChartGeoPath = useGeoProjectionSelectors.selectorChartGeoPath;
1
+ import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
2
+ import { geoPath } from '@mui/x-charts-vendor/d3-geo';
3
+ import { selectorChartDrawingArea } from '@mui/x-charts/internals';
4
+ import { getParallels, resolveProjectionInstance } from "./projection.utils.mjs";
5
+ const ZERO_COORDINATES = [0, 0];
6
+ export const selectorChartGeoProjectionState = state => state.geoProjection;
7
+ const selectorChartGeoProjectionZoomState = state => state.geoProjectionZoom;
8
+ export const selectorChartGeoData = createSelector(selectorChartGeoProjectionState, geoProjection => geoProjection?.geoData ?? null);
9
+ export const selectorChartGeoFeatureKey = createSelector(selectorChartGeoProjectionState, geoProjection => geoProjection?.geoFeatureKey ?? 'name');
10
+ export const selectorChartRawProjection = createSelector(selectorChartGeoProjectionState, geoProjection => geoProjection?.projection ?? null);
11
+ export const selectorChartZoomLevel = createSelector(selectorChartGeoProjectionZoomState, function selectorChartZoomLevel(geoProjectionZoom) {
12
+ return geoProjectionZoom?.zoomLevel ?? 1;
13
+ });
14
+ const selectorChartCenter = createSelectorMemoized(selectorChartGeoProjectionZoomState, function selectorChartCenter(geoProjectionZoom) {
15
+ return geoProjectionZoom?.center ?? ZERO_COORDINATES;
16
+ });
17
+ const selectorChartTranslation = createSelectorMemoized(selectorChartGeoProjectionZoomState, function selectorChartTranslation(geoProjectionZoom) {
18
+ return geoProjectionZoom?.translation ?? null;
19
+ });
20
+ const selectorChartRoll = createSelector(selectorChartGeoProjectionZoomState, function selectorChartRoll(geoProjectionZoom) {
21
+ return geoProjectionZoom?.roll ?? 0;
22
+ });
23
+ const selectorChartInitialCenter = createSelectorMemoized(selectorChartGeoProjectionZoomState, function selectorChartInitialCenter(geoProjectionZoom) {
24
+ return geoProjectionZoom?.initialCenter ?? ZERO_COORDINATES;
25
+ });
26
+ const selectorChartParallels = createSelectorMemoized(selectorChartGeoProjectionState, function selectorChartParallels(geoProjection) {
27
+ return getParallels(geoProjection?.parallels);
28
+ });
29
+
30
+ /**
31
+ * Map a feature's `properties.name` to its index in `geoData.features`,
32
+ * for fast lookup by name when joining series rows to features.
33
+ *
34
+ * Features without a string `properties.name` are skipped; on duplicates,
35
+ * the first occurrence wins.
36
+ */
37
+ export const selectorChartGeoFeatureIndexesByName = createSelectorMemoized(selectorChartGeoData, selectorChartGeoFeatureKey, (geoData, geoFeatureKey) => {
38
+ const map = new Map();
39
+ if (!geoData) {
40
+ return map;
41
+ }
42
+ geoData.features.forEach((feature, index) => {
43
+ const name = typeof geoFeatureKey === 'function' ? geoFeatureKey(feature) : feature.properties?.[geoFeatureKey];
44
+ if (typeof name !== 'string') {
45
+ return;
46
+ }
47
+ if (map.has(name)) {
48
+ map.get(name).push(index);
49
+ return;
50
+ }
51
+ map.set(name, [index]);
52
+ });
53
+ return map;
54
+ });
55
+ export const selectorFitScale = createSelector(selectorChartRawProjection, selectorChartParallels, selectorChartInitialCenter, selectorChartGeoData, selectorChartDrawingArea, function selectorFitScale(projectionInput, parallels, initialCenter, geoData, drawingArea) {
56
+ if (!geoData || projectionInput === null || initialCenter === null) {
57
+ return null;
58
+ }
59
+ const projection = resolveProjectionInstance(projectionInput, parallels);
60
+ if (projection === null) {
61
+ return null;
62
+ }
63
+ projection.rotate?.([-initialCenter[0], -initialCenter[1]]);
64
+ const [[x0, y0], [x1, y1]] = geoPath(projection).bounds(geoData);
65
+ const currentScale = projection.scale();
66
+ return Math.min(currentScale * (drawingArea.width / (x1 - x0)), currentScale * (drawingArea.height / (y1 - y0)));
67
+ });
68
+
69
+ /**
70
+ * Resolves the raw `projection` input into a ready-to-use `GeoProjection` instance,
71
+ * fitted to the chart's drawing area then zoomed/panned according to the current view.
72
+ *
73
+ * - String inputs (e.g. `'mercator'`) are mapped to the matching d3-geo factory.
74
+ * - `GeoProjection` instances are used as-is, then fitted.
75
+ * - The projection is first fitted to the data (the `zoomLevel === 1` baseline), then its
76
+ * scale is multiplied by `zoomLevel` and its translation is offset so `center` lands at the
77
+ * center of the drawing area. Keeping the view as `{ zoomLevel, center }` means the absolute
78
+ * scale/translation are derived here, never stored — so they stay correct across resizes.
79
+ * - Returns `null` when no projection is registered or the name is unknown.
80
+ */
81
+ export const selectorChartProjection = createSelectorMemoized(selectorChartRawProjection, selectorChartParallels, selectorChartGeoData, selectorChartCenter, selectorChartTranslation, selectorChartRoll, selectorChartZoomLevel, selectorChartDrawingArea, selectorFitScale, (projectionInput, parallels, geoData, center, translation, roll, zoomLevel, drawingArea, fitScale) => {
82
+ const projection = resolveProjectionInstance(projectionInput, parallels);
83
+ if (!projection) {
84
+ return null;
85
+ }
86
+ if (!geoData || fitScale == null) {
87
+ return projection;
88
+ }
89
+ projection.rotate?.([-center[0], -center[1], roll]);
90
+ // Edge case with conic conformal and albers:
91
+ // rotate impacts the center of the projection, so we need to reset it.
92
+ projection.center?.([0, 0]);
93
+
94
+ // `fitScale` is the `zoomLevel === 1` reference scale, computed independently in
95
+ // `selectorFitScale` so it stays stable across pan/zoom transforms.
96
+ projection.scale(zoomLevel != null && zoomLevel !== 1 ? fitScale * zoomLevel : fitScale);
97
+ projection.translate([drawingArea.left + drawingArea.width / 2 + (translation?.[0] ?? 0) * drawingArea.width, drawingArea.top + drawingArea.height / 2 + (translation?.[1] ?? 0) * drawingArea.height]);
98
+ return projection;
99
+ });
100
+
101
+ /**
102
+ * Resolves the raw `projection` input into a ready-to-use `GeoPath` instance
103
+ * fitted to the chart's drawing area.
104
+ */
105
+ export const selectorChartGeoPath = createSelectorMemoized(selectorChartProjection, projection => {
106
+ if (!projection) {
107
+ return null;
108
+ }
109
+ return geoPath(projection);
110
+ });
111
+ export const selectorGeoTooltipPosition = createSelectorMemoized(selectorChartGeoData, selectorChartProjection, selectorChartGeoFeatureIndexesByName, function selectorGeoTooltipPosition(geoData, projection, featureIndexesByName) {
112
+ return {
113
+ geoData,
114
+ projection,
115
+ featureIndexesByName
116
+ };
117
+ });
@@ -1,2 +1,63 @@
1
- import type { useGeoProjectionTypes } from '@mui/x-charts/internals';
2
- export type UseGeoProjectionSignature = useGeoProjectionTypes.UseGeoProjectionSignature;
1
+ import type { GeoProjection, ExtendedFeatureCollection } from '@mui/x-charts-vendor/d3-geo';
2
+ import type { ChartPluginSignature } from '@mui/x-charts/internals';
3
+ import type { UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom/useGeoProjectionZoom.types.mjs";
4
+ /**
5
+ * Geo data used to position a map series tooltip: the resolved projection, the
6
+ * feature collection, and a feature-name-to-index lookup.
7
+ */
8
+ export type GeoTooltipPosition = {
9
+ geoData: ExtendedFeatureCollection | null;
10
+ projection: GeoProjection | null;
11
+ featureIndexesByName: ReadonlyMap<string, number[]>;
12
+ };
13
+ export type D3NamedProjection = 'azimuthalEqualArea' | 'azimuthalEquidistant' | 'gnomonic' | 'orthographic' | 'stereographic' | 'conicConformal' | 'conicEqualArea' | 'conicEquidistant' | 'albers' | 'albersUsa' | 'equirectangular' | 'mercator' | 'transverseMercator' | 'equalEarth' | 'naturalEarth1';
14
+ /**
15
+ * A d3-geo projection accepted by `useGeoProjection`.
16
+ *
17
+ * Either a built-in projection name (e.g. `'mercator'`, `'naturalEarth1'`)
18
+ * or a `GeoProjection` instance returned by a d3-geo factory.
19
+ */
20
+ export type GeoProjectionInput = D3NamedProjection | GeoProjection;
21
+ export interface UseGeoProjectionParameters {
22
+ /**
23
+ * The GeoJSON `FeatureCollection` whose features will be rendered on the map.
24
+ */
25
+ geoData?: ExtendedFeatureCollection;
26
+ /**
27
+ * The key, or value getter, used to identify each feature in `geoData`.
28
+ * - If a string is provided, `feature.properties[geoFeatureKey]` will be used.
29
+ * - If a function is provided, it will be called with each feature and should return a key for that feature.
30
+ * @default 'name'
31
+ */
32
+ geoFeatureKey?: string | ((feature: ExtendedFeatureCollection['features'][number]) => string | null);
33
+ /**
34
+ * The d3-geo projection used to map geographic coordinates to SVG coordinates.
35
+ * Accepts a d3-geo projection name (e.g. `'mercator'`, `'naturalEarth1'`)
36
+ * or a custom `GeoProjection` instance.
37
+ */
38
+ projection?: GeoProjectionInput;
39
+ /**
40
+ * The two standard parallels used by conic projections, if applicable.
41
+ * Used for projection 'conicConformal', 'conicEqualArea', 'conicEquidistant'.
42
+ */
43
+ parallels?: [number, number] | null;
44
+ }
45
+ export type UseGeoProjectionDefaultizedParameters = UseGeoProjectionParameters;
46
+ export interface UseGeoProjectionState {
47
+ geoProjection: {
48
+ geoData: ExtendedFeatureCollection | null;
49
+ geoFeatureKey: string | ((feature: ExtendedFeatureCollection['features'][number]) => string | null);
50
+ projection: GeoProjectionInput | null;
51
+ /**
52
+ * The two standard parallels used by conic projections, if applicable.
53
+ * Used for projection 'conicConformal', 'conicEqualArea', 'conicEquidistant'.
54
+ */
55
+ parallels?: [number, number] | null;
56
+ };
57
+ }
58
+ export type UseGeoProjectionSignature = ChartPluginSignature<{
59
+ params: UseGeoProjectionParameters;
60
+ defaultizedParams: UseGeoProjectionDefaultizedParameters;
61
+ state: UseGeoProjectionState;
62
+ optionalDependencies: [UseGeoProjectionZoomSignature];
63
+ }>;
@@ -1,2 +1,63 @@
1
- import type { useGeoProjectionTypes } from '@mui/x-charts/internals';
2
- export type UseGeoProjectionSignature = useGeoProjectionTypes.UseGeoProjectionSignature;
1
+ import type { GeoProjection, ExtendedFeatureCollection } from '@mui/x-charts-vendor/d3-geo';
2
+ import type { ChartPluginSignature } from '@mui/x-charts/internals';
3
+ import type { UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom/useGeoProjectionZoom.types.js";
4
+ /**
5
+ * Geo data used to position a map series tooltip: the resolved projection, the
6
+ * feature collection, and a feature-name-to-index lookup.
7
+ */
8
+ export type GeoTooltipPosition = {
9
+ geoData: ExtendedFeatureCollection | null;
10
+ projection: GeoProjection | null;
11
+ featureIndexesByName: ReadonlyMap<string, number[]>;
12
+ };
13
+ export type D3NamedProjection = 'azimuthalEqualArea' | 'azimuthalEquidistant' | 'gnomonic' | 'orthographic' | 'stereographic' | 'conicConformal' | 'conicEqualArea' | 'conicEquidistant' | 'albers' | 'albersUsa' | 'equirectangular' | 'mercator' | 'transverseMercator' | 'equalEarth' | 'naturalEarth1';
14
+ /**
15
+ * A d3-geo projection accepted by `useGeoProjection`.
16
+ *
17
+ * Either a built-in projection name (e.g. `'mercator'`, `'naturalEarth1'`)
18
+ * or a `GeoProjection` instance returned by a d3-geo factory.
19
+ */
20
+ export type GeoProjectionInput = D3NamedProjection | GeoProjection;
21
+ export interface UseGeoProjectionParameters {
22
+ /**
23
+ * The GeoJSON `FeatureCollection` whose features will be rendered on the map.
24
+ */
25
+ geoData?: ExtendedFeatureCollection;
26
+ /**
27
+ * The key, or value getter, used to identify each feature in `geoData`.
28
+ * - If a string is provided, `feature.properties[geoFeatureKey]` will be used.
29
+ * - If a function is provided, it will be called with each feature and should return a key for that feature.
30
+ * @default 'name'
31
+ */
32
+ geoFeatureKey?: string | ((feature: ExtendedFeatureCollection['features'][number]) => string | null);
33
+ /**
34
+ * The d3-geo projection used to map geographic coordinates to SVG coordinates.
35
+ * Accepts a d3-geo projection name (e.g. `'mercator'`, `'naturalEarth1'`)
36
+ * or a custom `GeoProjection` instance.
37
+ */
38
+ projection?: GeoProjectionInput;
39
+ /**
40
+ * The two standard parallels used by conic projections, if applicable.
41
+ * Used for projection 'conicConformal', 'conicEqualArea', 'conicEquidistant'.
42
+ */
43
+ parallels?: [number, number] | null;
44
+ }
45
+ export type UseGeoProjectionDefaultizedParameters = UseGeoProjectionParameters;
46
+ export interface UseGeoProjectionState {
47
+ geoProjection: {
48
+ geoData: ExtendedFeatureCollection | null;
49
+ geoFeatureKey: string | ((feature: ExtendedFeatureCollection['features'][number]) => string | null);
50
+ projection: GeoProjectionInput | null;
51
+ /**
52
+ * The two standard parallels used by conic projections, if applicable.
53
+ * Used for projection 'conicConformal', 'conicEqualArea', 'conicEquidistant'.
54
+ */
55
+ parallels?: [number, number] | null;
56
+ };
57
+ }
58
+ export type UseGeoProjectionSignature = ChartPluginSignature<{
59
+ params: UseGeoProjectionParameters;
60
+ defaultizedParams: UseGeoProjectionDefaultizedParameters;
61
+ state: UseGeoProjectionState;
62
+ optionalDependencies: [UseGeoProjectionZoomSignature];
63
+ }>;
@@ -0,0 +1,11 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.mjs";
3
+ export declare const usePanOnDrag: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ }) => void;
@@ -0,0 +1,11 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.js";
3
+ export declare const usePanOnDrag: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ }) => void;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.usePanOnDrag = void 0;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _internals = require("@mui/x-charts-pro/internals");
11
+ var _useGeoProjection = require("../../useGeoProjection");
12
+ var _mapZoom = require("../mapZoom.utils");
13
+ const usePanOnDrag = ({
14
+ store,
15
+ instance
16
+ }, applyView, options) => {
17
+ const {
18
+ enabled,
19
+ rotationAllowed,
20
+ translationAllowed,
21
+ maxEmptySpace
22
+ } = options;
23
+ const projection = store.use(_useGeoProjection.selectorChartProjection);
24
+ const geoPoint = React.useRef(null);
25
+ const dragStartPoint = React.useRef(null);
26
+ const dragCurrentPoint = React.useRef(null);
27
+ (0, _internals.useDragGesture)(instance, {
28
+ enabled,
29
+ onPanStart: event => {
30
+ if (!projection || !projection.invert) {
31
+ return;
32
+ }
33
+ geoPoint.current = projection.invert([event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY]);
34
+ dragStartPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
35
+ dragCurrentPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
36
+ },
37
+ onPanEnd: () => {
38
+ geoPoint.current = null;
39
+ dragStartPoint.current = null;
40
+ dragCurrentPoint.current = null;
41
+ },
42
+ onPan: delta => {
43
+ if (!projection || dragCurrentPoint.current === null || geoPoint.current === null) {
44
+ return;
45
+ }
46
+ dragCurrentPoint.current = [dragCurrentPoint.current[0] + delta.x, dragCurrentPoint.current[1] + delta.y];
47
+ const nextRotation = (0, _mapZoom.getRotation)(projection, geoPoint.current, dragCurrentPoint.current, 1, rotationAllowed);
48
+ const rotate = projection.rotate?.();
49
+ if (nextRotation) {
50
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
51
+ }
52
+ const translation = (0, _mapZoom.getTranslation)(store, projection, geoPoint.current, dragCurrentPoint.current, translationAllowed, maxEmptySpace);
53
+ projection.rotate?.(rotate);
54
+ if (nextRotation || translation) {
55
+ applyView({
56
+ zoomLevel: store.state.geoProjectionZoom.zoomLevel ?? 1,
57
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
58
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
59
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
60
+ });
61
+ }
62
+ }
63
+ });
64
+ };
65
+ exports.usePanOnDrag = usePanOnDrag;
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { useDragGesture } from '@mui/x-charts-pro/internals';
5
+ import { selectorChartProjection } from "../../useGeoProjection/index.mjs";
6
+ import { getRotation, getTranslation } from "../mapZoom.utils.mjs";
7
+ export const usePanOnDrag = ({
8
+ store,
9
+ instance
10
+ }, applyView, options) => {
11
+ const {
12
+ enabled,
13
+ rotationAllowed,
14
+ translationAllowed,
15
+ maxEmptySpace
16
+ } = options;
17
+ const projection = store.use(selectorChartProjection);
18
+ const geoPoint = React.useRef(null);
19
+ const dragStartPoint = React.useRef(null);
20
+ const dragCurrentPoint = React.useRef(null);
21
+ useDragGesture(instance, {
22
+ enabled,
23
+ onPanStart: event => {
24
+ if (!projection || !projection.invert) {
25
+ return;
26
+ }
27
+ geoPoint.current = projection.invert([event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY]);
28
+ dragStartPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
29
+ dragCurrentPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
30
+ },
31
+ onPanEnd: () => {
32
+ geoPoint.current = null;
33
+ dragStartPoint.current = null;
34
+ dragCurrentPoint.current = null;
35
+ },
36
+ onPan: delta => {
37
+ if (!projection || dragCurrentPoint.current === null || geoPoint.current === null) {
38
+ return;
39
+ }
40
+ dragCurrentPoint.current = [dragCurrentPoint.current[0] + delta.x, dragCurrentPoint.current[1] + delta.y];
41
+ const nextRotation = getRotation(projection, geoPoint.current, dragCurrentPoint.current, 1, rotationAllowed);
42
+ const rotate = projection.rotate?.();
43
+ if (nextRotation) {
44
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
45
+ }
46
+ const translation = getTranslation(store, projection, geoPoint.current, dragCurrentPoint.current, translationAllowed, maxEmptySpace);
47
+ projection.rotate?.(rotate);
48
+ if (nextRotation || translation) {
49
+ applyView({
50
+ zoomLevel: store.state.geoProjectionZoom.zoomLevel ?? 1,
51
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
52
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
53
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
54
+ });
55
+ }
56
+ }
57
+ });
58
+ };
@@ -0,0 +1,13 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.mjs";
3
+ export declare const useZoomOnPinch: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ minZoomLevel: number;
12
+ maxZoomLevel: number;
13
+ }) => void;
@@ -0,0 +1,13 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.js";
3
+ export declare const useZoomOnPinch: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ minZoomLevel: number;
12
+ maxZoomLevel: number;
13
+ }) => void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useZoomOnPinch = void 0;
8
+ var _internals = require("@mui/x-charts-pro/internals");
9
+ var _useGeoProjection = require("../../useGeoProjection");
10
+ var _mapZoom = require("../mapZoom.utils");
11
+ const useZoomOnPinch = ({
12
+ store,
13
+ instance
14
+ }, applyView, options) => {
15
+ const {
16
+ enabled,
17
+ rotationAllowed,
18
+ translationAllowed,
19
+ maxEmptySpace
20
+ } = options;
21
+ const projection = store.use(_useGeoProjection.selectorChartProjection);
22
+ const clampZoomLevel = zoomLevel => Math.max(options.minZoomLevel, Math.min(options.maxZoomLevel, zoomLevel));
23
+ (0, _internals.usePinchGesture)(instance, {
24
+ enabled,
25
+ onPinch: (point, deltaScale) => {
26
+ if (!projection || !projection.invert) {
27
+ return;
28
+ }
29
+
30
+ // Same clamp-then-derive-factor flow as the wheel, so pinch obeys the identical bounds.
31
+ const currentZoom = store.state.geoProjectionZoom.zoomLevel ?? 1;
32
+ const nextZoom = clampZoomLevel(currentZoom * (1 + deltaScale));
33
+ const factor = nextZoom / currentZoom;
34
+ if (factor === 1) {
35
+ return;
36
+ }
37
+ const geoPoint = projection.invert([point.x, point.y]);
38
+ if (!geoPoint) {
39
+ return;
40
+ }
41
+ const nextRotation = (0, _mapZoom.getRotation)(projection, geoPoint, [point.x, point.y], factor, rotationAllowed);
42
+ const scale = projection.scale();
43
+ const rotate = projection.rotate?.();
44
+ if (nextRotation) {
45
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
46
+ }
47
+ projection.scale(scale * factor);
48
+ const translation = (0, _mapZoom.getTranslation)(store, projection, geoPoint, [point.x, point.y], translationAllowed, maxEmptySpace, store.state.geoProjectionZoom.translation ?? [0, 0]);
49
+ projection.rotate?.(rotate);
50
+ projection.scale(scale);
51
+ if (nextRotation || translation) {
52
+ applyView({
53
+ zoomLevel: nextZoom,
54
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
55
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
56
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
57
+ });
58
+ }
59
+ }
60
+ });
61
+ };
62
+ exports.useZoomOnPinch = useZoomOnPinch;