@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.
- package/BarChart/BarChart.d.ts +21 -5
- package/BarChart/BarChart.js +37 -13
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +1 -0
- package/BarChart/BarPlot.d.ts +3 -5
- package/BarChart/BarPlot.js +9 -10
- package/CHANGELOG.md +223 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsGrid/ChartsGrid.d.ts +30 -0
- package/ChartsGrid/ChartsGrid.js +128 -0
- package/ChartsGrid/chartsGridClasses.d.ts +13 -0
- package/ChartsGrid/chartsGridClasses.js +14 -0
- package/ChartsGrid/index.d.ts +2 -0
- package/ChartsGrid/index.js +27 -0
- package/ChartsGrid/package.json +6 -0
- package/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/common.d.ts +2 -1
- package/ChartsSurface.js +6 -4
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +1 -0
- package/ChartsTooltip/utils.js +7 -0
- package/ChartsXAxis/ChartsXAxis.js +15 -11
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- package/Gauge/Gauge.d.ts +13 -0
- package/Gauge/Gauge.js +156 -0
- package/Gauge/GaugeContainer.d.ts +19 -0
- package/Gauge/GaugeContainer.js +216 -0
- package/Gauge/GaugeProvider.d.ts +117 -0
- package/Gauge/GaugeProvider.js +96 -0
- package/Gauge/GaugeReferenceArc.d.ts +2 -0
- package/Gauge/GaugeReferenceArc.js +44 -0
- package/Gauge/GaugeValueArc.d.ts +2 -0
- package/Gauge/GaugeValueArc.js +51 -0
- package/Gauge/GaugeValueText.d.ts +15 -0
- package/Gauge/GaugeValueText.js +77 -0
- package/Gauge/gaugeClasses.d.ts +14 -0
- package/Gauge/gaugeClasses.js +15 -0
- package/Gauge/index.d.ts +7 -0
- package/Gauge/index.js +87 -0
- package/Gauge/package.json +6 -0
- package/Gauge/utils.d.ts +19 -0
- package/Gauge/utils.js +75 -0
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaElement.js +1 -1
- package/LineChart/LineChart.d.ts +24 -5
- package/LineChart/LineChart.js +41 -13
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineElement.js +1 -1
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +2 -1
- package/LineChart/MarkElement.d.ts +3 -2
- package/LineChart/MarkElement.js +1 -0
- package/PieChart/PieArc.d.ts +7 -6
- package/PieChart/PieArc.js +10 -9
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.js +14 -14
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.d.ts +22 -0
- package/PieChart/PieChart.js +32 -8
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
- package/ScatterChart/ScatterChart.d.ts +18 -0
- package/ScatterChart/ScatterChart.js +35 -8
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +5 -4
- package/context/CartesianContextProvider.js +8 -6
- package/esm/BarChart/BarChart.js +37 -13
- package/esm/BarChart/BarElement.js +1 -0
- package/esm/BarChart/BarPlot.js +8 -10
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsGrid/ChartsGrid.js +121 -0
- package/esm/ChartsGrid/chartsGridClasses.js +6 -0
- package/esm/ChartsGrid/index.js +2 -0
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsSurface.js +6 -4
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +14 -10
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/Gauge/Gauge.js +149 -0
- package/esm/Gauge/GaugeContainer.js +211 -0
- package/esm/Gauge/GaugeProvider.js +85 -0
- package/esm/Gauge/GaugeReferenceArc.js +35 -0
- package/esm/Gauge/GaugeValueArc.js +42 -0
- package/esm/Gauge/GaugeValueText.js +69 -0
- package/esm/Gauge/gaugeClasses.js +7 -0
- package/esm/Gauge/index.js +7 -0
- package/esm/Gauge/utils.js +68 -0
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +1 -1
- package/esm/LineChart/LineChart.js +41 -13
- package/esm/LineChart/LineElement.js +1 -1
- package/esm/LineChart/LineHighlightElement.js +2 -1
- package/esm/LineChart/MarkElement.js +1 -0
- package/esm/PieChart/PieArc.js +10 -9
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +14 -14
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +32 -8
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/esm/ScatterChart/ScatterChart.js +35 -8
- package/esm/SparkLineChart/SparkLineChart.js +5 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- package/esm/hooks/useTicks.js +2 -3
- package/esm/index.js +2 -0
- package/hooks/useTicks.d.ts +1 -2
- package/hooks/useTicks.js +2 -3
- package/index.d.ts +2 -0
- package/index.js +23 -1
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/stackSeries.d.ts +4 -7
- package/legacy/BarChart/BarChart.js +37 -13
- package/legacy/BarChart/BarElement.js +1 -0
- package/legacy/BarChart/BarPlot.js +10 -10
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsGrid/ChartsGrid.js +119 -0
- package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
- package/legacy/ChartsGrid/index.js +2 -0
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsSurface.js +5 -3
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsXAxis/ChartsXAxis.js +13 -9
- package/legacy/ChartsYAxis/ChartsYAxis.js +2 -2
- package/legacy/Gauge/Gauge.js +146 -0
- package/legacy/Gauge/GaugeContainer.js +215 -0
- package/legacy/Gauge/GaugeProvider.js +87 -0
- package/legacy/Gauge/GaugeReferenceArc.js +37 -0
- package/legacy/Gauge/GaugeValueArc.js +44 -0
- package/legacy/Gauge/GaugeValueText.js +66 -0
- package/legacy/Gauge/gaugeClasses.js +7 -0
- package/legacy/Gauge/index.js +7 -0
- package/legacy/Gauge/utils.js +84 -0
- package/legacy/LineChart/AnimatedArea.js +1 -1
- package/legacy/LineChart/AnimatedLine.js +1 -1
- package/legacy/LineChart/AreaElement.js +1 -1
- package/legacy/LineChart/LineChart.js +41 -13
- package/legacy/LineChart/LineElement.js +1 -1
- package/legacy/LineChart/LineHighlightElement.js +2 -1
- package/legacy/LineChart/MarkElement.js +1 -0
- package/legacy/PieChart/PieArc.js +11 -10
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +15 -15
- package/legacy/PieChart/PieArcPlot.js +1 -1
- package/legacy/PieChart/PieChart.js +32 -8
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -81
- package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
- package/legacy/ScatterChart/ScatterChart.js +35 -8
- package/legacy/SparkLineChart/SparkLineChart.js +6 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- package/legacy/hooks/useTicks.js +2 -3
- package/legacy/index.js +3 -1
- package/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +37 -13
- package/modern/BarChart/BarElement.js +1 -0
- package/modern/BarChart/BarPlot.js +8 -10
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsGrid/ChartsGrid.js +121 -0
- package/modern/ChartsGrid/chartsGridClasses.js +6 -0
- package/modern/ChartsGrid/index.js +2 -0
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsSurface.js +6 -4
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsXAxis/ChartsXAxis.js +14 -10
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/Gauge/Gauge.js +149 -0
- package/modern/Gauge/GaugeContainer.js +208 -0
- package/modern/Gauge/GaugeProvider.js +85 -0
- package/modern/Gauge/GaugeReferenceArc.js +35 -0
- package/modern/Gauge/GaugeValueArc.js +42 -0
- package/modern/Gauge/GaugeValueText.js +69 -0
- package/modern/Gauge/gaugeClasses.js +7 -0
- package/modern/Gauge/index.js +7 -0
- package/modern/Gauge/utils.js +68 -0
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +1 -1
- package/modern/LineChart/LineChart.js +41 -13
- package/modern/LineChart/LineElement.js +1 -1
- package/modern/LineChart/LineHighlightElement.js +2 -1
- package/modern/LineChart/MarkElement.js +1 -0
- package/modern/PieChart/PieArc.js +10 -9
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +14 -14
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +32 -8
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/modern/ScatterChart/ScatterChart.js +35 -8
- package/modern/SparkLineChart/SparkLineChart.js +5 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- package/modern/hooks/useTicks.js +2 -3
- package/modern/index.js +3 -1
- package/package.json +4 -4
|
@@ -13,6 +13,7 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
13
13
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
14
14
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
15
15
|
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
16
|
+
import { ChartsGrid } from '../ChartsGrid';
|
|
16
17
|
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -47,6 +48,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
47
48
|
},
|
|
48
49
|
disableLineItemHighlight,
|
|
49
50
|
legend,
|
|
51
|
+
grid,
|
|
50
52
|
topAxis,
|
|
51
53
|
leftAxis,
|
|
52
54
|
rightAxis,
|
|
@@ -84,6 +86,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
84
86
|
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
|
|
85
87
|
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
86
88
|
onAxisClick: onAxisClick
|
|
89
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
90
|
+
vertical: grid.vertical,
|
|
91
|
+
horizontal: grid.horizontal
|
|
87
92
|
}), /*#__PURE__*/_jsxs("g", {
|
|
88
93
|
clipPath: `url(#${clipPathId})`,
|
|
89
94
|
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
@@ -129,11 +134,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
129
134
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
130
135
|
// ----------------------------------------------------------------------
|
|
131
136
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* - 'none': display nothing.
|
|
135
|
-
* - 'line': display a line at the current mouse position.
|
|
136
|
-
* - 'band': display a band at the current mouse position. Only available with band scale.
|
|
137
|
+
* The configuration of axes highlight.
|
|
138
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
137
139
|
* @default { x: 'line' }
|
|
138
140
|
*/
|
|
139
141
|
axisHighlight: PropTypes.shape({
|
|
@@ -146,7 +148,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
146
148
|
* @default xAxisIds[0] The id of the first provided axis
|
|
147
149
|
*/
|
|
148
150
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
149
|
-
axisId: PropTypes.string,
|
|
151
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
150
152
|
classes: PropTypes.object,
|
|
151
153
|
disableLine: PropTypes.bool,
|
|
152
154
|
disableTicks: PropTypes.bool,
|
|
@@ -189,6 +191,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
189
191
|
* If `true`, render the line highlight item.
|
|
190
192
|
*/
|
|
191
193
|
disableLineItemHighlight: PropTypes.bool,
|
|
194
|
+
/**
|
|
195
|
+
* Option to display a cartesian grid in the background.
|
|
196
|
+
*/
|
|
197
|
+
grid: PropTypes.shape({
|
|
198
|
+
horizontal: PropTypes.bool,
|
|
199
|
+
vertical: PropTypes.bool
|
|
200
|
+
}),
|
|
192
201
|
/**
|
|
193
202
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
194
203
|
* @default undefined
|
|
@@ -200,7 +209,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
200
209
|
* @default yAxisIds[0] The id of the first provided axis
|
|
201
210
|
*/
|
|
202
211
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
203
|
-
axisId: PropTypes.string,
|
|
212
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
204
213
|
classes: PropTypes.object,
|
|
205
214
|
disableLine: PropTypes.bool,
|
|
206
215
|
disableTicks: PropTypes.bool,
|
|
@@ -247,6 +256,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
247
256
|
right: PropTypes.number,
|
|
248
257
|
top: PropTypes.number
|
|
249
258
|
}),
|
|
259
|
+
/**
|
|
260
|
+
* Callback fired when an area element is clicked.
|
|
261
|
+
*/
|
|
250
262
|
onAreaClick: PropTypes.func,
|
|
251
263
|
/**
|
|
252
264
|
* The function called for onClick events.
|
|
@@ -255,7 +267,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
255
267
|
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
256
268
|
*/
|
|
257
269
|
onAxisClick: PropTypes.func,
|
|
270
|
+
/**
|
|
271
|
+
* Callback fired when a line element is clicked.
|
|
272
|
+
*/
|
|
258
273
|
onLineClick: PropTypes.func,
|
|
274
|
+
/**
|
|
275
|
+
* Callback fired when a mark element is clicked.
|
|
276
|
+
*/
|
|
259
277
|
onMarkClick: PropTypes.func,
|
|
260
278
|
/**
|
|
261
279
|
* Indicate which axis to display the right of the charts.
|
|
@@ -263,7 +281,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
263
281
|
* @default null
|
|
264
282
|
*/
|
|
265
283
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
266
|
-
axisId: PropTypes.string,
|
|
284
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
267
285
|
classes: PropTypes.object,
|
|
268
286
|
disableLine: PropTypes.bool,
|
|
269
287
|
disableTicks: PropTypes.bool,
|
|
@@ -284,6 +302,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
284
302
|
tickNumber: PropTypes.number,
|
|
285
303
|
tickSize: PropTypes.number
|
|
286
304
|
}), PropTypes.string]),
|
|
305
|
+
/**
|
|
306
|
+
* The series to display in the line chart.
|
|
307
|
+
*/
|
|
287
308
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
288
309
|
/**
|
|
289
310
|
* If `true`, animations are skipped.
|
|
@@ -302,6 +323,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
302
323
|
slots: PropTypes.object,
|
|
303
324
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
304
325
|
title: PropTypes.string,
|
|
326
|
+
/**
|
|
327
|
+
* The configuration of the tooltip.
|
|
328
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
329
|
+
* @default { trigger: 'item' }
|
|
330
|
+
*/
|
|
305
331
|
tooltip: PropTypes.shape({
|
|
306
332
|
axisContent: PropTypes.elementType,
|
|
307
333
|
classes: PropTypes.object,
|
|
@@ -316,7 +342,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
316
342
|
* @default null
|
|
317
343
|
*/
|
|
318
344
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
319
|
-
axisId: PropTypes.string,
|
|
345
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
320
346
|
classes: PropTypes.object,
|
|
321
347
|
disableLine: PropTypes.bool,
|
|
322
348
|
disableTicks: PropTypes.bool,
|
|
@@ -353,7 +379,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
353
379
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
354
380
|
*/
|
|
355
381
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
356
|
-
axisId: PropTypes.string,
|
|
382
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
357
383
|
classes: PropTypes.object,
|
|
358
384
|
data: PropTypes.array,
|
|
359
385
|
dataKey: PropTypes.string,
|
|
@@ -361,13 +387,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
361
387
|
disableTicks: PropTypes.bool,
|
|
362
388
|
fill: PropTypes.string,
|
|
363
389
|
hideTooltip: PropTypes.bool,
|
|
364
|
-
id: PropTypes.string,
|
|
390
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
365
391
|
label: PropTypes.string,
|
|
366
392
|
labelFontSize: PropTypes.number,
|
|
367
393
|
labelStyle: PropTypes.object,
|
|
368
394
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
369
395
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
370
396
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
397
|
+
reverse: PropTypes.bool,
|
|
371
398
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
372
399
|
slotProps: PropTypes.object,
|
|
373
400
|
slots: PropTypes.object,
|
|
@@ -387,7 +414,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
387
414
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
388
415
|
*/
|
|
389
416
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
390
|
-
axisId: PropTypes.string,
|
|
417
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
391
418
|
classes: PropTypes.object,
|
|
392
419
|
data: PropTypes.array,
|
|
393
420
|
dataKey: PropTypes.string,
|
|
@@ -395,13 +422,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
395
422
|
disableTicks: PropTypes.bool,
|
|
396
423
|
fill: PropTypes.string,
|
|
397
424
|
hideTooltip: PropTypes.bool,
|
|
398
|
-
id: PropTypes.string,
|
|
425
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
399
426
|
label: PropTypes.string,
|
|
400
427
|
labelFontSize: PropTypes.number,
|
|
401
428
|
labelStyle: PropTypes.object,
|
|
402
429
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
403
430
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
404
431
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
432
|
+
reverse: PropTypes.bool,
|
|
405
433
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
406
434
|
slotProps: PropTypes.object,
|
|
407
435
|
slots: PropTypes.object,
|
|
@@ -97,7 +97,7 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
|
97
97
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
98
98
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
99
99
|
}),
|
|
100
|
-
id: PropTypes.string.isRequired,
|
|
100
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
101
101
|
/**
|
|
102
102
|
* If `true`, animations are skipped.
|
|
103
103
|
* @default false
|
|
@@ -74,6 +74,7 @@ process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
|
74
74
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
75
75
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
76
76
|
// ----------------------------------------------------------------------
|
|
77
|
-
classes: PropTypes.object
|
|
77
|
+
classes: PropTypes.object,
|
|
78
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
|
|
78
79
|
} : void 0;
|
|
79
80
|
export { LineHighlightElement };
|
|
@@ -137,6 +137,7 @@ process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
|
|
|
137
137
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
138
138
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
139
139
|
}),
|
|
140
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
140
141
|
/**
|
|
141
142
|
* The shape of the marker.
|
|
142
143
|
*/
|
package/esm/PieChart/PieArc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
3
|
+
const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "highlightScope", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { arc as d3Arc } from 'd3-shape';
|
|
@@ -40,20 +40,20 @@ const PieArcRoot = styled(animated.path, {
|
|
|
40
40
|
}));
|
|
41
41
|
function PieArc(props) {
|
|
42
42
|
const {
|
|
43
|
-
id,
|
|
44
|
-
dataIndex,
|
|
45
43
|
classes: innerClasses,
|
|
46
44
|
color,
|
|
45
|
+
cornerRadius,
|
|
46
|
+
dataIndex,
|
|
47
|
+
endAngle,
|
|
47
48
|
highlightScope,
|
|
48
|
-
|
|
49
|
+
id,
|
|
50
|
+
innerRadius,
|
|
49
51
|
isFaded,
|
|
50
52
|
isHighlighted,
|
|
51
|
-
|
|
52
|
-
endAngle,
|
|
53
|
-
paddingAngle,
|
|
54
|
-
innerRadius,
|
|
53
|
+
onClick,
|
|
55
54
|
outerRadius,
|
|
56
|
-
|
|
55
|
+
paddingAngle,
|
|
56
|
+
startAngle
|
|
57
57
|
} = props,
|
|
58
58
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
59
59
|
const ownerState = {
|
|
@@ -95,6 +95,7 @@ process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
|
|
|
95
95
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
96
96
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
97
97
|
}),
|
|
98
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
98
99
|
isFaded: PropTypes.bool.isRequired,
|
|
99
100
|
isHighlighted: PropTypes.bool.isRequired
|
|
100
101
|
} : void 0;
|
|
@@ -98,6 +98,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
|
98
98
|
// ----------------------------------------------------------------------
|
|
99
99
|
classes: PropTypes.object,
|
|
100
100
|
formattedArcLabel: PropTypes.string,
|
|
101
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
101
102
|
isFaded: PropTypes.bool.isRequired,
|
|
102
103
|
isHighlighted: PropTypes.bool.isRequired
|
|
103
104
|
} : void 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
3
|
+
const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "highlightScope", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
|
|
4
4
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -27,23 +27,23 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
27
27
|
function PieArcLabelPlot(props) {
|
|
28
28
|
var _slots$pieArcLabel;
|
|
29
29
|
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
innerRadius,
|
|
33
|
-
outerRadius,
|
|
30
|
+
arcLabel,
|
|
31
|
+
arcLabelMinAngle = 0,
|
|
34
32
|
arcLabelRadius,
|
|
35
33
|
cornerRadius = 0,
|
|
36
|
-
|
|
37
|
-
id,
|
|
38
|
-
highlightScope,
|
|
39
|
-
highlighted,
|
|
34
|
+
data,
|
|
40
35
|
faded = {
|
|
41
36
|
additionalRadius: -5
|
|
42
37
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
highlighted,
|
|
39
|
+
highlightScope,
|
|
40
|
+
id,
|
|
41
|
+
innerRadius,
|
|
42
|
+
outerRadius,
|
|
43
|
+
paddingAngle = 0,
|
|
44
|
+
skipAnimation,
|
|
45
|
+
slotProps,
|
|
46
|
+
slots
|
|
47
47
|
} = props,
|
|
48
48
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
49
49
|
const transformedData = useTransformData({
|
|
@@ -159,7 +159,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
159
159
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
160
160
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
161
161
|
}),
|
|
162
|
-
id: PropTypes.string.isRequired,
|
|
162
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
163
163
|
/**
|
|
164
164
|
* The radius between circle center and the begining of the arc.
|
|
165
165
|
* @default 0
|
|
@@ -138,7 +138,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
138
138
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
139
139
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
140
140
|
}),
|
|
141
|
-
id: PropTypes.string.isRequired,
|
|
141
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
142
142
|
/**
|
|
143
143
|
* The radius between circle center and the begining of the arc.
|
|
144
144
|
* @default 0
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -101,6 +101,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
101
101
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
102
102
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
103
103
|
// ----------------------------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* The configuration of axes highlight.
|
|
106
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
107
|
+
* @default { x: 'none', y: 'none' }
|
|
108
|
+
*/
|
|
104
109
|
axisHighlight: PropTypes.shape({
|
|
105
110
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
106
111
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
@@ -111,7 +116,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
111
116
|
* @default null
|
|
112
117
|
*/
|
|
113
118
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
114
|
-
axisId: PropTypes.string,
|
|
119
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
115
120
|
classes: PropTypes.object,
|
|
116
121
|
disableLine: PropTypes.bool,
|
|
117
122
|
disableTicks: PropTypes.bool,
|
|
@@ -161,7 +166,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
161
166
|
* @default null
|
|
162
167
|
*/
|
|
163
168
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
164
|
-
axisId: PropTypes.string,
|
|
169
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
165
170
|
classes: PropTypes.object,
|
|
166
171
|
disableLine: PropTypes.bool,
|
|
167
172
|
disableTicks: PropTypes.bool,
|
|
@@ -183,6 +188,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
183
188
|
tickSize: PropTypes.number
|
|
184
189
|
}), PropTypes.string]),
|
|
185
190
|
/**
|
|
191
|
+
* The props of the legend.
|
|
192
|
+
* @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
|
|
186
193
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
187
194
|
*/
|
|
188
195
|
legend: PropTypes.shape({
|
|
@@ -208,6 +215,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
208
215
|
right: PropTypes.number,
|
|
209
216
|
top: PropTypes.number
|
|
210
217
|
}),
|
|
218
|
+
/**
|
|
219
|
+
* Callback fired when a pie arc is clicked.
|
|
220
|
+
*/
|
|
211
221
|
onItemClick: PropTypes.func,
|
|
212
222
|
/**
|
|
213
223
|
* Indicate which axis to display the right of the charts.
|
|
@@ -215,7 +225,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
215
225
|
* @default null
|
|
216
226
|
*/
|
|
217
227
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
218
|
-
axisId: PropTypes.string,
|
|
228
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
219
229
|
classes: PropTypes.object,
|
|
220
230
|
disableLine: PropTypes.bool,
|
|
221
231
|
disableTicks: PropTypes.bool,
|
|
@@ -236,6 +246,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
236
246
|
tickNumber: PropTypes.number,
|
|
237
247
|
tickSize: PropTypes.number
|
|
238
248
|
}), PropTypes.string]),
|
|
249
|
+
/**
|
|
250
|
+
* The series to display in the pie chart.
|
|
251
|
+
*/
|
|
239
252
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
240
253
|
/**
|
|
241
254
|
* If `true`, animations are skipped.
|
|
@@ -247,9 +260,18 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
247
260
|
* @default {}
|
|
248
261
|
*/
|
|
249
262
|
slotProps: PropTypes.object,
|
|
263
|
+
/**
|
|
264
|
+
* Overridable component slots.
|
|
265
|
+
* @default {}
|
|
266
|
+
*/
|
|
250
267
|
slots: PropTypes.object,
|
|
251
268
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
252
269
|
title: PropTypes.string,
|
|
270
|
+
/**
|
|
271
|
+
* The configuration of the tooltip.
|
|
272
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
273
|
+
* @default { trigger: 'item' }
|
|
274
|
+
*/
|
|
253
275
|
tooltip: PropTypes.shape({
|
|
254
276
|
axisContent: PropTypes.elementType,
|
|
255
277
|
classes: PropTypes.object,
|
|
@@ -264,7 +286,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
264
286
|
* @default null
|
|
265
287
|
*/
|
|
266
288
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
267
|
-
axisId: PropTypes.string,
|
|
289
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
268
290
|
classes: PropTypes.object,
|
|
269
291
|
disableLine: PropTypes.bool,
|
|
270
292
|
disableTicks: PropTypes.bool,
|
|
@@ -301,7 +323,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
301
323
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
302
324
|
*/
|
|
303
325
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
304
|
-
axisId: PropTypes.string,
|
|
326
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
305
327
|
classes: PropTypes.object,
|
|
306
328
|
data: PropTypes.array,
|
|
307
329
|
dataKey: PropTypes.string,
|
|
@@ -309,13 +331,14 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
309
331
|
disableTicks: PropTypes.bool,
|
|
310
332
|
fill: PropTypes.string,
|
|
311
333
|
hideTooltip: PropTypes.bool,
|
|
312
|
-
id: PropTypes.string,
|
|
334
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
313
335
|
label: PropTypes.string,
|
|
314
336
|
labelFontSize: PropTypes.number,
|
|
315
337
|
labelStyle: PropTypes.object,
|
|
316
338
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
317
339
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
318
340
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
341
|
+
reverse: PropTypes.bool,
|
|
319
342
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
320
343
|
slotProps: PropTypes.object,
|
|
321
344
|
slots: PropTypes.object,
|
|
@@ -335,7 +358,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
335
358
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
336
359
|
*/
|
|
337
360
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
338
|
-
axisId: PropTypes.string,
|
|
361
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
339
362
|
classes: PropTypes.object,
|
|
340
363
|
data: PropTypes.array,
|
|
341
364
|
dataKey: PropTypes.string,
|
|
@@ -343,13 +366,14 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
343
366
|
disableTicks: PropTypes.bool,
|
|
344
367
|
fill: PropTypes.string,
|
|
345
368
|
hideTooltip: PropTypes.bool,
|
|
346
|
-
id: PropTypes.string,
|
|
369
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
347
370
|
label: PropTypes.string,
|
|
348
371
|
labelFontSize: PropTypes.number,
|
|
349
372
|
labelStyle: PropTypes.object,
|
|
350
373
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
351
374
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
352
375
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
376
|
+
reverse: PropTypes.bool,
|
|
353
377
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
354
378
|
slotProps: PropTypes.object,
|
|
355
379
|
slots: PropTypes.object,
|
|
@@ -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 == 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
10
|
const ResizableContainer = styled('div', {
|
|
75
11
|
name: 'MuiResponsiveChart',
|
|
76
12
|
slot: 'Container'
|
|
@@ -100,7 +36,7 @@ const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function Responsi
|
|
|
100
36
|
height: inHeight
|
|
101
37
|
} = props,
|
|
102
38
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
103
|
-
const [containerRef, width, height] =
|
|
39
|
+
const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
|
|
104
40
|
return /*#__PURE__*/_jsx(ResizableContainer, {
|
|
105
41
|
ref: containerRef,
|
|
106
42
|
ownerState: {
|
|
@@ -178,7 +114,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
178
114
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
179
115
|
*/
|
|
180
116
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
181
|
-
axisId: PropTypes.string,
|
|
117
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
182
118
|
classes: PropTypes.object,
|
|
183
119
|
data: PropTypes.array,
|
|
184
120
|
dataKey: PropTypes.string,
|
|
@@ -186,13 +122,14 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
186
122
|
disableTicks: PropTypes.bool,
|
|
187
123
|
fill: PropTypes.string,
|
|
188
124
|
hideTooltip: PropTypes.bool,
|
|
189
|
-
id: PropTypes.string,
|
|
125
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
190
126
|
label: PropTypes.string,
|
|
191
127
|
labelFontSize: PropTypes.number,
|
|
192
128
|
labelStyle: PropTypes.object,
|
|
193
129
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
194
130
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
195
131
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
132
|
+
reverse: PropTypes.bool,
|
|
196
133
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
197
134
|
slotProps: PropTypes.object,
|
|
198
135
|
slots: PropTypes.object,
|
|
@@ -212,7 +149,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
212
149
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
213
150
|
*/
|
|
214
151
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
215
|
-
axisId: PropTypes.string,
|
|
152
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
216
153
|
classes: PropTypes.object,
|
|
217
154
|
data: PropTypes.array,
|
|
218
155
|
dataKey: PropTypes.string,
|
|
@@ -220,13 +157,14 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
220
157
|
disableTicks: PropTypes.bool,
|
|
221
158
|
fill: PropTypes.string,
|
|
222
159
|
hideTooltip: PropTypes.bool,
|
|
223
|
-
id: PropTypes.string,
|
|
160
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
224
161
|
label: PropTypes.string,
|
|
225
162
|
labelFontSize: PropTypes.number,
|
|
226
163
|
labelStyle: PropTypes.object,
|
|
227
164
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
228
165
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
229
166
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
167
|
+
reverse: PropTypes.bool,
|
|
230
168
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
231
169
|
slotProps: PropTypes.object,
|
|
232
170
|
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 == null ? void 0 : 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 != null ? inWidth : width, inHeight != null ? inHeight : height];
|
|
66
|
+
};
|