@mui/x-charts 7.22.1 → 8.0.0-alpha.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 (193) hide show
  1. package/BarChart/BarChart.d.ts +7 -7
  2. package/BarChart/BarChart.js +9 -29
  3. package/BarChart/BarElement.d.ts +1 -1
  4. package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
  5. package/BarChart/BarPlot.js +12 -4
  6. package/BarChart/extremums.js +3 -3
  7. package/BarChart/useBarChartProps.d.ts +2 -2
  8. package/BarChart/useBarChartProps.js +3 -4
  9. package/CHANGELOG.md +143 -92
  10. package/ChartContainer/ChartContainer.d.ts +16 -33
  11. package/ChartContainer/ChartContainer.js +24 -41
  12. package/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.d.ts +2 -2
  13. package/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.d.ts +1 -1
  14. package/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.js +6 -4
  15. package/ChartContainer/useChartContainerProps.d.ts +11 -86
  16. package/ChartContainer/useChartContainerProps.js +42 -58
  17. package/ChartsLegend/ChartsLegend.js +0 -3
  18. package/ChartsLegend/DefaultChartsLegend.d.ts +0 -5
  19. package/ChartsLegend/DefaultChartsLegend.js +1 -12
  20. package/ChartsLegend/LegendPerItem.d.ts +1 -1
  21. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  22. package/ChartsOverlay/ChartsOverlay.d.ts +1 -1
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  24. package/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  25. package/ChartsTooltip/ChartsTooltip.js +45 -6
  26. package/ChartsTooltip/useAxisTooltip.js +3 -3
  27. package/ChartsTooltip/useItemTooltip.js +3 -3
  28. package/ChartsTooltip/utils.d.ts +5 -13
  29. package/ChartsTooltip/utils.js +45 -42
  30. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -5
  31. package/Gauge/GaugeContainer.js +1 -1
  32. package/LineChart/AreaElement.d.ts +1 -1
  33. package/LineChart/AreaPlot.js +2 -6
  34. package/LineChart/LineChart.d.ts +7 -7
  35. package/LineChart/LineChart.js +9 -29
  36. package/LineChart/LineElement.d.ts +1 -1
  37. package/LineChart/LineHighlightPlot.d.ts +1 -1
  38. package/LineChart/LineHighlightPlot.js +2 -6
  39. package/LineChart/LinePlot.js +2 -6
  40. package/LineChart/MarkPlot.js +2 -6
  41. package/LineChart/extremums.js +10 -6
  42. package/LineChart/useLineChartProps.d.ts +2 -2
  43. package/LineChart/useLineChartProps.js +3 -4
  44. package/PieChart/PieArc.d.ts +0 -5
  45. package/PieChart/PieArc.js +1 -10
  46. package/PieChart/PieArcPlot.js +0 -5
  47. package/PieChart/PieChart.d.ts +9 -32
  48. package/PieChart/PieChart.js +19 -102
  49. package/README.md +2 -2
  50. package/ScatterChart/ScatterChart.d.ts +7 -7
  51. package/ScatterChart/ScatterChart.js +9 -29
  52. package/ScatterChart/ScatterPlot.js +3 -6
  53. package/ScatterChart/extremums.js +6 -6
  54. package/ScatterChart/useScatterChartProps.d.ts +2 -2
  55. package/ScatterChart/useScatterChartProps.js +3 -4
  56. package/SparkLineChart/SparkLineChart.d.ts +4 -4
  57. package/SparkLineChart/SparkLineChart.js +4 -2
  58. package/context/CartesianProvider/defaultizeAxis.d.ts +5 -1
  59. package/context/ChartDataProvider/ChartDataProvider.d.ts +41 -0
  60. package/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +48 -27
  61. package/context/ChartDataProvider/index.d.ts +1 -0
  62. package/context/ChartDataProvider/index.js +1 -0
  63. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +97 -0
  64. package/context/ChartDataProvider/useChartDataProviderProps.js +86 -0
  65. package/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.d.ts +16 -12
  66. package/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
  67. package/context/HighlightedProvider/HighlightedContext.d.ts +0 -8
  68. package/context/HighlightedProvider/HighlightedProvider.js +1 -16
  69. package/context/PluginProvider/ExtremumGetter.types.d.ts +2 -2
  70. package/context/ZAxisContextProvider.d.ts +1 -1
  71. package/index.d.ts +1 -2
  72. package/index.js +2 -3
  73. package/internals/computeAxisValue.js +13 -5
  74. package/internals/defaultizeColor.d.ts +1 -8
  75. package/internals/getSymbol.js +19 -3
  76. package/internals/index.d.ts +5 -5
  77. package/internals/index.js +5 -5
  78. package/internals/useStringInterpolator.js +1 -0
  79. package/models/axis.d.ts +10 -0
  80. package/models/seriesType/bar.d.ts +1 -1
  81. package/models/seriesType/common.d.ts +2 -12
  82. package/models/seriesType/config.d.ts +1 -1
  83. package/models/seriesType/line.d.ts +1 -1
  84. package/models/seriesType/pie.d.ts +1 -1
  85. package/models/seriesType/scatter.d.ts +1 -6
  86. package/modern/BarChart/BarChart.js +9 -29
  87. package/modern/BarChart/BarPlot.js +12 -4
  88. package/modern/BarChart/extremums.js +3 -3
  89. package/modern/BarChart/useBarChartProps.js +3 -4
  90. package/modern/ChartContainer/ChartContainer.js +24 -41
  91. package/modern/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.js +6 -4
  92. package/modern/ChartContainer/useChartContainerProps.js +42 -58
  93. package/modern/ChartsLegend/ChartsLegend.js +0 -3
  94. package/modern/ChartsLegend/DefaultChartsLegend.js +1 -12
  95. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  96. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  97. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  98. package/modern/ChartsTooltip/ChartsTooltip.js +45 -6
  99. package/modern/ChartsTooltip/useAxisTooltip.js +3 -3
  100. package/modern/ChartsTooltip/useItemTooltip.js +3 -3
  101. package/modern/ChartsTooltip/utils.js +45 -42
  102. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -5
  103. package/modern/Gauge/GaugeContainer.js +1 -1
  104. package/modern/LineChart/AreaPlot.js +2 -6
  105. package/modern/LineChart/LineChart.js +9 -29
  106. package/modern/LineChart/LineHighlightPlot.js +2 -6
  107. package/modern/LineChart/LinePlot.js +2 -6
  108. package/modern/LineChart/MarkPlot.js +2 -6
  109. package/modern/LineChart/extremums.js +10 -6
  110. package/modern/LineChart/useLineChartProps.js +3 -4
  111. package/modern/PieChart/PieArc.js +1 -10
  112. package/modern/PieChart/PieArcPlot.js +0 -5
  113. package/modern/PieChart/PieChart.js +19 -102
  114. package/modern/ScatterChart/ScatterChart.js +9 -29
  115. package/modern/ScatterChart/ScatterPlot.js +3 -6
  116. package/modern/ScatterChart/extremums.js +6 -6
  117. package/modern/ScatterChart/useScatterChartProps.js +3 -4
  118. package/modern/SparkLineChart/SparkLineChart.js +4 -2
  119. package/modern/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +48 -27
  120. package/modern/context/ChartDataProvider/index.js +1 -0
  121. package/modern/context/ChartDataProvider/useChartDataProviderProps.js +86 -0
  122. package/modern/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
  123. package/modern/context/HighlightedProvider/HighlightedProvider.js +1 -16
  124. package/modern/index.js +2 -3
  125. package/modern/internals/computeAxisValue.js +13 -5
  126. package/modern/internals/getSymbol.js +19 -3
  127. package/modern/internals/index.js +5 -5
  128. package/modern/internals/useStringInterpolator.js +1 -0
  129. package/node/BarChart/BarChart.js +9 -29
  130. package/node/BarChart/BarPlot.js +11 -3
  131. package/node/BarChart/extremums.js +3 -3
  132. package/node/BarChart/useBarChartProps.js +3 -4
  133. package/node/ChartContainer/ChartContainer.js +23 -40
  134. package/node/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.js +6 -4
  135. package/node/ChartContainer/useChartContainerProps.js +42 -59
  136. package/node/ChartsLegend/ChartsLegend.js +0 -3
  137. package/node/ChartsLegend/DefaultChartsLegend.js +1 -12
  138. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  139. package/node/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  140. package/node/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  141. package/node/ChartsTooltip/ChartsTooltip.js +44 -5
  142. package/node/ChartsTooltip/useAxisTooltip.js +3 -3
  143. package/node/ChartsTooltip/useItemTooltip.js +3 -3
  144. package/node/ChartsTooltip/utils.js +46 -44
  145. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -5
  146. package/node/Gauge/GaugeContainer.js +1 -1
  147. package/node/LineChart/AreaPlot.js +2 -6
  148. package/node/LineChart/LineChart.js +9 -29
  149. package/node/LineChart/LineHighlightPlot.js +2 -6
  150. package/node/LineChart/LinePlot.js +2 -6
  151. package/node/LineChart/MarkPlot.js +2 -6
  152. package/node/LineChart/extremums.js +10 -6
  153. package/node/LineChart/useLineChartProps.js +3 -4
  154. package/node/PieChart/PieArc.js +1 -10
  155. package/node/PieChart/PieArcPlot.js +0 -5
  156. package/node/PieChart/PieChart.js +19 -102
  157. package/node/ScatterChart/ScatterChart.js +9 -29
  158. package/node/ScatterChart/ScatterPlot.js +3 -6
  159. package/node/ScatterChart/extremums.js +6 -6
  160. package/node/ScatterChart/useScatterChartProps.js +3 -4
  161. package/node/SparkLineChart/SparkLineChart.js +4 -2
  162. package/node/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +47 -26
  163. package/node/context/ChartDataProvider/index.js +16 -0
  164. package/node/context/ChartDataProvider/useChartDataProviderProps.js +94 -0
  165. package/node/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
  166. package/node/context/HighlightedProvider/HighlightedProvider.js +1 -16
  167. package/node/index.js +5 -16
  168. package/node/internals/computeAxisValue.js +13 -5
  169. package/node/internals/getSymbol.js +19 -3
  170. package/node/internals/index.js +37 -29
  171. package/node/internals/useStringInterpolator.js +2 -0
  172. package/package.json +4 -4
  173. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -24
  174. package/ResponsiveChartContainer/index.d.ts +0 -1
  175. package/ResponsiveChartContainer/index.js +0 -1
  176. package/ResponsiveChartContainer/package.json +0 -6
  177. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +0 -19
  178. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
  179. package/internals/SlotComponentPropsFromProps.d.ts +0 -1
  180. package/internals/SlotComponentPropsFromProps.js +0 -1
  181. package/models/helpers.d.ts +0 -3
  182. package/models/helpers.js +0 -1
  183. package/modern/ResponsiveChartContainer/index.js +0 -1
  184. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
  185. package/modern/internals/SlotComponentPropsFromProps.js +0 -1
  186. package/modern/models/helpers.js +0 -1
  187. package/node/ResponsiveChartContainer/index.js +0 -16
  188. package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -77
  189. package/node/internals/SlotComponentPropsFromProps.js +0 -5
  190. package/node/models/helpers.js +0 -5
  191. /package/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.js +0 -0
  192. /package/modern/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.js +0 -0
  193. /package/node/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.js +0 -0
