@mui/x-charts 8.18.0 → 8.20.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 (140) hide show
  1. package/BarChart/seriesConfig/bar/seriesProcessor.js +15 -9
  2. package/CHANGELOG.md +175 -0
  3. package/ChartsGrid/ChartsHorizontalGrid.js +5 -1
  4. package/ChartsGrid/ChartsVerticalGrid.js +5 -1
  5. package/ChartsSurface/ChartsSurface.js +5 -2
  6. package/ChartsTooltip/ChartsTooltipContainer.js +1 -1
  7. package/LineChart/seriesConfig/seriesProcessor.js +15 -10
  8. package/PieChart/PieArcPlot.js +5 -3
  9. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +2 -2
  10. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +2 -2
  11. package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +7 -0
  12. package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.js +26 -0
  13. package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +15 -9
  14. package/esm/ChartsGrid/ChartsHorizontalGrid.js +5 -1
  15. package/esm/ChartsGrid/ChartsVerticalGrid.js +5 -1
  16. package/esm/ChartsSurface/ChartsSurface.js +5 -2
  17. package/esm/ChartsTooltip/ChartsTooltipContainer.js +1 -1
  18. package/esm/LineChart/seriesConfig/seriesProcessor.js +15 -10
  19. package/esm/PieChart/PieArcPlot.js +5 -3
  20. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +1 -1
  21. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -1
  22. package/esm/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +7 -0
  23. package/esm/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.js +18 -0
  24. package/esm/hooks/useBarSeries.js +3 -5
  25. package/esm/hooks/useInteractionItemProps.d.ts +0 -5
  26. package/esm/hooks/useInteractionItemProps.js +0 -11
  27. package/esm/hooks/useLineSeries.js +3 -5
  28. package/esm/hooks/usePieSeries.js +3 -5
  29. package/esm/hooks/useRadarSeries.js +3 -5
  30. package/esm/hooks/useScatterSeries.js +3 -5
  31. package/esm/hooks/useTicks.js +12 -3
  32. package/esm/index.d.ts +2 -1
  33. package/esm/index.js +2 -1
  34. package/esm/internals/domUtils.js +30 -14
  35. package/esm/internals/getScale.d.ts +2 -1
  36. package/esm/internals/index.d.ts +1 -1
  37. package/esm/internals/index.js +1 -1
  38. package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +2 -2
  39. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +5 -6
  40. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +2 -2
  41. package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +2 -2
  42. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -1
  43. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +3 -1
  44. package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +16 -10
  45. package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.js +20 -12
  46. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +5 -7
  47. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +11 -4
  48. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +14 -5
  49. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -2
  50. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +1 -1
  51. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +15 -15
  52. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +1 -1
  53. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +5 -5
  54. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3 -0
  55. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +11 -11
  56. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +5 -6
  57. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +7 -8
  58. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +2 -2
  59. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +2 -2
  60. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +16 -12
  61. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +15 -16
  62. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +4 -0
  63. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +8 -8
  64. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +1 -1
  65. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +4 -4
  66. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +15 -10
  67. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -11
  68. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +6 -6
  69. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +7 -8
  70. package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +2 -2
  71. package/esm/internals/plugins/utils/selectors.d.ts +1 -14
  72. package/esm/internals/plugins/utils/selectors.js +1 -5
  73. package/esm/internals/seriesSelectorOfType.d.ts +20 -0
  74. package/esm/internals/seriesSelectorOfType.js +38 -0
  75. package/esm/models/seriesType/config.d.ts +2 -2
  76. package/esm/utils/index.d.ts +4 -0
  77. package/esm/utils/index.js +5 -0
  78. package/esm/utils/niceDomain.d.ts +20 -0
  79. package/esm/utils/niceDomain.js +24 -0
  80. package/hooks/useBarSeries.js +3 -6
  81. package/hooks/useInteractionItemProps.d.ts +0 -5
  82. package/hooks/useInteractionItemProps.js +1 -13
  83. package/hooks/useLineSeries.js +3 -6
  84. package/hooks/usePieSeries.js +3 -6
  85. package/hooks/useRadarSeries.js +3 -6
  86. package/hooks/useScatterSeries.js +3 -6
  87. package/hooks/useTicks.js +12 -3
  88. package/index.d.ts +2 -1
  89. package/index.js +13 -1
  90. package/internals/domUtils.js +30 -14
  91. package/internals/getScale.d.ts +2 -1
  92. package/internals/index.d.ts +1 -1
  93. package/internals/index.js +4 -4
  94. package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +2 -2
  95. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +4 -5
  96. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +2 -2
  97. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +2 -2
  98. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -1
  99. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +3 -1
  100. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +16 -10
  101. package/internals/plugins/corePlugins/useChartSeries/processSeries.js +23 -14
  102. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +4 -6
  103. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +11 -4
  104. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +15 -6
  105. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -2
  106. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +1 -1
  107. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +15 -15
  108. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +1 -1
  109. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +5 -5
  110. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3 -0
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +11 -11
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +4 -5
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +6 -7
  114. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +2 -2
  115. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +2 -2
  116. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +16 -12
  117. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +14 -15
  118. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +4 -0
  119. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +8 -8
  120. package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +1 -1
  121. package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +4 -4
  122. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +15 -10
  123. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -11
  124. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +6 -6
  125. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +6 -7
  126. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +2 -2
  127. package/internals/plugins/utils/selectors.d.ts +1 -14
  128. package/internals/plugins/utils/selectors.js +1 -8
  129. package/internals/seriesSelectorOfType.d.ts +20 -0
  130. package/internals/seriesSelectorOfType.js +46 -0
  131. package/models/seriesType/config.d.ts +2 -2
  132. package/package.json +4 -4
  133. package/utils/index.d.ts +4 -0
  134. package/utils/index.js +16 -0
  135. package/utils/niceDomain.d.ts +20 -0
  136. package/utils/niceDomain.js +29 -0
  137. package/esm/internals/createSeriesSelectorOfType.d.ts +0 -4
  138. package/esm/internals/createSeriesSelectorOfType.js +0 -45
  139. package/internals/createSeriesSelectorOfType.d.ts +0 -4
  140. package/internals/createSeriesSelectorOfType.js +0 -53
