@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
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.selectorChartsInteractionTooltipRotationAxes = exports.selectorChartsInteractionTooltipRadiusAxes = exports.selectorChartsInteractionRotationAxisValues = exports.selectorChartsInteractionRotationAxisValue = exports.selectorChartsInteractionRotationAxisIndexes = exports.selectorChartsInteractionRotationAxisIndex = exports.selectorChartsInteractionPolarAxisTooltip = void 0;
7
7
  var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
8
8
  var _store = require("@mui/x-internals/store");
9
- var _selectors = require("../../utils/selectors");
10
9
  var _useChartInteraction = require("../useChartInteraction/useChartInteraction.selectors");
11
10
  var _coordinateTransformation = require("./coordinateTransformation");
12
11
  var _getAxisIndex = require("./getAxisIndex");
@@ -25,15 +24,15 @@ function indexGetter(value, axes, ids) {
25
24
  /**
26
25
  * Helper to get the rotation associated to the interaction coordinate.
27
26
  */
28
- const selectorChartsInteractionRotationAngle = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartInteraction.selectorChartsInteractionPointerY, _useChartPolarAxis.selectorChartPolarCenter], (x, y, center) => {
27
+ const selectorChartsInteractionRotationAngle = (0, _store.createSelector)(_useChartInteraction.selectorChartsInteractionPointerX, _useChartInteraction.selectorChartsInteractionPointerY, _useChartPolarAxis.selectorChartPolarCenter, (x, y, center) => {
29
28
  if (x === null || y === null) {
30
29
  return null;
31
30
  }
32
31
  return (0, _coordinateTransformation.generateSvg2rotation)(center)(x, y);
33
32
  });
34
- const selectorChartsInteractionRotationAxisIndex = exports.selectorChartsInteractionRotationAxisIndex = (0, _selectors.createSelector)([selectorChartsInteractionRotationAngle, _useChartPolarAxis.selectorChartRotationAxis, optionalGetAxisId], (rotation, rotationAxis, id = rotationAxis.axisIds[0]) => rotation === null ? null : indexGetter(rotation, rotationAxis, id));
35
- const selectorChartsInteractionRotationAxisIndexes = exports.selectorChartsInteractionRotationAxisIndexes = (0, _selectors.createSelector)([selectorChartsInteractionRotationAngle, _useChartPolarAxis.selectorChartRotationAxis, optionalGetAxisIds], (rotation, rotationAxis, ids = rotationAxis.axisIds) => rotation === null ? null : indexGetter(rotation, rotationAxis, ids));
36
- const selectorChartsInteractionRotationAxisValue = exports.selectorChartsInteractionRotationAxisValue = (0, _selectors.createSelector)([_useChartPolarAxis.selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndex, optionalGetAxisId], (rotationAxis, rotationIndex, id = rotationAxis.axisIds[0]) => {
33
+ const selectorChartsInteractionRotationAxisIndex = exports.selectorChartsInteractionRotationAxisIndex = (0, _store.createSelector)(selectorChartsInteractionRotationAngle, _useChartPolarAxis.selectorChartRotationAxis, optionalGetAxisId, (rotation, rotationAxis, id = rotationAxis.axisIds[0]) => rotation === null ? null : indexGetter(rotation, rotationAxis, id));
34
+ const selectorChartsInteractionRotationAxisIndexes = exports.selectorChartsInteractionRotationAxisIndexes = (0, _store.createSelector)(selectorChartsInteractionRotationAngle, _useChartPolarAxis.selectorChartRotationAxis, optionalGetAxisIds, (rotation, rotationAxis, ids = rotationAxis.axisIds) => rotation === null ? null : indexGetter(rotation, rotationAxis, ids));
35
+ const selectorChartsInteractionRotationAxisValue = exports.selectorChartsInteractionRotationAxisValue = (0, _store.createSelector)(_useChartPolarAxis.selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndex, optionalGetAxisId, (rotationAxis, rotationIndex, id = rotationAxis.axisIds[0]) => {
37
36
  if (rotationIndex === null || rotationIndex === -1 || rotationAxis.axisIds.length === 0) {
38
37
  return null;
39
38
  }
@@ -43,7 +42,7 @@ const selectorChartsInteractionRotationAxisValue = exports.selectorChartsInterac
43
42
  }
44
43
  return data[rotationIndex];
45
44
  });
46
- const selectorChartsInteractionRotationAxisValues = exports.selectorChartsInteractionRotationAxisValues = (0, _selectors.createSelector)([_useChartPolarAxis.selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndexes, optionalGetAxisIds], (rotationAxis, rotationIndexes, ids = rotationAxis.axisIds) => {
45
+ const selectorChartsInteractionRotationAxisValues = exports.selectorChartsInteractionRotationAxisValues = (0, _store.createSelector)(_useChartPolarAxis.selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndexes, optionalGetAxisIds, (rotationAxis, rotationIndexes, ids = rotationAxis.axisIds) => {
47
46
  if (rotationIndexes === null) {
48
47
  return null;
49
48
  }
@@ -91,4 +90,4 @@ const selectorChartsInteractionTooltipRadiusAxes = () => {
91
90
  * Return `true` if the axis tooltip has something to display.
92
91
  */
93
92
  exports.selectorChartsInteractionTooltipRadiusAxes = selectorChartsInteractionTooltipRadiusAxes;
94
- const selectorChartsInteractionPolarAxisTooltip = exports.selectorChartsInteractionPolarAxisTooltip = (0, _selectors.createSelector)([selectorChartsInteractionTooltipRotationAxes], rotationTooltip => rotationTooltip.length > 0);
93
+ const selectorChartsInteractionPolarAxisTooltip = exports.selectorChartsInteractionPolarAxisTooltip = (0, _store.createSelector)(selectorChartsInteractionTooltipRotationAxes, rotationTooltip => rotationTooltip.length > 0);
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.selectorChartZAxis = void 0;
7
- var _selectors = require("../../utils/selectors");
7
+ var _store = require("@mui/x-internals/store");
8
8
  const selectRootState = state => state;
9
- const selectorChartZAxis = exports.selectorChartZAxis = (0, _selectors.createSelector)([selectRootState], state => state.zAxis);
9
+ const selectorChartZAxis = exports.selectorChartZAxis = (0, _store.createSelector)(selectRootState, state => state.zAxis);
@@ -2,17 +2,4 @@ import type { Selector } from 'reselect';
2
2
  import { ChartAnyPluginSignature } from "../models/plugin.js";
3
3
  import { ChartState } from "../models/chart.js";
4
4
  export type ChartRootSelector<TSignature extends ChartAnyPluginSignature, T extends keyof TSignature['state'] = keyof TSignature['state']> = Selector<ChartState<[TSignature]>, TSignature['state'][T]>;
5
- export type ChartOptionalRootSelector<TSignature extends ChartAnyPluginSignature> = Selector<ChartState<[], [TSignature]>, TSignature['state'][keyof TSignature['state']] | undefined>;
6
- type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends [f: infer F, ...other: infer R] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
7
- type StateFromSelector<T> = T extends ((first: infer F, ...args: any[]) => any) ? F : never;
8
- type Fn = (...args: any[]) => any;
9
- type ReturnTypes<FunctionsArray extends readonly Fn[]> = { [Index in keyof FunctionsArray]: FunctionsArray[Index] extends FunctionsArray[number] ? ReturnType<FunctionsArray[Index]> : never };
10
- type MergeParams<STypes extends readonly unknown[], CTypes extends readonly unknown[]> = STypes['length'] extends 0 ? CTypes : MergeParams<DropFirst<STypes>, DropFirst<CTypes>>;
11
- type DropFirst<T> = T extends [any, ...infer Xs] ? Xs : [];
12
- type SelectorArgs<Args extends any[], Selectors extends ReadonlyArray<Selector<any>>, Combiner extends (...args: readonly [...ReturnTypes<Selectors>, ...Args]) => any> = Selectors['length'] extends 0 ? MergeParams<ReturnTypes<Selectors>, Parameters<Combiner>> : [StateFromSelectorList<Selectors>, ...MergeParams<ReturnTypes<Selectors>, Parameters<Combiner>>];
13
- type ChartSelector<Args extends any[], Selectors extends ReadonlyArray<Selector<any>>, Combiner extends (...args: readonly [...ReturnTypes<Selectors>, ...Args]) => any> = (...args: SelectorArgs<Args, Selectors, Combiner>) => ReturnType<Combiner>;
14
- /**
15
- * Method wrapping reselect's createChartSelector to provide caching for chart instances.
16
- */
17
- export declare const createSelector: <const Args extends any[], const Selectors extends ReadonlyArray<Selector<any>>, const Combiner extends (...args: readonly [...ReturnTypes<Selectors>, ...Args]) => any>(inputSelectors: [...Selectors], combiner: Combiner) => ChartSelector<Args, Selectors, Combiner>;
18
- export {};
5
+ export type ChartOptionalRootSelector<TSignature extends ChartAnyPluginSignature> = Selector<ChartState<[], [TSignature]>, TSignature['state'][keyof TSignature['state']] | undefined>;
@@ -2,11 +2,4 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
6
- exports.createSelector = void 0;
7
- var _store = require("@mui/x-internals/store");
8
- /**
9
- * Method wrapping reselect's createChartSelector to provide caching for chart instances.
10
- */
11
- const createSelector = (inputSelectors, combiner) => (0, _store.createSelector)(...inputSelectors, combiner);
12
- exports.createSelector = createSelector;
5
+ });
@@ -0,0 +1,20 @@
1
+ import { ChartSeriesDefaultized, ChartsSeriesConfig } from "../models/seriesType/config.js";
2
+ import { SeriesId } from "../models/seriesType/common.js";
3
+ import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index.js";
4
+ export declare const selectorAllSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
5
+ cacheKey: import("./index.js").ChartStateCacheKey;
6
+ }, seriesType: keyof ChartsSeriesConfig) => import("./index.js").SeriesProcessorResult<"line"> | import("./index.js").SeriesProcessorResult<"bar"> | {
7
+ series: Record<SeriesId, import("../index.js").DefaultizedScatterSeriesType>;
8
+ seriesOrder: SeriesId[];
9
+ } | {
10
+ series: Record<SeriesId, import("../index.js").DefaultizedPieSeriesType>;
11
+ seriesOrder: SeriesId[];
12
+ } | {
13
+ series: Record<SeriesId, import("../index.js").DefaultizedRadarSeriesType>;
14
+ seriesOrder: SeriesId[];
15
+ } | undefined;
16
+ export declare const selectorSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
17
+ cacheKey: import("./index.js").ChartStateCacheKey;
18
+ }, seriesType: keyof ChartsSeriesConfig, ids?: SeriesId | SeriesId[] | undefined) => import("../index.js").DefaultizedRadarSeriesType | import("../index.js").DefaultizedLineSeriesType | import("../index.js").DefaultizedBarSeriesType | import("../index.js").DefaultizedScatterSeriesType | import("../index.js").DefaultizedPieSeriesType | (import("../index.js").DefaultizedRadarSeriesType | import("../index.js").DefaultizedLineSeriesType | import("../index.js").DefaultizedBarSeriesType | import("../index.js").DefaultizedScatterSeriesType | import("../index.js").DefaultizedPieSeriesType | undefined)[] | undefined;
19
+ export declare const useAllSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T) => ProcessedSeries[T];
20
+ export declare const useSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T, seriesId?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | ChartSeriesDefaultized<T>[] | undefined;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSeriesOfType = exports.useAllSeriesOfType = exports.selectorSeriesOfType = exports.selectorAllSeriesOfType = void 0;
7
+ var _warning = require("@mui/x-internals/warning");
8
+ var _store = require("@mui/x-internals/store");
9
+ var _useChartSeries = require("./plugins/corePlugins/useChartSeries/useChartSeries.selectors");
10
+ var _useStore = require("./store/useStore");
11
+ var _useSelector = require("./store/useSelector");
12
+ const selectorAllSeriesOfType = exports.selectorAllSeriesOfType = (0, _store.createSelector)(_useChartSeries.selectorChartSeriesProcessed, (processedSeries, seriesType) => processedSeries[seriesType]);
13
+ const selectorSeriesOfType = exports.selectorSeriesOfType = (0, _store.createSelectorMemoized)(_useChartSeries.selectorChartSeriesProcessed, (processedSeries, seriesType, ids) => {
14
+ if (!ids || Array.isArray(ids) && ids.length === 0) {
15
+ return processedSeries[seriesType]?.seriesOrder?.map(seriesId => processedSeries[seriesType]?.series[seriesId]) ?? [];
16
+ }
17
+ if (!Array.isArray(ids)) {
18
+ return processedSeries[seriesType]?.series?.[ids];
19
+ }
20
+ const result = [];
21
+ const failedIds = [];
22
+ for (const id of ids) {
23
+ const series = processedSeries[seriesType]?.series?.[id];
24
+ if (series) {
25
+ result.push(series);
26
+ } else {
27
+ failedIds.push(id);
28
+ }
29
+ }
30
+ if (process.env.NODE_ENV !== 'production' && failedIds.length > 0) {
31
+ const formattedIds = failedIds.map(v => JSON.stringify(v)).join(', ');
32
+ const fnName = `use${seriesType.charAt(0).toUpperCase()}${seriesType.slice(1)}Series`;
33
+ (0, _warning.warnOnce)([`MUI X Charts: The following ids provided to "${fnName}" could not be found: ${formattedIds}.`, `Make sure that they exist and their series are using the "${seriesType}" series type.`]);
34
+ }
35
+ return result;
36
+ });
37
+ const useAllSeriesOfType = seriesType => {
38
+ const store = (0, _useStore.useStore)();
39
+ return (0, _useSelector.useSelector)(store, selectorAllSeriesOfType, seriesType);
40
+ };
41
+ exports.useAllSeriesOfType = useAllSeriesOfType;
42
+ const useSeriesOfType = (seriesType, seriesId) => {
43
+ const store = (0, _useStore.useStore)();
44
+ return (0, _useSelector.useSelector)(store, selectorSeriesOfType, seriesType, seriesId);
45
+ };
46
+ exports.useSeriesOfType = useSeriesOfType;
@@ -83,6 +83,6 @@ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConf
83
83
  export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
