@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.
Files changed (234) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +37 -13
  3. package/BarChart/BarElement.d.ts +20 -13
  4. package/BarChart/BarElement.js +1 -0
  5. package/BarChart/BarPlot.d.ts +3 -5
  6. package/BarChart/BarPlot.js +9 -10
  7. package/CHANGELOG.md +223 -1
  8. package/ChartContainer/ChartContainer.js +6 -4
  9. package/ChartsAxis/ChartsAxis.js +4 -4
  10. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  11. package/ChartsGrid/ChartsGrid.js +128 -0
  12. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  13. package/ChartsGrid/chartsGridClasses.js +14 -0
  14. package/ChartsGrid/index.d.ts +2 -0
  15. package/ChartsGrid/index.js +27 -0
  16. package/ChartsGrid/package.json +6 -0
  17. package/ChartsLegend/ChartsLegend.d.ts +5 -54
  18. package/ChartsLegend/ChartsLegend.js +2 -307
  19. package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
  20. package/ChartsLegend/DefaultChartsLegend.js +294 -0
  21. package/ChartsLegend/index.d.ts +1 -0
  22. package/ChartsLegend/index.js +11 -0
  23. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  24. package/ChartsReferenceLine/common.d.ts +2 -1
  25. package/ChartsSurface.js +6 -4
  26. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  27. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  28. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  29. package/ChartsTooltip/utils.d.ts +1 -0
  30. package/ChartsTooltip/utils.js +7 -0
  31. package/ChartsXAxis/ChartsXAxis.js +15 -11
  32. package/ChartsYAxis/ChartsYAxis.js +3 -3
  33. package/Gauge/Gauge.d.ts +13 -0
  34. package/Gauge/Gauge.js +156 -0
  35. package/Gauge/GaugeContainer.d.ts +19 -0
  36. package/Gauge/GaugeContainer.js +216 -0
  37. package/Gauge/GaugeProvider.d.ts +117 -0
  38. package/Gauge/GaugeProvider.js +96 -0
  39. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  40. package/Gauge/GaugeReferenceArc.js +44 -0
  41. package/Gauge/GaugeValueArc.d.ts +2 -0
  42. package/Gauge/GaugeValueArc.js +51 -0
  43. package/Gauge/GaugeValueText.d.ts +15 -0
  44. package/Gauge/GaugeValueText.js +77 -0
  45. package/Gauge/gaugeClasses.d.ts +14 -0
  46. package/Gauge/gaugeClasses.js +15 -0
  47. package/Gauge/index.d.ts +7 -0
  48. package/Gauge/index.js +87 -0
  49. package/Gauge/package.json +6 -0
  50. package/Gauge/utils.d.ts +19 -0
  51. package/Gauge/utils.js +75 -0
  52. package/LineChart/AnimatedArea.js +1 -1
  53. package/LineChart/AnimatedLine.js +1 -1
  54. package/LineChart/AreaElement.d.ts +2 -1
  55. package/LineChart/AreaElement.js +1 -1
  56. package/LineChart/LineChart.d.ts +24 -5
  57. package/LineChart/LineChart.js +41 -13
  58. package/LineChart/LineElement.d.ts +2 -1
  59. package/LineChart/LineElement.js +1 -1
  60. package/LineChart/LineHighlightElement.d.ts +3 -2
  61. package/LineChart/LineHighlightElement.js +2 -1
  62. package/LineChart/MarkElement.d.ts +3 -2
  63. package/LineChart/MarkElement.js +1 -0
  64. package/PieChart/PieArc.d.ts +7 -6
  65. package/PieChart/PieArc.js +10 -9
  66. package/PieChart/PieArcLabel.d.ts +3 -2
  67. package/PieChart/PieArcLabel.js +1 -0
  68. package/PieChart/PieArcLabelPlot.js +14 -14
  69. package/PieChart/PieArcPlot.js +1 -1
  70. package/PieChart/PieChart.d.ts +22 -0
  71. package/PieChart/PieChart.js +32 -8
  72. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  73. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  74. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  75. package/ScatterChart/ScatterChart.d.ts +18 -0
  76. package/ScatterChart/ScatterChart.js +35 -8
  77. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  78. package/SparkLineChart/SparkLineChart.js +5 -4
  79. package/context/CartesianContextProvider.js +8 -6
  80. package/esm/BarChart/BarChart.js +37 -13
  81. package/esm/BarChart/BarElement.js +1 -0
  82. package/esm/BarChart/BarPlot.js +8 -10
  83. package/esm/ChartContainer/ChartContainer.js +6 -4
  84. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  85. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  86. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  87. package/esm/ChartsGrid/index.js +2 -0
  88. package/esm/ChartsLegend/ChartsLegend.js +2 -307
  89. package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
  90. package/esm/ChartsLegend/index.js +1 -0
  91. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  92. package/esm/ChartsSurface.js +6 -4
  93. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  94. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  95. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  96. package/esm/ChartsTooltip/utils.js +6 -0
  97. package/esm/ChartsXAxis/ChartsXAxis.js +14 -10
  98. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  99. package/esm/Gauge/Gauge.js +149 -0
  100. package/esm/Gauge/GaugeContainer.js +211 -0
  101. package/esm/Gauge/GaugeProvider.js +85 -0
  102. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  103. package/esm/Gauge/GaugeValueArc.js +42 -0
  104. package/esm/Gauge/GaugeValueText.js +69 -0
  105. package/esm/Gauge/gaugeClasses.js +7 -0
  106. package/esm/Gauge/index.js +7 -0
  107. package/esm/Gauge/utils.js +68 -0
  108. package/esm/LineChart/AnimatedArea.js +1 -1
  109. package/esm/LineChart/AnimatedLine.js +1 -1
  110. package/esm/LineChart/AreaElement.js +1 -1
  111. package/esm/LineChart/LineChart.js +41 -13
  112. package/esm/LineChart/LineElement.js +1 -1
  113. package/esm/LineChart/LineHighlightElement.js +2 -1
  114. package/esm/LineChart/MarkElement.js +1 -0
  115. package/esm/PieChart/PieArc.js +10 -9
  116. package/esm/PieChart/PieArcLabel.js +1 -0
  117. package/esm/PieChart/PieArcLabelPlot.js +14 -14
  118. package/esm/PieChart/PieArcPlot.js +1 -1
  119. package/esm/PieChart/PieChart.js +32 -8
  120. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  121. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  122. package/esm/ScatterChart/ScatterChart.js +35 -8
  123. package/esm/SparkLineChart/SparkLineChart.js +5 -4
  124. package/esm/context/CartesianContextProvider.js +8 -6
  125. package/esm/hooks/useTicks.js +2 -3
  126. package/esm/index.js +2 -0
  127. package/hooks/useTicks.d.ts +1 -2
  128. package/hooks/useTicks.js +2 -3
  129. package/index.d.ts +2 -0
  130. package/index.js +23 -1
  131. package/internals/defaultizeColor.d.ts +16 -16
  132. package/internals/defaultizeValueFormatter.d.ts +4 -7
  133. package/internals/stackSeries.d.ts +4 -7
  134. package/legacy/BarChart/BarChart.js +37 -13
  135. package/legacy/BarChart/BarElement.js +1 -0
  136. package/legacy/BarChart/BarPlot.js +10 -10
  137. package/legacy/ChartContainer/ChartContainer.js +6 -4
  138. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  139. package/legacy/ChartsGrid/ChartsGrid.js +119 -0
  140. package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
  141. package/legacy/ChartsGrid/index.js +2 -0
  142. package/legacy/ChartsLegend/ChartsLegend.js +2 -323
  143. package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
  144. package/legacy/ChartsLegend/index.js +1 -0
  145. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  146. package/legacy/ChartsSurface.js +5 -3
  147. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  148. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  149. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  150. package/legacy/ChartsTooltip/utils.js +6 -0
  151. package/legacy/ChartsXAxis/ChartsXAxis.js +13 -9
  152. package/legacy/ChartsYAxis/ChartsYAxis.js +2 -2
  153. package/legacy/Gauge/Gauge.js +146 -0
  154. package/legacy/Gauge/GaugeContainer.js +215 -0
  155. package/legacy/Gauge/GaugeProvider.js +87 -0
  156. package/legacy/Gauge/GaugeReferenceArc.js +37 -0
  157. package/legacy/Gauge/GaugeValueArc.js +44 -0
  158. package/legacy/Gauge/GaugeValueText.js +66 -0
  159. package/legacy/Gauge/gaugeClasses.js +7 -0
  160. package/legacy/Gauge/index.js +7 -0
  161. package/legacy/Gauge/utils.js +84 -0
  162. package/legacy/LineChart/AnimatedArea.js +1 -1
  163. package/legacy/LineChart/AnimatedLine.js +1 -1
  164. package/legacy/LineChart/AreaElement.js +1 -1
  165. package/legacy/LineChart/LineChart.js +41 -13
  166. package/legacy/LineChart/LineElement.js +1 -1
  167. package/legacy/LineChart/LineHighlightElement.js +2 -1
  168. package/legacy/LineChart/MarkElement.js +1 -0
  169. package/legacy/PieChart/PieArc.js +11 -10
  170. package/legacy/PieChart/PieArcLabel.js +1 -0
  171. package/legacy/PieChart/PieArcLabelPlot.js +15 -15
  172. package/legacy/PieChart/PieArcPlot.js +1 -1
  173. package/legacy/PieChart/PieChart.js +32 -8
  174. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -81
  175. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
  176. package/legacy/ScatterChart/ScatterChart.js +35 -8
  177. package/legacy/SparkLineChart/SparkLineChart.js +6 -5
  178. package/legacy/context/CartesianContextProvider.js +8 -6
  179. package/legacy/hooks/useTicks.js +2 -3
  180. package/legacy/index.js +3 -1
  181. package/models/axis.d.ts +7 -2
  182. package/models/seriesType/common.d.ts +2 -1
  183. package/models/seriesType/config.d.ts +7 -12
  184. package/models/seriesType/line.d.ts +2 -2
  185. package/models/seriesType/pie.d.ts +7 -3
  186. package/models/seriesType/scatter.d.ts +5 -2
  187. package/modern/BarChart/BarChart.js +37 -13
  188. package/modern/BarChart/BarElement.js +1 -0
  189. package/modern/BarChart/BarPlot.js +8 -10
  190. package/modern/ChartContainer/ChartContainer.js +6 -4
  191. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  192. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  193. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  194. package/modern/ChartsGrid/index.js +2 -0
  195. package/modern/ChartsLegend/ChartsLegend.js +2 -307
  196. package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
  197. package/modern/ChartsLegend/index.js +1 -0
  198. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  199. package/modern/ChartsSurface.js +6 -4
  200. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  201. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  202. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  203. package/modern/ChartsTooltip/utils.js +6 -0
  204. package/modern/ChartsXAxis/ChartsXAxis.js +14 -10
  205. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  206. package/modern/Gauge/Gauge.js +149 -0
  207. package/modern/Gauge/GaugeContainer.js +208 -0
  208. package/modern/Gauge/GaugeProvider.js +85 -0
  209. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  210. package/modern/Gauge/GaugeValueArc.js +42 -0
  211. package/modern/Gauge/GaugeValueText.js +69 -0
  212. package/modern/Gauge/gaugeClasses.js +7 -0
  213. package/modern/Gauge/index.js +7 -0
  214. package/modern/Gauge/utils.js +68 -0
  215. package/modern/LineChart/AnimatedArea.js +1 -1
  216. package/modern/LineChart/AnimatedLine.js +1 -1
  217. package/modern/LineChart/AreaElement.js +1 -1
  218. package/modern/LineChart/LineChart.js +41 -13
  219. package/modern/LineChart/LineElement.js +1 -1
  220. package/modern/LineChart/LineHighlightElement.js +2 -1
  221. package/modern/LineChart/MarkElement.js +1 -0
  222. package/modern/PieChart/PieArc.js +10 -9
  223. package/modern/PieChart/PieArcLabel.js +1 -0
  224. package/modern/PieChart/PieArcLabelPlot.js +14 -14
  225. package/modern/PieChart/PieArcPlot.js +1 -1
  226. package/modern/PieChart/PieChart.js +32 -8
  227. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  228. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  229. package/modern/ScatterChart/ScatterChart.js +35 -8
  230. package/modern/SparkLineChart/SparkLineChart.js +5 -4
  231. package/modern/context/CartesianContextProvider.js +8 -6
  232. package/modern/hooks/useTicks.js +2 -3
  233. package/modern/index.js +3 -1
  234. package/package.json +4 -4