@@ -1,17 +1,24 @@
1
1
  import { ChartRootSelector } from "../../utils/selectors.js";
2
2
  import { UseChartSeriesSignature } from "./useChartSeries.types.js";
3
3
  export declare const selectorChartSeriesState: ChartRootSelector<UseChartSeriesSignature>;
4
- export declare const selectorChartSeriesProcessed: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
4
+ export declare const selectorChartDefaultizedSeries: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
5
5
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
6
- }) => import("./useChartSeries.types.js").ProcessedSeries<keyof import("../../../index.js").ChartsSeriesConfig>;
6
+ }) => import("./useChartSeries.types.js").DefaultizedSeriesGroups<keyof import("../../../index.js").ChartsSeriesConfig>;
7
7
  export declare const selectorChartSeriesConfig: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
8
8
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
9
  }) => import("../../models/index.js").ChartSeriesConfig<keyof import("../../../index.js").ChartsSeriesConfig>;
10
10
  /**
11
11
  * Get the dataset from the series state.
12
- * @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
13
12
  * @returns {DatasetType | undefined} The dataset.
14
13
  */
15
14
  export declare const selectorChartDataset: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
16
15
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
17
- }) => readonly import("../../../index.js").DatasetElementType<string | number | Date | null | undefined>[] | undefined;
16
+ }) => readonly import("../../../index.js").DatasetElementType<unknown>[] | undefined;
17
+ /**
18
+ * Get the processed series after applying series processors.
19
+ * This selector computes the processed series on-demand from the defaultized series.
20
+ * @returns {ProcessedSeries} The processed series.
21
+ */
22
+ export declare const selectorChartSeriesProcessed: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
23
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
24
+ }) => import("./useChartSeries.types.js").ProcessedSeries<keyof import("../../../index.js").ChartsSeriesConfig>;
@@ -1,11 +1,20 @@
1
- import { createSelector } from "../../utils/selectors.js";
1
+ import { createSelectorMemoized, createSelector } from '@mui/x-internals/store';
2
+ import { applySeriesProcessors } from "./processSeries.js";
2
3
  export const selectorChartSeriesState = state => state.series;
3
- export const selectorChartSeriesProcessed = createSelector([selectorChartSeriesState], seriesState => seriesState.processedSeries);
4
- export const selectorChartSeriesConfig = createSelector([selectorChartSeriesState], seriesState => seriesState.seriesConfig);
4
+ export const selectorChartDefaultizedSeries = createSelector(selectorChartSeriesState, seriesState => seriesState.defaultizedSeries);
5
+ export const selectorChartSeriesConfig = createSelector(selectorChartSeriesState, seriesState => seriesState.seriesConfig);
5
6
 
6
7
  /**
7
8
  * Get the dataset from the series state.
8
- * @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
9
9
  * @returns {DatasetType | undefined} The dataset.
10
10
  */
11
- export const selectorChartDataset = createSelector([selectorChartSeriesState], seriesState => seriesState.dataset);
11
+ export const selectorChartDataset = createSelector(selectorChartSeriesState, seriesState => seriesState.dataset);
12
+
13
+ /**
14
+ * Get the processed series after applying series processors.
15
+ * This selector computes the processed series on-demand from the defaultized series.
16
+ * @returns {ProcessedSeries} The processed series.
17
+ */
18
+ export const selectorChartSeriesProcessed = createSelectorMemoized(selectorChartDefaultizedSeries, selectorChartSeriesConfig, selectorChartDataset, function selectorChartSeriesProcessed(defaultizedSeries, seriesConfig, dataset) {
19
+ return applySeriesProcessors(defaultizedSeries, seriesConfig, dataset);
20
+ });
@@ -2,7 +2,7 @@ import { AllSeriesType } from "../../../../models/seriesType/index.js";
2
2
  import { ChartsColorPalette } from "../../../../colorPalettes/index.js";
3
3
  import { ChartPluginSignature, ChartSeriesConfig } from "../../models/index.js";
