@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
package/Gauge/index.js ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ useGaugeState: true
8
+ };
9
+ Object.defineProperty(exports, "useGaugeState", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _GaugeProvider.useGaugeState;
13
+ }
14
+ });
15
+ var _Gauge = require("./Gauge");
16
+ Object.keys(_Gauge).forEach(function (key) {
17
+ if (key === "default" || key === "__esModule") return;
18
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
+ if (key in exports && exports[key] === _Gauge[key]) return;
20
+ Object.defineProperty(exports, key, {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _Gauge[key];
24
+ }
25
+ });
26
+ });
27
+ var _GaugeContainer = require("./GaugeContainer");
28
+ Object.keys(_GaugeContainer).forEach(function (key) {
29
+ if (key === "default" || key === "__esModule") return;
30
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
31
+ if (key in exports && exports[key] === _GaugeContainer[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _GaugeContainer[key];
36
+ }
37
+ });
38
+ });
39
+ var _GaugeValueText = require("./GaugeValueText");
40
+ Object.keys(_GaugeValueText).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
43
+ if (key in exports && exports[key] === _GaugeValueText[key]) return;
44
+ Object.defineProperty(exports, key, {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _GaugeValueText[key];
48
+ }
49
+ });
50
+ });
51
+ var _GaugeValueArc = require("./GaugeValueArc");
52
+ Object.keys(_GaugeValueArc).forEach(function (key) {
53
+ if (key === "default" || key === "__esModule") return;
54
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
55
+ if (key in exports && exports[key] === _GaugeValueArc[key]) return;
56
+ Object.defineProperty(exports, key, {
57
+ enumerable: true,
58
+ get: function () {
59
+ return _GaugeValueArc[key];
60
+ }
61
+ });
62
+ });
63
+ var _GaugeReferenceArc = require("./GaugeReferenceArc");
64
+ Object.keys(_GaugeReferenceArc).forEach(function (key) {
65
+ if (key === "default" || key === "__esModule") return;
66
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
67
+ if (key in exports && exports[key] === _GaugeReferenceArc[key]) return;
68
+ Object.defineProperty(exports, key, {
69
+ enumerable: true,
70
+ get: function () {
71
+ return _GaugeReferenceArc[key];
72
+ }
73
+ });
74
+ });
75
+ var _gaugeClasses = require("./gaugeClasses");
76
+ Object.keys(_gaugeClasses).forEach(function (key) {
77
+ if (key === "default" || key === "__esModule") return;
78
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
79
+ if (key in exports && exports[key] === _gaugeClasses[key]) return;
80
+ Object.defineProperty(exports, key, {
81
+ enumerable: true,
82
+ get: function () {
83
+ return _gaugeClasses[key];
84
+ }
85
+ });
86
+ });
87
+ var _GaugeProvider = require("./GaugeProvider");
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/Gauge/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Retruns the ratio of the arc bounding box and its center.
3
+ * @param startAngle The start angle (in deg)
4
+ * @param endAngle The end angle (in deg)
5
+ */
6
+ export declare function getArcRatios(startAngle: number, endAngle: number): {
7
+ cx: number;
8
+ cy: number;
9
+ minX: number;
10
+ maxX: number;
11
+ minY: number;
12
+ maxY: number;
13
+ };
14
+ export declare function getAvailableRadius(cx: number, cy: number, width: number, height: number, { minX, maxX, minY, maxY, }: {
15
+ minX: number;
16
+ maxX: number;
17
+ minY: number;
18
+ maxY: number;
19
+ }): number;
package/Gauge/utils.js ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getArcRatios = getArcRatios;
7
+ exports.getAvailableRadius = getAvailableRadius;
8
+ function deg2rad(angle) {
9
+ return Math.PI * angle / 180;
10
+ }
11
+ function getPoint(angle) {
12
+ const radAngle = deg2rad(angle);
13
+ return [Math.sin(radAngle), -Math.cos(radAngle)];
14
+ }
15
+
16
+ /**
17
+ * Retruns the ratio of the arc bounding box and its center.
18
+ * @param startAngle The start angle (in deg)
19
+ * @param endAngle The end angle (in deg)
20
+ */
21
+ function getArcRatios(startAngle, endAngle) {
22
+ // Set the start, end and center point.
23
+ const points = [[0, 0], getPoint(startAngle), getPoint(endAngle)];
24
+
25
+ // Add cardinal points included in the arc
26
+ const minAngle = Math.min(startAngle, endAngle);
27
+ const maxAngle = Math.max(startAngle, endAngle);
28
+ const initialAngle = Math.floor(minAngle / 90) * 90;
29
+ for (let step = 1; step <= 4; step += 1) {
30
+ const cartinalAngle = initialAngle + step * 90;
31
+ if (cartinalAngle < maxAngle) {
32
+ points.push(getPoint(cartinalAngle));
33
+ }
34
+ }
35
+ const minX = Math.min(...points.map(([x]) => x));
36
+ const maxX = Math.max(...points.map(([x]) => x));
37
+ const minY = Math.min(...points.map(([, y]) => y));
38
+ const maxY = Math.max(...points.map(([, y]) => y));
39
+ return {
40
+ cx: -minX / (maxX - minX),
41
+ cy: -minY / (maxY - minY),
42
+ minX,
43
+ maxX,
44
+ minY,
45
+ maxY
46
+ };
47
+ }
48
+ function getAvailableRadius(cx, cy, width, height, {
49
+ minX,
50
+ maxX,
51
+ minY,
52
+ maxY
53
+ }) {
54
+ return Math.min(...[{
55
+ ratio: Math.abs(minX),
56
+ space: cx
57
+ }, {
58
+ ratio: Math.abs(maxX),
59
+ space: width - cx
60
+ }, {
61
+ ratio: Math.abs(minY),
62
+ space: cy
63
+ }, {
64
+ ratio: Math.abs(maxY),
65
+ space: height - cy
66
+ }].map(({
67
+ ratio,
68
+ space
69
+ }) => {
70
+ if (ratio < 0.00001) {
71
+ return Infinity;
72
+ }
73
+ return space / ratio;
74
+ }));
75
+ }
@@ -11,20 +11,30 @@ import { ChartsLegendProps, ChartsLegendSlotProps, ChartsLegendSlots } from '../
11
11
  import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
