@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.
Files changed (124) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +27 -5
  3. package/CHANGELOG.md +73 -9
  4. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  5. package/ChartsGrid/ChartsGrid.js +128 -0
  6. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  7. package/ChartsGrid/chartsGridClasses.js +14 -0
  8. package/ChartsGrid/index.d.ts +2 -0
  9. package/ChartsGrid/index.js +27 -0
  10. package/ChartsGrid/package.json +6 -0
  11. package/ChartsSurface.js +6 -4
  12. package/ChartsXAxis/ChartsXAxis.js +2 -2
  13. package/ChartsYAxis/ChartsYAxis.js +2 -2
  14. package/Gauge/Gauge.d.ts +13 -0
  15. package/Gauge/Gauge.js +156 -0
  16. package/Gauge/GaugeContainer.d.ts +19 -0
  17. package/Gauge/GaugeContainer.js +216 -0
  18. package/Gauge/GaugeProvider.d.ts +117 -0
  19. package/Gauge/GaugeProvider.js +96 -0
  20. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  21. package/Gauge/GaugeReferenceArc.js +44 -0
  22. package/Gauge/GaugeValueArc.d.ts +2 -0
  23. package/Gauge/GaugeValueArc.js +51 -0
  24. package/Gauge/GaugeValueText.d.ts +15 -0
  25. package/Gauge/GaugeValueText.js +77 -0
  26. package/Gauge/gaugeClasses.d.ts +14 -0
  27. package/Gauge/gaugeClasses.js +15 -0
  28. package/Gauge/index.d.ts +7 -0
  29. package/Gauge/index.js +87 -0
  30. package/Gauge/package.json +6 -0
  31. package/Gauge/utils.d.ts +19 -0
  32. package/Gauge/utils.js +75 -0
  33. package/LineChart/LineChart.d.ts +24 -5
  34. package/LineChart/LineChart.js +31 -5
  35. package/PieChart/PieArc.d.ts +4 -4
  36. package/PieChart/PieArc.js +9 -9
  37. package/PieChart/PieArcLabelPlot.js +13 -13
  38. package/PieChart/PieChart.d.ts +22 -0
  39. package/PieChart/PieChart.js +22 -0
  40. package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
  41. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  42. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  43. package/ScatterChart/ScatterChart.d.ts +18 -0
  44. package/ScatterChart/ScatterChart.js +25 -0
  45. package/esm/BarChart/BarChart.js +27 -5
  46. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  47. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  48. package/esm/ChartsGrid/index.js +2 -0
  49. package/esm/ChartsSurface.js +6 -4
  50. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  51. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  52. package/esm/Gauge/Gauge.js +149 -0
  53. package/esm/Gauge/GaugeContainer.js +211 -0
  54. package/esm/Gauge/GaugeProvider.js +85 -0
  55. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  56. package/esm/Gauge/GaugeValueArc.js +42 -0
  57. package/esm/Gauge/GaugeValueText.js +69 -0
  58. package/esm/Gauge/gaugeClasses.js +7 -0
  59. package/esm/Gauge/index.js +7 -0
  60. package/esm/Gauge/utils.js +68 -0
  61. package/esm/LineChart/LineChart.js +31 -5
  62. package/esm/PieChart/PieArc.js +9 -9
  63. package/esm/PieChart/PieArcLabelPlot.js +13 -13
  64. package/esm/PieChart/PieChart.js +22 -0
  65. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
  66. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  67. package/esm/ScatterChart/ScatterChart.js +25 -0
  68. package/esm/hooks/useTicks.js +2 -3
  69. package/esm/index.js +2 -0
  70. package/hooks/useTicks.d.ts +1 -2
  71. package/hooks/useTicks.js +2 -3
  72. package/index.d.ts +2 -0
  73. package/index.js +23 -1
  74. package/legacy/BarChart/BarChart.js +27 -5
  75. package/legacy/ChartsGrid/ChartsGrid.js +119 -0
  76. package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
  77. package/legacy/ChartsGrid/index.js +2 -0
  78. package/legacy/ChartsSurface.js +5 -3
  79. package/legacy/ChartsXAxis/ChartsXAxis.js +1 -1
  80. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  81. package/legacy/Gauge/Gauge.js +146 -0
  82. package/legacy/Gauge/GaugeContainer.js +215 -0
  83. package/legacy/Gauge/GaugeProvider.js +87 -0
  84. package/legacy/Gauge/GaugeReferenceArc.js +37 -0
  85. package/legacy/Gauge/GaugeValueArc.js +44 -0
  86. package/legacy/Gauge/GaugeValueText.js +66 -0
  87. package/legacy/Gauge/gaugeClasses.js +7 -0
  88. package/legacy/Gauge/index.js +7 -0
  89. package/legacy/Gauge/utils.js +84 -0
  90. package/legacy/LineChart/LineChart.js +31 -5
  91. package/legacy/PieChart/PieArc.js +10 -10
  92. package/legacy/PieChart/PieArcLabelPlot.js +14 -14
  93. package/legacy/PieChart/PieChart.js +22 -0
  94. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -77
  95. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
  96. package/legacy/ScatterChart/ScatterChart.js +25 -0
  97. package/legacy/hooks/useTicks.js +2 -3
  98. package/legacy/index.js +3 -1
  99. package/modern/BarChart/BarChart.js +27 -5
  100. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  101. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  102. package/modern/ChartsGrid/index.js +2 -0
  103. package/modern/ChartsSurface.js +6 -4
  104. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  105. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  106. package/modern/Gauge/Gauge.js +149 -0
  107. package/modern/Gauge/GaugeContainer.js +208 -0
  108. package/modern/Gauge/GaugeProvider.js +85 -0
  109. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  110. package/modern/Gauge/GaugeValueArc.js +42 -0
  111. package/modern/Gauge/GaugeValueText.js +69 -0
  112. package/modern/Gauge/gaugeClasses.js +7 -0
  113. package/modern/Gauge/index.js +7 -0
  114. package/modern/Gauge/utils.js +68 -0
  115. package/modern/LineChart/LineChart.js +31 -5
  116. package/modern/PieChart/PieArc.js +9 -9
  117. package/modern/PieChart/PieArcLabelPlot.js +13 -13
  118. package/modern/PieChart/PieChart.js +22 -0
  119. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
  120. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  121. package/modern/ScatterChart/ScatterChart.js +25 -0
  122. package/modern/hooks/useTicks.js +2 -3
  123. package/modern/index.js +3 -1
  124. package/package.json +4 -4
