@mui/x-charts 7.0.0-alpha.9 → 7.0.0-beta.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 (62) hide show
  1. package/BarChart/BarChart.js +1 -19
  2. package/CHANGELOG.md +139 -38
  3. package/ChartContainer/ChartContainer.d.ts +12 -0
  4. package/ChartContainer/ChartContainer.js +197 -0
  5. package/ChartContainer/index.d.ts +1 -11
  6. package/ChartContainer/index.js +9 -63
  7. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  8. package/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
  9. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  10. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
  11. package/LineChart/LineChart.js +1 -23
  12. package/PieChart/PieChart.js +1 -46
  13. package/README.md +2 -2
  14. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +16 -0
  15. package/ResponsiveChartContainer/ResponsiveChartContainer.js +250 -0
  16. package/ResponsiveChartContainer/index.d.ts +1 -15
  17. package/ResponsiveChartContainer/index.js +8 -113
  18. package/ScatterChart/Scatter.js +1 -20
  19. package/ScatterChart/ScatterChart.js +1 -20
  20. package/esm/BarChart/BarChart.js +1 -19
  21. package/esm/ChartContainer/ChartContainer.js +189 -0
  22. package/esm/ChartContainer/index.js +1 -61
  23. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  24. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
  25. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  26. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
  27. package/esm/LineChart/LineChart.js +1 -23
  28. package/esm/PieChart/PieChart.js +1 -46
  29. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +245 -0
  30. package/esm/ResponsiveChartContainer/index.js +1 -115
  31. package/esm/ScatterChart/Scatter.js +1 -20
  32. package/esm/ScatterChart/ScatterChart.js +1 -20
  33. package/index.js +1 -1
  34. package/legacy/BarChart/BarChart.js +1 -19
  35. package/legacy/ChartContainer/ChartContainer.js +187 -0
  36. package/legacy/ChartContainer/index.js +1 -59
  37. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  38. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
  39. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  40. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
  41. package/legacy/LineChart/LineChart.js +1 -23
  42. package/legacy/PieChart/PieChart.js +1 -46
  43. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +253 -0
  44. package/legacy/ResponsiveChartContainer/index.js +1 -123
  45. package/legacy/ScatterChart/Scatter.js +1 -20
  46. package/legacy/ScatterChart/ScatterChart.js +1 -20
  47. package/legacy/index.js +1 -1
  48. package/modern/BarChart/BarChart.js +1 -19
  49. package/modern/ChartContainer/ChartContainer.js +189 -0
  50. package/modern/ChartContainer/index.js +1 -61
  51. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  52. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
  53. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  54. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
  55. package/modern/LineChart/LineChart.js +1 -23
  56. package/modern/PieChart/PieChart.js +1 -46
  57. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +242 -0
  58. package/modern/ResponsiveChartContainer/index.js +1 -112
  59. package/modern/ScatterChart/Scatter.js +1 -20
  60. package/modern/ScatterChart/ScatterChart.js +1 -20
  61. package/modern/index.js +1 -1
  62. package/package.json +4 -4