12
12
  import { ChartsAxisSlotProps, ChartsAxisSlots } from '../models/axis';
13
13
  import { LineHighlightPlotSlots, LineHighlightPlotSlotProps } from './LineHighlightPlot';
14
+ import { ChartsGridProps } from '../ChartsGrid';
14
15
  import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
15
16
  export interface LineChartSlots extends ChartsAxisSlots, AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, ChartsLegendSlots, ChartsTooltipSlots {
16
17
  }
17
18
  export interface LineChartSlotProps extends ChartsAxisSlotProps, AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps {
18
19
  }
19
20
  export interface LineChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, ChartsOnAxisClickHandlerProps {
21
+ /**
22
+ * The series to display in the line chart.
23
+ */
20
24
  series: MakeOptional<LineSeriesType, 'type'>[];
25
+ /**
26
+ * The configuration of the tooltip.
27
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
28
+ * @default { trigger: 'item' }
29
+ */
21
30
  tooltip?: ChartsTooltipProps;
22
31
  /**
23
- * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
24
- * The two properties accept the following values:
25
- * - 'none': display nothing.
26
- * - 'line': display a line at the current mouse position.
27
- * - 'band': display a band at the current mouse position. Only available with band scale.
32
+ * Option to display a cartesian grid in the background.
33
+ */
34
+ grid?: Pick<ChartsGridProps, 'vertical' | 'horizontal'>;
35
+ /**
36
+ * The configuration of axes highlight.
37
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
28
38
  * @default { x: 'line' }
29
39
  */
30
40
  axisHighlight?: ChartsAxisHighlightProps;
@@ -46,8 +56,17 @@ export interface LineChartProps extends Omit<ResponsiveChartContainerProps, 'ser
46
56
  * @default {}
47
57
  */
48
58
  slotProps?: LineChartSlotProps;
59
+ /**
60
+ * Callback fired when an area element is clicked.
61
+ */
49
62
  onAreaClick?: AreaPlotProps['onItemClick'];
63
+ /**
64
+ * Callback fired when a line element is clicked.
65
+ */
50
66
  onLineClick?: LinePlotProps['onItemClick'];
67
+ /**
68
+ * Callback fired when a mark element is clicked.
69
+ */
51
70
  onMarkClick?: MarkPlotProps['onItemClick'];
52
71
  /**
53
72
  * If `true`, animations are skipped.
@@ -20,6 +20,7 @@ var _ChartsLegend = require("../ChartsLegend");
20
20
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
21
21
  var _ChartsClipPath = require("../ChartsClipPath");
22
22
  var _LineHighlightPlot = require("./LineHighlightPlot");
23
+ var _ChartsGrid = require("../ChartsGrid");
23
24
  var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
24
25
  var _jsxRuntime = require("react/jsx-runtime");
25
26
  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); }
@@ -55,6 +56,7 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
55
56
  },
56
57
  disableLineItemHighlight,
57
58
  legend,
59
+ grid,
58
60
  topAxis,
59
61
  leftAxis,
60
62
  rightAxis,
@@ -89,6 +91,9 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
89
91
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
90
92
  children: [onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, {
91
93
  onAxisClick: onAxisClick
94
+ }), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
95
+ vertical: grid.vertical,
96
+ horizontal: grid.horizontal
92
97
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
93
98
  clipPath: `url(#${clipPathId})`,
94
99
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaPlot.AreaPlot, {
@@ -134,11 +139,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
134
139
  // | To update them edit the TypeScript types and run "yarn proptypes" |
135
140
  // ----------------------------------------------------------------------
136
141
  /**
137
- * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
138
- * The two properties accept the following values:
139
- * - 'none': display nothing.
140
- * - 'line': display a line at the current mouse position.
141
- * - 'band': display a band at the current mouse position. Only available with band scale.
142
+ * The configuration of axes highlight.
143
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
142
144
  * @default { x: 'line' }
143
145
  */
144
146
  axisHighlight: _propTypes.default.shape({
@@ -194,9 +196,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
194
196
  * If `true`, render the line highlight item.
195
197
  */
196
198
  disableLineItemHighlight: _propTypes.default.bool,
199
+ /**
200
+ * Option to display a cartesian grid in the background.
201
+ */
202
+ grid: _propTypes.default.shape({
203
+ horizontal: _propTypes.default.bool,
204
+ vertical: _propTypes.default.bool
205
+ }),
197
206
  /**
198
207
  * The height of the chart in px. If not defined, it takes the height of the parent element.
199
- * @default undefined
200
208
  */
201
209
  height: _propTypes.default.number,
202
210
  /**
@@ -252,6 +260,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
252
260
  right: _propTypes.default.number,
253
261
  top: _propTypes.default.number
254
262
  }),
263
+ /**
264
+ * Callback fired when an area element is clicked.
265
+ */
255
266
  onAreaClick: _propTypes.default.func,
256
267
  /**
257
268
  * The function called for onClick events.
@@ -260,7 +271,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
260
271
  * @param {null | AxisData} data The data about the clicked axis and items associated with it.
261
272
  */
262
273
  onAxisClick: _propTypes.default.func,
274
+ /**
275
+ * Callback fired when a line element is clicked.
276
+ */
263
277
  onLineClick: _propTypes.default.func,
278
+ /**
279
+ * Callback fired when a mark element is clicked.
280
+ */
264
281
  onMarkClick: _propTypes.default.func,
265
282
  /**
266
283
  * Indicate which axis to display the right of the charts.
@@ -289,6 +306,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
289
306
  tickNumber: _propTypes.default.number,
290
307
  tickSize: _propTypes.default.number
291
308
  }), _propTypes.default.string]),
309
+ /**
310
+ * The series to display in the line chart.
311
+ */
292
312
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
293
313
  /**
294
314
  * If `true`, animations are skipped.
@@ -307,6 +327,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
307
327
  slots: _propTypes.default.object,
308
328
  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]),
309
329
  title: _propTypes.default.string,
330
+ /**
331
+ * The configuration of the tooltip.
332
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
333
+ * @default { trigger: 'item' }
334
+ */
310
335
  tooltip: _propTypes.default.shape({
311
336
  axisContent: _propTypes.default.elementType,
312
337
  classes: _propTypes.default.object,
@@ -350,7 +375,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
350
375
  }),
351
376
  /**
352
377
  * The width of the chart in px. If not defined, it takes the width of the parent element.
353
- * @default undefined
354
378
  */
355
379
  width: _propTypes.default.number,
356
380
  /**
@@ -22,14 +22,14 @@ interface PieArcOwnerState {
22
22
  export declare function getPieArcUtilityClass(slot: string): string;
23
23
  export declare const pieArcClasses: PieArcClasses;
24
24
  export type PieArcProps = Omit<React.ComponentPropsWithoutRef<'path'>, 'id'> & PieArcOwnerState & {
25
- startAngle: SpringValue<number>;
25
+ cornerRadius: SpringValue<number>;
26
26
  endAngle: SpringValue<number>;
27
+ highlightScope?: Partial<HighlightScope>;
27
28
  innerRadius: SpringValue<number>;
29
+ onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
28
30
  outerRadius: SpringValue<number>;
29
- cornerRadius: SpringValue<number>;
30
31
  paddingAngle: SpringValue<number>;
31
- highlightScope?: Partial<HighlightScope>;
32
- onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
32
+ startAngle: SpringValue<number>;
33
33
  };
34
34
  declare function PieArc(props: PieArcProps): React.JSX.Element;
35
35
  declare namespace PieArc {
@@ -19,7 +19,7 @@ var _styles = require("@mui/material/styles");
19
19
  var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
20
20
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
21
21
  var _jsxRuntime = require("react/jsx-runtime");
22
- const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "onClick", "isFaded", "isHighlighted", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
22
+ const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "highlightScope", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle"];
23
23
  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); }
24
24
  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; }
25
25
  function getPieArcUtilityClass(slot) {
@@ -51,20 +51,20 @@ const PieArcRoot = (0, _styles.styled)(_web.animated.path, {
51
51
  }));
52
52
  function PieArc(props) {
53
53
  const {
54
- id,
55
- dataIndex,
56
54
  classes: innerClasses,
57
55
  color,
56
+ cornerRadius,
57
+ dataIndex,
58
+ endAngle,
58
59
  highlightScope,
59
- onClick,
60
+ id,
61
+ innerRadius,
60
62
  isFaded,
61
63
  isHighlighted,
62
- startAngle,
63
- endAngle,
64
- paddingAngle,
65
- innerRadius,
64
+ onClick,
66
65
  outerRadius,
67
- cornerRadius
66
+ paddingAngle,
67
+ startAngle
68
68
  } = props,
69
69
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
70
70
  const ownerState = {
@@ -14,7 +14,7 @@ var _transition = require("./dataTransform/transition");
14
14
  var _useTransformData = require("./dataTransform/useTransformData");
15
15
  var _PieArcLabel = require("./PieArcLabel");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
17
+ const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "highlightScope", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
18
18
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
19
19
  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); }
20
20
  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; }
@@ -34,23 +34,23 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
34
34
  }
35
35
  function PieArcLabelPlot(props) {
36
36
  const {
37
- slots,
38
- slotProps,
39
- innerRadius,
40
- outerRadius,
37
+ arcLabel,
38
+ arcLabelMinAngle = 0,
41
39
  arcLabelRadius,
42
40
  cornerRadius = 0,
43
- paddingAngle = 0,
44
- id,
45
- highlightScope,
46
- highlighted,
41
+ data,
47
42
  faded = {
48
43
  additionalRadius: -5
49
44
  },
50
- data,
51
- arcLabel,
52
- arcLabelMinAngle = 0,
53
- skipAnimation
45
+ highlighted,
46
+ highlightScope,
47
+ id,
48
+ innerRadius,
49
+ outerRadius,
50
+ paddingAngle = 0,
51
+ skipAnimation,
52
+ slotProps,
53
+ slots
54
54
  } = props,
55
55
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
56
56
  const transformedData = (0, _useTransformData.useTransformData)({
@@ -26,14 +26,36 @@ export interface PieChartProps extends Omit<ResponsiveChartContainerProps, 'seri
26
26
  * @default null
27
27
  */
28
28
  leftAxis?: null | string | ChartsYAxisProps;
29
+ /**
30
+ * The series to display in the pie chart.
31
+ */
29
32
  series: MakeOptional<PieSeriesType<MakeOptional<PieValueType, 'id'>>, 'type'>[];
33
+ /**
34
+ * The configuration of the tooltip.
35
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
36
+ * @default { trigger: 'item' }
37
+ */
30
38
  tooltip?: ChartsTooltipProps;
39
+ /**
40
+ * The configuration of axes highlight.
41
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
42
+ * @default { x: 'none', y: 'none' }
43
+ */
31
44
  axisHighlight?: ChartsAxisHighlightProps;
32
45
  /**
46
+ * The props of the legend.
47
+ * @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
33
48
  * @deprecated Consider using `slotProps.legend` instead.
34
49
  */
35
50
  legend?: ChartsLegendProps;
51
+ /**
52
+ * Callback fired when a pie arc is clicked.
53
+ */
36
54
  onItemClick?: PiePlotProps['onItemClick'];
55
+ /**
56
+ * Overridable component slots.
57
+ * @default {}
58
+ */
37
59
  slots?: PieChartSlots;
38
60
  /**
39
61
  * The props used for each component slot.
@@ -109,6 +109,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
109
109
  // | These PropTypes are generated from the TypeScript type definitions |
110
110
  // | To update them edit the TypeScript types and run "yarn proptypes" |
111
111
  // ----------------------------------------------------------------------
112
+ /**
113
+ * The configuration of axes highlight.
114
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
115
+ * @default { x: 'none', y: 'none' }
116
+ */
112
117
  axisHighlight: _propTypes.default.shape({
113
118
  x: _propTypes.default.oneOf(['band', 'line', 'none']),
114
119
  y: _propTypes.default.oneOf(['band', 'line', 'none'])
@@ -160,7 +165,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
160
165
  disableAxisListener: _propTypes.default.bool,
161
166
  /**
162
167
  * The height of the chart in px. If not defined, it takes the height of the parent element.
163
- * @default undefined
164
168
  */
165
169
  height: _propTypes.default.number,
166
170
  /**
@@ -191,6 +195,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
191
195
  tickSize: _propTypes.default.number
192
196
  }), _propTypes.default.string]),
193
197
  /**
198
+ * The props of the legend.
199
+ * @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
194
200
  * @deprecated Consider using `slotProps.legend` instead.
195
201
  */
196
202
  legend: _propTypes.default.shape({
@@ -216,6 +222,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
216
222
  right: _propTypes.default.number,
217
223
  top: _propTypes.default.number
218
224
  }),
225
+ /**
226
+ * Callback fired when a pie arc is clicked.
227
+ */
219
228
  onItemClick: _propTypes.default.func,
220
229
  /**
221
230
  * Indicate which axis to display the right of the charts.
@@ -244,6 +253,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
244
253
  tickNumber: _propTypes.default.number,
245
254
  tickSize: _propTypes.default.number
246
255
  }), _propTypes.default.string]),
256
+ /**
257
+ * The series to display in the pie chart.
258
+ */
247
259
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
248
260
  /**
249
261
  * If `true`, animations are skipped.
@@ -255,9 +267,18 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
255
267
  * @default {}
256
268
  */
257
269
  slotProps: _propTypes.default.object,
270
+ /**
271
+ * Overridable component slots.
272
+ * @default {}
273
+ */
258
274
  slots: _propTypes.default.object,
259
275
  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]),
260
276
  title: _propTypes.default.string,
277
+ /**
278
+ * The configuration of the tooltip.
279
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
280
+ * @default { trigger: 'item' }
281
+ */
261
282
  tooltip: _propTypes.default.shape({
262
283
  axisContent: _propTypes.default.elementType,
263
284
  classes: _propTypes.default.object,
@@ -301,7 +322,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
301
322
  }),
302
323
  /**
303
324
  * The width of the chart in px. If not defined, it takes the width of the parent element.
304
- * @default undefined
305
325
  */
306
326
  width: _propTypes.default.number,
307
327
  /**
@@ -3,12 +3,10 @@ import { ChartContainerProps } from '../ChartContainer';
3
3
  export interface ResponsiveChartContainerProps extends Omit<ChartContainerProps, 'width' | 'height'> {
4
4
  /**
5
5
  * The width of the chart in px. If not defined, it takes the width of the parent element.
6
- * @default undefined
7
6
  */
8
7
  width?: number;
9
8
  /**
10
9
  * The height of the chart in px. If not defined, it takes the height of the parent element.
11
- * @default undefined
12
10
  */
13
11
  height?: number;
14
12
  }