84
84
  export type ChartItemIdentifierWithData<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifierWithData'];
85
85
  export type DatasetElementType<T> = {
86
- [key: string]: Readonly<T>;
86
+ [key: string]: T;
87
87
  };
88
- export type DatasetType<T = number | string | Date | null | undefined> = DatasetElementType<T>[];
88
+ export type DatasetType<T = unknown> = DatasetElementType<T>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.18.0",
3
+ "version": "8.20.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of MUI X Charts components.",
6
6
  "license": "MIT",
@@ -35,9 +35,9 @@
35
35
  "prop-types": "^15.8.1",
36
36
  "reselect": "^5.1.1",
37
37
  "use-sync-external-store": "^1.6.0",
38
- "@mui/x-internals": "8.18.0",
39
- "@mui/x-internal-gestures": "0.3.5",
40
- "@mui/x-charts-vendor": "8.18.0"
38
+ "@mui/x-internals": "8.19.0",
39
+ "@mui/x-internal-gestures": "0.3.6",
40
+ "@mui/x-charts-vendor": "8.19.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@emotion/react": "^11.9.0",
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Exported utility functions for the x-charts library.
3
+ */
4
+ export * from "./niceDomain.js";
package/utils/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _niceDomain = require("./niceDomain");
7
+ Object.keys(_niceDomain).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _niceDomain[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _niceDomain[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,20 @@
1
+ import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
2
+ import { ContinuousScaleName } from "../models/index.js";
3
+ /**
4
+ * Returns a nice domain for the given scale type and domain.
5
+ * Does not modify the original domain.
6
+ *
7
+ * Providing a count improves the nice domain calculation by trying to align tick values to round
8
+ * numbers or dates.
9
+ *
10
+ * For example, if you have a domain of [29, 72] and there are 5 ticks, the nice domain will be
11
+ * [20, 80] so that the ticks can be at [20, 35, 50, 65, 80].
12
+ * However, if there are 11 ticks, the nice domain will be [25, 75] so that the ticks can be at
13
+ * [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75].
14
+ *
15
+ * @param scaleType The type of the scale (e.g., 'linear', 'log', 'time', etc.).
16
+ * @param domain The domain to be made nicer.
17
+ * @param count An optional number of ticks to improve the nice domain calculation. Defaults to 5.
18
+ */
19
+ export declare function niceDomain<Domain extends NumberValue>(scaleType: Exclude<ContinuousScaleName, 'time' | 'utc'>, domain: Iterable<Domain>, count?: number): Domain[];
20
+ export declare function niceDomain<Domain extends NumberValue>(scaleType: 'time' | 'utc', domain: Iterable<Domain>, count?: number): Date[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.niceDomain = niceDomain;
7
+ var _getScale = require("../internals/getScale");
8
+ /**
9
+ * Returns a nice domain for the given scale type and domain.
10
+ * Does not modify the original domain.
11
+ *
12
+ * Providing a count improves the nice domain calculation by trying to align tick values to round
13
+ * numbers or dates.
14
+ *
15
+ * For example, if you have a domain of [29, 72] and there are 5 ticks, the nice domain will be
16
+ * [20, 80] so that the ticks can be at [20, 35, 50, 65, 80].
17
+ * However, if there are 11 ticks, the nice domain will be [25, 75] so that the ticks can be at
18
+ * [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75].
19
+ *
20
+ * @param scaleType The type of the scale (e.g., 'linear', 'log', 'time', etc.).
21
+ * @param domain The domain to be made nicer.
22
+ * @param count An optional number of ticks to improve the nice domain calculation. Defaults to 5.
23
+ */
24
+
25
+ function niceDomain(scaleType, domain, count = 5) {
26
+ const scale = (0, _getScale.getScale)(scaleType, domain, [0, 1]);
27
+ scale.nice(count);
28
+ return scale.domain();
29
+ }
@@ -1,4 +0,0 @@
1
- import { ChartSeriesDefaultized, ChartsSeriesConfig } from "../models/seriesType/config.js";
2
- import { SeriesId } from "../models/seriesType/common.js";
3
- export declare function createSeriesSelectorsOfType<T extends keyof ChartsSeriesConfig>(seriesType: T): (ids?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | (ChartSeriesDefaultized<T> | undefined)[] | undefined;
4
- export declare function createAllSeriesSelectorOfType<T extends keyof ChartsSeriesConfig>(seriesType: T): () => import("./index.js").ProcessedSeries<keyof ChartsSeriesConfig>[T];
@@ -1,45 +0,0 @@
1
- // import { fastArrayCompare } from '@mui/x-internals/fastArrayCompare';
2
- import { warnOnce } from '@mui/x-internals/warning';
3
- import { createSelector } from "./plugins/utils/selectors.js";
4
- import { selectorChartSeriesProcessed } from "./plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
5
- import { useStore } from "./store/useStore.js";
6
- import { useSelector } from "./store/useSelector.js";
7
- export function createSeriesSelectorsOfType(seriesType) {
8
- const selectorSeriesWithIds = createSelector([selectorChartSeriesProcessed], (processedSeries, ids) => {
9
- if (!ids || Array.isArray(ids) && ids.length === 0) {
10
- return processedSeries[seriesType]?.seriesOrder?.map(seriesId => processedSeries[seriesType]?.series[seriesId]) ?? [];
11
- }
12
- if (!Array.isArray(ids)) {
13
- return processedSeries[seriesType]?.series?.[ids];
14
- }
15
- const result = [];
16
- const failedIds = [];
17
- for (const id of ids) {
18
- const series = processedSeries[seriesType]?.series?.[id];
19
- if (series) {
20
- result.push(series);
21
- } else {
22
- failedIds.push(id);
23
- }
24
- }
25
- if (process.env.NODE_ENV !== 'production' && failedIds.length > 0) {
26
- const formattedIds = failedIds.map(v => JSON.stringify(v)).join(', ');
27
- const fnName = `use${seriesType.charAt(0).toUpperCase()}${seriesType.slice(1)}Series`;
28
- warnOnce([`MUI X Charts: The following ids provided to "${fnName}" could not be found: ${formattedIds}.`, `Make sure that they exist and their series are using the "${seriesType}" series type.`]);
29
- }
30
- return result;
31
- });
32
- return ids => {
33
- const store = useStore();
34
- return useSelector(store, selectorSeriesWithIds, ids
35
- // fastArrayCompare
36
- );
37
- };
38
- }
39
- export function createAllSeriesSelectorOfType(seriesType) {
40
- const selectorSeries = createSelector([selectorChartSeriesProcessed], processedSeries => processedSeries[seriesType]);
41
- return () => {
42
- const store = useStore();
43
- return useSelector(store, selectorSeries);
44
- };
45
- }
@@ -1,4 +0,0 @@
1
- import { ChartSeriesDefaultized, ChartsSeriesConfig } from "../models/seriesType/config.js";
2
- import { SeriesId } from "../models/seriesType/common.js";
3
- export declare function createSeriesSelectorsOfType<T extends keyof ChartsSeriesConfig>(seriesType: T): (ids?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | (ChartSeriesDefaultized<T> | undefined)[] | undefined;
4
- export declare function createAllSeriesSelectorOfType<T extends keyof ChartsSeriesConfig>(seriesType: T): () => import("./index.js").ProcessedSeries<keyof ChartsSeriesConfig>[T];
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createAllSeriesSelectorOfType = createAllSeriesSelectorOfType;
7
- exports.createSeriesSelectorsOfType = createSeriesSelectorsOfType;
8
- var _warning = require("@mui/x-internals/warning");
9
- var _selectors = require("./plugins/utils/selectors");
10
- var _useChartSeries = require("./plugins/corePlugins/useChartSeries/useChartSeries.selectors");
11
- var _useStore = require("./store/useStore");
12
- var _useSelector = require("./store/useSelector");
13
- // import { fastArrayCompare } from '@mui/x-internals/fastArrayCompare';
14
-
15
- function createSeriesSelectorsOfType(seriesType) {
16
- const selectorSeriesWithIds = (0, _selectors.createSelector)([_useChartSeries.selectorChartSeriesProcessed], (processedSeries, ids) => {
17
- if (!ids || Array.isArray(ids) && ids.length === 0) {
18
- return processedSeries[seriesType]?.seriesOrder?.map(seriesId => processedSeries[seriesType]?.series[seriesId]) ?? [];
19
- }
20
- if (!Array.isArray(ids)) {
21
- return processedSeries[seriesType]?.series?.[ids];
22
- }
23
- const result = [];
24
- const failedIds = [];
25
- for (const id of ids) {
26
- const series = processedSeries[seriesType]?.series?.[id];
27
- if (series) {
28
- result.push(series);
29
- } else {
30
- failedIds.push(id);
31
- }
32
- }
33
- if (process.env.NODE_ENV !== 'production' && failedIds.length > 0) {
34
- const formattedIds = failedIds.map(v => JSON.stringify(v)).join(', ');
35
- const fnName = `use${seriesType.charAt(0).toUpperCase()}${seriesType.slice(1)}Series`;
36
- (0, _warning.warnOnce)([`MUI X Charts: The following ids provided to "${fnName}" could not be found: ${formattedIds}.`, `Make sure that they exist and their series are using the "${seriesType}" series type.`]);
37
- }
38
- return result;
39
- });
40
- return ids => {
41
- const store = (0, _useStore.useStore)();
42
- return (0, _useSelector.useSelector)(store, selectorSeriesWithIds, ids
43
- // fastArrayCompare
44
- );
45
- };
46
- }
47
- function createAllSeriesSelectorOfType(seriesType) {
48
- const selectorSeries = (0, _selectors.createSelector)([_useChartSeries.selectorChartSeriesProcessed], processedSeries => processedSeries[seriesType]);
49
- return () => {
50
- const store = (0, _useStore.useStore)();
51
- return (0, _useSelector.useSelector)(store, selectorSeries);
52
- };
53
- }