@@ -1,14 +1,14 @@
1
1
  export * from './components/ChartsAxesGradients';
2
- export * from '../ResponsiveChartContainer/useChartContainerDimensions';
3
- export * from '../ResponsiveChartContainer/ResizableContainer';
2
+ export * from '../ChartContainer/useChartContainerDimensions';
3
+ export * from '../ChartContainer/ResizableContainer';
4
4
  export { useSeries } from '../hooks/useSeries';
5
5
  export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
6
6
  export { useDrawingArea } from '../hooks/useDrawingArea';
7
7
  export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
8
8
  export { useLineChartProps } from '../LineChart/useLineChartProps';
9
9
  export { useBarChartProps } from '../BarChart/useBarChartProps';
10
- export { useResponsiveChartContainerProps } from '../ResponsiveChartContainer/useResponsiveChartContainerProps';
11
- export { useChartContainerProps } from '../ChartContainer/useChartContainerProps';
10
+ export * from '../ChartContainer/useChartContainerProps';
11
+ export * from '../context/ChartDataProvider/useChartDataProviderProps';
12
12
  export * from './defaultizeValueFormatter';
13
13
  export * from './configInit';
14
14
  export * from './getLabel';
@@ -26,8 +26,8 @@ export * from '../context/PluginProvider';
26
26
  export * from '../context/AnimationProvider';
