@mui/x-charts 7.0.0-beta.2 → 7.0.0-beta.4

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 (265) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +27 -7
  3. package/CHANGELOG.md +298 -23
  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/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  12. package/ChartsSurface.js +6 -4
  13. package/ChartsTooltip/utils.js +1 -1
  14. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
  15. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
  16. package/ChartsXAxis/ChartsXAxis.js +3 -3
  17. package/ChartsYAxis/ChartsYAxis.js +3 -3
  18. package/Gauge/Gauge.d.ts +13 -0
  19. package/Gauge/Gauge.js +154 -0
  20. package/Gauge/GaugeContainer.d.ts +17 -0
  21. package/Gauge/GaugeContainer.js +214 -0
  22. package/Gauge/GaugeProvider.d.ts +117 -0
  23. package/Gauge/GaugeProvider.js +99 -0
  24. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  25. package/Gauge/GaugeReferenceArc.js +44 -0
  26. package/Gauge/GaugeValueArc.d.ts +2 -0
  27. package/Gauge/GaugeValueArc.js +51 -0
  28. package/Gauge/GaugeValueText.d.ts +15 -0
  29. package/Gauge/GaugeValueText.js +77 -0
  30. package/Gauge/gaugeClasses.d.ts +14 -0
  31. package/Gauge/gaugeClasses.js +15 -0
  32. package/Gauge/index.d.ts +7 -0
  33. package/Gauge/index.js +87 -0
  34. package/Gauge/package.json +6 -0
  35. package/Gauge/utils.d.ts +19 -0
  36. package/Gauge/utils.js +75 -0
  37. package/LineChart/LineChart.d.ts +24 -5
  38. package/LineChart/LineChart.js +31 -7
  39. package/PieChart/PieArc.d.ts +4 -4
  40. package/PieChart/PieArc.js +9 -9
  41. package/PieChart/PieArcLabelPlot.js +13 -13
  42. package/PieChart/PieChart.d.ts +22 -0
  43. package/PieChart/PieChart.js +22 -2
  44. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
  45. package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  46. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  47. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  48. package/ScatterChart/ScatterChart.d.ts +18 -0
  49. package/ScatterChart/ScatterChart.js +25 -3
  50. package/SparkLineChart/SparkLineChart.js +0 -2
  51. package/context/CartesianContextProvider.d.ts +0 -8
  52. package/context/CartesianContextProvider.js +4 -89
  53. package/context/DrawingProvider.d.ts +2 -11
  54. package/context/DrawingProvider.js +10 -35
  55. package/context/HighlightProvider.js +3 -0
  56. package/context/InteractionProvider.js +3 -0
  57. package/context/SeriesContextProvider.js +3 -0
  58. package/context/index.d.ts +0 -2
  59. package/context/index.js +1 -15
  60. package/esm/BarChart/BarChart.js +27 -7
  61. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  62. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  63. package/esm/ChartsGrid/index.js +2 -0
  64. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  65. package/esm/ChartsSurface.js +6 -4
  66. package/esm/ChartsTooltip/utils.js +2 -2
  67. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  68. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  69. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  70. package/esm/Gauge/Gauge.js +147 -0
  71. package/esm/Gauge/GaugeContainer.js +209 -0
  72. package/esm/Gauge/GaugeProvider.js +88 -0
  73. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  74. package/esm/Gauge/GaugeValueArc.js +42 -0
  75. package/esm/Gauge/GaugeValueText.js +69 -0
  76. package/esm/Gauge/gaugeClasses.js +7 -0
  77. package/esm/Gauge/index.js +7 -0
  78. package/esm/Gauge/utils.js +68 -0
  79. package/esm/LineChart/LineChart.js +31 -7
  80. package/esm/PieChart/PieArc.js +9 -9
  81. package/esm/PieChart/PieArcLabelPlot.js +13 -13
  82. package/esm/PieChart/PieChart.js +22 -2
  83. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  84. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  85. package/esm/ScatterChart/ScatterChart.js +25 -3
  86. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  87. package/esm/context/CartesianContextProvider.js +3 -88
  88. package/esm/context/DrawingProvider.js +10 -36
  89. package/esm/context/HighlightProvider.js +3 -0
  90. package/esm/context/InteractionProvider.js +3 -0
  91. package/esm/context/SeriesContextProvider.js +3 -0
  92. package/esm/context/index.js +1 -2
  93. package/esm/hooks/useAxisEvents.js +2 -2
  94. package/esm/hooks/useTicks.js +2 -3
  95. package/esm/index.js +2 -0
  96. package/hooks/useAxisEvents.js +1 -1
  97. package/hooks/useTicks.d.ts +2 -3
  98. package/hooks/useTicks.js +2 -3
  99. package/index.d.ts +2 -0
  100. package/index.js +23 -1
  101. package/modern/BarChart/BarChart.js +27 -7
  102. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  103. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  104. package/modern/ChartsGrid/index.js +2 -0
  105. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  106. package/modern/ChartsSurface.js +6 -4
  107. package/modern/ChartsTooltip/utils.js +2 -2
  108. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  109. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  110. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  111. package/modern/Gauge/Gauge.js +147 -0
  112. package/modern/Gauge/GaugeContainer.js +206 -0
  113. package/modern/Gauge/GaugeProvider.js +88 -0
  114. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  115. package/modern/Gauge/GaugeValueArc.js +42 -0
  116. package/modern/Gauge/GaugeValueText.js +69 -0
  117. package/modern/Gauge/gaugeClasses.js +7 -0
  118. package/modern/Gauge/index.js +7 -0
  119. package/modern/Gauge/utils.js +68 -0
  120. package/modern/LineChart/LineChart.js +31 -7
  121. package/modern/PieChart/PieArc.js +9 -9
  122. package/modern/PieChart/PieArcLabelPlot.js +13 -13
  123. package/modern/PieChart/PieChart.js +22 -2
  124. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  125. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  126. package/modern/ScatterChart/ScatterChart.js +25 -3
  127. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  128. package/modern/context/CartesianContextProvider.js +3 -88
  129. package/modern/context/DrawingProvider.js +10 -36
  130. package/modern/context/HighlightProvider.js +3 -0
  131. package/modern/context/InteractionProvider.js +3 -0
  132. package/modern/context/SeriesContextProvider.js +3 -0
  133. package/modern/context/index.js +1 -2
  134. package/modern/hooks/useAxisEvents.js +2 -2
  135. package/modern/hooks/useTicks.js +2 -3
  136. package/modern/index.js +3 -1
  137. package/package.json +4 -4
  138. package/legacy/BarChart/BarChart.js +0 -418
  139. package/legacy/BarChart/BarElement.js +0 -119
  140. package/legacy/BarChart/BarPlot.js +0 -232
  141. package/legacy/BarChart/extremums.js +0 -45
  142. package/legacy/BarChart/formatter.js +0 -78
  143. package/legacy/BarChart/index.js +0 -3
  144. package/legacy/BarChart/legend.js +0 -15
  145. package/legacy/ChartContainer/ChartContainer.js +0 -189
  146. package/legacy/ChartContainer/index.js +0 -1
  147. package/legacy/ChartsAxis/ChartsAxis.js +0 -215
  148. package/legacy/ChartsAxis/axisClasses.js +0 -5
  149. package/legacy/ChartsAxis/index.js +0 -2
  150. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
  151. package/legacy/ChartsAxisHighlight/index.js +0 -1
  152. package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
  153. package/legacy/ChartsClipPath/index.js +0 -1
  154. package/legacy/ChartsLegend/ChartsLegend.js +0 -100
  155. package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
  156. package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
  157. package/legacy/ChartsLegend/index.js +0 -4
  158. package/legacy/ChartsLegend/utils.js +0 -15
  159. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
  160. package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
  161. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
  162. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
  163. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
  164. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
  165. package/legacy/ChartsReferenceLine/common.js +0 -19
  166. package/legacy/ChartsReferenceLine/index.js +0 -2
  167. package/legacy/ChartsSurface.js +0 -76
  168. package/legacy/ChartsText/ChartsText.js +0 -95
  169. package/legacy/ChartsText/index.js +0 -1
  170. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
  171. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
  172. package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
  173. package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
  174. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
  175. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
  176. package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
  177. package/legacy/ChartsTooltip/index.js +0 -6
  178. package/legacy/ChartsTooltip/utils.js +0 -103
  179. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
  180. package/legacy/ChartsVoronoiHandler/index.js +0 -1
  181. package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
  182. package/legacy/ChartsXAxis/index.js +0 -1
  183. package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
  184. package/legacy/ChartsYAxis/index.js +0 -1
  185. package/legacy/LineChart/AnimatedArea.js +0 -102
  186. package/legacy/LineChart/AnimatedLine.js +0 -104
  187. package/legacy/LineChart/AreaElement.js +0 -112
  188. package/legacy/LineChart/AreaPlot.js +0 -149
  189. package/legacy/LineChart/LineChart.js +0 -426
  190. package/legacy/LineChart/LineElement.js +0 -112
  191. package/legacy/LineChart/LineHighlightElement.js +0 -79
  192. package/legacy/LineChart/LineHighlightPlot.js +0 -97
  193. package/legacy/LineChart/LinePlot.js +0 -144
  194. package/legacy/LineChart/MarkElement.js +0 -153
  195. package/legacy/LineChart/MarkPlot.js +0 -178
  196. package/legacy/LineChart/extremums.js +0 -54
  197. package/legacy/LineChart/formatter.js +0 -82
  198. package/legacy/LineChart/index.js +0 -11
  199. package/legacy/LineChart/legend.js +0 -15
  200. package/legacy/PieChart/PieArc.js +0 -103
  201. package/legacy/PieChart/PieArcLabel.js +0 -112
  202. package/legacy/PieChart/PieArcLabelPlot.js +0 -193
  203. package/legacy/PieChart/PieArcPlot.js +0 -180
  204. package/legacy/PieChart/PieChart.js +0 -382
  205. package/legacy/PieChart/PiePlot.js +0 -137
  206. package/legacy/PieChart/dataTransform/transition.js +0 -149
  207. package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
  208. package/legacy/PieChart/formatter.js +0 -55
  209. package/legacy/PieChart/index.js +0 -6
  210. package/legacy/PieChart/legend.js +0 -16
  211. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -255
  212. package/legacy/ResponsiveChartContainer/index.js +0 -1
  213. package/legacy/ScatterChart/Scatter.js +0 -110
  214. package/legacy/ScatterChart/ScatterChart.js +0 -370
  215. package/legacy/ScatterChart/ScatterPlot.js +0 -80
  216. package/legacy/ScatterChart/extremums.js +0 -39
  217. package/legacy/ScatterChart/formatter.js +0 -12
  218. package/legacy/ScatterChart/index.js +0 -3
  219. package/legacy/ScatterChart/legend.js +0 -15
  220. package/legacy/SparkLineChart/SparkLineChart.js +0 -266
  221. package/legacy/SparkLineChart/index.js +0 -1
  222. package/legacy/colorPalettes/colorPalettes.js +0 -15
  223. package/legacy/colorPalettes/index.js +0 -1
  224. package/legacy/constants.js +0 -8
  225. package/legacy/context/CartesianContextProvider.js +0 -327
  226. package/legacy/context/DrawingProvider.js +0 -74
  227. package/legacy/context/HighlightProvider.js +0 -56
  228. package/legacy/context/InteractionProvider.js +0 -81
  229. package/legacy/context/SeriesContextProvider.js +0 -74
  230. package/legacy/context/index.js +0 -2
  231. package/legacy/hooks/index.js +0 -2
  232. package/legacy/hooks/useAxisEvents.js +0 -120
  233. package/legacy/hooks/useChartDimensions.js +0 -18
  234. package/legacy/hooks/useDrawingArea.js +0 -21
  235. package/legacy/hooks/useInteractionItemProps.js +0 -71
  236. package/legacy/hooks/useMounted.js +0 -21
  237. package/legacy/hooks/useReducedMotion.js +0 -27
  238. package/legacy/hooks/useScale.js +0 -33
  239. package/legacy/hooks/useTicks.js +0 -66
  240. package/legacy/index.js +0 -31
  241. package/legacy/internals/components/AxisSharedComponents.js +0 -25
  242. package/legacy/internals/defaultizeColor.js +0 -17
  243. package/legacy/internals/defaultizeValueFormatter.js +0 -12
  244. package/legacy/internals/domUtils.js +0 -121
  245. package/legacy/internals/geometry.js +0 -37
  246. package/legacy/internals/getCurve.js +0 -39
  247. package/legacy/internals/getScale.js +0 -17
  248. package/legacy/internals/getWordsByLines.js +0 -15
  249. package/legacy/internals/isBandScale.js +0 -3
  250. package/legacy/internals/stackSeries.js +0 -92
  251. package/legacy/internals/useAnimatedPath.js +0 -32
  252. package/legacy/internals/utils.js +0 -52
  253. package/legacy/models/axis.js +0 -6
  254. package/legacy/models/helpers.js +0 -1
  255. package/legacy/models/index.js +0 -4
  256. package/legacy/models/layout.js +0 -1
  257. package/legacy/models/seriesType/bar.js +0 -1
  258. package/legacy/models/seriesType/common.js +0 -1
  259. package/legacy/models/seriesType/config.js +0 -1
  260. package/legacy/models/seriesType/index.js +0 -5
  261. package/legacy/models/seriesType/line.js +0 -1
  262. package/legacy/models/seriesType/pie.js +0 -1
  263. package/legacy/models/seriesType/scatter.js +0 -1
  264. package/legacy/models/stacking.js +0 -1
  265. package/legacy/themeAugmentation/index.js +0 -3
