@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,286 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["rotate", "dominantBaseline"],
4
+ _excluded2 = ["label"];
5
+ import * as React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import { NoSsr } from '@mui/base/NoSsr';
8
+ import { useTheme, styled } from '@mui/material/styles';
9
+ import { ChartsText } from '../ChartsText';
10
+ import { getWordsByLines } from '../internals/getWordsByLines';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ export const ChartsLegendRoot = styled('g', {
14
+ name: 'MuiChartsLegend',
15
+ slot: 'Root',
16
+ overridesResolver: (props, styles) => styles.root
17
+ })({});
18
+ /**
19
+ * Transforms number or partial padding object to a defaultized padding object.
20
+ */
21
+ const getStandardizedPadding = padding => {
22
+ if (typeof padding === 'number') {
23
+ return {
24
+ left: padding,
25
+ right: padding,
26
+ top: padding,
27
+ bottom: padding
28
+ };
29
+ }
30
+ return _extends({
31
+ left: 0,
32
+ right: 0,
33
+ top: 0,
34
+ bottom: 0
35
+ }, padding);
36
+ };
37
+ function DefaultChartsLegend(props) {
38
+ const {
39
+ hidden,
40
+ position,
41
+ direction,
42
+ seriesToDisplay,
43
+ drawingArea,
44
+ classes,
45
+ itemMarkWidth = 20,
46
+ itemMarkHeight = 20,
47
+ markGap = 5,
48
+ itemGap = 10,
49
+ padding: paddingProps = 10,
50
+ labelStyle: inLabelStyle
51
+ } = props;
52
+ const theme = useTheme();
53
+ const labelStyle = React.useMemo(() => _extends({}, theme.typography.subtitle1, {
54
+ color: 'inherit',
55
+ dominantBaseline: 'central',
56
+ textAnchor: 'start',
57
+ fill: (theme.vars || theme).palette.text.primary,
58
+ lineHeight: 1
59
+ }, inLabelStyle),
60
+ // To say to TS that the dominantBaseline and textAnchor are correct
61
+ [inLabelStyle, theme]);
62
+ const padding = React.useMemo(() => getStandardizedPadding(paddingProps), [paddingProps]);
63
+ const getItemSpace = React.useCallback((label, inStyle = {}) => {
64
+ const style = _objectWithoutPropertiesLoose(inStyle, _excluded);
65
+ const linesSize = getWordsByLines({
66
+ style,
67
+ needsComputation: true,
68
+ text: label
69
+ });
70
+ const innerSize = {
71
+ innerWidth: itemMarkWidth + markGap + Math.max(...linesSize.map(size => size.width)),
72
+ innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
73
+ };
74
+ return _extends({}, innerSize, {
75
+ outerWidth: innerSize.innerWidth + itemGap,
76
+ outerHeight: innerSize.innerHeight + itemGap
77
+ });
78
+ }, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
79
+ const totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
80
+ const totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
81
+ const availableWidth = totalWidth - padding.left - padding.right;
82
+ const availableHeight = totalHeight - padding.top - padding.bottom;
83
+ const seriesWithPosition = React.useMemo(() => {
84
+ // Start at 0, 0. Will be modified later by padding and position.
85
+ let x = 0;
86
+ let y = 0;
87
+
88
+ // total values used to align legend later.
89
+ let totalWidthUsed = 0;
90
+ let totalHeightUsed = 0;
91
+ let rowIndex = 0;
92
+ const rowMaxHeight = [0];
93
+ const seriesWithRawPosition = seriesToDisplay.map(_ref => {
94
+ let {
95
+ label
96
+ } = _ref,
97
+ other = _objectWithoutPropertiesLoose(_ref, _excluded2);
98
+ const itemSpace = getItemSpace(label, labelStyle);
99
+ const rep = _extends({}, other, {
100
+ label,
101
+ positionX: x,
102
+ positionY: y,
103
+ innerHeight: itemSpace.innerHeight,
104
+ innerWidth: itemSpace.innerWidth,
105
+ outerHeight: itemSpace.outerHeight,
106
+ outerWidth: itemSpace.outerWidth,
107
+ rowIndex
108
+ });
109
+ if (direction === 'row') {
110
+ if (x + itemSpace.innerWidth > availableWidth) {
111
+ // This legend item would create overflow along the x-axis, so we start a new row.
112
+ x = 0;
113
+ y += rowMaxHeight[rowIndex];
114
+ rowIndex += 1;
115
+ if (rowMaxHeight.length <= rowIndex) {
116
+ rowMaxHeight.push(0);
117
+ }
118
+ rep.positionX = x;
119
+ rep.positionY = y;
120
+ rep.rowIndex = rowIndex;
121
+ }
122
+ totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
123
+ totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
124
+ rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
125
+ x += itemSpace.outerWidth;
126
+ }
127
+ if (direction === 'column') {
128
+ if (y + itemSpace.innerHeight > availableHeight) {
129
+ // This legend item would create overflow along the y-axis, so we start a new column.
130
+ x = totalWidthUsed + itemGap;
131
+ y = 0;
132
+ rowIndex = 0;
133
+ rep.positionX = x;
134
+ rep.positionY = y;
135
+ rep.rowIndex = rowIndex;
136
+ }
137
+ if (rowMaxHeight.length <= rowIndex) {
138
+ rowMaxHeight.push(0);
139
+ }
140
+ totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
141
+ totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
142
+ rowIndex += 1;
143
+ y += itemSpace.outerHeight;
144
+ }
145
+ return rep;
146
+ });
147
+
148
+ // Move the legend according to padding and position
149
+ let gapX = 0;
150
+ let gapY = 0;
151
+ switch (position.horizontal) {
152
+ case 'left':
153
+ gapX = padding.left;
154
+ break;
155
+ case 'right':
156
+ gapX = totalWidth - padding.right - totalWidthUsed;
157
+ break;
158
+ default:
159
+ gapX = (totalWidth - totalWidthUsed) / 2;
160
+ break;
161
+ }
162
+ switch (position.vertical) {
163
+ case 'top':
164
+ gapY = padding.top;
165
+ break;
166
+ case 'bottom':
167
+ gapY = totalHeight - padding.bottom - totalHeightUsed;
168
+ break;
169
+ default:
170
+ gapY = (totalHeight - totalHeightUsed) / 2;
171
+ break;
172
+ }
173
+ return seriesWithRawPosition.map(item => _extends({}, item, {
174
+ // Add the gap due to the position
175
+ positionX: item.positionX + gapX,
176
+ // Add the gap due to the position
177
+ positionY: item.positionY + gapY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
178
+ : item.outerHeight / 2) // Get the center of the item
179
+ }));
180
+ }, [seriesToDisplay, position.horizontal, position.vertical, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap, padding.left, padding.right, padding.top, padding.bottom, totalWidth, totalHeight]);
181
+ if (hidden) {
182
+ return null;
183
+ }
184
+ return /*#__PURE__*/_jsx(NoSsr, {
185
+ children: /*#__PURE__*/_jsx(ChartsLegendRoot, {
186
+ className: classes.root,
187
+ children: seriesWithPosition.map(({
188
+ id,
189
+ label,
190
+ color,
191
+ positionX,
192
+ positionY
193
+ }) => /*#__PURE__*/_jsxs("g", {
194
+ className: classes.series,
195
+ transform: `translate(${positionX} ${positionY})`,
196
+ children: [/*#__PURE__*/_jsx("rect", {
197
+ className: classes.mark,
198
+ y: -itemMarkHeight / 2,
199
+ width: itemMarkWidth,
200
+ height: itemMarkHeight,
201
+ fill: color
202
+ }), /*#__PURE__*/_jsx(ChartsText, {
203
+ style: labelStyle,
204
+ text: label,
205
+ x: itemMarkWidth + markGap,
206
+ y: 0
207
+ })]
208
+ }, id))
209
+ })
210
+ });
211
+ }
212
+ process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
213
+ // ----------------------------- Warning --------------------------------
214
+ // | These PropTypes are generated from the TypeScript type definitions |
215
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
216
+ // ----------------------------------------------------------------------
217
+ /**
218
+ * Override or extend the styles applied to the component.
219
+ */
220
+ classes: PropTypes.object.isRequired,
221
+ /**
222
+ * The direction of the legend layout.
223
+ * The default depends on the chart.
224
+ */
225
+ direction: PropTypes.oneOf(['column', 'row']).isRequired,
226
+ drawingArea: PropTypes.shape({
227
+ bottom: PropTypes.number.isRequired,
228
+ height: PropTypes.number.isRequired,
229
+ left: PropTypes.number.isRequired,
230
+ right: PropTypes.number.isRequired,
231
+ top: PropTypes.number.isRequired,
232
+ width: PropTypes.number.isRequired
233
+ }).isRequired,
234
+ /**
235
+ * Set to true to hide the legend.
236
+ * @default false
237
+ */
238
+ hidden: PropTypes.bool,
239
+ /**
240
+ * Space between two legend items (in px).
241
+ * @default 10
242
+ */
243
+ itemGap: PropTypes.number,
244
+ /**
245
+ * Height of the item mark (in px).
246
+ * @default 20
247
+ */
248
+ itemMarkHeight: PropTypes.number,
249
+ /**
250
+ * Width of the item mark (in px).
251
+ * @default 20
252
+ */
253
+ itemMarkWidth: PropTypes.number,
254
+ /**
255
+ * Style applied to legend labels.
256
+ * @default theme.typography.subtitle1
257
+ */
258
+ labelStyle: PropTypes.object,
259
+ /**
260
+ * Space between the mark and the label (in px).
261
+ * @default 5
262
+ */
263
+ markGap: PropTypes.number,
264
+ /**
265
+ * Legend padding (in px).
266
+ * Can either be a single number, or an object with top, left, bottom, right properties.
267
+ * @default 10
268
+ */
269
+ padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
270
+ bottom: PropTypes.number,
271
+ left: PropTypes.number,
272
+ right: PropTypes.number,
273
+ top: PropTypes.number
274
+ })]),
275
+ position: PropTypes.shape({
276
+ horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
277
+ vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
278
+ }).isRequired,
279
+ series: PropTypes.object.isRequired,
280
+ seriesToDisplay: PropTypes.arrayOf(PropTypes.shape({
281
+ color: PropTypes.string.isRequired,
282
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
283
+ label: PropTypes.string.isRequired
284
+ })).isRequired
285
+ } : void 0;
286
+ export { DefaultChartsLegend };
@@ -1,3 +1,4 @@
1
1
  export * from './ChartsLegend';