27
27
  export type * from '../context/context.types';
28
28
  export { getAxisExtremum } from '../context/CartesianProvider/getAxisExtremum';
29
+ export * from '../context/ChartDataProvider';
29
30
  export * from '../models/seriesType/config';
30
31
  export * from '../models/seriesType/common';
31
- export * from '../models/helpers';
32
32
  export * from '../models/z-axis';
33
33
  export * from '../models/axis';
@@ -1,7 +1,7 @@
1
1
  // Components
2
2
  export * from "./components/ChartsAxesGradients/index.js";
3
- export * from "../ResponsiveChartContainer/useChartContainerDimensions.js";
4
- export * from "../ResponsiveChartContainer/ResizableContainer.js";
3
+ export * from "../ChartContainer/useChartContainerDimensions.js";
4
+ export * from "../ChartContainer/ResizableContainer.js";
5
5
 
6
6
  // hooks
7
7
  export { useSeries } from "../hooks/useSeries.js";
@@ -10,8 +10,8 @@ export { useDrawingArea } from "../hooks/useDrawingArea.js";
10
10
  export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
11
11
  export { useLineChartProps } from "../LineChart/useLineChartProps.js";
12
12
  export { useBarChartProps } from "../BarChart/useBarChartProps.js";
13
- export { useResponsiveChartContainerProps } from "../ResponsiveChartContainer/useResponsiveChartContainerProps.js";
14
- export { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
13
+ export * from "../ChartContainer/useChartContainerProps.js";
14
+ export * from "../context/ChartDataProvider/useChartDataProviderProps.js";
15
15
 
16
16
  // utils
17
17
  export * from "./defaultizeValueFormatter.js";
@@ -33,10 +33,10 @@ export * from "../context/ZAxisContextProvider.js";
33
33
  export * from "../context/PluginProvider/index.js";
34
34
  export * from "../context/AnimationProvider/index.js";
35
35
  export { getAxisExtremum } from "../context/CartesianProvider/getAxisExtremum.js";
36
+ export * from "../context/ChartDataProvider/index.js";
36
37
 
37
38
  // series configuration
38
39
  export * from "../models/seriesType/config.js";
39
40
  export * from "../models/seriesType/common.js";
40
- export * from "../models/helpers.js";
41
41
  export * from "../models/z-axis.js";
42
42
  export * from "../models/axis.js";
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-compiler/react-compiler */
1
2
  import * as React from 'react';
2
3
  import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate';
3
4
  function usePrevious(value) {
package/models/axis.d.ts CHANGED
@@ -280,6 +280,16 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps = Cha
280
280
  * If `true`, Reverse the axis scaleBand.
281
281
  */
282
282
  reverse?: boolean;
283
+ /**
284
+ * Defines the axis scale domain based on the min/max values of series linked to it.
285
+ * - 'nice': Rounds the domain at human friendly values.
286
+ * - 'strict': Set the domain to the min/max value provided. No extras space is added.
287
+ * - function: Receives the calculated extremums as parameters, and should return the axis domain.
288
+ */
289
+ domainLimit?: 'nice' | 'strict' | ((min: number, max: number) => {
290
+ min: number;
291
+ max: number;
292
+ });
283
293
  } & Omit<Partial<AxisProps>, 'axisId'> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams & AxisConfigExtension;
284
294
  export interface AxisConfigExtension {
285
295
  }
@@ -1,4 +1,4 @@
1
- import { DefaultizedProps } from '../helpers';
1
+ import { DefaultizedProps } from '@mui/x-internals/types';
2
2
  import type { StackOffsetType } from '../stacking';
3
3
  import { CartesianSeriesType, CommonSeriesType, CommonDefaultizedProps, StackableSeriesType } from './common';
4
4
  export interface BarSeriesType extends CommonSeriesType<number | null>, CartesianSeriesType, StackableSeriesType {
@@ -7,7 +7,7 @@ export type SeriesValueFormatterContext = {
7
7
  */
8
8
  dataIndex: number;
9
9
  };
10
- export type SeriesValueFormatter<TValue> = (value: TValue, context: SeriesValueFormatterContext) => string;
10
+ export type SeriesValueFormatter<TValue> = (value: TValue, context: SeriesValueFormatterContext) => string | null;
11
11
  export type CommonSeriesType<TValue> = {
12
12
  id?: SeriesId;
13
13
  color?: string;
@@ -15,7 +15,7 @@ export type CommonSeriesType<TValue> = {
15
15
  * Formatter used to render values in tooltip or other data display.
16
16
  * @param {TValue} value The series' value to render.
17
17
  * @param {SeriesValueFormatterContext} context The rendering context of the value.
18
- * @returns {string} The string to display.
18
+ * @returns {string | null} The string to display or null if the value should not be shown.
19
19
  */
20
20
  valueFormatter?: SeriesValueFormatter<TValue>;
21
21
  /**
@@ -25,16 +25,6 @@ export type CommonSeriesType<TValue> = {
25
25
  };
26
26
  export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';
27
27
  export type CartesianSeriesType = {
28
- /**
29
- * The id of the x-axis used to render the series.
30
- * @deprecated Use `xAxisId` instead
31
- */
32
- xAxisKey?: string;
33
- /**
34
- * The id of the y-axis used to render the series.
35
- * @deprecated Use `xAxisId` instead
36
- */
37
- yAxisKey?: string;
38
28
  /**
39
29
  * The id of the x-axis used to render the series.
40
30
  */
@@ -1,8 +1,8 @@
1
+ import { DefaultizedProps, MakeOptional } from '@mui/x-internals/types';
1
2
  import { ScatterSeriesType, DefaultizedScatterSeriesType, ScatterItemIdentifier, ScatterValueType } from './scatter';
2
3
  import { LineSeriesType, DefaultizedLineSeriesType, LineItemIdentifier } from './line';
3
4
  import { BarItemIdentifier, BarSeriesType, DefaultizedBarSeriesType } from './bar';
4
5
  import { PieSeriesType, DefaultizedPieSeriesType, PieItemIdentifier, PieValueType, DefaultizedPieValueType } from './pie';
5
- import { DefaultizedProps, MakeOptional } from '../helpers';
6
6
  export interface ChartsSeriesConfig {
7
7
  bar: {
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { DefaultizedProps } from '../helpers';
1
+ import { DefaultizedProps } from '@mui/x-internals/types';
2
2
  import type { StackOffsetType } from '../stacking';
3
3
  import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType, SeriesId, StackableSeriesType } from './common';
4
4
  export type CurveType = 'catmullRom' | 'linear' | 'monotoneX' | 'monotoneY' | 'natural' | 'step' | 'stepBefore' | 'stepAfter';
@@ -1,5 +1,5 @@
1
1
  import { PieArcDatum as D3PieArcDatum } from '@mui/x-charts-vendor/d3-shape';
2
- import { DefaultizedProps } from '../helpers';
2
+ import { DefaultizedProps } from '@mui/x-internals/types';
3
3
  import { CommonDefaultizedProps, CommonSeriesType, SeriesId } from './common';
4
4
  export type PieItemId = string | number;
5
5
  export type PieValueType = {
@@ -1,4 +1,4 @@
1
- import { DefaultizedProps } from '../helpers';
1
+ import { DefaultizedProps } from '@mui/x-internals/types';
2
2
  import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType, SeriesId } from './common';
3
3
  export type ScatterValueType = {
4
4
  x: number;
@@ -22,11 +22,6 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, C
22
22
  * @default false
23
23
  */
24
24
  disableHover?: boolean;
25
- /**
26
- * The id of the z-axis used to render the series.
27
- * @deprecated Use `zAxisId` instead.
28
- */
29
- zAxisKey?: string;
30
25
  /**
31
26
  * The id of the z-axis used to render the series.
32
27
  */
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useThemeProps } from '@mui/material/styles';
7
7
  import { BarPlot } from "./BarPlot.js";
8
- import { ResponsiveChartContainer } from "../ResponsiveChartContainer/index.js";
8
+ import { ChartContainer } from "../ChartContainer/index.js";
9
9
  import { ChartsAxis } from "../ChartsAxis/index.js";
10
10
  import { ChartsTooltip } from "../ChartsTooltip/index.js";
11
11
  import { ChartsLegend } from "../ChartsLegend/index.js";
@@ -46,12 +46,12 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(inProps, ref) {
46
46
  tooltipProps,
47
47
  children
48
48
  } = useBarChartProps(props);
49
- return /*#__PURE__*/_jsxs(ResponsiveChartContainer, _extends({
49
+ return /*#__PURE__*/_jsxs(ChartContainer, _extends({
50
50
  ref: ref
51
51
  }, chartContainerProps, {
52
52
  children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
53
53
  children: [/*#__PURE__*/_jsx(BarPlot, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
54
- })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
54
+ })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
55
55
  }));
56
56
  });
57
57
  process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
@@ -116,6 +116,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
116
116
  * The height of the chart in px. If not defined, it takes the height of the parent element.
117
117
  */
118
118
  height: PropTypes.number,
119
+ /**
120
+ * If `true`, the legend is not rendered.
121
+ */
122
+ hideLegend: PropTypes.bool,
119
123
  /**
120
124
  * The item currently highlighted. Turns highlighting into a controlled prop.
121
125
  */
@@ -134,32 +138,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
134
138
  * @default yAxisIds[0] The id of the first provided axis
135
139
  */
136
140
  leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
137
- /**
138
- * @deprecated Consider using `slotProps.legend` instead.
139
- */
140
- legend: PropTypes.shape({
141
- classes: PropTypes.object,
142
- direction: PropTypes.oneOf(['column', 'row']),
143
- hidden: PropTypes.bool,
144
- itemGap: PropTypes.number,
145
- itemMarkHeight: PropTypes.number,
146
- itemMarkWidth: PropTypes.number,
147
- labelStyle: PropTypes.object,
148
- markGap: PropTypes.number,
149
- onItemClick: PropTypes.func,
150
- padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
151
- bottom: PropTypes.number,
152
- left: PropTypes.number,
153
- right: PropTypes.number,
154
- top: PropTypes.number
155
- })]),
156
- position: PropTypes.shape({
157
- horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
158
- vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
159
- }),
160
- slotProps: PropTypes.object,
161
- slots: PropTypes.object
162
- }),
163
141
  /**
164
142
  * If `true`, a loading overlay is displayed.
165
143
  * @default false
@@ -288,6 +266,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
288
266
  dataKey: PropTypes.string,
289
267
  disableLine: PropTypes.bool,
290
268
  disableTicks: PropTypes.bool,
269
+ domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
291
270
  fill: PropTypes.string,
292
271
  hideTooltip: PropTypes.bool,
293
272
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -341,6 +320,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
341
320
  dataKey: PropTypes.string,
342
321
  disableLine: PropTypes.bool,
343
322
  disableTicks: PropTypes.bool,
323
+ domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
344
324
  fill: PropTypes.string,
345
325
  hideTooltip: PropTypes.bool,
346
326
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -9,7 +9,7 @@ import { useTransition } from '@react-spring/web';
9
9
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
10
10
  import { BarElement } from "./BarElement.js";
11
11
  import getColor from "./getColor.js";
12
- import { useChartId } from "../hooks/index.js";
12
+ import { useChartId, useDrawingArea } from "../hooks/index.js";
13
13
  import { BarClipPath } from "./BarClipPath.js";
14
14
  import { BarLabelPlot } from "./BarLabel/BarLabelPlot.js";
15
15
  import { checkScaleErrors } from "./checkScaleErrors.js";
@@ -51,6 +51,7 @@ const useAggregatedData = () => {
51
51
  seriesOrder: []
52
52
  };
53
53
  const axisData = useCartesianContext();
54
+ const drawingArea = useDrawingArea();
54
55
  const chartId = useChartId();
55
56
  const {
56
57
  series,
@@ -68,9 +69,13 @@ const useAggregatedData = () => {
68
69
  const data = stackingGroups.flatMap(({
69
70
  ids: groupIds
70
71
  }, groupIndex) => {
72
+ const xMin = drawingArea.left;
73
+ const xMax = drawingArea.left + drawingArea.width;
74
+ const yMin = drawingArea.top;
75
+ const yMax = drawingArea.top + drawingArea.height;
71
76
  return groupIds.flatMap(seriesId => {
72
- const xAxisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey ?? defaultXAxisId;
73
- const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey ?? defaultYAxisId;
77
+ const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
78
+ const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;
74
79
  const xAxisConfig = xAxis[xAxisId];
75
80
  const yAxisConfig = yAxis[yAxisId];
76
81
  const verticalLayout = series[seriesId].layout === 'vertical';
@@ -111,6 +116,9 @@ const useAggregatedData = () => {
111
116
  value: series[seriesId].data[dataIndex],
112
117
  maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
113
118
  };
119
+ if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
120
+ return null;
121
+ }
114
122
  if (!masks[result.maskId]) {
115
123
  masks[result.maskId] = {
116
124
  id: result.maskId,
@@ -133,7 +141,7 @@ const useAggregatedData = () => {
133
141
  mask.hasNegative = mask.hasNegative || (result.value ?? 0) < 0;
134
142
  mask.hasPositive = mask.hasPositive || (result.value ?? 0) > 0;
135
143
  return result;
136
- });
144
+ }).filter(rectangle => rectangle !== null);
137
145
  });
138
146
  });
139
147
  return {
@@ -36,7 +36,7 @@ const getValueExtremum = direction => params => {
36
36
  isDefaultAxis
37
37
  } = params;
38
38
  return Object.keys(series).filter(seriesId => {
39
- const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
39
+ const yAxisId = series[seriesId].yAxisId;
40
40
  return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
41
41
  }).reduce((acc, seriesId) => {
42
42
  const {
@@ -45,8 +45,8 @@ const getValueExtremum = direction => params => {
45
45
  const filter = getFilters?.({
46
46
  currentAxisId: axis.id,
47
47
  isDefaultAxis,
48
- seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
49
- seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey
48
+ seriesXAxisId: series[seriesId].xAxisId,
49
+ seriesYAxisId: series[seriesId].yAxisId
50
50
  });
51
51
  const [seriesMin, seriesMax] = stackedData?.reduce((seriesAcc, values, index) => {
52
52
  if (filter && (!filter(createResult(values[0], direction), index) || !filter(createResult(values[1], direction), index))) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "tooltip", "onAxisClick", "axisHighlight", "legend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className"];
5
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "tooltip", "onAxisClick", "axisHighlight", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend"];
6
6
  import useId from '@mui/utils/useId';
7
7
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../constants/index.js";
8
8
  /**
@@ -26,7 +26,6 @@ export const useBarChartProps = props => {
26
26
  tooltip,
27
27
  onAxisClick,
28
28
  axisHighlight,
29
- legend,
30
29
  grid,
31
30
  topAxis,
32
31
  leftAxis,
@@ -117,10 +116,10 @@ export const useBarChartProps = props => {
117
116
  } : {
118
117
  x: 'band'
119
118
  }, axisHighlight);
120
- const legendProps = _extends({}, legend, {
119
+ const legendProps = {
121
120
  slots,
122
121
  slotProps
123
- });
122
+ };
124
123
  const tooltipProps = _extends({}, tooltip, {
125
124
  slots,
126
125
  slotProps
@@ -3,47 +3,18 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { DrawingProvider } from "../context/DrawingProvider.js";
7
- import { SeriesProvider } from "../context/SeriesProvider/index.js";
8
- import { InteractionProvider } from "../context/InteractionProvider.js";
9
- import { ChartsSurface } from "../ChartsSurface/index.js";
10
- import { CartesianProvider } from "../context/CartesianProvider/index.js";
11
- import { ChartsAxesGradients } from "../internals/components/ChartsAxesGradients/index.js";
12
- import { HighlightedProvider, ZAxisContextProvider } from "../context/index.js";
13
- import { PluginProvider } from "../context/PluginProvider/index.js";
6
+ import { ChartDataProvider } from "../context/ChartDataProvider/index.js";
7
+ import { ResizableContainer } from "./ResizableContainer.js";
14
8
  import { useChartContainerProps } from "./useChartContainerProps.js";
15
- import { AnimationProvider } from "../context/AnimationProvider/index.js";
16
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
17
10
  const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
18
11
  const {
19
- children,
20
- drawingProviderProps,
21
- seriesProviderProps,
22
- cartesianProviderProps,
23
- zAxisContextProps,
24
- highlightedProviderProps,
25
- chartsSurfaceProps,
26
- pluginProviderProps,
27
- animationProviderProps
12
+ hasIntrinsicSize,
13
+ chartDataProviderProps,
14
+ resizableChartContainerProps
28
15
  } = useChartContainerProps(props, ref);
29
- return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
30
- children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
31
- children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
32
- children: /*#__PURE__*/_jsx(CartesianProvider, _extends({}, cartesianProviderProps, {
33
- children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
34
- children: /*#__PURE__*/_jsx(InteractionProvider, {
35
- children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
36
- children: /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
37
- children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), /*#__PURE__*/_jsx(AnimationProvider, _extends({}, animationProviderProps, {
38
- children: children
39
- }))]
40
- }))
41
- }))
42
- })
43
- }))
44
- }))
45
- }))
46
- }))
16
+ return /*#__PURE__*/_jsx(ResizableContainer, _extends({}, resizableChartContainerProps, {
17
+ children: hasIntrinsicSize ? /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps)) : null
47
18
  }));