@@ -0,0 +1,209 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["width", "height", "margin", "title", "desc", "value", "valueMin", "valueMax", "startAngle", "endAngle", "outerRadius", "innerRadius", "cornerRadius", "cx", "cy", "children"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import useForkRef from '@mui/utils/useForkRef';
7
+ import { styled } from '@mui/material/styles';
8
+ import { useChartContainerDimensions } from '../ResponsiveChartContainer/useChartContainerDimensions';
9
+ import { ChartsSurface } from '../ChartsSurface';
10
+ import { DrawingProvider } from '../context/DrawingProvider';
11
+ import { GaugeProvider } from './GaugeProvider';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const ResizableContainer = styled('div', {
14
+ name: 'MuiGauge',
15
+ slot: 'Container'
16
+ })(({
17
+ ownerState,
18
+ theme
19
+ }) => {
20
+ var _ownerState$width, _ownerState$height;
21
+ return {
22
+ width: (_ownerState$width = ownerState.width) != null ? _ownerState$width : '100%',
23
+ height: (_ownerState$height = ownerState.height) != null ? _ownerState$height : '100%',
24
+ display: 'flex',
25
+ position: 'relative',
26
+ flexGrow: 1,
27
+ flexDirection: 'column',
28
+ alignItems: 'center',
29
+ justifyContent: 'center',
30
+ overflow: 'hidden',
31
+ '&>svg': {
32
+ width: '100%',
33
+ height: '100%'
34
+ },
35
+ '& text': {
36
+ fill: (theme.vars || theme).palette.text.primary
37
+ }
38
+ };
39
+ });
40
+ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(props, ref) {
41
+ const {
42
+ width: inWidth,
43
+ height: inHeight,
44
+ margin,
45
+ title,
46
+ desc,
47
+ value,
48
+ valueMin = 0,
49
+ valueMax = 100,
50
+ startAngle,
51
+ endAngle,
52
+ outerRadius,
53
+ innerRadius,
54
+ cornerRadius,
55
+ cx,
56
+ cy,
57
+ children
58
+ } = props,
59
+ other = _objectWithoutPropertiesLoose(props, _excluded);
60
+ const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
61
+ const svgRef = React.useRef(null);
62
+ const handleRef = useForkRef(ref, svgRef);
63
+ return /*#__PURE__*/_jsx(ResizableContainer, _extends({
64
+ ref: containerRef,
65
+ ownerState: {
66
+ width: inWidth,
67
+ height: inHeight
68
+ },
69
+ role: "meter",
70
+ "aria-valuenow": value === null ? undefined : value,
71
+ "aria-valuemin": valueMin,
72
+ "aria-valuemax": valueMax
73
+ }, other, {
74
+ children: width && height ? /*#__PURE__*/_jsx(DrawingProvider, {
75
+ width: width,
76
+ height: height,
77
+ margin: _extends({
78
+ left: 10,
79
+ right: 10,
80
+ top: 10,
81
+ bottom: 10
82
+ }, margin),
83
+ svgRef: svgRef,
84
+ children: /*#__PURE__*/_jsx(GaugeProvider, {
85
+ value: value,
86
+ valueMin: valueMin,
87
+ valueMax: valueMax,
88
+ startAngle: startAngle,
89
+ endAngle: endAngle,
90
+ outerRadius: outerRadius,
91
+ innerRadius: innerRadius,
92
+ cornerRadius: cornerRadius,
93
+ cx: cx,
94
+ cy: cy,
95
+ children: /*#__PURE__*/_jsx(ChartsSurface, {
96
+ width: width,
97
+ height: height,
98
+ ref: handleRef,
99
+ title: title,
100
+ desc: desc,
101
+ disableAxisListener: true,
102
+ "aria-hidden": "true",
103
+ children: children
104
+ })
105
+ })
106
+ }) : null
107
+ }));
108
+ });
109
+ process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
110
+ // ----------------------------- Warning --------------------------------
111
+ // | These PropTypes are generated from the TypeScript type definitions |
112
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
113
+ // ----------------------------------------------------------------------
114
+ children: PropTypes.node,
115
+ className: PropTypes.string,
116
+ /**
117
+ * The radius applied to arc corners (similar to border radius).
118
+ * Set it to '50%' to get rounded arc.
119
+ * @default 0
120
+ */
121
+ cornerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
122
+ /**
123
+ * The x coordinate of the arc center.
124
+ * Can be a number (in px) or a string with a percentage such as '50%'.
125
+ * The '100%' is the width the drawing area.
126
+ */
127
+ cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
128
+ /**
129
+ * The y 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 height the drawing area.
132
+ */
133
+ cy: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
134
+ desc: PropTypes.string,
135
+ /**
136
+ * If `true`, the charts will not listen to the mouse move event.
137
+ * It might break interactive features, but will improve performance.
138
+ * @default false
139
+ */
140
+ disableAxisListener: PropTypes.bool,
141
+ /**
142
+ * The end angle (deg).
143
+ * @default 360
144
+ */
145
+ endAngle: PropTypes.number,
146
+ /**
147
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
148
+ */
149
+ height: PropTypes.number,
150
+ /**
151
+ * The radius between circle center and the begining of the arc.
152
+ * Can be a number (in px) or a string with a percentage such as '50%'.
153
+ * The '100%' is the maximal radius that fit into the drawing area.
154
+ * @default '80%'
155
+ */
156
+ innerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
157
+ /**
158
+ * The margin between the SVG and the drawing area.
159
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
160
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
161
+ * @default object Depends on the charts type.
162
+ */
163
+ margin: PropTypes.shape({
164
+ bottom: PropTypes.number,
165
+ left: PropTypes.number,
166
+ right: PropTypes.number,
167
+ top: PropTypes.number
168
+ }),
169
+ /**
170
+ * The radius between circle center and the end of the arc.
171
+ * Can be a number (in px) or a string with a percentage such as '50%'.
172
+ * The '100%' is the maximal radius that fit into the drawing area.
173
+ * @default '100%'
174
+ */
175
+ outerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
176
+ /**
177
+ * The start angle (deg).
178
+ * @default 0
179
+ */
180
+ startAngle: PropTypes.number,
181
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
182
+ title: PropTypes.string,
183
+ /**
184
+ * The value of the gauge.
185
+ * Set to `null` to not display a value.
186
+ */
187
+ value: PropTypes.number,
188
+ /**
189
+ * The maximal value of the gauge.
190
+ * @default 100
191
+ */
192
+ valueMax: PropTypes.number,
193
+ /**
194
+ * The minimal value of the gauge.
195
+ * @default 0
196
+ */
197
+ valueMin: PropTypes.number,
198
+ viewBox: PropTypes.shape({
199
+ height: PropTypes.number,
200
+ width: PropTypes.number,
201
+ x: PropTypes.number,
202
+ y: PropTypes.number
203
+ }),
204
+ /**
205
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
206
+ */
207
+ width: PropTypes.number
208
+ } : void 0;
209
+ export { GaugeContainer };
@@ -0,0 +1,88 @@
1
+ // @ignore - do not document.
2
+ import * as React from 'react';
3
+ import { DrawingContext } from '../context/DrawingProvider';
4
+ import { getPercentageValue } from '../internals/utils';
5
+ import { getArcRatios, getAvailableRadius } from './utils';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export const GaugeContext = /*#__PURE__*/React.createContext({
8
+ value: null,
9
+ valueMin: 0,
10
+ valueMax: 0,
11
+ startAngle: 0,
12
+ endAngle: 0,
13
+ innerRadius: 0,
14
+ outerRadius: 0,
15
+ cornerRadius: 0,
16
+ cx: 0,
17
+ cy: 0,
18
+ maxRadius: 0,
19
+ valueAngle: null
20
+ });
21
+ if (process.env.NODE_ENV !== 'production') {
22
+ GaugeContext.displayName = 'GaugeContext';
23
+ }
24
+ export function GaugeProvider(props) {
25
+ const {
26
+ value = null,
27
+ valueMin = 0,
28
+ valueMax = 100,
29
+ startAngle = 0,
30
+ endAngle = 360,
31
+ outerRadius: outerRadiusParam,
32
+ innerRadius: innerRadiusParam,
33
+ cornerRadius: cornerRadiusParam,
34
+ cx: cxParam,
35
+ cy: cyParam,
36
+ children
37
+ } = props;
38
+ const {
39
+ width,
40
+ height,
41
+ top,
42
+ left
43
+ } = React.useContext(DrawingContext);
44
+ const ratios = getArcRatios(startAngle, endAngle);
45
+ const innerCx = cxParam ? getPercentageValue(cxParam, width) : ratios.cx * width;
46
+ const innerCy = cyParam ? getPercentageValue(cyParam, height) : ratios.cy * height;
47
+ let cx = left + innerCx;
48
+ let cy = top + innerCy;
49
+ const maxRadius = getAvailableRadius(innerCx, innerCy, width, height, ratios);
50
+
51
+ // If the center is not defined, after computation of the available radius, udpate the center to use the remaining space.
52
+ if (cxParam === undefined) {
53
+ const usedWidth = maxRadius * (ratios.maxX - ratios.minX);
54
+ cx = left + (width - usedWidth) / 2 + ratios.cx * usedWidth;
55
+ }
56
+ if (cyParam === undefined) {
57
+ const usedHeight = maxRadius * (ratios.maxY - ratios.minY);
58
+ cy = top + (height - usedHeight) / 2 + ratios.cy * usedHeight;
59
+ }
60
+ const outerRadius = getPercentageValue(outerRadiusParam != null ? outerRadiusParam : maxRadius, maxRadius);
61
+ const innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : '80%', maxRadius);
62
+ const cornerRadius = getPercentageValue(cornerRadiusParam != null ? cornerRadiusParam : 0, outerRadius - innerRadius);
63
+ const contextValue = React.useMemo(() => {
64
+ const startAngleRad = Math.PI * startAngle / 180;
65
+ const endAngleRad = Math.PI * endAngle / 180;
66
+ return {
67
+ value,
68
+ valueMin,
69
+ valueMax,
70
+ startAngle: startAngleRad,
71
+ endAngle: endAngleRad,
72
+ outerRadius,
73
+ innerRadius,
74
+ cornerRadius,
75
+ cx,
76
+ cy,
77
+ maxRadius,
78
+ valueAngle: value === null ? null : startAngleRad + (endAngleRad - startAngleRad) * (value - valueMin) / (valueMax - valueMin)
79
+ };
80
+ }, [value, valueMin, valueMax, startAngle, endAngle, outerRadius, innerRadius, cornerRadius, cx, cy, maxRadius]);
81
+ return /*#__PURE__*/_jsx(GaugeContext.Provider, {
82
+ value: contextValue,
83
+ children: children
84
+ });
85
+ }
86
+ export function useGaugeState() {
87
+ return React.useContext(GaugeContext);
88
+ }
@@ -0,0 +1,35 @@
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
+ const StyledPath = styled('path', {
8
+ name: 'MuiGauge',
9
+ slot: 'ReferenceArc',
10
+ overridesResolver: (props, styles) => styles.referenceArc
11
+ })(({
12
+ theme
13
+ }) => ({
14
+ fill: (theme.vars || theme).palette.divider
15
+ }));
16
+ export function GaugeReferenceArc(props) {
17
+ const {
18
+ startAngle,
19
+ endAngle,
20
+ outerRadius,
21
+ innerRadius,
22
+ cornerRadius,
23
+ cx,
24
+ cy
25
+ } = useGaugeState();
26
+ return /*#__PURE__*/_jsx(StyledPath, _extends({
27
+ transform: `translate(${cx}, ${cy})`,
28
+ d: d3Arc().cornerRadius(cornerRadius)({
29
+ startAngle,
30
+ endAngle,
31
+ innerRadius,
32
+ outerRadius
33
+ })
34
+ }, props));
35
+ }
@@ -0,0 +1,42 @@
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
+ const StyledPath = styled('path', {
8
+ name: 'MuiGauge',
9
+ slot: 'ReferenceArc',
10
+ overridesResolver: (props, styles) => styles.referenceArc
11
+ })(({
12
+ theme
13
+ }) => ({
14
+ fill: (theme.vars || theme).palette.primary.main
15
+ }));
16
+ export function GaugeValueArc(props) {
17
+ const {
18
+ value,
19
+ valueMin,
20
+ valueMax,
21
+ startAngle,
22
+ endAngle,
23
+ outerRadius,
24
+ innerRadius,
25
+ cornerRadius,
26
+ cx,
27
+ cy
28
+ } = useGaugeState();
29
+ if (value === null) {
30
+ return null;
31
+ }
32
+ const valueAngle = startAngle + (value - valueMin) / (valueMax - valueMin) * (endAngle - startAngle);
33
+ return /*#__PURE__*/_jsx(StyledPath, _extends({
34
+ transform: `translate(${cx}, ${cy})`,
35
+ d: d3Arc().cornerRadius(cornerRadius)({
36
+ startAngle,
37
+ endAngle: valueAngle,
38
+ innerRadius,
39
+ outerRadius
40
+ })
41
+ }, props));
42
+ }
@@ -0,0 +1,69 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _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({
10
+ value
11
+ }) {
12
+ return value === null ? null : value.toLocaleString();
13
+ }
14
+ function GaugeValueText(props) {
15
+ const {
16
+ text = defaultFormatter,
17
+ className
18
+ } = props,
19
+ other = _objectWithoutPropertiesLoose(props, _excluded);
20
+ const {
21
+ value,
22
+ valueMin,
23
+ valueMax,
24
+ cx,
25
+ cy
26
+ } = useGaugeState();
27
+ const formattedText = typeof text === 'function' ? text({
28
+ value,
29
+ valueMin,
30
+ valueMax
31
+ }) : text;
32
+ if (formattedText === null) {
33
+ return null;
34
+ }
35
+ return /*#__PURE__*/_jsx("g", {
36
+ className: className,
37
+ children: /*#__PURE__*/_jsx(ChartsText, _extends({
38
+ x: cx,
39
+ y: cy,
40
+ text: formattedText,
41
+ style: {
42
+ textAnchor: 'middle',
43
+ dominantBaseline: 'central'
44
+ }
45
+ }, other))
46
+ });
47
+ }
48
+ process.env.NODE_ENV !== "production" ? GaugeValueText.propTypes = {
49
+ // ----------------------------- Warning --------------------------------
50
+ // | These PropTypes are generated from the TypeScript type definitions |
51
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
52
+ // ----------------------------------------------------------------------
53
+ /**
54
+ * Height of a text line (in `em`).
55
+ */
56
+ lineHeight: PropTypes.number,
57
+ /**
58
+ * If `true`, the line width is computed.
59
+ * @default false
60
+ */
61
+ needsComputation: PropTypes.bool,
62
+ ownerState: PropTypes.any,
63
+ /**
64
+ * Style applied to text elements.
65
+ */
66
+ style: PropTypes.object,
67
+ text: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
68
+ } : void 0;
69
+ 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 const gaugeClasses = generateUtilityClasses('MuiGauge', ['root', 'valueArc', 'referenceArc', 'valueText']);
7
+ export 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';
@@ -0,0 +1,68 @@
1
+ function deg2rad(angle) {
2
+ return Math.PI * angle / 180;
3
+ }
4
+ function getPoint(angle) {
5
+ const radAngle = deg2rad(angle);
6
+ return [Math.sin(radAngle), -Math.cos(radAngle)];
7
+ }
8
+
9
+ /**
10
+ * Retruns the ratio of the arc bounding box and its center.
11
+ * @param startAngle The start angle (in deg)
12
+ * @param endAngle The end angle (in deg)
13
+ */
14
+ export function getArcRatios(startAngle, endAngle) {
15
+ // Set the start, end and center point.
16
+ const points = [[0, 0], getPoint(startAngle), getPoint(endAngle)];
17
+
18
+ // Add cardinal points included in the arc
19
+ const minAngle = Math.min(startAngle, endAngle);
20
+ const maxAngle = Math.max(startAngle, endAngle);
21
+ const initialAngle = Math.floor(minAngle / 90) * 90;
22
+ for (let step = 1; step <= 4; step += 1) {
23
+ const cartinalAngle = initialAngle + step * 90;
24
+ if (cartinalAngle < maxAngle) {
25
+ points.push(getPoint(cartinalAngle));
26
+ }
27
+ }
28
+ const minX = Math.min(...points.map(([x]) => x));
29
+ const maxX = Math.max(...points.map(([x]) => x));
30
+ const minY = Math.min(...points.map(([, y]) => y));
31
+ const maxY = Math.max(...points.map(([, y]) => y));
32
+ return {
33
+ cx: -minX / (maxX - minX),
34
+ cy: -minY / (maxY - minY),
35
+ minX,
36
+ maxX,
37
+ minY,
38
+ maxY
39
+ };
40
+ }
41
+ export function getAvailableRadius(cx, cy, width, height, {
42
+ minX,
43
+ maxX,
44
+ minY,
45
+ maxY
46
+ }) {
47
+ return Math.min(...[{
48
+ ratio: Math.abs(minX),
49
+ space: cx
50
+ }, {
51
+ ratio: Math.abs(maxX),
52
+ space: width - cx
53
+ }, {
54
+ ratio: Math.abs(minY),
55
+ space: cy
56
+ }, {
57
+ ratio: Math.abs(maxY),
58
+ space: height - cy
59
+ }].map(({
60
+ ratio,
61
+ space
62
+ }) => {
63
+ if (ratio < 0.00001) {
64
+ return Infinity;
65
+ }
66
+ return space / ratio;
67
+ }));
68
+ }
@@ -13,6 +13,7 @@ import { ChartsLegend } from '../ChartsLegend';
13
13
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
14
14
  import { ChartsClipPath } from '../ChartsClipPath';
