@mui/x-charts-premium 9.8.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.
- package/BarChartPremium/BarChartPremium.d.mts +1 -1
- package/BarChartPremium/BarChartPremium.d.ts +1 -1
- package/BarChartPremium/BarChartPremium.js +14 -3
- package/BarChartPremium/BarChartPremium.mjs +14 -3
- package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.mts +2 -1
- package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.ts +2 -1
- package/BarChartPremium/RangeBar/FocusedRangeBar.d.mts +1 -1
- package/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +1 -1
- package/BarChartPremium/RangeBar/seriesConfig/index.js +2 -2
- package/BarChartPremium/RangeBar/seriesConfig/index.mjs +2 -2
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.mts +2 -3
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.ts +2 -3
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +12 -15
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.mjs +11 -14
- package/CHANGELOG.md +119 -0
- package/CandlestickChart/CandlestickPlot.d.mts +2 -1
- package/CandlestickChart/CandlestickPlot.d.ts +2 -1
- package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.mts +2 -1
- package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.ts +2 -1
- package/CandlestickChart/seriesConfig/index.js +2 -2
- package/CandlestickChart/seriesConfig/index.mjs +2 -2
- package/CandlestickChart/seriesConfig/tooltipPosition.d.mts +2 -3
- package/CandlestickChart/seriesConfig/tooltipPosition.d.ts +2 -3
- package/CandlestickChart/seriesConfig/tooltipPosition.js +10 -14
- package/CandlestickChart/seriesConfig/tooltipPosition.mjs +10 -14
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.mts +1 -1
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.ts +1 -1
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.mts +1 -1
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.ts +1 -1
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.mts +4 -3
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.ts +4 -3
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.js +2 -1
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.mjs +2 -1
- package/ChartsGeoDataProviderPremium/index.d.mts +2 -1
- package/ChartsGeoDataProviderPremium/index.d.ts +2 -1
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.mts +2 -1
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.ts +2 -1
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
- package/ChartsRenderer/components/PaletteOption.d.mts +1 -1
- package/ChartsRenderer/components/PaletteOption.d.ts +1 -1
- package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.mts +2 -1
- package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.ts +2 -1
- package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.mts +1 -1
- package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.ts +1 -1
- package/HeatmapPremium/HeatmapPlotPremium.d.mts +1 -1
- package/HeatmapPremium/HeatmapPlotPremium.d.ts +1 -1
- package/Map/FocusedMapShape.d.mts +2 -1
- package/Map/FocusedMapShape.d.ts +2 -1
- package/Map/GeoDataPlot.d.mts +1 -1
- package/Map/GeoDataPlot.d.ts +1 -1
- package/Map/Graticule.d.mts +1 -1
- package/Map/Graticule.d.ts +1 -1
- package/Map/MapImagePlot.d.mts +1 -1
- package/Map/MapImagePlot.d.ts +1 -1
- package/Map/MapShape.d.mts +1 -1
- package/Map/MapShape.d.ts +1 -1
- package/Map/MapShapePlot.d.mts +1 -1
- package/Map/MapShapePlot.d.ts +1 -1
- package/Map/index.d.mts +1 -3
- package/Map/index.d.ts +1 -3
- package/Map/seriesConfig/tooltipPosition.d.mts +1 -1
- package/Map/seriesConfig/tooltipPosition.d.ts +1 -1
- package/Map/seriesConfig/tooltipPosition.js +2 -8
- package/Map/seriesConfig/tooltipPosition.mjs +3 -9
- package/RadialBarChart/RadialBarElement.d.mts +1 -1
- package/RadialBarChart/RadialBarElement.d.ts +1 -1
- package/RadialBarChart/seriesConfig/index.js +2 -2
- package/RadialBarChart/seriesConfig/index.mjs +2 -2
- package/RadialBarChart/seriesConfig/tooltipPosition.d.mts +2 -3
- package/RadialBarChart/seriesConfig/tooltipPosition.d.ts +2 -3
- package/RadialBarChart/seriesConfig/tooltipPosition.js +4 -6
- package/RadialBarChart/seriesConfig/tooltipPosition.mjs +2 -5
- package/RadialLineChart/RadialArea.d.mts +2 -1
- package/RadialLineChart/RadialArea.d.ts +2 -1
- package/RadialLineChart/RadialAreaPlot.d.mts +1 -1
- package/RadialLineChart/RadialAreaPlot.d.ts +1 -1
- package/RadialLineChart/RadialLine.d.mts +1 -1
- package/RadialLineChart/RadialLine.d.ts +1 -1
- package/RadialLineChart/RadialLineHighlightElement.d.mts +1 -1
- package/RadialLineChart/RadialLineHighlightElement.d.ts +1 -1
- package/RadialLineChart/RadialLineHighlightPlot.d.mts +1 -1
- package/RadialLineChart/RadialLineHighlightPlot.d.ts +1 -1
- package/RadialLineChart/RadialLinePlot.d.mts +1 -1
- package/RadialLineChart/RadialLinePlot.d.ts +1 -1
- package/RadialLineChart/RadialMarkPlot.d.mts +1 -1
- package/RadialLineChart/RadialMarkPlot.d.ts +1 -1
- package/RadialLineChart/seriesConfig/index.js +2 -2
- package/RadialLineChart/seriesConfig/index.mjs +2 -2
- package/RadialLineChart/seriesConfig/tooltipPosition.d.mts +2 -3
- package/RadialLineChart/seriesConfig/tooltipPosition.d.ts +2 -3
- package/RadialLineChart/seriesConfig/tooltipPosition.js +4 -6
- package/RadialLineChart/seriesConfig/tooltipPosition.mjs +2 -5
- package/ScatterChartPremium/ScatterPlotPremium.d.mts +2 -1
- package/ScatterChartPremium/ScatterPlotPremium.d.ts +2 -1
- package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.mts +2 -1
- package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.ts +2 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/plugins/useGeoProjection/factories.d.mts +3 -0
- package/internals/plugins/useGeoProjection/factories.d.ts +3 -0
- package/internals/plugins/useGeoProjection/factories.js +29 -0
- package/internals/plugins/useGeoProjection/factories.mjs +23 -0
- package/internals/plugins/useGeoProjection/projection.utils.d.mts +17 -0
- package/internals/plugins/useGeoProjection/projection.utils.d.ts +17 -0
- package/internals/plugins/useGeoProjection/projection.utils.js +67 -0
- package/internals/plugins/useGeoProjection/projection.utils.mjs +59 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.js +7 -40
- package/internals/plugins/useGeoProjection/useGeoProjection.mjs +7 -40
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.mts +47 -11
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.ts +47 -11
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.js +118 -8
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.mjs +117 -8
- package/internals/plugins/useGeoProjection/useGeoProjection.types.d.mts +63 -2
- package/internals/plugins/useGeoProjection/useGeoProjection.types.d.ts +63 -2
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.mts +11 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.ts +11 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.js +65 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.mjs +58 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.mts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.ts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.js +62 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.mjs +56 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.mts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.ts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.js +64 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.mjs +58 -0
- package/internals/plugins/useGeoProjectionZoom/index.d.mts +2 -0
- package/internals/plugins/useGeoProjectionZoom/index.d.ts +2 -0
- package/internals/plugins/useGeoProjectionZoom/index.js +12 -0
- package/internals/plugins/useGeoProjectionZoom/index.mjs +1 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.mts +31 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.ts +31 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.js +187 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.mjs +177 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.d.mts +23 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.d.ts +23 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.js +190 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.mjs +182 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.mts +3 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.ts +3 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.js +174 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.mjs +166 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.mts +152 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.ts +152 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.js +5 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.mjs +1 -0
- package/package.json +6 -6
|
@@ -1,17 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ExtendedFeatureCollection, GeoProjection, GeoPath } from '@mui/x-charts-vendor/d3-geo';
|
|
2
|
+
import type { ChartState } from '@mui/x-charts/internals';
|
|
3
|
+
import type { GeoProjectionInput, GeoTooltipPosition, UseGeoProjectionSignature, UseGeoProjectionState } from "./useGeoProjection.types.mjs";
|
|
4
|
+
import type { UseGeoProjectionZoomState } from "../useGeoProjectionZoom/useGeoProjectionZoom.types.mjs";
|
|
5
|
+
export declare const selectorChartGeoProjectionState: (state: ChartState<[], [UseGeoProjectionSignature]>) => UseGeoProjectionState["geoProjection"] | undefined;
|
|
6
|
+
export declare const selectorChartGeoData: (state: ChartState<[], [UseGeoProjectionSignature]>) => ExtendedFeatureCollection | null;
|
|
7
|
+
export declare const selectorChartGeoFeatureKey: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
2
8
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
3
|
-
}) =>
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
}) => string | ((feature: ExtendedFeatureCollection["features"][number]) => string | null);
|
|
10
|
+
export declare const selectorChartRawProjection: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
11
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
12
|
+
}) => GeoProjectionInput | null;
|
|
13
|
+
export declare const selectorChartZoomLevel: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionZoomState> & {
|
|
7
14
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
8
|
-
}) =>
|
|
9
|
-
|
|
15
|
+
}) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Map a feature's `properties.name` to its index in `geoData.features`,
|
|
18
|
+
* for fast lookup by name when joining series rows to features.
|
|
19
|
+
*
|
|
20
|
+
* Features without a string `properties.name` are skipped; on duplicates,
|
|
21
|
+
* the first occurrence wins.
|
|
22
|
+
*/
|
|
23
|
+
export declare const selectorChartGeoFeatureIndexesByName: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
24
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
25
|
+
}) => ReadonlyMap<string, number[]>;
|
|
26
|
+
export declare const selectorFitScale: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
10
27
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
11
28
|
}) => number | null;
|
|
12
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the raw `projection` input into a ready-to-use `GeoProjection` instance,
|
|
31
|
+
* fitted to the chart's drawing area then zoomed/panned according to the current view.
|
|
32
|
+
*
|
|
33
|
+
* - String inputs (e.g. `'mercator'`) are mapped to the matching d3-geo factory.
|
|
34
|
+
* - `GeoProjection` instances are used as-is, then fitted.
|
|
35
|
+
* - The projection is first fitted to the data (the `zoomLevel === 1` baseline), then its
|
|
36
|
+
* scale is multiplied by `zoomLevel` and its translation is offset so `center` lands at the
|
|
37
|
+
* center of the drawing area. Keeping the view as `{ zoomLevel, center }` means the absolute
|
|
38
|
+
* scale/translation are derived here, never stored — so they stay correct across resizes.
|
|
39
|
+
* - Returns `null` when no projection is registered or the name is unknown.
|
|
40
|
+
*/
|
|
41
|
+
export declare const selectorChartProjection: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
42
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
43
|
+
}) => GeoProjection | null;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the raw `projection` input into a ready-to-use `GeoPath` instance
|
|
46
|
+
* fitted to the chart's drawing area.
|
|
47
|
+
*/
|
|
48
|
+
export declare const selectorChartGeoPath: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
13
49
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
14
|
-
}) => import("@mui/x-charts-vendor/d3-geo").
|
|
15
|
-
export declare const
|
|
50
|
+
}) => GeoPath<any, import("@mui/x-charts-vendor/d3-geo").GeoPermissibleObjects> | null;
|
|
51
|
+
export declare const selectorGeoTooltipPosition: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
16
52
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
17
|
-
}) =>
|
|
53
|
+
}) => GeoTooltipPosition;
|
|
@@ -1,17 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ExtendedFeatureCollection, GeoProjection, GeoPath } from '@mui/x-charts-vendor/d3-geo';
|
|
2
|
+
import type { ChartState } from '@mui/x-charts/internals';
|
|
3
|
+
import type { GeoProjectionInput, GeoTooltipPosition, UseGeoProjectionSignature, UseGeoProjectionState } from "./useGeoProjection.types.js";
|
|
4
|
+
import type { UseGeoProjectionZoomState } from "../useGeoProjectionZoom/useGeoProjectionZoom.types.js";
|
|
5
|
+
export declare const selectorChartGeoProjectionState: (state: ChartState<[], [UseGeoProjectionSignature]>) => UseGeoProjectionState["geoProjection"] | undefined;
|
|
6
|
+
export declare const selectorChartGeoData: (state: ChartState<[], [UseGeoProjectionSignature]>) => ExtendedFeatureCollection | null;
|
|
7
|
+
export declare const selectorChartGeoFeatureKey: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
2
8
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
3
|
-
}) =>
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
}) => string | ((feature: ExtendedFeatureCollection["features"][number]) => string | null);
|
|
10
|
+
export declare const selectorChartRawProjection: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
11
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
12
|
+
}) => GeoProjectionInput | null;
|
|
13
|
+
export declare const selectorChartZoomLevel: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionZoomState> & {
|
|
7
14
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
8
|
-
}) =>
|
|
9
|
-
|
|
15
|
+
}) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Map a feature's `properties.name` to its index in `geoData.features`,
|
|
18
|
+
* for fast lookup by name when joining series rows to features.
|
|
19
|
+
*
|
|
20
|
+
* Features without a string `properties.name` are skipped; on duplicates,
|
|
21
|
+
* the first occurrence wins.
|
|
22
|
+
*/
|
|
23
|
+
export declare const selectorChartGeoFeatureIndexesByName: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
24
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
25
|
+
}) => ReadonlyMap<string, number[]>;
|
|
26
|
+
export declare const selectorFitScale: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
10
27
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
11
28
|
}) => number | null;
|
|
12
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the raw `projection` input into a ready-to-use `GeoProjection` instance,
|
|
31
|
+
* fitted to the chart's drawing area then zoomed/panned according to the current view.
|
|
32
|
+
*
|
|
33
|
+
* - String inputs (e.g. `'mercator'`) are mapped to the matching d3-geo factory.
|
|
34
|
+
* - `GeoProjection` instances are used as-is, then fitted.
|
|
35
|
+
* - The projection is first fitted to the data (the `zoomLevel === 1` baseline), then its
|
|
36
|
+
* scale is multiplied by `zoomLevel` and its translation is offset so `center` lands at the
|
|
37
|
+
* center of the drawing area. Keeping the view as `{ zoomLevel, center }` means the absolute
|
|
38
|
+
* scale/translation are derived here, never stored — so they stay correct across resizes.
|
|
39
|
+
* - Returns `null` when no projection is registered or the name is unknown.
|
|
40
|
+
*/
|
|
41
|
+
export declare const selectorChartProjection: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
42
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
43
|
+
}) => GeoProjection | null;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the raw `projection` input into a ready-to-use `GeoPath` instance
|
|
46
|
+
* fitted to the chart's drawing area.
|
|
47
|
+
*/
|
|
48
|
+
export declare const selectorChartGeoPath: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
13
49
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
14
|
-
}) => import("@mui/x-charts-vendor/d3-geo").
|
|
15
|
-
export declare const
|
|
50
|
+
}) => GeoPath<any, import("@mui/x-charts-vendor/d3-geo").GeoPermissibleObjects> | null;
|
|
51
|
+
export declare const selectorGeoTooltipPosition: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<UseGeoProjectionState> & {
|
|
16
52
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
17
|
-
}) =>
|
|
53
|
+
}) => GeoTooltipPosition;
|
|
@@ -3,12 +3,122 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
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
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
export const
|
|
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 {
|
|
2
|
-
|
|
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 {
|
|
2
|
-
|
|
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;
|