48
19
  });
49
20
  process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
@@ -70,9 +41,9 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
70
41
  */
71
42
  disableAxisListener: PropTypes.bool,
72
43
  /**
73
- * The height of the chart in px.
44
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
74
45
  */
75
- height: PropTypes.number.isRequired,
46
+ height: PropTypes.number,
76
47
  /**
77
48
  * The item currently highlighted. Turns highlighting into a controlled prop.
78
49
  */
@@ -103,6 +74,16 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
103
74
  * If not provided, the container supports line, bar, scatter and pie charts.
104
75
  */
105
76
  plugins: PropTypes.arrayOf(PropTypes.object),
77
+ /**
78
+ * The chart will try to wait for the parent container to resolve its size
79
+ * before it renders for the first time.
80
+ *
81
+ * This can be useful in some scenarios where the chart appear to grow after
82
+ * the first render, like when used inside a grid.
83
+ *
84
+ * @default false
85
+ */
86
+ resolveSizeBeforeRender: PropTypes.bool,
106
87
  /**
107
88
  * The array of series to display.
108
89
  * Each type of series has its own specificity.
@@ -123,9 +104,9 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
123
104
  y: PropTypes.number
124
105
  }),
125
106
  /**
126
- * The width of the chart in px.
107
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
127
108
  */