@@ -0,0 +1,253 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ var _excluded = ["width", "height"];
5
+ import * as React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
8
+ import ownerWindow from '@mui/utils/ownerWindow';
9
+ import { styled } from '@mui/material/styles';
10
+ import { ChartContainer } from '../ChartContainer';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ var useChartDimensions = function useChartDimensions(inWidth, inHeight) {
13
+ var rootRef = React.useRef(null);
14
+ var displayError = React.useRef(false);
15
+ var _React$useState = React.useState(0),
16
+ _React$useState2 = _slicedToArray(_React$useState, 2),
17
+ width = _React$useState2[0],
18
+ setWidth = _React$useState2[1];
19
+ var _React$useState3 = React.useState(0),
20
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
21
+ height = _React$useState4[0],
22
+ setHeight = _React$useState4[1];
23
+
24
+ // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
25
+ var computeSize = React.useCallback(function () {
26
+ var mainEl = rootRef == null ? void 0 : rootRef.current;
27
+ if (!mainEl) {
28
+ return;
29
+ }
30
+ var win = ownerWindow(mainEl);
31
+ var computedStyle = win.getComputedStyle(mainEl);
32
+ var newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
33
+ var newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
34
+ setWidth(newWidth);
35
+ setHeight(newHeight);
36
+ }, []);
37
+ React.useEffect(function () {
38
+ // Ensure the error detection occurs after the first rendering.
39
+ displayError.current = true;
40
+ }, []);
41
+ useEnhancedEffect(function () {
42
+ if (inWidth !== undefined && inHeight !== undefined) {
43
+ return function () {};
44
+ }
45
+ computeSize();
46
+ var elementToObserve = rootRef.current;
47
+ if (typeof ResizeObserver === 'undefined') {
48
+ return function () {};
49
+ }
50
+ var animationFrame;
51
+ var observer = new ResizeObserver(function () {
52
+ // See https://github.com/mui/mui-x/issues/8733
53
+ animationFrame = requestAnimationFrame(function () {
54
+ computeSize();
55
+ });
56
+ });
57
+ if (elementToObserve) {
58
+ observer.observe(elementToObserve);
59
+ }
60
+ return function () {
61
+ if (animationFrame) {
62
+ window.cancelAnimationFrame(animationFrame);
63
+ }
64
+ if (elementToObserve) {
65
+ observer.unobserve(elementToObserve);
66
+ }
67
+ };
68
+ }, [computeSize, inHeight, inWidth]);
69
+ if (process.env.NODE_ENV !== 'production') {
70
+ if (displayError.current && inWidth === undefined && width === 0) {
71
+ console.error("MUI X Charts: ChartContainer does not have `width` prop, and its container has no `width` defined.");
72
+ displayError.current = false;
73
+ }
74
+ if (displayError.current && inHeight === undefined && height === 0) {
75
+ console.error("MUI X Charts: ChartContainer does not have `height` prop, and its container has no `height` defined.");
76
+ displayError.current = false;
77
+ }
78
+ }
79
+ return [rootRef, inWidth != null ? inWidth : width, inHeight != null ? inHeight : height];
80
+ };
81
+ var ResizableContainer = styled('div', {
82
+ name: 'MuiResponsiveChart',
83
+ slot: 'Container'
84
+ })(function (_ref) {
85
+ var _ownerState$width, _ownerState$height;
86
+ var ownerState = _ref.ownerState;
87
+ return {
88
+ width: (_ownerState$width = ownerState.width) != null ? _ownerState$width : '100%',
89
+ height: (_ownerState$height = ownerState.height) != null ? _ownerState$height : '100%',
90
+ display: 'flex',
91
+ position: 'relative',
92
+ flexGrow: 1,
93
+ flexDirection: 'column',
94
+ alignItems: 'center',
95
+ justifyContent: 'center',
96
+ overflow: 'hidden',
97
+ '&>svg': {
98
+ width: '100%',
99
+ height: '100%'
100
+ }
101
+ };
102
+ });
103
+ var ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
104
+ var inWidth = props.width,
105
+ inHeight = props.height,
106
+ other = _objectWithoutProperties(props, _excluded);
107
+ var _useChartDimensions = useChartDimensions(inWidth, inHeight),
108
+ _useChartDimensions2 = _slicedToArray(_useChartDimensions, 3),
109
+ containerRef = _useChartDimensions2[0],
110
+ width = _useChartDimensions2[1],
111
+ height = _useChartDimensions2[2];
112
+ return /*#__PURE__*/_jsx(ResizableContainer, {
113
+ ref: containerRef,
114
+ ownerState: {
115
+ width: inWidth,
116
+ height: inHeight
117
+ },
118
+ children: width && height ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, other, {
119
+ width: width,
120
+ height: height,
121
+ ref: ref
122
+ })) : null
123
+ });
124
+ });
125
+ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
126
+ // ----------------------------- Warning --------------------------------
127
+ // | These PropTypes are generated from the TypeScript type definitions |
128
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
129
+ // ----------------------------------------------------------------------
130
+ children: PropTypes.node,
131
+ className: PropTypes.string,
132
+ /**
133
+ * Color palette used to colorize multiple series.
134
+ * @default blueberryTwilightPalette
135
+ */
136
+ colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
137
+ /**
138
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
139
+ */
140
+ dataset: PropTypes.arrayOf(PropTypes.object),
141
+ desc: PropTypes.string,
142
+ /**
143
+ * If `true`, the charts will not listen to the mouse move event.
144
+ * It might break interactive features, but will improve performance.
145
+ * @default false
146
+ */
147
+ disableAxisListener: PropTypes.bool,
148
+ /**
149
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
150
+ * @default undefined
151
+ */
152
+ height: PropTypes.number,
153
+ /**
154
+ * The margin between the SVG and the drawing area.
155
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
156
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
157
+ * @default object Depends on the charts type.
158
+ */
159
+ margin: PropTypes.shape({
160
+ bottom: PropTypes.number,
161
+ left: PropTypes.number,
162
+ right: PropTypes.number,
163
+ top: PropTypes.number
164
+ }),
165
+ /**
166
+ * The array of series to display.
167
+ * Each type of series has its own specificity.
168
+ * Please refer to the appropriate docs page to learn more about it.
169
+ */
170
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
171
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
172
+ title: PropTypes.string,
173
+ viewBox: PropTypes.shape({
174
+ height: PropTypes.number,
175
+ width: PropTypes.number,
176
+ x: PropTypes.number,
177
+ y: PropTypes.number
178
+ }),
179
+ /**
180
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
181
+ * @default undefined
182
+ */
183
+ width: PropTypes.number,
184
+ /**
185
+ * The configuration of the x-axes.
186
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
187
+ */
188
+ xAxis: PropTypes.arrayOf(PropTypes.shape({
189
+ axisId: PropTypes.string,
190
+ classes: PropTypes.object,
191
+ data: PropTypes.array,
192
+ dataKey: PropTypes.string,
193
+ disableLine: PropTypes.bool,
194
+ disableTicks: PropTypes.bool,
195
+ fill: PropTypes.string,
196
+ hideTooltip: PropTypes.bool,
197
+ id: PropTypes.string,
198
+ label: PropTypes.string,
199
+ labelFontSize: PropTypes.number,
200
+ labelStyle: PropTypes.object,
201
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
202
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
203
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
204
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
205
+ slotProps: PropTypes.object,
206
+ slots: PropTypes.object,
207
+ stroke: PropTypes.string,
208
+ tickFontSize: PropTypes.number,
209
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
210
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
211
+ tickLabelStyle: PropTypes.object,
212
+ tickMaxStep: PropTypes.number,
213
+ tickMinStep: PropTypes.number,
214
+ tickNumber: PropTypes.number,
215
+ tickSize: PropTypes.number,
216
+ valueFormatter: PropTypes.func
217
+ })),
218
+ /**
219
+ * The configuration of the y-axes.
220
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
221
+ */
222
+ yAxis: PropTypes.arrayOf(PropTypes.shape({
223
+ axisId: PropTypes.string,
224
+ classes: PropTypes.object,
225
+ data: PropTypes.array,
226
+ dataKey: PropTypes.string,
227
+ disableLine: PropTypes.bool,
228
+ disableTicks: PropTypes.bool,
229
+ fill: PropTypes.string,
230
+ hideTooltip: PropTypes.bool,
231
+ id: PropTypes.string,
232
+ label: PropTypes.string,
233
+ labelFontSize: PropTypes.number,
234
+ labelStyle: PropTypes.object,
235
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
236
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
237
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
238
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
239
+ slotProps: PropTypes.object,
240
+ slots: PropTypes.object,
241
+ stroke: PropTypes.string,
242
+ tickFontSize: PropTypes.number,
243
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
244
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
245
+ tickLabelStyle: PropTypes.object,
246
+ tickMaxStep: PropTypes.number,
247
+ tickMinStep: PropTypes.number,
248
+ tickNumber: PropTypes.number,
249
+ tickSize: PropTypes.number,
250
+ valueFormatter: PropTypes.func
251
+ }))
252
+ } : void 0;
253
+ export { ResponsiveChartContainer };
@@ -1,123 +1 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- var _excluded = ["width", "height"];
5
- import * as React from 'react';
6
- import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
- import ownerWindow from '@mui/utils/ownerWindow';
8
- import { styled } from '@mui/material/styles';
9
- import { ChartContainer } from '../ChartContainer';
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- var useChartDimensions = function useChartDimensions(inWidth, inHeight) {
12
- var rootRef = React.useRef(null);
13
- var displayError = React.useRef(false);
14
- var _React$useState = React.useState(0),
15
- _React$useState2 = _slicedToArray(_React$useState, 2),
16
- width = _React$useState2[0],
17
- setWidth = _React$useState2[1];
18
- var _React$useState3 = React.useState(0),
19
- _React$useState4 = _slicedToArray(_React$useState3, 2),
20
- height = _React$useState4[0],
21
- setHeight = _React$useState4[1];
22
-
23
- // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
24
- var computeSize = React.useCallback(function () {
25
- var mainEl = rootRef == null ? void 0 : rootRef.current;
26
- if (!mainEl) {
27
- return;
28
- }
29
- var win = ownerWindow(mainEl);
30
- var computedStyle = win.getComputedStyle(mainEl);
31
- var newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
32
- var newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
33
- setWidth(newWidth);
34
- setHeight(newHeight);
35
- }, []);
36
- React.useEffect(function () {
37
- // Ensure the error detection occurs after the first rendering.
38
- displayError.current = true;
39
- }, []);
40
- useEnhancedEffect(function () {
41
- if (inWidth !== undefined && inHeight !== undefined) {
42
- return function () {};
43
- }
44
- computeSize();
45
- var elementToObserve = rootRef.current;
46
- if (typeof ResizeObserver === 'undefined') {
47
- return function () {};
48
- }
49
- var animationFrame;
50
- var observer = new ResizeObserver(function () {
51
- // See https://github.com/mui/mui-x/issues/8733
52
- animationFrame = requestAnimationFrame(function () {
53
- computeSize();
54
- });
55
- });
56
- if (elementToObserve) {
57
- observer.observe(elementToObserve);
58
- }
59
- return function () {
60
- if (animationFrame) {
61
- window.cancelAnimationFrame(animationFrame);
62
- }
63
- if (elementToObserve) {
64
- observer.unobserve(elementToObserve);
65
- }
66
- };
67
- }, [computeSize, inHeight, inWidth]);
68
- if (process.env.NODE_ENV !== 'production') {
69
- if (displayError.current && inWidth === undefined && width === 0) {
70
- console.error("MUI X Charts: ChartContainer does not have `width` prop, and its container has no `width` defined.");
71
- displayError.current = false;
72
- }
73
- if (displayError.current && inHeight === undefined && height === 0) {
74
- console.error("MUI X Charts: ChartContainer does not have `height` prop, and its container has no `height` defined.");
75
- displayError.current = false;
76
- }
77
- }
78
- return [rootRef, inWidth != null ? inWidth : width, inHeight != null ? inHeight : height];
79
- };
80
- var ResizableContainer = styled('div', {
81
- name: 'MuiResponsiveChart',
82
- slot: 'Container'
83
- })(function (_ref) {
84
- var _ownerState$width, _ownerState$height;
85
- var ownerState = _ref.ownerState;
86
- return {
87
- width: (_ownerState$width = ownerState.width) != null ? _ownerState$width : '100%',
88
- height: (_ownerState$height = ownerState.height) != null ? _ownerState$height : '100%',
89
- display: 'flex',
90
- position: 'relative',
91
- flexGrow: 1,
92
- flexDirection: 'column',
93
- alignItems: 'center',
94
- justifyContent: 'center',
95
- overflow: 'hidden',
96
- '&>svg': {
97
- width: '100%',
98
- height: '100%'
99
- }
100
- };
101
- });
102
- export var ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
103
- var inWidth = props.width,
104
- inHeight = props.height,
105
- other = _objectWithoutProperties(props, _excluded);
106
- var _useChartDimensions = useChartDimensions(inWidth, inHeight),
107
- _useChartDimensions2 = _slicedToArray(_useChartDimensions, 3),
108
- containerRef = _useChartDimensions2[0],
109
- width = _useChartDimensions2[1],
110
- height = _useChartDimensions2[2];
111
- return /*#__PURE__*/_jsx(ResizableContainer, {
112
- ref: containerRef,
113
- ownerState: {
114
- width: inWidth,
115
- height: inHeight
116
- },
117
- children: width && height ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, other, {
118
- width: width,
119
- height: height,
120
- ref: ref
121
- })) : null
122
- });
123
- });
1
+ export * from './ResponsiveChartContainer';
@@ -87,26 +87,7 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
87
87
  // ----------------------------------------------------------------------
