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