@mui/x-charts 7.0.0-beta.2 → 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 +27 -5
- package/CHANGELOG.md +73 -9
- 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/ChartsSurface.js +6 -4
- package/ChartsXAxis/ChartsXAxis.js +2 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- 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/LineChart.d.ts +24 -5
- package/LineChart/LineChart.js +31 -5
- package/PieChart/PieArc.d.ts +4 -4
- package/PieChart/PieArc.js +9 -9
- package/PieChart/PieArcLabelPlot.js +13 -13
- package/PieChart/PieChart.d.ts +22 -0
- package/PieChart/PieChart.js +22 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
- package/ScatterChart/ScatterChart.d.ts +18 -0
- package/ScatterChart/ScatterChart.js +25 -0
- package/esm/BarChart/BarChart.js +27 -5
- package/esm/ChartsGrid/ChartsGrid.js +121 -0
- package/esm/ChartsGrid/chartsGridClasses.js +6 -0
- package/esm/ChartsGrid/index.js +2 -0
- package/esm/ChartsSurface.js +6 -4
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- 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/LineChart.js +31 -5
- package/esm/PieChart/PieArc.js +9 -9
- package/esm/PieChart/PieArcLabelPlot.js +13 -13
- package/esm/PieChart/PieChart.js +22 -0
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/esm/ScatterChart/ScatterChart.js +25 -0
- 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/legacy/BarChart/BarChart.js +27 -5
- package/legacy/ChartsGrid/ChartsGrid.js +119 -0
- package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
- package/legacy/ChartsGrid/index.js +2 -0
- package/legacy/ChartsSurface.js +5 -3
- package/legacy/ChartsXAxis/ChartsXAxis.js +1 -1
- package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
- 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/LineChart.js +31 -5
- package/legacy/PieChart/PieArc.js +10 -10
- package/legacy/PieChart/PieArcLabelPlot.js +14 -14
- package/legacy/PieChart/PieChart.js +22 -0
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -77
- package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
- package/legacy/ScatterChart/ScatterChart.js +25 -0
- package/legacy/hooks/useTicks.js +2 -3
- package/legacy/index.js +3 -1
- package/modern/BarChart/BarChart.js +27 -5
- package/modern/ChartsGrid/ChartsGrid.js +121 -0
- package/modern/ChartsGrid/chartsGridClasses.js +6 -0
- package/modern/ChartsGrid/index.js +2 -0
- package/modern/ChartsSurface.js +6 -4
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- 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/LineChart.js +31 -5
- package/modern/PieChart/PieArc.js +9 -9
- package/modern/PieChart/PieArcLabelPlot.js +13 -13
- package/modern/PieChart/PieChart.js +22 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/modern/ScatterChart/ScatterChart.js +25 -0
- package/modern/hooks/useTicks.js +2 -3
- package/modern/index.js +3 -1
- package/package.json +4 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { arc as d3Arc } from 'd3-shape';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { useGaugeState } from './GaugeProvider';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
var StyledPath = styled('path', {
|
|
8
|
+
name: 'MuiGauge',
|
|
9
|
+
slot: 'ReferenceArc',
|
|
10
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
11
|
+
return styles.referenceArc;
|
|
12
|
+
}
|
|
13
|
+
})(function (_ref) {
|
|
14
|
+
var theme = _ref.theme;
|
|
15
|
+
return {
|
|
16
|
+
fill: (theme.vars || theme).palette.primary.main
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
export function GaugeValueArc(props) {
|
|
20
|
+
var _useGaugeState = useGaugeState(),
|
|
21
|
+
value = _useGaugeState.value,
|
|
22
|
+
valueMin = _useGaugeState.valueMin,
|
|
23
|
+
valueMax = _useGaugeState.valueMax,
|
|
24
|
+
startAngle = _useGaugeState.startAngle,
|
|
25
|
+
endAngle = _useGaugeState.endAngle,
|
|
26
|
+
outerRadius = _useGaugeState.outerRadius,
|
|
27
|
+
innerRadius = _useGaugeState.innerRadius,
|
|
28
|
+
cornerRadius = _useGaugeState.cornerRadius,
|
|
29
|
+
cx = _useGaugeState.cx,
|
|
30
|
+
cy = _useGaugeState.cy;
|
|
31
|
+
if (value === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var valueAngle = startAngle + (value - valueMin) / (valueMax - valueMin) * (endAngle - startAngle);
|
|
35
|
+
return /*#__PURE__*/_jsx(StyledPath, _extends({
|
|
36
|
+
transform: "translate(".concat(cx, ", ").concat(cy, ")"),
|
|
37
|
+
d: d3Arc().cornerRadius(cornerRadius)({
|
|
38
|
+
startAngle: startAngle,
|
|
39
|
+
endAngle: valueAngle,
|
|
40
|
+
innerRadius: innerRadius,
|
|
41
|
+
outerRadius: outerRadius
|
|
42
|
+
})
|
|
43
|
+
}, props));
|
|
44
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["text", "className"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useGaugeState } from './GaugeProvider';
|
|
7
|
+
import { ChartsText } from '../ChartsText';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
function defaultFormatter(_ref) {
|
|
10
|
+
var value = _ref.value;
|
|
11
|
+
return value === null ? 'NaN' : value.toLocaleString();
|
|
12
|
+
}
|
|
13
|
+
function GaugeValueText(props) {
|
|
14
|
+
var _props$text = props.text,
|
|
15
|
+
text = _props$text === void 0 ? defaultFormatter : _props$text,
|
|
16
|
+
className = props.className,
|
|
17
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
18
|
+
var _useGaugeState = useGaugeState(),
|
|
19
|
+
value = _useGaugeState.value,
|
|
20
|
+
valueMin = _useGaugeState.valueMin,
|
|
21
|
+
valueMax = _useGaugeState.valueMax,
|
|
22
|
+
cx = _useGaugeState.cx,
|
|
23
|
+
cy = _useGaugeState.cy;
|
|
24
|
+
var formattedText = typeof text === 'function' ? text({
|
|
25
|
+
value: value,
|
|
26
|
+
valueMin: valueMin,
|
|
27
|
+
valueMax: valueMax
|
|
28
|
+
}) : text;
|
|
29
|
+
if (formattedText === null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return /*#__PURE__*/_jsx("g", {
|
|
33
|
+
className: className,
|
|
34
|
+
children: /*#__PURE__*/_jsx(ChartsText, _extends({
|
|
35
|
+
x: cx,
|
|
36
|
+
y: cy,
|
|
37
|
+
text: formattedText,
|
|
38
|
+
style: {
|
|
39
|
+
textAnchor: 'middle',
|
|
40
|
+
dominantBaseline: 'central'
|
|
41
|
+
}
|
|
42
|
+
}, other))
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
process.env.NODE_ENV !== "production" ? GaugeValueText.propTypes = {
|
|
46
|
+
// ----------------------------- Warning --------------------------------
|
|
47
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
49
|
+
// ----------------------------------------------------------------------
|
|
50
|
+
/**
|
|
51
|
+
* Height of a text line (in `em`).
|
|
52
|
+
*/
|
|
53
|
+
lineHeight: PropTypes.number,
|
|
54
|
+
/**
|
|
55
|
+
* If `true`, the line width is computed.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
needsComputation: PropTypes.bool,
|
|
59
|
+
ownerState: PropTypes.any,
|
|
60
|
+
/**
|
|
61
|
+
* Style applied to text elements.
|
|
62
|
+
*/
|
|
63
|
+
style: PropTypes.object,
|
|
64
|
+
text: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
|
|
65
|
+
} : void 0;
|
|
66
|
+
export { GaugeValueText };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
export function getGaugeUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiGauge', slot);
|
|
5
|
+
}
|
|
6
|
+
export var gaugeClasses = generateUtilityClasses('MuiGauge', ['root', 'valueArc', 'referenceArc', 'valueText']);
|
|
7
|
+
export default gaugeClasses;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
function deg2rad(angle) {
|
|
4
|
+
return Math.PI * angle / 180;
|
|
5
|
+
}
|
|
6
|
+
function getPoint(angle) {
|
|
7
|
+
var radAngle = deg2rad(angle);
|
|
8
|
+
return [Math.sin(radAngle), -Math.cos(radAngle)];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Retruns the ratio of the arc bounding box and its center.
|
|
13
|
+
* @param startAngle The start angle (in deg)
|
|
14
|
+
* @param endAngle The end angle (in deg)
|
|
15
|
+
*/
|
|
16
|
+
export function getArcRatios(startAngle, endAngle) {
|
|
17
|
+
// Set the start, end and center point.
|
|
18
|
+
var points = [[0, 0], getPoint(startAngle), getPoint(endAngle)];
|
|
19
|
+
|
|
20
|
+
// Add cardinal points included in the arc
|
|
21
|
+
var minAngle = Math.min(startAngle, endAngle);
|
|
22
|
+
var maxAngle = Math.max(startAngle, endAngle);
|
|
23
|
+
var initialAngle = Math.floor(minAngle / 90) * 90;
|
|
24
|
+
for (var step = 1; step <= 4; step += 1) {
|
|
25
|
+
var cartinalAngle = initialAngle + step * 90;
|
|
26
|
+
if (cartinalAngle < maxAngle) {
|
|
27
|
+
points.push(getPoint(cartinalAngle));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var minX = Math.min.apply(Math, _toConsumableArray(points.map(function (_ref) {
|
|
31
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
32
|
+
x = _ref2[0];
|
|
33
|
+
return x;
|
|
34
|
+
})));
|
|
35
|
+
var maxX = Math.max.apply(Math, _toConsumableArray(points.map(function (_ref3) {
|
|
36
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
|
37
|
+
x = _ref4[0];
|
|
38
|
+
return x;
|
|
39
|
+
})));
|
|
40
|
+
var minY = Math.min.apply(Math, _toConsumableArray(points.map(function (_ref5) {
|
|
41
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
42
|
+
y = _ref6[1];
|
|
43
|
+
return y;
|
|
44
|
+
})));
|
|
45
|
+
var maxY = Math.max.apply(Math, _toConsumableArray(points.map(function (_ref7) {
|
|
46
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
47
|
+
y = _ref8[1];
|
|
48
|
+
return y;
|
|
49
|
+
})));
|
|
50
|
+
return {
|
|
51
|
+
cx: -minX / (maxX - minX),
|
|
52
|
+
cy: -minY / (maxY - minY),
|
|
53
|
+
minX: minX,
|
|
54
|
+
maxX: maxX,
|
|
55
|
+
minY: minY,
|
|
56
|
+
maxY: maxY
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function getAvailableRadius(cx, cy, width, height, _ref9) {
|
|
60
|
+
var minX = _ref9.minX,
|
|
61
|
+
maxX = _ref9.maxX,
|
|
62
|
+
minY = _ref9.minY,
|
|
63
|
+
maxY = _ref9.maxY;
|
|
64
|
+
return Math.min.apply(Math, _toConsumableArray([{
|
|
65
|
+
ratio: Math.abs(minX),
|
|
66
|
+
space: cx
|
|
67
|
+
}, {
|
|
68
|
+
ratio: Math.abs(maxX),
|
|
69
|
+
space: width - cx
|
|
70
|
+
}, {
|
|
71
|
+
ratio: Math.abs(minY),
|
|
72
|
+
space: cy
|
|
73
|
+
}, {
|
|
74
|
+
ratio: Math.abs(maxY),
|
|
75
|
+
space: height - cy
|
|
76
|
+
}].map(function (_ref10) {
|
|
77
|
+
var ratio = _ref10.ratio,
|
|
78
|
+
space = _ref10.space;
|
|
79
|
+
if (ratio < 0.00001) {
|
|
80
|
+
return Infinity;
|
|
81
|
+
}
|
|
82
|
+
return space / ratio;
|
|
83
|
+
})));
|
|
84
|
+
}
|
|
@@ -14,6 +14,7 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
14
14
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
15
15
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
16
16
|
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
17
|
+
import { ChartsGrid } from '../ChartsGrid';
|
|
17
18
|
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -48,6 +49,7 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
48
49
|
} : _props$axisHighlight,
|
|
49
50
|
disableLineItemHighlight = props.disableLineItemHighlight,
|
|
50
51
|
legend = props.legend,
|
|
52
|
+
grid = props.grid,
|
|
51
53
|
topAxis = props.topAxis,
|
|
52
54
|
leftAxis = props.leftAxis,
|
|
53
55
|
rightAxis = props.rightAxis,
|
|
@@ -88,6 +90,9 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
88
90
|
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
|
|
89
91
|
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
90
92
|
onAxisClick: onAxisClick
|
|
93
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
94
|
+
vertical: grid.vertical,
|
|
95
|
+
horizontal: grid.horizontal
|
|
91
96
|
}), /*#__PURE__*/_jsxs("g", {
|
|
92
97
|
clipPath: "url(#".concat(clipPathId, ")"),
|
|
93
98
|
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
@@ -133,11 +138,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
133
138
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
134
139
|
// ----------------------------------------------------------------------
|
|
135
140
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* - 'none': display nothing.
|
|
139
|
-
* - 'line': display a line at the current mouse position.
|
|
140
|
-
* - 'band': display a band at the current mouse position. Only available with band scale.
|
|
141
|
+
* The configuration of axes highlight.
|
|
142
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
141
143
|
* @default { x: 'line' }
|
|
142
144
|
*/
|
|
143
145
|
axisHighlight: PropTypes.shape({
|
|
@@ -193,6 +195,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
193
195
|
* If `true`, render the line highlight item.
|
|
194
196
|
*/
|
|
195
197
|
disableLineItemHighlight: PropTypes.bool,
|
|
198
|
+
/**
|
|
199
|
+
* Option to display a cartesian grid in the background.
|
|
200
|
+
*/
|
|
201
|
+
grid: PropTypes.shape({
|
|
202
|
+
horizontal: PropTypes.bool,
|
|
203
|
+
vertical: PropTypes.bool
|
|
204
|
+
}),
|
|
196
205
|
/**
|
|
197
206
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
198
207
|
* @default undefined
|
|
@@ -251,6 +260,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
251
260
|
right: PropTypes.number,
|
|
252
261
|
top: PropTypes.number
|
|
253
262
|
}),
|
|
263
|
+
/**
|
|
264
|
+
* Callback fired when an area element is clicked.
|
|
265
|
+
*/
|
|
254
266
|
onAreaClick: PropTypes.func,
|
|
255
267
|
/**
|
|
256
268
|
* The function called for onClick events.
|
|
@@ -259,7 +271,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
259
271
|
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
260
272
|
*/
|
|
261
273
|
onAxisClick: PropTypes.func,
|
|
274
|
+
/**
|
|
275
|
+
* Callback fired when a line element is clicked.
|
|
276
|
+
*/
|
|
262
277
|
onLineClick: PropTypes.func,
|
|
278
|
+
/**
|
|
279
|
+
* Callback fired when a mark element is clicked.
|
|
280
|
+
*/
|
|
263
281
|
onMarkClick: PropTypes.func,
|
|
264
282
|
/**
|
|
265
283
|
* Indicate which axis to display the right of the charts.
|
|
@@ -288,6 +306,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
288
306
|
tickNumber: PropTypes.number,
|
|
289
307
|
tickSize: PropTypes.number
|
|
290
308
|
}), PropTypes.string]),
|
|
309
|
+
/**
|
|
310
|
+
* The series to display in the line chart.
|
|
311
|
+
*/
|
|
291
312
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
292
313
|
/**
|
|
293
314
|
* If `true`, animations are skipped.
|
|
@@ -306,6 +327,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
306
327
|
slots: PropTypes.object,
|
|
307
328
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
308
329
|
title: PropTypes.string,
|
|
330
|
+
/**
|
|
331
|
+
* The configuration of the tooltip.
|
|
332
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
333
|
+
* @default { trigger: 'item' }
|
|
334
|
+
*/
|
|
309
335
|
tooltip: PropTypes.shape({
|
|
310
336
|
axisContent: PropTypes.elementType,
|
|
311
337
|
classes: PropTypes.object,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["
|
|
3
|
+
var _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 @@ var PieArcRoot = styled(animated.path, {
|
|
|
40
40
|
};
|
|
41
41
|
});
|
|
42
42
|
function PieArc(props) {
|
|
43
|
-
var
|
|
44
|
-
dataIndex = props.dataIndex,
|
|
45
|
-
innerClasses = props.classes,
|
|
43
|
+
var innerClasses = props.classes,
|
|
46
44
|
color = props.color,
|
|
45
|
+
cornerRadius = props.cornerRadius,
|
|
46
|
+
dataIndex = props.dataIndex,
|
|
47
|
+
endAngle = props.endAngle,
|
|
47
48
|
highlightScope = props.highlightScope,
|
|
48
|
-
|
|
49
|
+
id = props.id,
|
|
50
|
+
innerRadius = props.innerRadius,
|
|
49
51
|
isFaded = props.isFaded,
|
|
50
52
|
isHighlighted = props.isHighlighted,
|
|
51
|
-
|
|
52
|
-
endAngle = props.endAngle,
|
|
53
|
-
paddingAngle = props.paddingAngle,
|
|
54
|
-
innerRadius = props.innerRadius,
|
|
53
|
+
onClick = props.onClick,
|
|
55
54
|
outerRadius = props.outerRadius,
|
|
56
|
-
|
|
55
|
+
paddingAngle = props.paddingAngle,
|
|
56
|
+
startAngle = props.startAngle,
|
|
57
57
|
other = _objectWithoutProperties(props, _excluded);
|
|
58
58
|
var ownerState = {
|
|
59
59
|
id: id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["
|
|
3
|
+
var _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';
|
|
@@ -26,27 +26,27 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
26
26
|
}
|
|
27
27
|
function PieArcLabelPlot(props) {
|
|
28
28
|
var _slots$pieArcLabel;
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
outerRadius = props.outerRadius,
|
|
29
|
+
var arcLabel = props.arcLabel,
|
|
30
|
+
_props$arcLabelMinAng = props.arcLabelMinAngle,
|
|
31
|
+
arcLabelMinAngle = _props$arcLabelMinAng === void 0 ? 0 : _props$arcLabelMinAng,
|
|
33
32
|
arcLabelRadius = props.arcLabelRadius,
|
|
34
33
|
_props$cornerRadius = props.cornerRadius,
|
|
35
34
|
cornerRadius = _props$cornerRadius === void 0 ? 0 : _props$cornerRadius,
|
|
36
|
-
|
|
37
|
-
paddingAngle = _props$paddingAngle === void 0 ? 0 : _props$paddingAngle,
|
|
38
|
-
id = props.id,
|
|
39
|
-
highlightScope = props.highlightScope,
|
|
40
|
-
highlighted = props.highlighted,
|
|
35
|
+
data = props.data,
|
|
41
36
|
_props$faded = props.faded,
|
|
42
37
|
faded = _props$faded === void 0 ? {
|
|
43
38
|
additionalRadius: -5
|
|
44
39
|
} : _props$faded,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
highlighted = props.highlighted,
|
|
41
|
+
highlightScope = props.highlightScope,
|
|
42
|
+
id = props.id,
|
|
43
|
+
innerRadius = props.innerRadius,
|
|
44
|
+
outerRadius = props.outerRadius,
|
|
45
|
+
_props$paddingAngle = props.paddingAngle,
|
|
46
|
+
paddingAngle = _props$paddingAngle === void 0 ? 0 : _props$paddingAngle,
|
|
49
47
|
skipAnimation = props.skipAnimation,
|
|
48
|
+
slotProps = props.slotProps,
|
|
49
|
+
slots = props.slots,
|
|
50
50
|
other = _objectWithoutProperties(props, _excluded);
|
|
51
51
|
var transformedData = useTransformData({
|
|
52
52
|
innerRadius: innerRadius,
|
|
@@ -113,6 +113,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
113
113
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
114
114
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
115
115
|
// ----------------------------------------------------------------------
|
|
116
|
+
/**
|
|
117
|
+
* The configuration of axes highlight.
|
|
118
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
119
|
+
* @default { x: 'none', y: 'none' }
|
|
120
|
+
*/
|
|
116
121
|
axisHighlight: PropTypes.shape({
|
|
117
122
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
118
123
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
@@ -195,6 +200,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
195
200
|
tickSize: PropTypes.number
|
|
196
201
|
}), PropTypes.string]),
|
|
197
202
|
/**
|
|
203
|
+
* The props of the legend.
|
|
204
|
+
* @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
|
|
198
205
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
199
206
|
*/
|
|
200
207
|
legend: PropTypes.shape({
|
|
@@ -220,6 +227,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
220
227
|
right: PropTypes.number,
|
|
221
228
|
top: PropTypes.number
|
|
222
229
|
}),
|
|
230
|
+
/**
|
|
231
|
+
* Callback fired when a pie arc is clicked.
|
|
232
|
+
*/
|
|
223
233
|
onItemClick: PropTypes.func,
|
|
224
234
|
/**
|
|
225
235
|
* Indicate which axis to display the right of the charts.
|
|
@@ -248,6 +258,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
248
258
|
tickNumber: PropTypes.number,
|
|
249
259
|
tickSize: PropTypes.number
|
|
250
260
|
}), PropTypes.string]),
|
|
261
|
+
/**
|
|
262
|
+
* The series to display in the pie chart.
|
|
263
|
+
*/
|
|
251
264
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
252
265
|
/**
|
|
253
266
|
* If `true`, animations are skipped.
|
|
@@ -259,9 +272,18 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
259
272
|
* @default {}
|
|
260
273
|
*/
|
|
261
274
|
slotProps: PropTypes.object,
|
|
275
|
+
/**
|
|
276
|
+
* Overridable component slots.
|
|
277
|
+
* @default {}
|
|
278
|
+
*/
|
|
262
279
|
slots: PropTypes.object,
|
|
263
280
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
264
281
|
title: PropTypes.string,
|
|
282
|
+
/**
|
|
283
|
+
* The configuration of the tooltip.
|
|
284
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
285
|
+
* @default { trigger: 'item' }
|
|
286
|
+
*/
|
|
265
287
|
tooltip: PropTypes.shape({
|
|
266
288
|
axisContent: PropTypes.elementType,
|
|
267
289
|
classes: PropTypes.object,
|
|
@@ -1,83 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["width", "height"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
|
-
import ownerWindow from '@mui/utils/ownerWindow';
|
|
9
7
|
import { styled } from '@mui/material/styles';
|
|
10
8
|
import { ChartContainer } from '../ChartContainer';
|
|
9
|
+
import { useChartContainerDimensions } from './useChartContainerDimensions';
|
|
11
10
|
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
11
|
var ResizableContainer = styled('div', {
|
|
82
12
|
name: 'MuiResponsiveChart',
|
|
83
13
|
slot: 'Container'
|
|
@@ -104,11 +34,11 @@ var ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function Responsive
|
|
|
104
34
|
var inWidth = props.width,
|
|
105
35
|
inHeight = props.height,
|
|
106
36
|
other = _objectWithoutProperties(props, _excluded);
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
containerRef =
|
|
110
|
-
width =
|
|
111
|
-
height =
|
|
37
|
+
var _useChartContainerDim = useChartContainerDimensions(inWidth, inHeight),
|
|
38
|
+
_useChartContainerDim2 = _slicedToArray(_useChartContainerDim, 3),
|
|
39
|
+
containerRef = _useChartContainerDim2[0],
|
|
40
|
+
width = _useChartContainerDim2[1],
|
|
41
|
+
height = _useChartContainerDim2[2];
|
|
112
42
|
return /*#__PURE__*/_jsx(ResizableContainer, {
|
|
113
43
|
ref: containerRef,
|
|
114
44
|
ownerState: {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
4
|
+
import ownerWindow from '@mui/utils/ownerWindow';
|
|
5
|
+
export var useChartContainerDimensions = function useChartContainerDimensions(inWidth, inHeight) {
|
|
6
|
+
var rootRef = React.useRef(null);
|
|
7
|
+
var displayError = React.useRef(false);
|
|
8
|
+
var _React$useState = React.useState(0),
|
|
9
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
10
|
+
width = _React$useState2[0],
|
|
11
|
+
setWidth = _React$useState2[1];
|
|
12
|
+
var _React$useState3 = React.useState(0),
|
|
13
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
14
|
+
height = _React$useState4[0],
|
|
15
|
+
setHeight = _React$useState4[1];
|
|
16
|
+
|
|
17
|
+
// Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
|
|
18
|
+
var computeSize = React.useCallback(function () {
|
|
19
|
+
var mainEl = rootRef == null ? void 0 : rootRef.current;
|
|
20
|
+
if (!mainEl) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var win = ownerWindow(mainEl);
|
|
24
|
+
var computedStyle = win.getComputedStyle(mainEl);
|
|
25
|
+
var newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
|
|
26
|
+
var newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
27
|
+
setWidth(newWidth);
|
|
28
|
+
setHeight(newHeight);
|
|
29
|
+
}, []);
|
|
30
|
+
React.useEffect(function () {
|
|
31
|
+
// Ensure the error detection occurs after the first rendering.
|
|
32
|
+
displayError.current = true;
|
|
33
|
+
}, []);
|
|
34
|
+
useEnhancedEffect(function () {
|
|
35
|
+
if (inWidth !== undefined && inHeight !== undefined) {
|
|
36
|
+
return function () {};
|
|
37
|
+
}
|
|
38
|
+
computeSize();
|
|
39
|
+
var elementToObserve = rootRef.current;
|
|
40
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
41
|
+
return function () {};
|
|
42
|
+
}
|
|
43
|
+
var animationFrame;
|
|
44
|
+
var observer = new ResizeObserver(function () {
|
|
45
|
+
// See https://github.com/mui/mui-x/issues/8733
|
|
46
|
+
animationFrame = requestAnimationFrame(function () {
|
|
47
|
+
computeSize();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
if (elementToObserve) {
|
|
51
|
+
observer.observe(elementToObserve);
|
|
52
|
+
}
|
|
53
|
+
return function () {
|
|
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
|
+
};
|