88
88
  color: PropTypes.string.isRequired,
89
89
  markerSize: PropTypes.number.isRequired,
90
- series: PropTypes.shape({
91
- color: PropTypes.string.isRequired,
92
- data: PropTypes.arrayOf(PropTypes.shape({
93
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
94
- x: PropTypes.number.isRequired,
95
- y: PropTypes.number.isRequired
96
- })).isRequired,
97
- disableHover: PropTypes.bool,
98
- highlightScope: PropTypes.shape({
99
- faded: PropTypes.oneOf(['global', 'none', 'series']),
100
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
101
- }),
102
- id: PropTypes.string.isRequired,
103
- label: PropTypes.string,
104
- markerSize: PropTypes.number,
105
- type: PropTypes.oneOf(['scatter']).isRequired,
106
- valueFormatter: PropTypes.func.isRequired,
107
- xAxisKey: PropTypes.string,
108
- yAxisKey: PropTypes.string
109
- }).isRequired,
90
+ series: PropTypes.object.isRequired,
110
91
  xScale: PropTypes.func.isRequired,
111
92
  yScale: PropTypes.func.isRequired
112
93
  } : void 0;
@@ -222,26 +222,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
222
222
  tickNumber: PropTypes.number,
223
223
  tickSize: PropTypes.number