4
4
  import { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
5
- import { SeriesProcessorResult } from "../../models/seriesConfig/seriesProcessor.types.js";
5
+ import { SeriesProcessorParams, SeriesProcessorResult } from "../../models/seriesConfig/seriesProcessor.types.js";
6
6
  export interface UseChartSeriesParameters<T extends ChartSeriesType = ChartSeriesType> {
7
7
  /**
8
8
  * An array of objects that can be used to populate series and axes data using their `dataKey` property.
@@ -36,9 +36,10 @@ export type UseChartSeriesDefaultizedParameters<T extends ChartSeriesType = Char
36
36
  theme: 'light' | 'dark';
37
37
  };
38
38
  export type ProcessedSeries<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesProcessorResult<type> };
39
+ export type DefaultizedSeriesGroups<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesProcessorParams<type> };
39
40
  export interface UseChartSeriesState<T extends ChartSeriesType = ChartSeriesType> {
40
41
  series: {
41
- processedSeries: ProcessedSeries<T>;
42
+ defaultizedSeries: DefaultizedSeriesGroups<T>;
42
43
  seriesConfig: ChartSeriesConfig<T>;
43
44
  dataset?: Readonly<DatasetType>;
44
45
  };
@@ -1,4 +1,4 @@
1
- import { type ChartOptionalRootSelector } from "../../utils/selectors.js";
1
+ import type { ChartOptionalRootSelector } from "../../utils/selectors.js";
2
2
  import type { UseChartBrushSignature } from "./useChartBrush.types.js";
3
3
  export declare const selectorBrush: ChartOptionalRootSelector<UseChartBrushSignature>;
4
4
  export declare const selectorBrushStart: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
@@ -1,14 +1,14 @@
1
- import { createSelector } from "../../utils/selectors.js";
1
+ import { createSelector } from '@mui/x-internals/store';
2
2
  import { selectorChartZoomOptionsLookup } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
3
3
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
4
4
  export const selectorBrush = state => state.brush;
5
- export const selectorBrushStart = createSelector([selectorBrush], brush => brush?.start);
6
- export const selectorBrushCurrent = createSelector([selectorBrush], brush => brush?.current);
7
- export const selectorBrushStartX = createSelector([selectorBrush], brush => brush?.start?.x ?? null);
8
- export const selectorBrushStartY = createSelector([selectorBrush], brush => brush?.start?.y ?? null);
9
- export const selectorBrushCurrentX = createSelector([selectorBrush], brush => brush?.current?.x ?? null);
10
- export const selectorBrushCurrentY = createSelector([selectorBrush], brush => brush?.current?.y ?? null);
11
- export const selectorBrushState = createSelector([selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY], (startX, startY, currentX, currentY) => {
5
+ export const selectorBrushStart = createSelector(selectorBrush, brush => brush?.start);
6
+ export const selectorBrushCurrent = createSelector(selectorBrush, brush => brush?.current);
7
+ export const selectorBrushStartX = createSelector(selectorBrush, brush => brush?.start?.x ?? null);
8
+ export const selectorBrushStartY = createSelector(selectorBrush, brush => brush?.start?.y ?? null);
9
+ export const selectorBrushCurrentX = createSelector(selectorBrush, brush => brush?.current?.x ?? null);
10
+ export const selectorBrushCurrentY = createSelector(selectorBrush, brush => brush?.current?.y ?? null);
11
+ export const selectorBrushState = createSelector(selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY, (startX, startY, currentX, currentY) => {
12
12
  if (startX === null || startY === null || currentX === null || currentY === null) {
13
13
  return null;
14
14
  }
@@ -23,7 +23,7 @@ export const selectorBrushState = createSelector([selectorBrushStartX, selectorB
23
23
  }
24
24
  };
25
25
  });
26
- export const selectorBrushConfigNoZoom = createSelector([selectorChartSeriesProcessed], series => {
26
+ export const selectorBrushConfigNoZoom = createSelector(selectorChartSeriesProcessed, series => {
27
27
  let hasHorizontal = false;
28
28
  let isBothDirections = false;
29
29
  if (series) {
@@ -44,7 +44,7 @@ export const selectorBrushConfigNoZoom = createSelector([selectorChartSeriesProc
44
44
  }
45
45
  return 'x';
46
46
  });
47
- export const selectorBrushConfigZoom = createSelector([selectorChartZoomOptionsLookup], function selectorBrushConfigZoom(optionsLookup) {
47
+ export const selectorBrushConfigZoom = createSelector(selectorChartZoomOptionsLookup, function selectorBrushConfigZoom(optionsLookup) {
48
48
  let hasX = false;
49
49
  let hasY = false;
50
50
  Object.values(optionsLookup).forEach(options => {
@@ -66,10 +66,10 @@ export const selectorBrushConfigZoom = createSelector([selectorChartZoomOptionsL
66
66
  }
67
67
  return null;
68
68
  });
69
- export const selectorBrushConfig = createSelector([selectorBrushConfigNoZoom, selectorBrushConfigZoom], (configNoZoom, configZoom) => configZoom ?? configNoZoom);
70
- export const selectorIsBrushEnabled = createSelector([selectorBrush], brush => brush?.enabled || brush?.isZoomBrushEnabled);
71
- export const selectorIsBrushSelectionActive = createSelector([selectorIsBrushEnabled, selectorBrush], (isBrushEnabled, brush) => {
69
+ export const selectorBrushConfig = createSelector(selectorBrushConfigNoZoom, selectorBrushConfigZoom, (configNoZoom, configZoom) => configZoom ?? configNoZoom);
70
+ export const selectorIsBrushEnabled = createSelector(selectorBrush, brush => brush?.enabled || brush?.isZoomBrushEnabled);
71
+ export const selectorIsBrushSelectionActive = createSelector(selectorIsBrushEnabled, selectorBrush, (isBrushEnabled, brush) => {
72
72
  return isBrushEnabled && brush?.start !== null && brush?.current !== null;
73
73
  });
74
- export const selectorBrushShouldPreventAxisHighlight = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
75
- export const selectorBrushShouldPreventTooltip = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
74
+ export const selectorBrushShouldPreventAxisHighlight = createSelector(selectorBrush, selectorIsBrushSelectionActive, (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
75
+ export const selectorBrushShouldPreventTooltip = createSelector(selectorBrush, selectorIsBrushSelectionActive, (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
@@ -72,7 +72,7 @@ export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slid
72
72
  }
73
73
  export interface UseChartCartesianAxisState {
74
74
  /**
75
- * @ignore - state populated by the useChartProZoomPlugin
75
+ * @ignore - state populated by the useChartProZoom plugin
76
76
  */
77
77
  zoom?: {
78
78
  isInteracting: boolean;
@@ -1,4 +1,4 @@
1
- import { createSelector } from "../../utils/selectors.js";
1
+ import { createSelector } from '@mui/x-internals/store';
2
2
  import { selectorChartRawXAxis, selectorChartRawYAxis } from "./useChartCartesianAxisLayout.selectors.js";
3
3
  import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
4
4
  import { computeAxisValue } from "./computeAxisValue.js";
@@ -25,7 +25,7 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
25
25
  bottom: mainChartDrawingArea.height
26
26
  };
27
27
  }
28
- export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedXScales], function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
28
+ export const selectorChartPreviewXScales = createSelector(selectorChartRawXAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedXScales, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
29
29
  const hasAxis = xAxes?.some(axis => axis.id === axisId);
30
30
  const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
31
31
  const options = zoomOptions[axisId];
@@ -40,7 +40,7 @@ export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis
40
40
  });
