@mui/x-charts 7.0.0-beta.1 → 7.0.0-beta.3

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 (234) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +37 -13
  3. package/BarChart/BarElement.d.ts +20 -13
  4. package/BarChart/BarElement.js +1 -0
  5. package/BarChart/BarPlot.d.ts +3 -5
  6. package/BarChart/BarPlot.js +9 -10
  7. package/CHANGELOG.md +223 -1
  8. package/ChartContainer/ChartContainer.js +6 -4
  9. package/ChartsAxis/ChartsAxis.js +4 -4
  10. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  11. package/ChartsGrid/ChartsGrid.js +128 -0
  12. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  13. package/ChartsGrid/chartsGridClasses.js +14 -0
  14. package/ChartsGrid/index.d.ts +2 -0
  15. package/ChartsGrid/index.js +27 -0
  16. package/ChartsGrid/package.json +6 -0
  17. package/ChartsLegend/ChartsLegend.d.ts +5 -54
  18. package/ChartsLegend/ChartsLegend.js +2 -307
  19. package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
  20. package/ChartsLegend/DefaultChartsLegend.js +294 -0
  21. package/ChartsLegend/index.d.ts +1 -0
  22. package/ChartsLegend/index.js +11 -0
  23. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  24. package/ChartsReferenceLine/common.d.ts +2 -1
  25. package/ChartsSurface.js +6 -4
  26. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  27. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  28. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  29. package/ChartsTooltip/utils.d.ts +1 -0
  30. package/ChartsTooltip/utils.js +7 -0
  31. package/ChartsXAxis/ChartsXAxis.js +15 -11
  32. package/ChartsYAxis/ChartsYAxis.js +3 -3
  33. package/Gauge/Gauge.d.ts +13 -0
  34. package/Gauge/Gauge.js +156 -0
  35. package/Gauge/GaugeContainer.d.ts +19 -0
  36. package/Gauge/GaugeContainer.js +216 -0
  37. package/Gauge/GaugeProvider.d.ts +117 -0
  38. package/Gauge/GaugeProvider.js +96 -0
  39. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  40. package/Gauge/GaugeReferenceArc.js +44 -0
  41. package/Gauge/GaugeValueArc.d.ts +2 -0
  42. package/Gauge/GaugeValueArc.js +51 -0
  43. package/Gauge/GaugeValueText.d.ts +15 -0
  44. package/Gauge/GaugeValueText.js +77 -0
  45. package/Gauge/gaugeClasses.d.ts +14 -0
  46. package/Gauge/gaugeClasses.js +15 -0
  47. package/Gauge/index.d.ts +7 -0
  48. package/Gauge/index.js +87 -0
  49. package/Gauge/package.json +6 -0
  50. package/Gauge/utils.d.ts +19 -0
  51. package/Gauge/utils.js +75 -0
  52. package/LineChart/AnimatedArea.js +1 -1
  53. package/LineChart/AnimatedLine.js +1 -1
  54. package/LineChart/AreaElement.d.ts +2 -1
  55. package/LineChart/AreaElement.js +1 -1
  56. package/LineChart/LineChart.d.ts +24 -5
  57. package/LineChart/LineChart.js +41 -13
  58. package/LineChart/LineElement.d.ts +2 -1
  59. package/LineChart/LineElement.js +1 -1
  60. package/LineChart/LineHighlightElement.d.ts +3 -2
  61. package/LineChart/LineHighlightElement.js +2 -1
  62. package/LineChart/MarkElement.d.ts +3 -2
  63. package/LineChart/MarkElement.js +1 -0
  64. package/PieChart/PieArc.d.ts +7 -6
  65. package/PieChart/PieArc.js +10 -9
  66. package/PieChart/PieArcLabel.d.ts +3 -2
  67. package/PieChart/PieArcLabel.js +1 -0
  68. package/PieChart/PieArcLabelPlot.js +14 -14
  69. package/PieChart/PieArcPlot.js +1 -1
  70. package/PieChart/PieChart.d.ts +22 -0
  71. package/PieChart/PieChart.js +32 -8
  72. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  73. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  74. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  75. package/ScatterChart/ScatterChart.d.ts +18 -0
  76. package/ScatterChart/ScatterChart.js +35 -8
  77. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  78. package/SparkLineChart/SparkLineChart.js +5 -4
  79. package/context/CartesianContextProvider.js +8 -6
  80. package/esm/BarChart/BarChart.js +37 -13
  81. package/esm/BarChart/BarElement.js +1 -0
  82. package/esm/BarChart/BarPlot.js +8 -10
  83. package/esm/ChartContainer/ChartContainer.js +6 -4
  84. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  85. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  86. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  87. package/esm/ChartsGrid/index.js +2 -0
  88. package/esm/ChartsLegend/ChartsLegend.js +2 -307
  89. package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
  90. package/esm/ChartsLegend/index.js +1 -0
  91. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  92. package/esm/ChartsSurface.js +6 -4
  93. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  94. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  95. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  96. package/esm/ChartsTooltip/utils.js +6 -0
  97. package/esm/ChartsXAxis/ChartsXAxis.js +14 -10
  98. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  99. package/esm/Gauge/Gauge.js +149 -0
  100. package/esm/Gauge/GaugeContainer.js +211 -0
  101. package/esm/Gauge/GaugeProvider.js +85 -0
  102. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  103. package/esm/Gauge/GaugeValueArc.js +42 -0
  104. package/esm/Gauge/GaugeValueText.js +69 -0
  105. package/esm/Gauge/gaugeClasses.js +7 -0
  106. package/esm/Gauge/index.js +7 -0
  107. package/esm/Gauge/utils.js +68 -0
  108. package/esm/LineChart/AnimatedArea.js +1 -1
  109. package/esm/LineChart/AnimatedLine.js +1 -1
  110. package/esm/LineChart/AreaElement.js +1 -1
  111. package/esm/LineChart/LineChart.js +41 -13
  112. package/esm/LineChart/LineElement.js +1 -1
  113. package/esm/LineChart/LineHighlightElement.js +2 -1
  114. package/esm/LineChart/MarkElement.js +1 -0
  115. package/esm/PieChart/PieArc.js +10 -9
  116. package/esm/PieChart/PieArcLabel.js +1 -0
  117. package/esm/PieChart/PieArcLabelPlot.js +14 -14
  118. package/esm/PieChart/PieArcPlot.js +1 -1
  119. package/esm/PieChart/PieChart.js +32 -8
  120. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  121. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  122. package/esm/ScatterChart/ScatterChart.js +35 -8
  123. package/esm/SparkLineChart/SparkLineChart.js +5 -4
  124. package/esm/context/CartesianContextProvider.js +8 -6
  125. package/esm/hooks/useTicks.js +2 -3
  126. package/esm/index.js +2 -0
  127. package/hooks/useTicks.d.ts +1 -2
  128. package/hooks/useTicks.js +2 -3
  129. package/index.d.ts +2 -0
  130. package/index.js +23 -1
  131. package/internals/defaultizeColor.d.ts +16 -16
  132. package/internals/defaultizeValueFormatter.d.ts +4 -7
  133. package/internals/stackSeries.d.ts +4 -7
  134. package/legacy/BarChart/BarChart.js +37 -13
  135. package/legacy/BarChart/BarElement.js +1 -0
  136. package/legacy/BarChart/BarPlot.js +10 -10
  137. package/legacy/ChartContainer/ChartContainer.js +6 -4
  138. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  139. package/legacy/ChartsGrid/ChartsGrid.js +119 -0
  140. package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
  141. package/legacy/ChartsGrid/index.js +2 -0
  142. package/legacy/ChartsLegend/ChartsLegend.js +2 -323
  143. package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
  144. package/legacy/ChartsLegend/index.js +1 -0
  145. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  146. package/legacy/ChartsSurface.js +5 -3
  147. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  148. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  149. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  150. package/legacy/ChartsTooltip/utils.js +6 -0
  151. package/legacy/ChartsXAxis/ChartsXAxis.js +13 -9
  152. package/legacy/ChartsYAxis/ChartsYAxis.js +2 -2
  153. package/legacy/Gauge/Gauge.js +146 -0
  154. package/legacy/Gauge/GaugeContainer.js +215 -0
  155. package/legacy/Gauge/GaugeProvider.js +87 -0
  156. package/legacy/Gauge/GaugeReferenceArc.js +37 -0
  157. package/legacy/Gauge/GaugeValueArc.js +44 -0
  158. package/legacy/Gauge/GaugeValueText.js +66 -0
  159. package/legacy/Gauge/gaugeClasses.js +7 -0
  160. package/legacy/Gauge/index.js +7 -0
  161. package/legacy/Gauge/utils.js +84 -0
  162. package/legacy/LineChart/AnimatedArea.js +1 -1
  163. package/legacy/LineChart/AnimatedLine.js +1 -1
  164. package/legacy/LineChart/AreaElement.js +1 -1
  165. package/legacy/LineChart/LineChart.js +41 -13
  166. package/legacy/LineChart/LineElement.js +1 -1
  167. package/legacy/LineChart/LineHighlightElement.js +2 -1
  168. package/legacy/LineChart/MarkElement.js +1 -0
  169. package/legacy/PieChart/PieArc.js +11 -10
  170. package/legacy/PieChart/PieArcLabel.js +1 -0
  171. package/legacy/PieChart/PieArcLabelPlot.js +15 -15
  172. package/legacy/PieChart/PieArcPlot.js +1 -1
  173. package/legacy/PieChart/PieChart.js +32 -8
  174. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -81
  175. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
  176. package/legacy/ScatterChart/ScatterChart.js +35 -8
  177. package/legacy/SparkLineChart/SparkLineChart.js +6 -5
  178. package/legacy/context/CartesianContextProvider.js +8 -6
  179. package/legacy/hooks/useTicks.js +2 -3
  180. package/legacy/index.js +3 -1
  181. package/models/axis.d.ts +7 -2
  182. package/models/seriesType/common.d.ts +2 -1
  183. package/models/seriesType/config.d.ts +7 -12
  184. package/models/seriesType/line.d.ts +2 -2
  185. package/models/seriesType/pie.d.ts +7 -3
  186. package/models/seriesType/scatter.d.ts +5 -2
  187. package/modern/BarChart/BarChart.js +37 -13
  188. package/modern/BarChart/BarElement.js +1 -0
  189. package/modern/BarChart/BarPlot.js +8 -10
  190. package/modern/ChartContainer/ChartContainer.js +6 -4
  191. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  192. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  193. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  194. package/modern/ChartsGrid/index.js +2 -0
  195. package/modern/ChartsLegend/ChartsLegend.js +2 -307
  196. package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
  197. package/modern/ChartsLegend/index.js +1 -0
  198. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  199. package/modern/ChartsSurface.js +6 -4
  200. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  201. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  202. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  203. package/modern/ChartsTooltip/utils.js +6 -0
  204. package/modern/ChartsXAxis/ChartsXAxis.js +14 -10
  205. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  206. package/modern/Gauge/Gauge.js +149 -0
  207. package/modern/Gauge/GaugeContainer.js +208 -0
  208. package/modern/Gauge/GaugeProvider.js +85 -0
  209. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  210. package/modern/Gauge/GaugeValueArc.js +42 -0
  211. package/modern/Gauge/GaugeValueText.js +69 -0
  212. package/modern/Gauge/gaugeClasses.js +7 -0
  213. package/modern/Gauge/index.js +7 -0
  214. package/modern/Gauge/utils.js +68 -0
  215. package/modern/LineChart/AnimatedArea.js +1 -1
  216. package/modern/LineChart/AnimatedLine.js +1 -1
  217. package/modern/LineChart/AreaElement.js +1 -1
  218. package/modern/LineChart/LineChart.js +41 -13
  219. package/modern/LineChart/LineElement.js +1 -1
  220. package/modern/LineChart/LineHighlightElement.js +2 -1
  221. package/modern/LineChart/MarkElement.js +1 -0
  222. package/modern/PieChart/PieArc.js +10 -9
  223. package/modern/PieChart/PieArcLabel.js +1 -0
  224. package/modern/PieChart/PieArcLabelPlot.js +14 -14
  225. package/modern/PieChart/PieArcPlot.js +1 -1
  226. package/modern/PieChart/PieChart.js +32 -8
  227. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  228. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  229. package/modern/ScatterChart/ScatterChart.js +35 -8
  230. package/modern/SparkLineChart/SparkLineChart.js +5 -4
  231. package/modern/context/CartesianContextProvider.js +8 -6
  232. package/modern/hooks/useTicks.js +2 -3
  233. package/modern/index.js +3 -1
  234. package/package.json +4 -4