package/Gauge/Gauge.js ADDED
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Gauge = Gauge;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
13
+ var _GaugeContainer = require("./GaugeContainer");
14
+ var _GaugeValueArc = require("./GaugeValueArc");
15
+ var _GaugeReferenceArc = require("./GaugeReferenceArc");
16
+ var _gaugeClasses = require("./gaugeClasses");
17
+ var _GaugeValueText = require("./GaugeValueText");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const _excluded = ["text", "children", "classes"];
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ const useUtilityClasses = props => {
23
+ const {
24
+ classes
25
+ } = props;
26
+ const slots = {
27
+ root: ['root'],
28
+ valueArc: ['valueArc'],
29
+ referenceArc: ['referenceArc'],
30
+ valueText: ['valueText']
31
+ };
32
+ return (0, _composeClasses.default)(slots, _gaugeClasses.getGaugeUtilityClass, classes);
33
+ };
34
+ function Gauge(props) {
35
+ const {
36
+ text,
37
+ children
38
+ } = props,
39
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
40
+ const classes = useUtilityClasses(props);
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GaugeContainer.GaugeContainer, (0, _extends2.default)({}, other, {
42
+ className: classes.root,
43
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeReferenceArc.GaugeReferenceArc, {
44
+ className: classes.referenceArc
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeValueArc.GaugeValueArc, {
46
+ className: classes.valueArc
47
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeValueText.GaugeValueText, {
48
+ className: classes.valueText,
49
+ text: text
50
+ }), children]
51
+ }));
52
+ }
53
+ process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
54
+ // ----------------------------- Warning --------------------------------
55
+ // | These PropTypes are generated from the TypeScript type definitions |
56
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
57
+ // ----------------------------------------------------------------------
58
+ children: _propTypes.default.node,
59
+ classes: _propTypes.default.object,
60
+ className: _propTypes.default.string,
61
+ /**
62
+ * The radius applied to arc corners (similar to border radius).
63
+ * Set it to '50%' to get rounded arc.
64
+ * @default 0
65
+ */
66
+ cornerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
67
+ /**
68
+ * The x coordinate of the arc center.
69
+ * Can be a number (in px) or a string with a percentage such as '50%'.
70
+ * The '100%' is the width the drawing area.
71
+ */
72
+ cx: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
73
+ /**
74
+ * The y coordinate of the arc center.
75
+ * Can be a number (in px) or a string with a percentage such as '50%'.
76
+ * The '100%' is the height the drawing area.
77
+ */
78
+ cy: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
79
+ desc: _propTypes.default.string,
80
+ /**
81
+ * If `true`, the charts will not listen to the mouse move event.
82
+ * It might break interactive features, but will improve performance.
83
+ * @default false
84
+ */
85
+ disableAxisListener: _propTypes.default.bool,
86
+ /**
87
+ * The end angle (deg).
88
+ * @default 360
89
+ */
90
+ endAngle: _propTypes.default.number,
91
+ /**
92
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
93
+ * @default undefined
94
+ */
95
+ height: _propTypes.default.number,
96
+ /**
97
+ * The radius between circle center and the begining of the arc.
98
+ * Can be a number (in px) or a string with a percentage such as '50%'.
99
+ * The '100%' is the maximal radius that fit into the drawing area.
100
+ * @default '80%'
101
+ */
102
+ innerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
103
+ /**
104
+ * The margin between the SVG and the drawing area.
105
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
106
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
107
+ * @default object Depends on the charts type.
108
+ */
109
+ margin: _propTypes.default.shape({
110
+ bottom: _propTypes.default.number,
111
+ left: _propTypes.default.number,
112
+ right: _propTypes.default.number,
113
+ top: _propTypes.default.number
114
+ }),
115
+ /**
116
+ * The radius between circle center and the end of the arc.
117
+ * Can be a number (in px) or a string with a percentage such as '50%'.
118
+ * The '100%' is the maximal radius that fit into the drawing area.
119
+ * @default '100%'
120
+ */
121
+ outerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
122
+ /**
123
+ * The start angle (deg).
124
+ * @default 0
125
+ */
126
+ startAngle: _propTypes.default.number,
127
+ sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
128
+ text: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
129
+ title: _propTypes.default.string,
130
+ /**
131
+ * The value of the gauge.
132
+ * Set to `null` to not display a value.
133
+ */
134
+ value: _propTypes.default.number,
135
+ /**
136
+ * The maximal value of the gauge.
137
+ * @default 100
138
+ */
139
+ valueMax: _propTypes.default.number,
140
+ /**
141
+ * The minimal value of the gauge.
142
+ * @default 0
143
+ */
144
+ valueMin: _propTypes.default.number,
145
+ viewBox: _propTypes.default.shape({
146
+ height: _propTypes.default.number,
147
+ width: _propTypes.default.number,
148
+ x: _propTypes.default.number,
149
+ y: _propTypes.default.number
150
+ }),
151
+ /**
152
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
153
+ * @default undefined
154
+ */
155
+ width: _propTypes.default.number
156
+ } : void 0;
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { ChartsSurfaceProps } from '../ChartsSurface';
3
+ import { DrawingProviderProps } from '../context/DrawingProvider';
4
+ import { GaugeProviderProps } from './GaugeProvider';
5
+ export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'width' | 'height' | 'children'>, Omit<DrawingProviderProps, 'svgRef' | 'width' | 'height' | 'children'>, Omit<GaugeProviderProps, 'children'> {
6
+ /**
7
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
8
+ * @default undefined
9
+ */
10
+ width?: number;
11
+ /**
12
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
13
+ * @default undefined
14
+ */
15
+ height?: number;
16
+ children?: React.ReactNode;
17
+ }
18
+ declare const GaugeContainer: React.ForwardRefExoticComponent<GaugeContainerProps & React.RefAttributes<unknown>>;
19
+ export { GaugeContainer };
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GaugeContainer = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
13
+ var _styles = require("@mui/material/styles");
14
+ var _useChartContainerDimensions = require("../ResponsiveChartContainer/useChartContainerDimensions");
15
+ var _ChartsSurface = require("../ChartsSurface");
16
+ var _DrawingProvider = require("../context/DrawingProvider");
17
+ var _GaugeProvider = require("./GaugeProvider");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const _excluded = ["width", "height", "margin", "title", "desc", "value", "valueMin", "valueMax", "startAngle", "endAngle", "outerRadius", "innerRadius", "cornerRadius", "cx", "cy", "children"];
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ const ResizableContainer = (0, _styles.styled)('div', {
23
+ name: 'MuiGauge',
24
+ slot: 'Container'
25
+ })(({
26
+ ownerState,
27
+ theme
28
+ }) => ({
29
+ width: ownerState.width ?? '100%',
30
+ height: ownerState.height ?? '100%',
31
+ display: 'flex',
32
+ position: 'relative',
33
+ flexGrow: 1,
34
+ flexDirection: 'column',
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ overflow: 'hidden',
38
+ '&>svg': {
39
+ width: '100%',
40
+ height: '100%'
41
+ },
42
+ '& text': {
43
+ fill: (theme.vars || theme).palette.text.primary
44
+ }
45
+ }));
46
+ const GaugeContainer = exports.GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(props, ref) {
47
+ const {
48
+ width: inWidth,
49
+ height: inHeight,
50
+ margin,
51
+ title,
52
+ desc,
53
+ value,
54
+ valueMin = 0,
55
+ valueMax = 100,
56
+ startAngle,
57
+ endAngle,
58
+ outerRadius,
59
+ innerRadius,
60
+ cornerRadius,
61
+ cx,
62
+ cy,
63
+ children
64
+ } = props,
65
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
66
+ const [containerRef, width, height] = (0, _useChartContainerDimensions.useChartContainerDimensions)(inWidth, inHeight);
67
+ const svgRef = React.useRef(null);
68
+ const handleRef = (0, _useForkRef.default)(ref, svgRef);
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ResizableContainer, (0, _extends2.default)({
70
+ ref: containerRef,
71
+ ownerState: {
72
+ width: inWidth,
73
+ height: inHeight
74
+ },
75
+ role: "meter",
76
+ "aria-valuenow": value === null ? undefined : value,
77
+ "aria-valuemin": valueMin,
78
+ "aria-valuemax": valueMax
79
+ }, other, {
80
+ children: width && height ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DrawingProvider.DrawingProvider, {
81
+ width: width,
82
+ height: height,
83
+ margin: (0, _extends2.default)({
84
+ left: 10,
85
+ right: 10,
86
+ top: 10,
87
+ bottom: 10
88
+ }, margin),
89
+ svgRef: svgRef,
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeProvider.GaugeProvider, {
91
+ value: value,
92
+ valueMin: valueMin,
93
+ valueMax: valueMax,
94
+ startAngle: startAngle,
95
+ endAngle: endAngle,
96
+ outerRadius: outerRadius,
97
+ innerRadius: innerRadius,
98
+ cornerRadius: cornerRadius,
99
+ cx: cx,
100
+ cy: cy,
101
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSurface.ChartsSurface, {
102
+ width: width,
103
+ height: height,
104
+ ref: handleRef,
105
+ title: title,
106
+ desc: desc,
107
+ disableAxisListener: true,
108
+ "aria-hidden": "true",
109
+ children: children
110
+ })
111
+ })
112
+ }) : null
113
+ }));
114
+ });
115
+ process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
116
+ // ----------------------------- Warning --------------------------------
117
+ // | These PropTypes are generated from the TypeScript type definitions |
118
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
119
+ // ----------------------------------------------------------------------
120
+ children: _propTypes.default.node,
121
+ className: _propTypes.default.string,
122
+ /**
123
+ * The radius applied to arc corners (similar to border radius).
124
+ * Set it to '50%' to get rounded arc.
125
+ * @default 0
126
+ */
127
+ cornerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
128
+ /**
129
+ * The x coordinate of the arc center.
130
+ * Can be a number (in px) or a string with a percentage such as '50%'.
131
+ * The '100%' is the width the drawing area.
132
+ */
133
+ cx: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
134
+ /**
135
+ * The y coordinate of the arc center.
136
+ * Can be a number (in px) or a string with a percentage such as '50%'.
137
+ * The '100%' is the height the drawing area.
138
+ */
139
+ cy: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
140
+ desc: _propTypes.default.string,
141
+ /**
142
+ * If `true`, the charts will not listen to the mouse move event.
143
+ * It might break interactive features, but will improve performance.
144
+ * @default false
145
+ */
146
+ disableAxisListener: _propTypes.default.bool,
147
+ /**
148
+ * The end angle (deg).
149
+ * @default 360
150
+ */
151
+ endAngle: _propTypes.default.number,
152
+ /**
153
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
154
+ * @default undefined
155
+ */
156
+ height: _propTypes.default.number,
157
+ /**
158
+ * The radius between circle center and the begining of the arc.
159
+ * Can be a number (in px) or a string with a percentage such as '50%'.
160
+ * The '100%' is the maximal radius that fit into the drawing area.
161
+ * @default '80%'
162
+ */
163
+ innerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
164
+ /**
165
+ * The margin between the SVG and the drawing area.
166
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
167
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
168
+ * @default object Depends on the charts type.
169
+ */
170
+ margin: _propTypes.default.shape({
171
+ bottom: _propTypes.default.number,
172
+ left: _propTypes.default.number,
173
+ right: _propTypes.default.number,
174
+ top: _propTypes.default.number
175
+ }),
176
+ /**
177
+ * The radius between circle center and the end of the arc.
178
+ * Can be a number (in px) or a string with a percentage such as '50%'.
179
+ * The '100%' is the maximal radius that fit into the drawing area.
180
+ * @default '100%'
181
+ */
182
+ outerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
183
+ /**
184
+ * The start angle (deg).
185
+ * @default 0
186
+ */
187
+ startAngle: _propTypes.default.number,
188
+ sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
189
+ title: _propTypes.default.string,
190
+ /**
191
+ * The value of the gauge.
192
+ * Set to `null` to not display a value.
193
+ */
194
+ value: _propTypes.default.number,
195
+ /**
196
+ * The maximal value of the gauge.
197
+ * @default 100
198
+ */
199
+ valueMax: _propTypes.default.number,
200
+ /**
201
+ * The minimal value of the gauge.
202
+ * @default 0
203
+ */
204
+ valueMin: _propTypes.default.number,
205
+ viewBox: _propTypes.default.shape({
206
+ height: _propTypes.default.number,
207
+ width: _propTypes.default.number,
208
+ x: _propTypes.default.number,
209
+ y: _propTypes.default.number
210
+ }),
211
+ /**
212
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
213
+ * @default undefined
214
+ */
215
+ width: _propTypes.default.number
216
+ } : void 0;
@@ -0,0 +1,117 @@
1
+ import * as React from 'react';
2
+ interface CircularConfig {
3
+ /**
4
+ * The start angle (deg).
5
+ * @default 0
6
+ */
7
+ startAngle?: number;
8
+ /**
9
+ * The end angle (deg).
10
+ * @default 360
11
+ */
12
+ endAngle?: number;
13
+ /**
14
+ * The radius between circle center and the begining of the arc.
15
+ * Can be a number (in px) or a string with a percentage such as '50%'.
16
+ * The '100%' is the maximal radius that fit into the drawing area.
17
+ * @default '80%'
18
+ */
19
+ innerRadius?: number | string;
20
+ /**
21
+ * The radius between circle center and the end of the arc.
22
+ * Can be a number (in px) or a string with a percentage such as '50%'.
23
+ * The '100%' is the maximal radius that fit into the drawing area.
24
+ * @default '100%'
25
+ */
26
+ outerRadius?: number | string;
27
+ /**
28
+ * The radius applied to arc corners (similar to border radius).
29
+ * Set it to '50%' to get rounded arc.
30
+ * @default 0
31
+ */
32
+ cornerRadius?: number | string;
33
+ /**
34
+ * The x coordinate of the arc center.
35
+ * Can be a number (in px) or a string with a percentage such as '50%'.
36
+ * The '100%' is the width the drawing area.
37
+ */
38
+ cx?: number | string;
39
+ /**
40
+ * The y coordinate of the arc center.
41
+ * Can be a number (in px) or a string with a percentage such as '50%'.
42
+ * The '100%' is the height the drawing area.
43
+ */
44
+ cy?: number | string;
45
+ }
46
+ interface ProcessedCircularConfig {
47
+ /**
48
+ * The start angle (rad).
49
+ */
50
+ startAngle: number;
51
+ /**
52
+ * The end angle (rad).
53
+ */
54
+ endAngle: number;
55
+ /**
56
+ * The radius between circle center and the begining of the arc.
57
+ */
58
+ innerRadius: number;
59
+ /**
60
+ * The radius between circle center and the end of the arc.
61
+ */
62
+ outerRadius: number;
63
+ /**
64
+ * The radius applied to arc corners (similar to border radius).
65
+ */
66
+ cornerRadius: number;
67
+ /**
68
+ * The x coordinate of the pie center.
69
+ */
70
+ cx: number;
71
+ /**
72
+ * The y coordinate of the pie center.
73
+ */
74
+ cy: number;
75
+ }
76
+ interface GaugeConfig {
77
+ /**
78
+ * The value of the gauge.
79
+ * Set to `null` to not display a value.
80
+ */
81
+ value?: number | null;
82
+ /**
83
+ * The minimal value of the gauge.
84
+ * @default 0
85
+ */
86
+ valueMin?: number;
87
+ /**
88
+ * The maximal value of the gauge.
89
+ * @default 100
90
+ */
91
+ valueMax?: number;
92
+ }
93
+ export declare const GaugeContext: React.Context<Required<GaugeConfig> & ProcessedCircularConfig & {
94
+ /**
95
+ * The maximal radius from (cx, cy) that fits the arc in the drawing area.
96
+ */
97
+ maxRadius: number;
98
+ /**
99
+ * The angle (rad) associated to the current value.
100
+ */
101
+ valueAngle: null | number;
102
+ }>;
103
+ export interface GaugeProviderProps extends GaugeConfig, CircularConfig {
104
+ children: React.ReactNode;
105
+ }
106
+ export declare function GaugeProvider(props: GaugeProviderProps): React.JSX.Element;
107
+ export declare function useGaugeState(): Required<GaugeConfig> & ProcessedCircularConfig & {
108
+ /**
109
+ * The maximal radius from (cx, cy) that fits the arc in the drawing area.
110
+ */
111
+ maxRadius: number;
112
+ /**
113
+ * The angle (rad) associated to the current value.
114
+ */
115
+ valueAngle: number | null;
116
+ };
117
+ export {};
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GaugeContext = void 0;
7
+ exports.GaugeProvider = GaugeProvider;
8
+ exports.useGaugeState = useGaugeState;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _DrawingProvider = require("../context/DrawingProvider");
11
+ var _utils = require("../internals/utils");
12
+ var _utils2 = require("./utils");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ // @ignore - do not document.
17
+
18
+ const GaugeContext = exports.GaugeContext = /*#__PURE__*/React.createContext({
19
+ value: null,
20
+ valueMin: 0,
21
+ valueMax: 0,
22
+ startAngle: 0,
23
+ endAngle: 0,
24
+ innerRadius: 0,
25
+ outerRadius: 0,
26
+ cornerRadius: 0,
27
+ cx: 0,
28
+ cy: 0,
29
+ maxRadius: 0,
30
+ valueAngle: null
31
+ });
32
+ function GaugeProvider(props) {
33
+ const {
34
+ value = null,
35
+ valueMin = 0,
36
+ valueMax = 100,
37
+ startAngle = 0,
38
+ endAngle = 360,
39
+ outerRadius: outerRadiusParam,
40
+ innerRadius: innerRadiusParam,
41
+ cornerRadius: cornerRadiusParam,
42
+ cx: cxParam,
43
+ cy: cyParam,
44
+ children
45
+ } = props;
46
+ const {
47
+ width,
48
+ height,
49
+ top,
50
+ left
51
+ } = React.useContext(_DrawingProvider.DrawingContext);
52
+ const ratios = (0, _utils2.getArcRatios)(startAngle, endAngle);
53
+ const innerCx = cxParam ? (0, _utils.getPercentageValue)(cxParam, width) : ratios.cx * width;
54
+ const innerCy = cyParam ? (0, _utils.getPercentageValue)(cyParam, height) : ratios.cy * height;
55
+ let cx = left + innerCx;
56
+ let cy = top + innerCy;
57
+ const maxRadius = (0, _utils2.getAvailableRadius)(innerCx, innerCy, width, height, ratios);
58
+
59
+ // If the center is not defined, after computation of the available radius, udpate the center to use the remaining space.
60
+ if (cxParam === undefined) {
61
+ const usedWidth = maxRadius * (ratios.maxX - ratios.minX);
62
+ cx = left + (width - usedWidth) / 2 + ratios.cx * usedWidth;
63
+ }
64
+ if (cyParam === undefined) {
65
+ const usedHeight = maxRadius * (ratios.maxY - ratios.minY);
66
+ cy = top + (height - usedHeight) / 2 + ratios.cy * usedHeight;
67
+ }
68
+ const outerRadius = (0, _utils.getPercentageValue)(outerRadiusParam ?? maxRadius, maxRadius);
69
+ const innerRadius = (0, _utils.getPercentageValue)(innerRadiusParam ?? '80%', maxRadius);
70
+ const cornerRadius = (0, _utils.getPercentageValue)(cornerRadiusParam ?? 0, outerRadius - innerRadius);
71
+ const contextValue = React.useMemo(() => {
72
+ const startAngleRad = Math.PI * startAngle / 180;
73
+ const endAngleRad = Math.PI * endAngle / 180;
74
+ return {
75
+ value,
76
+ valueMin,
77
+ valueMax,
78
+ startAngle: startAngleRad,
79
+ endAngle: endAngleRad,
80
+ outerRadius,
81
+ innerRadius,
82
+ cornerRadius,
83
+ cx,
84
+ cy,
85
+ maxRadius,
86
+ valueAngle: value === null ? null : startAngleRad + (endAngleRad - startAngleRad) * (value - valueMin) / (valueMax - valueMin)
87
+ };
88
+ }, [value, valueMin, valueMax, startAngle, endAngle, outerRadius, innerRadius, cornerRadius, cx, cy, maxRadius]);
89
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(GaugeContext.Provider, {
90
+ value: contextValue,
91
+ children: children
92
+ });
93
+ }
94
+ function useGaugeState() {
95
+ return React.useContext(GaugeContext);
96
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare function GaugeReferenceArc(props: React.ComponentProps<'path'>): React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GaugeReferenceArc = GaugeReferenceArc;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _d3Shape = require("d3-shape");
11
+ var _styles = require("@mui/material/styles");
12
+ var _GaugeProvider = require("./GaugeProvider");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const StyledPath = (0, _styles.styled)('path', {
17
+ name: 'MuiGauge',
18
+ slot: 'ReferenceArc',
19
+ overridesResolver: (props, styles) => styles.referenceArc
20
+ })(({
21
+ theme
22
+ }) => ({
23
+ fill: (theme.vars || theme).palette.divider
24
+ }));
25
+ function GaugeReferenceArc(props) {
26
+ const {
27
+ startAngle,
28
+ endAngle,
29
+ outerRadius,
30
+ innerRadius,
31
+ cornerRadius,
32
+ cx,
33
+ cy
34
+ } = (0, _GaugeProvider.useGaugeState)();
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledPath, (0, _extends2.default)({
36
+ transform: `translate(${cx}, ${cy})`,
37
+ d: (0, _d3Shape.arc)().cornerRadius(cornerRadius)({
38
+ startAngle,
39
+ endAngle,
40
+ innerRadius,
41
+ outerRadius
42
+ })
43
+ }, props));
44
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare function GaugeValueArc(props: React.ComponentProps<'path'>): React.JSX.Element | null;