41
41
  return scales;
42
42
  });
43
- export const selectorChartPreviewComputedXAxis = createSelector([selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartDrawingArea, selectorChartPreviewXScales, selectorChartXAxisWithDomains], (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
43
+ export const selectorChartPreviewComputedXAxis = createSelector(selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartDrawingArea, selectorChartPreviewXScales, selectorChartXAxisWithDomains, (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
44
44
  axes,
45
45
  domains
46
46
  }, axisId) => {
@@ -69,7 +69,7 @@ export const selectorChartPreviewComputedXAxis = createSelector([selectorChartSe
69
69
  }
70
70
  return computedAxes.axis;
71
71
  });
72
- export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedYScales], function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
72
+ export const selectorChartPreviewYScales = createSelector(selectorChartRawYAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedYScales, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
73
73
  const hasAxis = yAxes?.some(axis => axis.id === axisId);
74
74
  const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
75
75
  const options = zoomOptions[axisId];
@@ -87,7 +87,7 @@ export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis
87
87
  });
88
88
  return scales;
89
89
  });
90
- export const selectorChartPreviewComputedYAxis = createSelector([selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartDrawingArea, selectorChartPreviewYScales, selectorChartYAxisWithDomains], (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
90
+ export const selectorChartPreviewComputedYAxis = createSelector(selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartDrawingArea, selectorChartPreviewYScales, selectorChartYAxisWithDomains, (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
91
91
  axes,
92
92
  domains
93
93
  }, axisId) => {
@@ -4,6 +4,9 @@ import { AxisId, D3Scale } from "../../../../models/axis.js";
4
4
  import { SeriesId } from "../../../../models/seriesType/common.js";
5
5
  import { Flatbush } from "../../../Flatbush.js";
6
6
  export declare const createZoomMap: (zoom: readonly ZoomData[]) => Map<AxisId, ZoomData>;
7
+ export declare const selectorChartHasZoom: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
8
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
+ }) => boolean;
7
10
  /**
8
11
  * Following selectors are not exported because they exist in the MIT chart only to ba able to reuse the Zoom state from the pro.
9
12
  */
@@ -1,8 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createSelectorMemoized } from '@mui/x-internals/store';
2
+ import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
3
3
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
4
4
  import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
5
- import { createSelector } from "../../utils/selectors.js";
6
5
  import { computeAxisValue } from "./computeAxisValue.js";
7
6
  import { createContinuousScaleGetAxisFilter, createDiscreteScaleGetAxisFilter, createGetAxisFilters } from "./createAxisFilterMapper.js";
8
7
  import { createZoomLookup } from "./createZoomLookup.js";
@@ -24,24 +23,25 @@ export const createZoomMap = zoom => {
24
23
  return zoomItemMap;
25
24
  };
26
25
  const selectorChartZoomState = state => state.zoom;
26
+ export const selectorChartHasZoom = createSelector(selectorChartRawXAxis, selectorChartRawYAxis, (xAxes, yAxes) => xAxes?.some(axis => Boolean(axis.zoom)) || yAxes?.some(axis => Boolean(axis.zoom)) || false);
27
27
 
28
28
  /**
29
29
  * Following selectors are not exported because they exist in the MIT chart only to ba able to reuse the Zoom state from the pro.
30
30
  */
31
31
 
32
- export const selectorChartZoomIsInteracting = createSelector([selectorChartZoomState], zoom => zoom?.isInteracting);
32
+ export const selectorChartZoomIsInteracting = createSelector(selectorChartZoomState, zoom => zoom?.isInteracting);
33
33
  export const selectorChartZoomMap = createSelectorMemoized(selectorChartZoomState, function selectorChartZoomMap(zoom) {
34
34
  return zoom?.zoomData && createZoomMap(zoom?.zoomData);
35
35
  });
36
- export const selectorChartAxisZoomData = createSelector([selectorChartZoomMap], (zoomMap, axisId) => zoomMap?.get(axisId));
36
+ export const selectorChartAxisZoomData = createSelector(selectorChartZoomMap, (zoomMap, axisId) => zoomMap?.get(axisId));
37
37
  export const selectorChartZoomOptionsLookup = createSelectorMemoized(selectorChartRawXAxis, selectorChartRawYAxis, function selectorChartZoomOptionsLookup(xAxis, yAxis) {
38
38
  return _extends({}, createZoomLookup('x')(xAxis), createZoomLookup('y')(yAxis));
39
39
  });