224
224
  }), PropTypes.string]),
225
- series: PropTypes.arrayOf(PropTypes.shape({
226
- color: PropTypes.string,
227
- data: PropTypes.arrayOf(PropTypes.shape({
228
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
229
- x: PropTypes.number.isRequired,
230
- y: PropTypes.number.isRequired
231
- })).isRequired,
232
- disableHover: PropTypes.bool,
233
- highlightScope: PropTypes.shape({
234
- faded: PropTypes.oneOf(['global', 'none', 'series']),
235
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
236
- }),
237
- id: PropTypes.string,
238
- label: PropTypes.string,
239
- markerSize: PropTypes.number,
240
- type: PropTypes.oneOf(['scatter']),
241
- valueFormatter: PropTypes.func,
242
- xAxisKey: PropTypes.string,
243
- yAxisKey: PropTypes.string
244
- })).isRequired,
225
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
245
226
  /**
246
227
  * The props used for each component slot.
247
228
  * @default {}
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-alpha.9
2
+ * @mui/x-charts v7.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -253,25 +253,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
253
253
  tickNumber: PropTypes.number,
254
254
  tickSize: PropTypes.number
255
255
  }), PropTypes.string]),
256
- series: PropTypes.arrayOf(PropTypes.shape({
257
- color: PropTypes.string,
258
- data: PropTypes.arrayOf(PropTypes.number),
259
- dataKey: PropTypes.string,
260
- highlightScope: PropTypes.shape({
261
- faded: PropTypes.oneOf(['global', 'none', 'series']),
262
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
263
- }),
264
- id: PropTypes.string,
265
- label: PropTypes.string,
266
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
267
- stack: PropTypes.string,
268
- stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
269
- stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
270
- type: PropTypes.oneOf(['bar']),
271
- valueFormatter: PropTypes.func,
272
- xAxisKey: PropTypes.string,
273
- yAxisKey: PropTypes.string
274
- })).isRequired,
256
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
275
257
  /**
276
258
  * If `true`, animations are skiped.
277
259
  * @default false
@@ -0,0 +1,189 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import useForkRef from '@mui/utils/useForkRef';
4
+ import { DrawingProvider } from '../context/DrawingProvider';
5
+ import { SeriesContextProvider } from '../context/SeriesContextProvider';
6
+ import { InteractionProvider } from '../context/InteractionProvider';
7
+ import { useReducedMotion } from '../hooks/useReducedMotion';
8
+ import { ChartsSurface } from '../ChartsSurface';
9
+ import { CartesianContextProvider } from '../context/CartesianContextProvider';
10
+ import { HighlightProvider } from '../context/HighlightProvider';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
13
+ const {
14
+ width,
15
+ height,
16
+ series,
17
+ margin,
18
+ xAxis,
19
+ yAxis,
20
+ colors,
21
+ dataset,
22
+ sx,
23
+ title,
24
+ desc,
25
+ disableAxisListener,
26
+ children
27
+ } = props;
28
+ const svgRef = React.useRef(null);
29
+ const handleRef = useForkRef(ref, svgRef);
30
+ useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
31
+
32
+ return /*#__PURE__*/_jsx(DrawingProvider, {
33
+ width: width,
34
+ height: height,
35
+ margin: margin,
36
+ svgRef: svgRef,
37
+ children: /*#__PURE__*/_jsx(SeriesContextProvider, {
38
+ series: series,
39
+ colors: colors,
40
+ dataset: dataset,
41
+ children: /*#__PURE__*/_jsx(CartesianContextProvider, {
42
+ xAxis: xAxis,
43
+ yAxis: yAxis,
44
+ dataset: dataset,
45
+ children: /*#__PURE__*/_jsx(InteractionProvider, {
46
+ children: /*#__PURE__*/_jsx(HighlightProvider, {
47
+ children: /*#__PURE__*/_jsx(ChartsSurface, {
48
+ width: width,
49
+ height: height,
50
+ ref: handleRef,
51
+ sx: sx,
52
+ title: title,
53
+ desc: desc,
54
+ disableAxisListener: disableAxisListener,
55
+ children: children
56
+ })
57
+ })
58
+ })
59
+ })
60
+ })
61
+ });
62
+ });
63
+ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
64
+ // ----------------------------- Warning --------------------------------
65
+ // | These PropTypes are generated from the TypeScript type definitions |
66
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
67
+ // ----------------------------------------------------------------------
68
+ children: PropTypes.node,
69
+ className: PropTypes.string,
70
+ /**
71
+ * Color palette used to colorize multiple series.
72
+ * @default blueberryTwilightPalette
73
+ */
74
+ colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
75
+ /**
76
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
77
+ */
78
+ dataset: PropTypes.arrayOf(PropTypes.object),
79
+ desc: PropTypes.string,
80
+ /**
81
+ * If `true`, the charts will not listen to the mouse move event.
82
+ * It might break interactive features, but will improve performance.
83
+ * @default false
84
+ */
85
+ disableAxisListener: PropTypes.bool,
86
+ /**
87
+ * The height of the chart in px.
88
+ */
89
+ height: PropTypes.number.isRequired,
90
+ /**
91
+ * The margin between the SVG and the drawing area.
92
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
93
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
94
+ * @default object Depends on the charts type.
95
+ */
96
+ margin: PropTypes.shape({
97
+ bottom: PropTypes.number,
98
+ left: PropTypes.number,
99
+ right: PropTypes.number,
100
+ top: PropTypes.number
101
+ }),
102
+ /**
103
+ * The array of series to display.
104
+ * Each type of series has its own specificity.
105
+ * Please refer to the appropriate docs page to learn more about it.
106
+ */
107
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
108
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
109
+ title: PropTypes.string,
110
+ viewBox: PropTypes.shape({
111
+ height: PropTypes.number,
112
+ width: PropTypes.number,
113
+ x: PropTypes.number,
114
+ y: PropTypes.number
115
+ }),
116
+ /**
117
+ * The width of the chart in px.
118
+ */
119
+ width: PropTypes.number.isRequired,
120
+ /**
121
+ * The configuration of the x-axes.
122
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
123
+ */
124
+ xAxis: PropTypes.arrayOf(PropTypes.shape({
125
+ axisId: PropTypes.string,
126
+ classes: PropTypes.object,
127
+ data: PropTypes.array,
128
+ dataKey: PropTypes.string,
129
+ disableLine: PropTypes.bool,
130
+ disableTicks: PropTypes.bool,
131
+ fill: PropTypes.string,
132
+ hideTooltip: PropTypes.bool,
133
+ id: PropTypes.string,
134
+ label: PropTypes.string,
135
+ labelFontSize: PropTypes.number,
136
+ labelStyle: PropTypes.object,
137
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
138
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
139
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
140
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
141
+ slotProps: PropTypes.object,
142
+ slots: PropTypes.object,
143
+ stroke: PropTypes.string,
144
+ tickFontSize: PropTypes.number,
145
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
146
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
147
+ tickLabelStyle: PropTypes.object,
148
+ tickMaxStep: PropTypes.number,
149
+ tickMinStep: PropTypes.number,
150
+ tickNumber: PropTypes.number,
151
+ tickSize: PropTypes.number,
152
+ valueFormatter: PropTypes.func
153
+ })),
154
+ /**
155
+ * The configuration of the y-axes.
156
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
157
+ */
158
+ yAxis: PropTypes.arrayOf(PropTypes.shape({
159
+ axisId: PropTypes.string,
160
+ classes: PropTypes.object,
161
+ data: PropTypes.array,
162
+ dataKey: PropTypes.string,
163
+ disableLine: PropTypes.bool,
164
+ disableTicks: PropTypes.bool,
165
+ fill: PropTypes.string,
166
+ hideTooltip: PropTypes.bool,
167
+ id: PropTypes.string,
168
+ label: PropTypes.string,
169
+ labelFontSize: PropTypes.number,
170
+ labelStyle: PropTypes.object,
171
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
172
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
173
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
174
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
175
+ slotProps: PropTypes.object,
176
+ slots: PropTypes.object,
177
+ stroke: PropTypes.string,
178
+ tickFontSize: PropTypes.number,
179
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
180
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
181
+ tickLabelStyle: PropTypes.object,
182
+ tickMaxStep: PropTypes.number,
183
+ tickMinStep: PropTypes.number,
184
+ tickNumber: PropTypes.number,
185
+ tickSize: PropTypes.number,
186
+ valueFormatter: PropTypes.func
187
+ }))
188
+ } : void 0;
189
+ export { ChartContainer };