15
15
  import { LineHighlightPlot } from './LineHighlightPlot';
16
+ import { ChartsGrid } from '../ChartsGrid';
16
17
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -47,6 +48,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
47
48
  },
48
49
  disableLineItemHighlight,
49
50
  legend,
51
+ grid,
50
52
  topAxis,
51
53
  leftAxis,
52
54
  rightAxis,
@@ -84,6 +86,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
84
86
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
85
87
  children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
86
88
  onAxisClick: onAxisClick
89
+ }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
90
+ vertical: grid.vertical,
91
+ horizontal: grid.horizontal
87
92
  }), /*#__PURE__*/_jsxs("g", {
88
93
  clipPath: `url(#${clipPathId})`,
89
94
  children: [/*#__PURE__*/_jsx(AreaPlot, {
@@ -129,11 +134,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
129
134
  // | To update them edit the TypeScript types and run "yarn proptypes" |
130
135
  // ----------------------------------------------------------------------
131
136
  /**
132
- * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
133
- * The two properties accept the following values:
134
- * - 'none': display nothing.
135
- * - 'line': display a line at the current mouse position.
136
- * - 'band': display a band at the current mouse position. Only available with band scale.
137
+ * The configuration of axes highlight.
138
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
137
139
  * @default { x: 'line' }
138
140
  */
139
141
  axisHighlight: PropTypes.shape({
@@ -189,9 +191,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
189
191
  * If `true`, render the line highlight item.
190
192
  */
191
193
  disableLineItemHighlight: PropTypes.bool,
194
+ /**
195
+ * Option to display a cartesian grid in the background.
196
+ */
197
+ grid: PropTypes.shape({
198
+ horizontal: PropTypes.bool,
199
+ vertical: PropTypes.bool
200
+ }),
192
201
  /**
193
202
  * The height of the chart in px. If not defined, it takes the height of the parent element.
194
- * @default undefined
195
203
  */
196
204
  height: PropTypes.number,
197
205
  /**
@@ -247,6 +255,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
247
255
  right: PropTypes.number,
248
256
  top: PropTypes.number
249
257
  }),
258
+ /**
259
+ * Callback fired when an area element is clicked.
260
+ */
250
261
  onAreaClick: PropTypes.func,
251
262
  /**
252
263
  * The function called for onClick events.
@@ -255,7 +266,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
255
266
  * @param {null | AxisData} data The data about the clicked axis and items associated with it.
256
267
  */
257
268
  onAxisClick: PropTypes.func,
269
+ /**
270
+ * Callback fired when a line element is clicked.
271
+ */
258
272
  onLineClick: PropTypes.func,
273
+ /**
274
+ * Callback fired when a mark element is clicked.
275
+ */
259
276
  onMarkClick: PropTypes.func,
260
277
  /**
261
278
  * Indicate which axis to display the right of the charts.
@@ -284,6 +301,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
284
301
  tickNumber: PropTypes.number,
285
302
  tickSize: PropTypes.number
286
303
  }), PropTypes.string]),
304
+ /**
305
+ * The series to display in the line chart.
306
+ */
287
307
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
288
308
  /**
289
309
  * If `true`, animations are skipped.
@@ -302,6 +322,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
302
322
  slots: PropTypes.object,
303
323
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
304
324
  title: PropTypes.string,
325
+ /**
326
+ * The configuration of the tooltip.
327
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
328
+ * @default { trigger: 'item' }
329
+ */
305
330
  tooltip: PropTypes.shape({
306
331
  axisContent: PropTypes.elementType,
307
332
  classes: PropTypes.object,
@@ -345,7 +370,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
345
370
  }),
346
371
  /**
347
372
  * The width of the chart in px. If not defined, it takes the width of the parent element.
348
- * @default undefined
349
373
  */
350
374
  width: PropTypes.number,
351
375
  /**
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "onClick", "isFaded", "isHighlighted", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
3
+ const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "highlightScope", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { arc as d3Arc } from 'd3-shape';
@@ -40,20 +40,20 @@ const PieArcRoot = styled(animated.path, {
40
40
  }));
41
41
  function PieArc(props) {
42
42
  const {
43
- id,
44
- dataIndex,
45
43
  classes: innerClasses,
46
44
  color,
45
+ cornerRadius,
46
+ dataIndex,
47
+ endAngle,
47
48
  highlightScope,
48
- onClick,
49
+ id,
50
+ innerRadius,
49
51
  isFaded,
50
52
  isHighlighted,
51
- startAngle,
52
- endAngle,
53
- paddingAngle,
54
- innerRadius,
53
+ onClick,
55
54
  outerRadius,
56
- cornerRadius
55
+ paddingAngle,
56
+ startAngle
57
57
  } = props,
58
58
  other = _objectWithoutPropertiesLoose(props, _excluded);
59
59
  const ownerState = {