40
- export const selectorChartAxisZoomOptionsLookup = createSelector([selectorChartZoomOptionsLookup], (axisLookup, axisId) => axisLookup[axisId]);
41
- export const selectorDefaultXAxisTickNumber = createSelector([selectorChartDrawingArea], function selectorDefaultXAxisTickNumber(drawingArea) {
40
+ export const selectorChartAxisZoomOptionsLookup = createSelector(selectorChartZoomOptionsLookup, (axisLookup, axisId) => axisLookup[axisId]);
41
+ export const selectorDefaultXAxisTickNumber = createSelector(selectorChartDrawingArea, function selectorDefaultXAxisTickNumber(drawingArea) {
42
42
  return getDefaultTickNumber(drawingArea.width);
43
43
  });
44
- export const selectorDefaultYAxisTickNumber = createSelector([selectorChartDrawingArea], function selectorDefaultYAxisTickNumber(drawingArea) {
44
+ export const selectorDefaultYAxisTickNumber = createSelector(selectorChartDrawingArea, function selectorDefaultYAxisTickNumber(drawingArea) {
45
45
  return getDefaultTickNumber(drawingArea.height);
46
46
  });
47
47
  export const selectorChartXAxisWithDomains = createSelectorMemoized(selectorChartRawXAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorPreferStrictDomainInLineCharts, selectorDefaultXAxisTickNumber, function selectorChartXAxisWithDomains(axes, formattedSeries, seriesConfig, preferStrictDomainInLineCharts, defaultTickNumber) {
@@ -255,16 +255,16 @@ export const selectorChartYAxis = createSelectorMemoized(selectorChartDrawingAre
255
255
  domains
256
256
  });
257
257
  });
258
- export const selectorChartAxis = createSelector([selectorChartXAxis, selectorChartYAxis], (xAxes, yAxes, axisId) => xAxes?.axis[axisId] ?? yAxes?.axis[axisId]);
259
- export const selectorChartRawAxis = createSelector([selectorChartRawXAxis, selectorChartRawYAxis], (xAxes, yAxes, axisId) => {
258
+ export const selectorChartAxis = createSelector(selectorChartXAxis, selectorChartYAxis, (xAxes, yAxes, axisId) => xAxes?.axis[axisId] ?? yAxes?.axis[axisId]);
259
+ export const selectorChartRawAxis = createSelector(selectorChartRawXAxis, selectorChartRawYAxis, (xAxes, yAxes, axisId) => {
260
260
  const axis = xAxes?.find(a => a.id === axisId) ?? yAxes?.find(a => a.id === axisId) ?? null;
261
261
  if (!axis) {
262
262
  return undefined;
263
263
  }
264
264
  return axis;
265
265
  });
266
- export const selectorChartDefaultXAxisId = createSelector([selectorChartRawXAxis], xAxes => xAxes[0].id);
267
- export const selectorChartDefaultYAxisId = createSelector([selectorChartRawYAxis], yAxes => yAxes[0].id);
266
+ export const selectorChartDefaultXAxisId = createSelector(selectorChartRawXAxis, xAxes => xAxes[0].id);
267
+ export const selectorChartDefaultYAxisId = createSelector(selectorChartRawYAxis, yAxes => yAxes[0].id);
268
268
  const EMPTY_MAP = new Map();
269
269
  export const selectorChartSeriesEmptyFlatbushMap = () => EMPTY_MAP;
270
270
  export const selectorChartSeriesFlatbushMap = createSelectorMemoized(selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId, function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId) {
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createSelectorMemoized } from '@mui/x-internals/store';
3
- import { createSelector } from "../../utils/selectors.js";
2
+ import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
4
3
  import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxisRendering.selectors.js";
5
4
  import { selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue } from "./useChartCartesianInteraction.selectors.js";
6
5
  import { selectorChartsKeyboardXAxisIndex, selectorChartsKeyboardYAxisIndex } from "../useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js";
@@ -59,8 +58,8 @@ const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, contro
59
58
  }
60
59
  return [];
61
60
  };
62
- export const selectorChartsHighlightXAxisValue = createSelector([selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardXAxisIndex, selectorChartsLastInteraction, selectorBrushShouldPreventAxisHighlight], selectAxisHighlightWithValue);
63
- export const selectorChartsHighlightYAxisValue = createSelector([selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue, selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardYAxisIndex, selectorChartsLastInteraction, selectorBrushShouldPreventAxisHighlight], selectAxisHighlightWithValue);
61
+ export const selectorChartsHighlightXAxisValue = createSelector(selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardXAxisIndex, selectorChartsLastInteraction, selectorBrushShouldPreventAxisHighlight, selectAxisHighlightWithValue);
62
+ export const selectorChartsHighlightYAxisValue = createSelector(selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue, selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardYAxisIndex, selectorChartsLastInteraction, selectorBrushShouldPreventAxisHighlight, selectAxisHighlightWithValue);
64
63
 
65
64
  /**
66
65
  * Get the scale of the axis with highlight if controlled. The default axis otherwise.
@@ -75,5 +74,5 @@ const selectAxis = (axisItems, axis) => {
75
74
  const filteredAxes = axisItems.map(item => axis.axis[item.axisId] ?? null).filter(item => item !== null);
76
75
  return filteredAxes;
77
76
  };
78
- export const selectorChartsHighlightXAxis = createSelector([selectorChartControlledCartesianAxisHighlight, selectorChartXAxis], selectAxis);
79
- export const selectorChartsHighlightYAxis = createSelector([selectorChartControlledCartesianAxisHighlight, selectorChartYAxis], selectAxis);
77
+ export const selectorChartsHighlightXAxis = createSelector(selectorChartControlledCartesianAxisHighlight, selectorChartXAxis, selectAxis);
78
+ export const selectorChartsHighlightYAxis = createSelector(selectorChartControlledCartesianAxisHighlight, selectorChartYAxis, selectAxis);
@@ -1,6 +1,5 @@
1
1
  import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
2
- import { createSelectorMemoizedWithOptions } from '@mui/x-internals/store';
3
- import { createSelector } from "../../utils/selectors.js";
2
+ import { createSelector, createSelectorMemoizedWithOptions } from '@mui/x-internals/store';
4
3
  import { selectorChartsInteractionPointerX, selectorChartsInteractionPointerY } from "../useChartInteraction/useChartInteraction.selectors.js";
5
4
  import { getAxisIndex, getAxisValue } from "./getAxisValue.js";
6
5
  import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxisRendering.selectors.js";
@@ -19,9 +18,9 @@ export const selectChartsInteractionAxisIndex = (value, axes, id) => {
19
18
  const index = indexGetter(value, axes, id);
20
19
  return index === -1 ? null : index;
21
20
  };
22
- export const selectorChartsInteractionXAxisIndex = createSelector([selectorChartsInteractionPointerX, selectorChartXAxis], selectChartsInteractionAxisIndex);
23
- export const selectorChartsInteractionYAxisIndex = createSelector([selectorChartsInteractionPointerY, selectorChartYAxis], selectChartsInteractionAxisIndex);
24
- export const selectorChartAxisInteraction = createSelector([selectorChartsInteractionPointerX, selectorChartsInteractionPointerY, selectorChartXAxis, selectorChartYAxis], (x, y, xAxis, yAxis) => [...(x === null ? [] : xAxis.axisIds.map(axisId => ({
21
+ export const selectorChartsInteractionXAxisIndex = createSelector(selectorChartsInteractionPointerX, selectorChartXAxis, selectChartsInteractionAxisIndex);
22
+ export const selectorChartsInteractionYAxisIndex = createSelector(selectorChartsInteractionPointerY, selectorChartYAxis, selectChartsInteractionAxisIndex);
23
+ export const selectorChartAxisInteraction = createSelector(selectorChartsInteractionPointerX, selectorChartsInteractionPointerY, selectorChartXAxis, selectorChartYAxis, (x, y, xAxis, yAxis) => [...(x === null ? [] : xAxis.axisIds.map(axisId => ({
25
24
  axisId,
26
25
  dataIndex: indexGetter(x, xAxis, axisId)
27
26
  }))), ...(y === null ? [] : yAxis.axisIds.map(axisId => ({
@@ -39,13 +38,13 @@ function valueGetter(value, axes, indexes, ids = axes.axisIds[0]) {
39
38
  return getAxisValue(axis.scale, axis.data, value, indexes[axisIndex]);
40
39
  }) : getAxisValue(axes.axis[ids].scale, axes.axis[ids].data, value, indexes);
41
40
  }
42
- export const selectorChartsInteractionXAxisValue = createSelector([selectorChartsInteractionPointerX, selectorChartXAxis, selectorChartsInteractionXAxisIndex], (x, xAxes, xIndex, id) => {
41
+ export const selectorChartsInteractionXAxisValue = createSelector(selectorChartsInteractionPointerX, selectorChartXAxis, selectorChartsInteractionXAxisIndex, (x, xAxes, xIndex, id) => {
43
42
  if (x === null || xAxes.axisIds.length === 0) {
44
43
  return null;
45
44
  }
46
45
  return valueGetter(x, xAxes, xIndex, id);
47
46
  });
48
- export const selectorChartsInteractionYAxisValue = createSelector([selectorChartsInteractionPointerY, selectorChartYAxis, selectorChartsInteractionYAxisIndex], (y, yAxes, yIndex, id) => {
47
+ export const selectorChartsInteractionYAxisValue = createSelector(selectorChartsInteractionPointerY, selectorChartYAxis, selectorChartsInteractionYAxisIndex, (y, yAxes, yIndex, id) => {
49
48
  if (y === null || yAxes.axisIds.length === 0) {
50
49
  return null;
51
50
  }
@@ -100,4 +99,4 @@ export const selectorChartsInteractionTooltipYAxes = createSelectorMemoizedWithO
100
99
  /**
101
100
  * Return `true` if the axis tooltip has something to display.
102
101
  */
103
- export const selectorChartsInteractionAxisTooltip = createSelector([selectorChartsInteractionTooltipXAxes, selectorChartsInteractionTooltipYAxes], (xTooltip, yTooltip) => xTooltip.length > 0 || yTooltip.length > 0);
102
+ export const selectorChartsInteractionAxisTooltip = createSelector(selectorChartsInteractionTooltipXAxes, selectorChartsInteractionTooltipYAxes, (xTooltip, yTooltip) => xTooltip.length > 0 || yTooltip.length > 0);
@@ -20,8 +20,8 @@ export function findClosestPoints(flatbush, drawingArea, seriesData, xScale, ySc
20
20
  function sqDistFn(dx, dy) {
21
21
  return fxSq * dx * dx + fySq * dy * dy;
22
22
  }
23
- const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex].x));
24
- const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex].y));
23
+ const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex]?.x));
24
+ const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex]?.y));
25
25
  return flatbush.neighbors(pointX, pointY, maxResults, maxRadius != null ? maxRadius * maxRadius : Infinity, excludeIfOutsideDrawingArea, sqDistFn);