2
+ export * from './DefaultChartsLegend';
2
3
  export * from './chartsLegendClasses';
3
4
  export * from './utils';
@@ -10,7 +10,7 @@ function ChartsReferenceLine(props) {
10
10
  y
11
11
  } = props;
12
12
  if (x !== undefined && y !== undefined) {
13
- throw new Error('MUI X Charts: The ChartsReferenceLine can not have both `x` and `y` props set.');
13
+ throw new Error('MUI X Charts: The ChartsReferenceLine cannot have both `x` and `y` props set.');
14
14
  }
15
15
  if (x === undefined && y === undefined) {
16
16
  throw new Error('MUI X Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
@@ -29,7 +29,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
29
29
  * The id of the axis used for the reference value.
30
30
  * @default The `id` of the first defined axis.
31
31
  */
32
- axisId: PropTypes.string,
32
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
33
33
  /**
34
34
  * Override or extend the styles applied to the component.
35
35
  */
@@ -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 = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
3
+ const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className", "title", "desc"];
4
4
  import { styled } from '@mui/material/styles';
5
5
  import PropTypes from 'prop-types';
6
6
  import * as React from 'react';
@@ -17,7 +17,9 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
17
17
  width,
18
18
  height,
19
19
  viewBox,
20
- disableAxisListener = false
20
+ disableAxisListener = false,
21
+ title,
22
+ desc
21
23
  } = props,
22
24
  other = _objectWithoutPropertiesLoose(props, _excluded);
23
25
  const svgView = _extends({
@@ -34,9 +36,9 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
34
36
  ref: ref
35
37
  }, other, {
36
38
  children: [/*#__PURE__*/_jsx("title", {
37
- children: props.title
39
+ children: title
38
40
  }), /*#__PURE__*/_jsx("desc", {
39
- children: props.desc
41
+ children: desc
40
42
  }), children]
41
43
  }));