@@ -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;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GaugeValueArc = GaugeValueArc;
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.primary.main
24
+ }));
25
+ function GaugeValueArc(props) {
26
+ const {
27
+ value,
28
+ valueMin,
29
+ valueMax,
30
+ startAngle,
31
+ endAngle,
32
+ outerRadius,
33
+ innerRadius,
34
+ cornerRadius,
35
+ cx,
36
+ cy
37
+ } = (0, _GaugeProvider.useGaugeState)();
38
+ if (value === null) {
39
+ return null;
40
+ }
41
+ const valueAngle = startAngle + (value - valueMin) / (valueMax - valueMin) * (endAngle - startAngle);
42
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledPath, (0, _extends2.default)({
43
+ transform: `translate(${cx}, ${cy})`,
44
+ d: (0, _d3Shape.arc)().cornerRadius(cornerRadius)({
45
+ startAngle,
46
+ endAngle: valueAngle,
47
+ innerRadius,
48
+ outerRadius
49
+ })
50
+ }, props));
51
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { ChartsTextProps } from '../ChartsText';
3
+ export interface GaugeFormatterParams {
4
+ value: number | null;
5
+ valueMin: number;
6
+ valueMax: number;
7
+ }
8
+ export interface GaugeValueTextProps extends Omit<ChartsTextProps, 'text'> {
9
+ text?: string | ((params: GaugeFormatterParams) => string | null);
10
+ }
11
+ declare function GaugeValueText(props: GaugeValueTextProps): React.JSX.Element | null;
12
+ declare namespace GaugeValueText {
13
+ var propTypes: any;
14
+ }
15
+ export { GaugeValueText };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GaugeValueText = GaugeValueText;
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 _GaugeProvider = require("./GaugeProvider");
13
+ var _ChartsText = require("../ChartsText");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ const _excluded = ["text", "className"];
16
+ 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); }
17
+ 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; }
18
+ function defaultFormatter({
19
+ value
20
+ }) {
21
+ return value === null ? 'NaN' : value.toLocaleString();
22
+ }
23
+ function GaugeValueText(props) {
24
+ const {
25
+ text = defaultFormatter,
26
+ className
27
+ } = props,
28
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
29
+ const {
30
+ value,
31
+ valueMin,
32
+ valueMax,
33
+ cx,
34
+ cy
35
+ } = (0, _GaugeProvider.useGaugeState)();
36
+ const formattedText = typeof text === 'function' ? text({
37
+ value,
38
+ valueMin,
39
+ valueMax
40
+ }) : text;
41
+ if (formattedText === null) {
42
+ return null;
43
+ }
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
45
+ className: className,
46
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, (0, _extends2.default)({
47
+ x: cx,
48
+ y: cy,
49
+ text: formattedText,
50
+ style: {
51
+ textAnchor: 'middle',
52
+ dominantBaseline: 'central'
53
+ }
54
+ }, other))
55
+ });
56
+ }
57
+ process.env.NODE_ENV !== "production" ? GaugeValueText.propTypes = {
58
+ // ----------------------------- Warning --------------------------------
59
+ // | These PropTypes are generated from the TypeScript type definitions |
60
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
61
+ // ----------------------------------------------------------------------
62
+ /**
63
+ * Height of a text line (in `em`).
64
+ */
65
+ lineHeight: _propTypes.default.number,
66
+ /**
67
+ * If `true`, the line width is computed.
68
+ * @default false
69
+ */
70
+ needsComputation: _propTypes.default.bool,
71
+ ownerState: _propTypes.default.any,
72
+ /**
73
+ * Style applied to text elements.
74
+ */
75
+ style: _propTypes.default.object,
76
+ text: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string])
77
+ } : void 0;
@@ -0,0 +1,14 @@
1
+ export interface GaugeClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ /** Styles applied to the arc diplaying the value. */
5
+ valueArc: string;
6
+ /** Styles applied to the arc diplaying the range of available values. */
7
+ referenceArc: string;
8
+ /** Styles applied to the value text. */
9
+ valueText: string;
10
+ }
11
+ export type GaugeClassKey = keyof GaugeClasses;
12
+ export declare function getGaugeUtilityClass(slot: string): string;
13
+ export declare const gaugeClasses: GaugeClasses;
14
+ export default gaugeClasses;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.gaugeClasses = exports.default = void 0;
8
+ exports.getGaugeUtilityClass = getGaugeUtilityClass;
9
+ var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
10
+ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
11
+ function getGaugeUtilityClass(slot) {
12
+ return (0, _generateUtilityClass.default)('MuiGauge', slot);
13
+ }
14
+ const gaugeClasses = exports.gaugeClasses = (0, _generateUtilityClasses.default)('MuiGauge', ['root', 'valueArc', 'referenceArc', 'valueText']);
15
+ var _default = exports.default = gaugeClasses;
@@ -0,0 +1,7 @@
1
+ export * from './Gauge';
2
+ export * from './GaugeContainer';
3
+ export * from './GaugeValueText';
4
+ export * from './GaugeValueArc';
5
+ export * from './GaugeReferenceArc';
6
+ export * from './gaugeClasses';
7
+ export { useGaugeState } from './GaugeProvider';