26
26
  }
27
27
  function invertScale(scale, value, getDataPoint) {
@@ -1,3 +1,3 @@
1
- import { createSelector } from "../../utils/selectors.js";
1
+ import { createSelector } from '@mui/x-internals/store';
2
2
  const selectVoronoi = state => state.voronoi;
3
- export const selectorChartsIsVoronoiEnabled = createSelector([selectVoronoi], voronoi => voronoi?.isVoronoiEnabled);
3
+ export const selectorChartsIsVoronoiEnabled = createSelector(selectVoronoi, voronoi => voronoi?.isVoronoiEnabled);
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { warnOnce } from '@mui/x-internals/warning';
2
3
  import { useAssertModelConsistency } from '@mui/x-internals/useAssertModelConsistency';
3
4
  import useEventCallback from '@mui/utils/useEventCallback';
4
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
@@ -20,27 +21,34 @@ export const useChartHighlight = ({
20
21
  item: params.highlightedItem
21
22
  }));
22
23
  }
24
+ if (process.env.NODE_ENV !== 'production') {
25
+ if (params.highlightedItem !== undefined && !store.state.highlight.isControlled) {
26
+ warnOnce(['MUI X Charts: The `highlightedItem` switched between controlled and uncontrolled state.', 'To remove the highlight when using controlled state, you must provide `null` to the `highlightedItem` prop instead of `undefined`.'].join('\n'));
27
+ }
28
+ }
23
29
  }, [store, params.highlightedItem]);