@@ -3,74 +3,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["width", "height"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
- import ownerWindow from '@mui/utils/ownerWindow';
8
6
  import { styled } from '@mui/material/styles';
9
7
  import { ChartContainer } from '../ChartContainer';
8
+ import { useChartContainerDimensions } from './useChartContainerDimensions';
10
9
  import { jsx as _jsx } from "react/jsx-runtime";
11
- const useChartDimensions = (inWidth, inHeight) => {
12
- const rootRef = React.useRef(null);
13
- const displayError = React.useRef(false);
14
- const [width, setWidth] = React.useState(0);
15
- const [height, setHeight] = React.useState(0);
16
-
17
- // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
18
- const computeSize = React.useCallback(() => {
19
- const mainEl = rootRef?.current;
20
- if (!mainEl) {
21
- return;
22
- }
23
- const win = ownerWindow(mainEl);
24
- const computedStyle = win.getComputedStyle(mainEl);
25
- const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
26
- const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
27
- setWidth(newWidth);
28
- setHeight(newHeight);
29
- }, []);
30
- React.useEffect(() => {
31
- // Ensure the error detection occurs after the first rendering.
32
- displayError.current = true;
33
- }, []);
34
- useEnhancedEffect(() => {
35
- if (inWidth !== undefined && inHeight !== undefined) {
36
- return () => {};
37
- }
38
- computeSize();
39
- const elementToObserve = rootRef.current;
40
- if (typeof ResizeObserver === 'undefined') {
41
- return () => {};
42
- }
43
- let animationFrame;
44
- const observer = new ResizeObserver(() => {
45
- // See https://github.com/mui/mui-x/issues/8733
46
- animationFrame = requestAnimationFrame(() => {
47
- computeSize();
48
- });
49
- });
50
- if (elementToObserve) {
51
- observer.observe(elementToObserve);
52
- }
53
- return () => {
54
- if (animationFrame) {
55
- window.cancelAnimationFrame(animationFrame);
56
- }
57
- if (elementToObserve) {
58
- observer.unobserve(elementToObserve);
59
- }
60
- };
61
- }, [computeSize, inHeight, inWidth]);
62
- if (process.env.NODE_ENV !== 'production') {
63
- if (displayError.current && inWidth === undefined && width === 0) {
64
- console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
65
- displayError.current = false;
66
- }
67
- if (displayError.current && inHeight === undefined && height === 0) {
68
- console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
69
- displayError.current = false;
70
- }
71
- }
72
- return [rootRef, inWidth ?? width, inHeight ?? height];
73
- };
74
10
  const ResizableContainer = styled('div', {
75
11
  name: 'MuiResponsiveChart',
76
12
  slot: 'Container'
@@ -97,7 +33,7 @@ const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function Responsi
97
33
  height: inHeight
98
34
  } = props,
99
35
  other = _objectWithoutPropertiesLoose(props, _excluded);
100
- const [containerRef, width, height] = useChartDimensions(inWidth, inHeight);
36
+ const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
101
37
  return /*#__PURE__*/_jsx(ResizableContainer, {
102
38
  ref: containerRef,
103
39
  ownerState: {
@@ -175,7 +111,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
175
111
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
176
112
  */
177
113
  xAxis: PropTypes.arrayOf(PropTypes.shape({
178
- axisId: PropTypes.string,
114
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
179
115
  classes: PropTypes.object,
180
116
  data: PropTypes.array,
181
117
  dataKey: PropTypes.string,
@@ -183,13 +119,14 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
183
119
  disableTicks: PropTypes.bool,
184
120
  fill: PropTypes.string,
185
121
  hideTooltip: PropTypes.bool,
186
- id: PropTypes.string,
122
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
187
123
  label: PropTypes.string,
188
124
  labelFontSize: PropTypes.number,
189
125
  labelStyle: PropTypes.object,
190
126
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
191
127
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
192
128
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
129
+ reverse: PropTypes.bool,
193
130
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
194
131
  slotProps: PropTypes.object,
195
132
  slots: PropTypes.object,
@@ -209,7 +146,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
209
146
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
210
147
  */
211
148
  yAxis: PropTypes.arrayOf(PropTypes.shape({
212
- axisId: PropTypes.string,
149
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
213
150
  classes: PropTypes.object,
214
151
  data: PropTypes.array,
215
152
  dataKey: PropTypes.string,
@@ -217,13 +154,14 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
217
154
  disableTicks: PropTypes.bool,
218
155
  fill: PropTypes.string,
219
156
  hideTooltip: PropTypes.bool,
220
- id: PropTypes.string,
157
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
221
158
  label: PropTypes.string,
222
159
  labelFontSize: PropTypes.number,
223
160
  labelStyle: PropTypes.object,
224
161
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
225
162
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
226
163
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
164
+ reverse: PropTypes.bool,
227
165
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
228
166
  slotProps: PropTypes.object,
229
167
  slots: PropTypes.object,
@@ -0,0 +1,66 @@
1
+ import * as React from 'react';
2
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
+ import ownerWindow from '@mui/utils/ownerWindow';
4
+ export const useChartContainerDimensions = (inWidth, inHeight) => {
5
+ const rootRef = React.useRef(null);
6
+ const displayError = React.useRef(false);
7
+ const [width, setWidth] = React.useState(0);
8
+ const [height, setHeight] = React.useState(0);
9
+
10
+ // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
11
+ const computeSize = React.useCallback(() => {
12
+ const mainEl = rootRef?.current;
13
+ if (!mainEl) {
14
+ return;
15
+ }
16
+ const win = ownerWindow(mainEl);
17
+ const computedStyle = win.getComputedStyle(mainEl);
18
+ const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
19
+ const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
20
+ setWidth(newWidth);
21
+ setHeight(newHeight);
22
+ }, []);
23
+ React.useEffect(() => {
24
+ // Ensure the error detection occurs after the first rendering.
25
+ displayError.current = true;
26
+ }, []);
27
+ useEnhancedEffect(() => {
28
+ if (inWidth !== undefined && inHeight !== undefined) {
29
+ return () => {};
30
+ }
31
+ computeSize();
32
+ const elementToObserve = rootRef.current;
33
+ if (typeof ResizeObserver === 'undefined') {
34
+ return () => {};
35
+ }
36
+ let animationFrame;
37
+ const observer = new ResizeObserver(() => {
38
+ // See https://github.com/mui/mui-x/issues/8733
39
+ animationFrame = requestAnimationFrame(() => {
40
+ computeSize();
41
+ });
42
+ });
43
+ if (elementToObserve) {
44
+ observer.observe(elementToObserve);
45
+ }
46
+ return () => {
47
+ if (animationFrame) {
48
+ window.cancelAnimationFrame(animationFrame);
49
+ }
50
+ if (elementToObserve) {
51
+ observer.unobserve(elementToObserve);
52
+ }
53
+ };
54
+ }, [computeSize, inHeight, inWidth]);
55
+ if (process.env.NODE_ENV !== 'production') {
56
+ if (displayError.current && inWidth === undefined && width === 0) {
57
+ console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
58
+ displayError.current = false;
59
+ }
60
+ if (displayError.current && inHeight === undefined && height === 0) {
61
+ console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
62
+ displayError.current = false;
63
+ }
64
+ }
65
+ return [rootRef, inWidth ?? width, inHeight ?? height];
66
+ };
@@ -8,6 +8,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
8
8
  import { ChartsLegend } from '../ChartsLegend';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
10
  import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
11
+ import { ChartsGrid } from '../ChartsGrid';
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
14
  /**
@@ -35,6 +36,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
35
36
  margin,
36
37
  colors,
37
38
  sx,
39
+ grid,
38
40
  topAxis,
39
41
  leftAxis,
40
42
  rightAxis,
@@ -66,6 +68,9 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
66
68
  bottomAxis: bottomAxis,
67
69
  slots: slots,
68
70
  slotProps: slotProps
71
+ }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
72
+ vertical: grid.vertical,
73
+ horizontal: grid.horizontal
69
74
  }), /*#__PURE__*/_jsx(ScatterPlot, {
70
75
  slots: slots,
71
76
  slotProps: slotProps,
@@ -86,6 +91,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
86
91
  // | These PropTypes are generated from the TypeScript type definitions |
87
92
  // | To update them edit the TypeScript types and run "yarn proptypes" |
88
93
  // ----------------------------------------------------------------------
94
+ /**
95
+ * The configuration of axes highlight.
96
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
97
+ * @default { x: 'none', y: 'none' }
98
+ */
89
99
  axisHighlight: PropTypes.shape({
90
100
  x: PropTypes.oneOf(['band', 'line', 'none']),
91
101
  y: PropTypes.oneOf(['band', 'line', 'none'])
@@ -96,7 +106,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
96
106
  * @default xAxisIds[0] The id of the first provided axis
97
107
  */
98
108
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
99
- axisId: PropTypes.string,
109
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
100
110
  classes: PropTypes.object,
101
111
  disableLine: PropTypes.bool,
102
112
  disableTicks: PropTypes.bool,
@@ -140,6 +150,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
140
150
  * @default false
141
151
  */
142
152
  disableVoronoi: PropTypes.bool,
153
+ /**
154
+ * Option to display a cartesian grid in the background.
155
+ */
156
+ grid: PropTypes.shape({
157
+ horizontal: PropTypes.bool,
158
+ vertical: PropTypes.bool
159
+ }),
143
160
  /**
144
161
  * The height of the chart in px. If not defined, it takes the height of the parent element.
145
162
  * @default undefined
@@ -151,7 +168,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
151
168
  * @default yAxisIds[0] The id of the first provided axis
152
169
  */
153
170
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
154
- axisId: PropTypes.string,
171
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
155
172
  classes: PropTypes.object,
156
173
  disableLine: PropTypes.bool,
157
174
  disableTicks: PropTypes.bool,
@@ -210,7 +227,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
210
227
  * @default null
211
228
  */
212
229
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
213
- axisId: PropTypes.string,
230
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
214
231
  classes: PropTypes.object,
215
232
  disableLine: PropTypes.bool,
216
233
  disableTicks: PropTypes.bool,
@@ -231,6 +248,9 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
231
248
  tickNumber: PropTypes.number,
232
249
  tickSize: PropTypes.number
233
250
  }), PropTypes.string]),
251
+ /**
252
+ * The series to display in the scatter chart.
253
+ */
234
254
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
235
255
  /**
236
256
  * The props used for each component slot.
@@ -244,6 +264,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
244
264
  slots: PropTypes.object,
245
265
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
246
266
  title: PropTypes.string,
267
+ /**
268
+ * The configuration of the tooltip.
269
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
270
+ * @default { trigger: 'item' }
271
+ */
247
272
  tooltip: PropTypes.shape({
248
273
  axisContent: PropTypes.elementType,
249
274
  classes: PropTypes.object,
@@ -258,7 +283,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
258
283
  * @default null
259
284
  */
260
285
  topAxis: PropTypes.oneOfType([PropTypes.shape({
261
- axisId: PropTypes.string,
286
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
262
287
  classes: PropTypes.object,
263
288
  disableLine: PropTypes.bool,
264
289
  disableTicks: PropTypes.bool,
@@ -301,7 +326,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
301
326
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
302
327
  */
303
328
  xAxis: PropTypes.arrayOf(PropTypes.shape({
304
- axisId: PropTypes.string,
329
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
305
330
  classes: PropTypes.object,
306
331
  data: PropTypes.array,
307
332
  dataKey: PropTypes.string,
@@ -309,13 +334,14 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
309
334
  disableTicks: PropTypes.bool,
310
335
  fill: PropTypes.string,
311
336
  hideTooltip: PropTypes.bool,
312
- id: PropTypes.string,
337
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
313
338
  label: PropTypes.string,
314
339
  labelFontSize: PropTypes.number,
315
340
  labelStyle: PropTypes.object,
316
341
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
317
342
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
318
343
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
344
+ reverse: PropTypes.bool,
319
345
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
320
346
  slotProps: PropTypes.object,
321
347
  slots: PropTypes.object,
@@ -335,7 +361,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
335
361
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
336
362
  */
337
363
  yAxis: PropTypes.arrayOf(PropTypes.shape({
338
- axisId: PropTypes.string,
364
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
339
365
  classes: PropTypes.object,
340
366
  data: PropTypes.array,
341
367
  dataKey: PropTypes.string,
@@ -343,13 +369,14 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
343
369
  disableTicks: PropTypes.bool,
344
370
  fill: PropTypes.string,
345
371
  hideTooltip: PropTypes.bool,
346
- id: PropTypes.string,
372
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
347
373
  label: PropTypes.string,
348
374
  labelFontSize: PropTypes.number,
349
375
  labelStyle: PropTypes.object,
350
376
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
351
377
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
352
378
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
379
+ reverse: PropTypes.bool,
353
380
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
354
381
  slotProps: PropTypes.object,
355
382
  slots: PropTypes.object,
@@ -42,7 +42,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
42
42
  slotProps,
43
43
  data,
44
44
  plotType = 'line',
45
- valueFormatter = v => v === null ? '' : v.toString(),
45
+ valueFormatter = value => value === null ? '' : value.toString(),
46
46
  area,
47
47
  curve = 'linear'
48
48
  } = props;
@@ -207,7 +207,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
207
207
  * Formatter used by the tooltip.
208
208
  * @param {number} value The value to format.
209
209
  * @returns {string} the formatted value.
210
- * @default (v: number | null) => (v === null ? '' : v.toString())
210
+ * @default (value: number | null) => (value === null ? '' : value.toString())
211
211
  */
212
212
  valueFormatter: PropTypes.func,
213
213
  viewBox: PropTypes.shape({
@@ -226,7 +226,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
226
226
  * Notice it is a single configuration object, not an array of configuration.
227
227
  */
228
228
  xAxis: PropTypes.shape({
229
- axisId: PropTypes.string,
229
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
230
230
  classes: PropTypes.object,
231
231
  data: PropTypes.array,
232
232
  dataKey: PropTypes.string,
@@ -234,13 +234,14 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
234
234
  disableTicks: PropTypes.bool,
235
235
  fill: PropTypes.string,
236
236
  hideTooltip: PropTypes.bool,
237
- id: PropTypes.string,
237
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
238
238
  label: PropTypes.string,
239
239
  labelFontSize: PropTypes.number,
240
240
  labelStyle: PropTypes.object,
241
241
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
242
242
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
243
243
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
244
+ reverse: PropTypes.bool,
244
245
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
245
246
  slotProps: PropTypes.object,
246
247
  slots: PropTypes.object,
@@ -107,7 +107,7 @@ function CartesianContextProvider(props) {
107
107
  allXAxis.forEach((axis, axisIndex) => {
108
108
  const isDefaultAxis = axisIndex === 0;
109
109
  const [minData, maxData] = getAxisExtremum(axis, xExtremumGetters, isDefaultAxis);
110
- const range = [drawingArea.left, drawingArea.left + drawingArea.width];
110
+ const range = axis.reverse ? [drawingArea.left + drawingArea.width, drawingArea.left] : [drawingArea.left, drawingArea.left + drawingArea.width];
111
111
  if (isBandScaleConfig(axis)) {
112
112
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
113
113
  const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
@@ -156,7 +156,7 @@ function CartesianContextProvider(props) {
156
156
  allYAxis.forEach((axis, axisIndex) => {
157
157
  const isDefaultAxis = axisIndex === 0;
158
158
  const [minData, maxData] = getAxisExtremum(axis, yExtremumGetters, isDefaultAxis);
159
- const range = [drawingArea.top + drawingArea.height, drawingArea.top];
159
+ const range = axis.reverse ? [drawingArea.top, drawingArea.top + drawingArea.height] : [drawingArea.top + drawingArea.height, drawingArea.top];
160
160
  if (isBandScaleConfig(axis)) {
161
161
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
162
162
  completedYAxis[axis.id] = _extends({
@@ -225,7 +225,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
225
225
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
226
226
  */
227
227
  xAxis: PropTypes.arrayOf(PropTypes.shape({
228
- axisId: PropTypes.string,
228
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
229
229
  classes: PropTypes.object,
230
230
  data: PropTypes.array,
231
231
  dataKey: PropTypes.string,
@@ -233,13 +233,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
233
233
  disableTicks: PropTypes.bool,
234
234
  fill: PropTypes.string,
235
235
  hideTooltip: PropTypes.bool,
236
- id: PropTypes.string,
236
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
237
237
  label: PropTypes.string,
238
238
  labelFontSize: PropTypes.number,
239
239
  labelStyle: PropTypes.object,
240
240
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
241
241
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
242
242
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
243
+ reverse: PropTypes.bool,
243
244
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
244
245
  slotProps: PropTypes.object,
245
246
  slots: PropTypes.object,
@@ -259,7 +260,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
259
260
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
260
261
  */
261
262
  yAxis: PropTypes.arrayOf(PropTypes.shape({
262
- axisId: PropTypes.string,
263
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
263
264
  classes: PropTypes.object,
264
265
  data: PropTypes.array,
265
266
  dataKey: PropTypes.string,
@@ -267,13 +268,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
267
268
  disableTicks: PropTypes.bool,
268
269
  fill: PropTypes.string,
269
270
  hideTooltip: PropTypes.bool,
270
- id: PropTypes.string,
271
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
271
272
  label: PropTypes.string,
272
273
  labelFontSize: PropTypes.number,
273
274
  labelStyle: PropTypes.object,
274
275
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
275
276
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
276
277
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
278
+ reverse: PropTypes.bool,
277
279
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
278
280
  slotProps: PropTypes.object,
279
281
  slots: PropTypes.object,
@@ -13,7 +13,7 @@ export function getTickNumber(params) {
13
13
  const defaultizedTickNumber = tickNumber ?? Math.floor(Math.abs(range[1] - range[0]) / 50);
14
14
  return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
15
15
  }
16
- function useTicks(options) {
16
+ export function useTicks(options) {
17
17
  const {
18
18
  scale,
19
19
  tickNumber,
@@ -55,5 +55,4 @@ function useTicks(options) {
55
55
  labelOffset: 0
56
56
  }));
57
57
  }, [tickNumber, scale, valueFormatter, tickInterval]);
58
- }
59
- export default useTicks;
58
+ }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-beta.1
2
+ * @mui/x-charts v7.0.0-beta.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -15,6 +15,7 @@ export * from './ChartsReferenceLine';
15
15
  export * from './ChartsAxis';
16
16
  export * from './ChartsXAxis';
17
17
  export * from './ChartsYAxis';
18
+ export * from './ChartsGrid';
18
19
  export * from './ChartsText';
19
20
  export * from './ChartsTooltip';
20
21
  export * from './ChartsLegend';
@@ -26,6 +27,7 @@ export * from './LineChart';
26
27
  export * from './PieChart';
27
28
  export * from './ScatterChart';
28
29
  export * from './SparkLineChart';
30
+ export * from './Gauge';
29
31
  export * from './ChartContainer';
30
32
  export * from './ChartsSurface';
31
33
  export * from './ResponsiveChartContainer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "7.0.0-beta.1",
3
+ "version": "7.0.0-beta.3",
4
4
  "description": "The community edition of the charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.23.9",
32
- "@mui/base": "^5.0.0-beta.34",
33
- "@mui/system": "^5.15.7",
34
- "@mui/utils": "^5.15.7",
32
+ "@mui/base": "^5.0.0-beta.36",
33
+ "@mui/system": "^5.15.9",
34
+ "@mui/utils": "^5.15.9",
35
35
  "@react-spring/rafz": "^9.7.3",
36
36
  "@react-spring/web": "^9.7.3",
37
37
  "clsx": "^2.1.0",