128
- width: PropTypes.number.isRequired,
109
+ width: PropTypes.number,
129
110
  /**
130
111
  * The configuration of the x-axes.
131
112
  * If not provided, a default axis config is used.
@@ -152,6 +133,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
152
133
  dataKey: PropTypes.string,
153
134
  disableLine: PropTypes.bool,
154
135
  disableTicks: PropTypes.bool,
136
+ domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
155
137
  fill: PropTypes.string,
156
138
  hideTooltip: PropTypes.bool,
157
139
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -205,6 +187,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
205
187
  dataKey: PropTypes.string,
206
188
  disableLine: PropTypes.bool,
207
189
  disableTicks: PropTypes.bool,
190
+ domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
208
191
  fill: PropTypes.string,
209
192
  hideTooltip: PropTypes.bool,
210
193
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -1,9 +1,11 @@
1
1
  'use client';
2
2
 
3
+ /* eslint-disable react-compiler/react-compiler */
3
4
  import * as React from 'react';
4
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
6
  import ownerWindow from '@mui/utils/ownerWindow';
6
7
  export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
8
+ const hasInSize = inWidth !== undefined && inHeight !== undefined;
7
9
  const stateRef = React.useRef({
8
10
  displayError: false,
9
11
  initialCompute: true,
@@ -40,7 +42,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
40
42
  // https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
41
43
  useEnhancedEffect(() => {
42
44
  // computeRun is used to avoid infinite loops.
43
- if (!resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
45
+ if (hasInSize || !resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
44
46
  return;
45
47
  }
46
48
  const computedSize = computeSize();
@@ -49,9 +51,9 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
49
51
  } else if (stateRef.current.initialCompute) {
50
52
  stateRef.current.initialCompute = false;
51
53
  }
52
- }, [width, height, computeSize, resolveSizeBeforeRender]);
54
+ }, [width, height, computeSize, resolveSizeBeforeRender, hasInSize]);
53
55
  useEnhancedEffect(() => {
54
- if (inWidth !== undefined && inHeight !== undefined) {
56
+ if (hasInSize) {
55
57
  return () => {};
56
58
  }
57
59
  computeSize();
@@ -77,7 +79,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
77
79
  observer.unobserve(elementToObserve);
78
80
  }
79
81
  };
80
- }, [computeSize, inHeight, inWidth]);
82
+ }, [computeSize, hasInSize]);
81
83
  if (process.env.NODE_ENV !== 'production') {
82
84
  if (stateRef.current.displayError && inWidth === undefined && width === 0) {
83
85
  console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
@@ -2,85 +2,69 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["width", "height", "series", "margin", "xAxis", "yAxis", "zAxis", "colors", "dataset", "sx", "title", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "children", "skipAnimation"];
6
- import * as React from 'react';
7
- import useForkRef from '@mui/utils/useForkRef';
8
- import { useDefaultizeAxis } from "./useDefaultizeAxis.js";
5
+ const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis", "skipAnimation"];
6
+ import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
9
7
  export const useChartContainerProps = (props, ref) => {
10
8
  const {
11
9
  width,
12
10
  height,
13
- series,
11
+ resolveSizeBeforeRender,
14
12
  margin,
15
- xAxis,
16
- yAxis,
17
- zAxis,
13
+ children,
14
+ series,
18
15
  colors,
19
16
  dataset,
20
- sx,
21
- title,
22
17
  desc,
23
18
  disableAxisListener,
24
19
  highlightedItem,
25
20
  onHighlightChange,
26
21
  plugins,
27
- children,
22
+ sx,
23
+ title,
24
+ viewBox,
25
+ xAxis,
26
+ yAxis,
27
+ zAxis,
28
28
  skipAnimation
29
29
  } = props,
30
30
  other = _objectWithoutPropertiesLoose(props, _excluded);
31
- const svgRef = React.useRef(null);
32
- const chartSurfaceRef = useForkRef(ref, svgRef);
33
- const [defaultizedXAxis, defaultizedYAxis] = useDefaultizeAxis(xAxis, yAxis, dataset);
34
- const drawingProviderProps = {
35
- width,
36
- height,
31
+ const {
32
+ containerRef,
33
+ width: dWidth,
34
+ height: dHeight
35
+ } = useChartContainerDimensions(width, height, resolveSizeBeforeRender);
36
+ const resizableChartContainerProps = _extends({}, other, {
37
+ ownerState: {
38
+ width,
39
+ height
40
+ },
41
+ ref: containerRef
42
+ });
43
+ const chartDataProviderProps = {
37
44
  margin,
38
- svgRef
39
- };
40
- const animationProviderProps = {
41
- skipAnimation
42
- };
43
- const pluginProviderProps = {
44
- plugins
45
- };
46
- const seriesProviderProps = {
45
+ children,
47
46
  series,
48
47
  colors,
49
- dataset
50
- };
51
- const cartesianProviderProps = {
52
- xAxis: defaultizedXAxis,
53
- yAxis: defaultizedYAxis,
54
- dataset
55
- };
56
- const zAxisContextProps = {
57
- zAxis,
58
- dataset
59
- };
60
- const highlightedProviderProps = {
48
+ dataset,
49
+ desc,
50
+ disableAxisListener,
61
51
  highlightedItem,
62
- onHighlightChange
63
- };
64
- const chartsSurfaceProps = _extends({}, other, {
65
- width,
66
- height,
67
- ref: chartSurfaceRef,
52
+ onHighlightChange,
53
+ plugins,
68
54
  sx,
69
55
  title,
70
- desc,
71
- disableAxisListener
72
- });
56
+ viewBox,
57
+ xAxis,
58
+ yAxis,
59
+ zAxis,
60
+ skipAnimation,
61
+ width: dWidth,
62
+ height: dHeight,
63
+ ref
64
+ };
73
65
  return {
74
- children,
75
- drawingProviderProps,
76
- seriesProviderProps,
77
- cartesianProviderProps,
78
- zAxisContextProps,
79
- highlightedProviderProps,
80
- chartsSurfaceProps,
81
- pluginProviderProps,
82
- animationProviderProps,
83
- xAxis: defaultizedXAxis,
84
- yAxis: defaultizedYAxis
66
+ hasIntrinsicSize: Boolean(dWidth && dHeight),
67
+ chartDataProviderProps,
68
+ resizableChartContainerProps
85
69
  };
86
70
  };