24
30
  const clearHighlight = useEventCallback(() => {
25
31
  params.onHighlightChange?.(null);
26
- const prevItem = store.getSnapshot().highlight.item;
27
- if (prevItem === null) {
32
+ const prevHighlight = store.getSnapshot().highlight;
33
+ if (prevHighlight.item === null || prevHighlight.isControlled) {
28
34
  return;
29
35
  }
30
36
  store.set('highlight', {
31
37
  item: null,
32
- lastUpdate: 'pointer'
38
+ lastUpdate: 'pointer',
39
+ isControlled: false
33
40
  });
34
41
  });
35
42
  const setHighlight = useEventCallback(newItem => {
36
- const prevItem = store.getSnapshot().highlight.item;
37
- if (fastObjectShallowCompare(prevItem, newItem)) {
43
+ const prevHighlight = store.getSnapshot().highlight;
44
+ if (prevHighlight.isControlled || fastObjectShallowCompare(prevHighlight.item, newItem)) {
38
45
  return;
39
46
  }
40
47
  params.onHighlightChange?.(newItem);
41
48
  store.set('highlight', {
42
49
  item: newItem,
43
- lastUpdate: 'pointer'
50
+ lastUpdate: 'pointer',
51
+ isControlled: false
44
52
  });
45
53
  });
46
54
  return {
@@ -50,15 +58,11 @@ export const useChartHighlight = ({
50
58
  }
51
59
  };
52
60
  };
53
- useChartHighlight.getDefaultizedParams = ({
54
- params
55
- }) => _extends({}, params, {
56
- highlightedItem: params.highlightedItem ?? null
57
- });
58
61
  useChartHighlight.getInitialState = params => ({
59
62
  highlight: {
60
63
  item: params.highlightedItem,
61
- lastUpdate: 'pointer'
64
+ lastUpdate: 'pointer',
65
+ isControlled: params.highlightedItem !== undefined
62
66
  }
63
67
  });
64
68
  useChartHighlight.params = {
@@ -1,15 +1,14 @@
1
- import { createSelectorMemoized } from '@mui/x-internals/store';
2
- import { createSelector } from "../../utils/selectors.js";
1
+ import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
3
2
  import { createIsHighlighted } from "./createIsHighlighted.js";
4
3
  import { createIsFaded } from "./createIsFaded.js";
5
4
  import { getSeriesHighlightedItem, getSeriesUnfadedItem, isSeriesFaded, isSeriesHighlighted } from "./highlightStates.js";
6
5
  import { selectorChartsKeyboardItem } from "../useChartKeyboardNavigation/index.js";
6
+ import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
7
7
  const selectHighlight = state => state.highlight;
8
- const selectSeries = state => state.series;
9
- export const selectorChartsHighlightScopePerSeriesId = createSelector([selectSeries], series => {
8
+ export const selectorChartsHighlightScopePerSeriesId = createSelector(selectorChartSeriesProcessed, processedSeries => {
10
9
  const map = new Map();
11
- Object.keys(series.processedSeries).forEach(seriesType => {
12
- const seriesData = series.processedSeries[seriesType];
10
+ Object.keys(processedSeries).forEach(seriesType => {
11
+ const seriesData = processedSeries[seriesType];
13
12
  seriesData?.seriesOrder?.forEach(seriesId => {
14
13
  const seriesItem = seriesData?.series[seriesId];
15
14
  map.set(seriesId, seriesItem?.highlightScope);
@@ -18,9 +17,9 @@ export const selectorChartsHighlightScopePerSeriesId = createSelector([selectSer
18
17
  return map;
19
18
  });
20
19
  export const selectorChartsHighlightedItem = createSelectorMemoized(selectHighlight, selectorChartsKeyboardItem, function selectorChartsHighlightedItem(highlight, keyboardItem) {
21
- return highlight.lastUpdate === 'pointer' ? highlight.item : keyboardItem;
20
+ return highlight.isControlled || highlight.lastUpdate === 'pointer' ? highlight.item : keyboardItem;
22
21
  });
23
- export const selectorChartsHighlightScope = createSelector([selectorChartsHighlightScopePerSeriesId, selectorChartsHighlightedItem], function selectorChartsHighlightScope(seriesIdToHighlightScope, highlightedItem) {
22
+ export const selectorChartsHighlightScope = createSelector(selectorChartsHighlightScopePerSeriesId, selectorChartsHighlightedItem, function selectorChartsHighlightScope(seriesIdToHighlightScope, highlightedItem) {
24
23
  if (!highlightedItem) {
25
24
  return null;
26
25
  }
@@ -30,15 +29,15 @@ export const selectorChartsHighlightScope = createSelector([selectorChartsHighli
30
29
  }
31
30
  return highlightScope;
32
31
  });
33
- export const selectorChartsIsHighlightedCallback = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], createIsHighlighted);
34
- export const selectorChartsIsFadedCallback = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], createIsFaded);
35
- export const selectorChartsIsHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
32
+ export const selectorChartsIsHighlightedCallback = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, createIsHighlighted);
33
+ export const selectorChartsIsFadedCallback = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, createIsFaded);
34
+ export const selectorChartsIsHighlighted = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
36
35
  return createIsHighlighted(highlightScope, highlightedItem)(item);
37
36
  });
38
- export const selectorChartIsSeriesHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], isSeriesHighlighted);
39
- export const selectorChartIsSeriesFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], isSeriesFaded);
40
- export const selectorChartSeriesUnfadedItem = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], getSeriesUnfadedItem);
41
- export const selectorChartSeriesHighlightedItem = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], getSeriesHighlightedItem);
42
- export const selectorChartsIsFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
37
+ export const selectorChartIsSeriesHighlighted = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, isSeriesHighlighted);
38
+ export const selectorChartIsSeriesFaded = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, isSeriesFaded);
39
+ export const selectorChartSeriesUnfadedItem = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, getSeriesUnfadedItem);
40
+ export const selectorChartSeriesHighlightedItem = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, getSeriesHighlightedItem);
41
+ export const selectorChartsIsFaded = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
43
42
  return createIsFaded(highlightScope, highlightedItem)(item);