42
44
  });
@@ -39,7 +39,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
39
39
  classes: PropTypes.object,
40
40
  itemData: PropTypes.shape({
41
41
  dataIndex: PropTypes.number,
42
- seriesId: PropTypes.string.isRequired,
42
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
43
43
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
44
44
  }),
45
45
  series: PropTypes.object,
@@ -47,7 +47,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
47
47
  }),
48
48
  itemData: PropTypes.shape({
49
49
  dataIndex: PropTypes.number,
50
- seriesId: PropTypes.string.isRequired,
50
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
51
51
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
52
52
  }).isRequired,
53
53
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import clsx from 'clsx';
4
4
  import Typography from '@mui/material/Typography';
5
5
  import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
6
- import { isCartesianSeries } from './utils';
6
+ import { isCartesianSeries, utcFormatter } from './utils';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
9
  function DefaultChartsAxisTooltipContent(props) {
@@ -19,7 +19,7 @@ function DefaultChartsAxisTooltipContent(props) {
19
19
  if (dataIndex == null) {
20
20
  return null;
21
21
  }
22
- const axisFormatter = (_axis$valueFormatter = axis.valueFormatter) != null ? _axis$valueFormatter : v => v.toLocaleString();
22
+ const axisFormatter = (_axis$valueFormatter = axis.valueFormatter) != null ? _axis$valueFormatter : v => axis.scaleType === 'utc' ? utcFormatter(v) : v.toLocaleString();
23
23
  return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
24
24
  sx: sx,
25
25
  className: classes.root,
@@ -69,7 +69,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
69
69
  */
70
70
  itemData: PropTypes.shape({
71
71
  dataIndex: PropTypes.number,
72
- seriesId: PropTypes.string.isRequired,
72
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
73
73
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
74
74
  }).isRequired,
75
75
  /**
@@ -84,4 +84,10 @@ export function isCartesianSeriesType(seriesType) {
84
84
  }
85
85
  export function isCartesianSeries(series) {
86
86
  return isCartesianSeriesType(series.type);
87
+ }
88
+ export function utcFormatter(v) {
89
+ if (v instanceof Date) {
90
+ return v.toUTCString();
91
+ }
92
+ return v.toLocaleString();
87
93
  }
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["scale", "tickNumber"];
3
+ const _excluded = ["scale", "tickNumber", "reverse"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useSlotProps } from '@mui/base/utils';
@@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { DrawingContext } from '../context/DrawingProvider';
11
- import useTicks from '../hooks/useTicks';
11
+ import { useTicks } from '../hooks/useTicks';
12
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
13
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
14
  import { ChartsText } from '../ChartsText';
@@ -35,6 +35,7 @@ const useUtilityClasses = ownerState => {
35
35
  function addLabelDimension(xTicks, {
36
36
  tickLabelStyle: style,
37
37
  tickLabelInterval,
38
+ reverse,
38
39
  isMounted
39
40
  }) {
40
41
  const withDimension = xTicks.map(tick => {
@@ -61,8 +62,9 @@ function addLabelDimension(xTicks, {
61
62
  }
62
63
 
63
64
  // Filter label to avoid overlap
64
- let textStart = 0;
65
- let textEnd = 0;
65
+ let currentTextLimit = 0;
66
+ let previouseTextLimit = 0;
67
+ const direction = reverse ? -1 : 1;
66
68
  return withDimension.map((item, labelIndex) => {
67
69
  const {
68
70
  width,
@@ -74,15 +76,15 @@ function addLabelDimension(xTicks, {
74
76
  const textPosition = offset + labelOffset;
75
77
  const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
76
78
 
77
- textStart = textPosition - gapRatio * distance / 2;
78
- if (labelIndex > 0 && textStart < textEnd) {
79
+ currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
80
+ if (labelIndex > 0 && direction * currentTextLimit < direction * previouseTextLimit) {
79
81
  // Except for the first label, we skip all label that overlap with the last accepted.
80
- // Notice that the early return prevents `textEnd` from being updated.
82
+ // Notice that the early return prevents `previouseTextLimit` from being updated.
81
83
  return _extends({}, item, {
82
84
  skipLabel: true
83
85
  });
84
86
  }
85
- textEnd = textPosition + gapRatio * distance / 2;
87
+ previouseTextLimit = textPosition + direction * (gapRatio * distance) / 2;
86
88
  return item;
87
89
  });
88
90
  }
@@ -117,7 +119,8 @@ function ChartsXAxis(inProps) {
117
119
  xAxis: {
118
120
  [_ref]: {
119
121
  scale: xScale,
120
- tickNumber
122
+ tickNumber,
123
+ reverse
121
124
  }
122
125
  }
123
126
  } = _React$useContext,
@@ -179,6 +182,7 @@ function ChartsXAxis(inProps) {
179
182
  const xTicksWithDimension = addLabelDimension(xTicks, {
180
183
  tickLabelStyle: axisTickLabelProps.style,
181
184
  tickLabelInterval,
185
+ reverse,
182
186
  isMounted
183
187
  });
184
188
  const labelRefPoint = {
@@ -242,7 +246,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
242
246
  * The id of the axis to render.
243
247
  * If undefined, it will be the first defined axis.
244
248
  */
245
- axisId: PropTypes.string,
249
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
246
250
  /**
247
251
  * Override or extend the styles applied to the component.
248
252
  */
@@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { DrawingContext } from '../context/DrawingProvider';
11
- import useTicks from '../hooks/useTicks';
11
+ import { useTicks } from '../hooks/useTicks';
12
12
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
13
  import { ChartsText } from '../ChartsText';
14
14
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
@@ -176,7 +176,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
176
176
  * The id of the axis to render.
177
177
  * If undefined, it will be the first defined axis.
178
178
  */
179
- axisId: PropTypes.string,
179
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
180
180
  /**
181
181
  * Override or extend the styles applied to the component.
182
182
  */
@@ -0,0 +1,149 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["text", "children", "classes"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import composeClasses from '@mui/utils/composeClasses';
7
+ import { GaugeContainer } from './GaugeContainer';
8
+ import { GaugeValueArc } from './GaugeValueArc';
9
+ import { GaugeReferenceArc } from './GaugeReferenceArc';
10
+ import { getGaugeUtilityClass } from './gaugeClasses';
11
+ import { GaugeValueText } from './GaugeValueText';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ const useUtilityClasses = props => {
15
+ const {
16
+ classes
17
+ } = props;
18
+ const slots = {
19
+ root: ['root'],
20
+ valueArc: ['valueArc'],
21
+ referenceArc: ['referenceArc'],
22
+ valueText: ['valueText']
23
+ };
24
+ return composeClasses(slots, getGaugeUtilityClass, classes);
25
+ };
26
+ function Gauge(props) {
27
+ const {
28
+ text,
29
+ children
30
+ } = props,
31
+ other = _objectWithoutPropertiesLoose(props, _excluded);
32
+ const classes = useUtilityClasses(props);
33
+ return /*#__PURE__*/_jsxs(GaugeContainer, _extends({}, other, {
34
+ className: classes.root,
35
+ children: [/*#__PURE__*/_jsx(GaugeReferenceArc, {
36
+ className: classes.referenceArc
37
+ }), /*#__PURE__*/_jsx(GaugeValueArc, {
38
+ className: classes.valueArc
39
+ }), /*#__PURE__*/_jsx(GaugeValueText, {
40
+ className: classes.valueText,
41
+ text: text
42
+ }), children]
43
+ }));
44
+ }
45
+ process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
46
+ // ----------------------------- Warning --------------------------------
47
+ // | These PropTypes are generated from the TypeScript type definitions |
48
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
49
+ // ----------------------------------------------------------------------
50
+ children: PropTypes.node,
51
+ classes: PropTypes.object,
52
+ className: PropTypes.string,
53
+ /**
54
+ * The radius applied to arc corners (similar to border radius).
55
+ * Set it to '50%' to get rounded arc.
56
+ * @default 0
57
+ */
58
+ cornerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
59
+ /**
60
+ * The x coordinate of the arc center.
61
+ * Can be a number (in px) or a string with a percentage such as '50%'.
62
+ * The '100%' is the width the drawing area.
63
+ */
64
+ cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
65
+ /**
66
+ * The y coordinate of the arc center.
67
+ * Can be a number (in px) or a string with a percentage such as '50%'.
68
+ * The '100%' is the height the drawing area.
69
+ */
70
+ cy: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
71
+ desc: PropTypes.string,
72
+ /**
73
+ * If `true`, the charts will not listen to the mouse move event.
74
+ * It might break interactive features, but will improve performance.
75
+ * @default false
76
+ */
77
+ disableAxisListener: PropTypes.bool,
78
+ /**
79
+ * The end angle (deg).
80
+ * @default 360
81
+ */
82
+ endAngle: PropTypes.number,
83
+ /**
84
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
85
+ * @default undefined
86
+ */
87
+ height: PropTypes.number,
88
+ /**
89
+ * The radius between circle center and the begining of the arc.
90
+ * Can be a number (in px) or a string with a percentage such as '50%'.
91
+ * The '100%' is the maximal radius that fit into the drawing area.
92
+ * @default '80%'
93
+ */
94
+ innerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
95
+ /**
96
+ * The margin between the SVG and the drawing area.
97
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
98
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
99
+ * @default object Depends on the charts type.
100
+ */
101
+ margin: PropTypes.shape({
102
+ bottom: PropTypes.number,
103
+ left: PropTypes.number,
104
+ right: PropTypes.number,
105
+ top: PropTypes.number
106
+ }),
107
+ /**
108
+ * The radius between circle center and the end of the arc.
109
+ * Can be a number (in px) or a string with a percentage such as '50%'.
110
+ * The '100%' is the maximal radius that fit into the drawing area.
111
+ * @default '100%'
112
+ */
113
+ outerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
114
+ /**
115
+ * The start angle (deg).
116
+ * @default 0
117
+ */
118
+ startAngle: PropTypes.number,
119
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
120
+ text: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
121
+ title: PropTypes.string,
122
+ /**
123
+ * The value of the gauge.
124
+ * Set to `null` to not display a value.
125
+ */
126
+ value: PropTypes.number,
127
+ /**
128
+ * The maximal value of the gauge.
129
+ * @default 100
130
+ */
131
+ valueMax: PropTypes.number,
132
+ /**
133
+ * The minimal value of the gauge.
134
+ * @default 0
135
+ */
136
+ valueMin: PropTypes.number,
137
+ viewBox: PropTypes.shape({
138
+ height: PropTypes.number,
139
+ width: PropTypes.number,
140
+ x: PropTypes.number,
141
+ y: PropTypes.number
142
+ }),
143
+ /**
144
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
145
+ * @default undefined
146
+ */
147
+ width: PropTypes.number
148
+ } : void 0;
149
+ export { Gauge };