44
43
  });
@@ -56,6 +56,10 @@ export interface UseChartHighlightParameters {
56
56
  export type UseChartHighlightDefaultizedParameters = DefaultizedProps<UseChartHighlightParameters, 'highlightedItem'>;
57
57
  export interface UseChartHighlightState {
58
58
  highlight: {
59
+ /**
60
+ * Indicates if the highlighted item is controlled.
61
+ */
62
+ isControlled: boolean;
59
63
  /**
60
64
  * The item currently highlighted.
61
65
  */
@@ -1,9 +1,9 @@
1
- import { createSelector } from "../../utils/selectors.js";
1
+ import { createSelector } from '@mui/x-internals/store';
2
2
  const selectInteraction = state => state.interaction;
3
- export const selectorChartsInteractionIsInitialized = createSelector([selectInteraction], interaction => interaction !== undefined);
4
- export const selectorChartsInteractionItem = createSelector([selectInteraction], interaction => interaction?.item ?? null);
5
- export const selectorChartsInteractionPointer = createSelector([selectInteraction], interaction => interaction?.pointer ?? null);
6
- export const selectorChartsInteractionPointerX = createSelector([selectorChartsInteractionPointer], pointer => pointer && pointer.x);
7
- export const selectorChartsInteractionPointerY = createSelector([selectorChartsInteractionPointer], pointer => pointer && pointer.y);
8
- export const selectorChartsInteractionItemIsDefined = createSelector([selectorChartsInteractionItem], item => item !== null);
9
- export const selectorChartsLastInteraction = createSelector([selectInteraction], interaction => interaction?.lastUpdate);
3
+ export const selectorChartsInteractionIsInitialized = createSelector(selectInteraction, interaction => interaction !== undefined);
4
+ export const selectorChartsInteractionItem = createSelector(selectInteraction, interaction => interaction?.item ?? null);
5
+ export const selectorChartsInteractionPointer = createSelector(selectInteraction, interaction => interaction?.pointer ?? null);
6
+ export const selectorChartsInteractionPointerX = createSelector(selectorChartsInteractionPointer, pointer => pointer && pointer.x);
7
+ export const selectorChartsInteractionPointerY = createSelector(selectorChartsInteractionPointer, pointer => pointer && pointer.y);
8
+ export const selectorChartsInteractionItemIsDefined = createSelector(selectorChartsInteractionItem, item => item !== null);
9
+ export const selectorChartsLastInteraction = createSelector(selectInteraction, interaction => interaction?.lastUpdate);
@@ -6,7 +6,7 @@ export declare const selectorChartsTooltipItemIsDefined: (args_0: import("../../
6
6
  }) => boolean;
7
7
  export declare const selectorChartsTooltipItemPosition: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartInteraction.types.js").UseChartInteractionState> & {
8
8
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
- }) => {
9
+ }, placement?: "bottom" | "left" | "right" | "top" | undefined) => {
10
10
  x: number;
11
11
  y: number;
12
12
  } | null;
@@ -1,13 +1,13 @@
1
+ import { createSelector } from '@mui/x-internals/store';
1
2
  import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
2
- import { createSelector } from "../../utils/selectors.js";
3
3
  import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
4
4
  import { selectorChartsKeyboardItem, selectorChartsKeyboardItemIsDefined } from "../useChartKeyboardNavigation/index.js";
5
5
  import { selectorChartsInteractionItem, selectorChartsInteractionItemIsDefined, selectorChartsLastInteraction } from "./useChartInteraction.selectors.js";
6
6
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
7
7
  import { isCartesianSeries } from "../../../isCartesian.js";
8
- export const selectorChartsTooltipItem = createSelector([selectorChartsLastInteraction, selectorChartsInteractionItem, selectorChartsKeyboardItem], (lastInteraction, interactionItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : interactionItem ?? null);
9
- export const selectorChartsTooltipItemIsDefined = createSelector([selectorChartsLastInteraction, selectorChartsInteractionItemIsDefined, selectorChartsKeyboardItemIsDefined], (lastInteraction, interactionItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : interactionItemIsDefined);
10
- export const selectorChartsTooltipItemPosition = createSelector([selectorChartsTooltipItem, selectorChartDrawingArea, selectorChartSeriesConfig, selectorChartXAxis, selectorChartYAxis, selectorChartSeriesProcessed, (_, placement) => placement], function selectorChartsTooltipItemPosition(identifier, drawingArea, seriesConfig, {
8
+ export const selectorChartsTooltipItem = createSelector(selectorChartsLastInteraction, selectorChartsInteractionItem, selectorChartsKeyboardItem, (lastInteraction, interactionItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : interactionItem ?? null);
9
+ export const selectorChartsTooltipItemIsDefined = createSelector(selectorChartsLastInteraction, selectorChartsInteractionItemIsDefined, selectorChartsKeyboardItemIsDefined, (lastInteraction, interactionItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : interactionItemIsDefined);
10
+ export const selectorChartsTooltipItemPosition = createSelector(selectorChartsTooltipItem, selectorChartDrawingArea, selectorChartSeriesConfig, selectorChartXAxis, selectorChartYAxis, selectorChartSeriesProcessed, function selectorChartsTooltipItemPosition(identifier, drawingArea, seriesConfig, {
11
11
  axis: xAxis,
12
12
  axisIds: xAxisIds
13
13
  }, {