@mui/x-charts 8.0.0-alpha.5 → 8.0.0-alpha.7

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 (251) hide show
  1. package/BarChart/AnimatedBarElement.js +1 -0
  2. package/BarChart/BarChart.js +17 -7
  3. package/BarChart/BarLabel/BarLabel.d.ts +1 -479
  4. package/BarChart/BarLabel/barLabelClasses.d.ts +1 -1
  5. package/BarChart/legend.js +1 -0
  6. package/BarChart/useBarChartProps.d.ts +4 -2
  7. package/BarChart/useBarChartProps.js +16 -3
  8. package/CHANGELOG.md +206 -1
  9. package/ChartsLabel/ChartsLabel.d.ts +2 -3
  10. package/ChartsLabel/ChartsLabel.js +3 -18
  11. package/ChartsLabel/ChartsLabelGradient.d.ts +9 -8
  12. package/ChartsLabel/ChartsLabelGradient.js +21 -18
  13. package/ChartsLabel/ChartsLabelMark.d.ts +2 -3
  14. package/ChartsLabel/ChartsLabelMark.js +5 -2
  15. package/ChartsLabel/index.d.ts +7 -0
  16. package/ChartsLabel/index.js +6 -0
  17. package/ChartsLabel/labelClasses.d.ts +0 -1
  18. package/ChartsLabel/labelGradientClasses.d.ts +5 -4
  19. package/ChartsLabel/labelGradientClasses.js +3 -2
  20. package/ChartsLabel/labelMarkClasses.d.ts +3 -2
  21. package/ChartsLabel/labelMarkClasses.js +3 -2
  22. package/ChartsLabel/package.json +6 -0
  23. package/ChartsLegend/ChartsLegend.d.ts +18 -22
  24. package/ChartsLegend/ChartsLegend.js +100 -109
  25. package/ChartsLegend/ContinuousColorLegend.d.ts +29 -38
  26. package/ChartsLegend/ContinuousColorLegend.js +198 -321
  27. package/ChartsLegend/PiecewiseColorLegend.d.ts +27 -19
  28. package/ChartsLegend/PiecewiseColorLegend.js +201 -111
  29. package/ChartsLegend/chartsLegend.types.d.ts +17 -60
  30. package/ChartsLegend/chartsLegendClasses.d.ts +7 -8
  31. package/ChartsLegend/chartsLegendClasses.js +16 -2
  32. package/ChartsLegend/colorLegend.types.d.ts +13 -0
  33. package/ChartsLegend/colorLegend.types.js +1 -0
  34. package/ChartsLegend/continuousColorLegendClasses.d.ts +26 -0
  35. package/ChartsLegend/continuousColorLegendClasses.js +23 -0
  36. package/ChartsLegend/direction.d.ts +1 -0
  37. package/ChartsLegend/direction.js +1 -0
  38. package/ChartsLegend/index.d.ts +13 -3
  39. package/ChartsLegend/index.js +9 -3
  40. package/ChartsLegend/legend.types.d.ts +10 -54
  41. package/ChartsLegend/legendContext.types.d.ts +55 -0
  42. package/ChartsLegend/legendContext.types.js +1 -0
  43. package/ChartsLegend/onClickContextBuilder.d.ts +2 -0
  44. package/ChartsLegend/onClickContextBuilder.js +7 -0
  45. package/ChartsLegend/piecewiseColorDefaultLabelFormatter.d.ts +2 -0
  46. package/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
  47. package/ChartsLegend/piecewiseColorLegend.types.d.ts +26 -0
  48. package/ChartsLegend/piecewiseColorLegend.types.js +1 -0
  49. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +28 -0
  50. package/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
  51. package/ChartsLegend/useAxis.d.ts +1 -1
  52. package/ChartsLegend/useAxis.js +0 -1
  53. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  54. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  55. package/ChartsSurface/ChartsSurface.js +0 -1
  56. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  57. package/LineChart/AnimatedArea.js +1 -0
  58. package/LineChart/AnimatedLine.js +1 -0
  59. package/LineChart/AppearingMask.js +1 -0
  60. package/LineChart/CircleMarkElement.js +1 -0
  61. package/LineChart/LineChart.js +20 -10
  62. package/LineChart/MarkElement.js +3 -1
  63. package/LineChart/legend.js +1 -0
  64. package/LineChart/useLineChartProps.d.ts +4 -2
  65. package/LineChart/useLineChartProps.js +15 -2
  66. package/PieChart/PieArc.js +3 -1
  67. package/PieChart/PieArcLabel.js +13 -9
  68. package/PieChart/PieArcLabelPlot.js +1 -0
  69. package/PieChart/PieArcPlot.js +1 -0
  70. package/PieChart/PieChart.js +42 -41
  71. package/PieChart/legend.js +1 -0
  72. package/ScatterChart/ScatterChart.js +21 -11
  73. package/ScatterChart/legend.js +1 -0
  74. package/ScatterChart/useScatterChartProps.d.ts +4 -2
  75. package/ScatterChart/useScatterChartProps.js +15 -2
  76. package/SparkLineChart/SparkLineChart.js +1 -4
  77. package/constants/index.d.ts +1 -0
  78. package/constants/index.js +2 -1
  79. package/context/CartesianProvider/defaultizeAxis.d.ts +9 -9
  80. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -18
  81. package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -9
  82. package/context/ChartProvider/ChartProvider.types.d.ts +1 -1
  83. package/context/InteractionSelectors.d.ts +11 -11
  84. package/context/PluginProvider/SeriesFormatter.types.d.ts +1 -1
  85. package/context/PluginProvider/mergePlugins.d.ts +8 -8
  86. package/context/SizeProvider/Size.types.d.ts +1 -1
  87. package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
  88. package/hooks/index.d.ts +1 -0
  89. package/hooks/index.js +2 -1
  90. package/hooks/useLegend.d.ts +13 -0
  91. package/{modern/ChartsLegend/utils.js → hooks/useLegend.js} +20 -1
  92. package/hooks/useSvgRef.d.ts +1 -1
  93. package/index.d.ts +1 -0
  94. package/index.js +2 -1
  95. package/internals/calculateMargins.d.ts +7 -0
  96. package/internals/calculateMargins.js +25 -0
  97. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
  98. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
  99. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
  100. package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.d.ts +13 -0
  101. package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
  102. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
  103. package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +17 -0
  104. package/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
  105. package/internals/components/ChartsWrapper/index.d.ts +1 -0
  106. package/internals/components/ChartsWrapper/index.js +1 -0
  107. package/internals/consumeSlots.d.ts +48 -0
  108. package/internals/consumeSlots.js +101 -0
  109. package/internals/consumeThemeProps.d.ts +3 -7
  110. package/internals/consumeThemeProps.js +18 -27
  111. package/internals/defaultizeColor.d.ts +6 -1
  112. package/internals/index.d.ts +1 -0
  113. package/internals/index.js +1 -0
  114. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  115. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
  116. package/internals/plugins/models/plugin.d.ts +1 -1
  117. package/internals/store/useCharts.d.ts +2 -2
  118. package/internals/store/useCharts.types.d.ts +1 -1
  119. package/models/seriesType/common.d.ts +9 -0
  120. package/models/seriesType/pie.d.ts +9 -0
  121. package/modern/BarChart/AnimatedBarElement.js +1 -0
  122. package/modern/BarChart/BarChart.js +17 -7
  123. package/modern/BarChart/legend.js +1 -0
  124. package/modern/BarChart/useBarChartProps.js +16 -3
  125. package/modern/ChartsLabel/ChartsLabel.js +3 -18
  126. package/modern/ChartsLabel/ChartsLabelGradient.js +21 -18
  127. package/modern/ChartsLabel/ChartsLabelMark.js +5 -2
  128. package/modern/ChartsLabel/index.js +6 -0
  129. package/modern/ChartsLabel/labelGradientClasses.js +3 -2
  130. package/modern/ChartsLabel/labelMarkClasses.js +3 -2
  131. package/modern/ChartsLegend/ChartsLegend.js +100 -109
  132. package/modern/ChartsLegend/ContinuousColorLegend.js +198 -321
  133. package/modern/ChartsLegend/PiecewiseColorLegend.js +201 -111
  134. package/modern/ChartsLegend/chartsLegendClasses.js +16 -2
  135. package/modern/ChartsLegend/colorLegend.types.js +1 -0
  136. package/modern/ChartsLegend/continuousColorLegendClasses.js +23 -0
  137. package/modern/ChartsLegend/direction.js +1 -0
  138. package/modern/ChartsLegend/index.js +9 -3
  139. package/modern/ChartsLegend/legendContext.types.js +1 -0
  140. package/modern/ChartsLegend/onClickContextBuilder.js +7 -0
  141. package/modern/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
  142. package/modern/ChartsLegend/piecewiseColorLegend.types.js +1 -0
  143. package/modern/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
  144. package/modern/ChartsLegend/useAxis.js +0 -1
  145. package/modern/ChartsSurface/ChartsSurface.js +0 -1
  146. package/modern/LineChart/AnimatedArea.js +1 -0
  147. package/modern/LineChart/AnimatedLine.js +1 -0
  148. package/modern/LineChart/AppearingMask.js +1 -0
  149. package/modern/LineChart/CircleMarkElement.js +1 -0
  150. package/modern/LineChart/LineChart.js +20 -10
  151. package/modern/LineChart/MarkElement.js +3 -1
  152. package/modern/LineChart/legend.js +1 -0
  153. package/modern/LineChart/useLineChartProps.js +15 -2
  154. package/modern/PieChart/PieArc.js +3 -1
  155. package/modern/PieChart/PieArcLabel.js +13 -9
  156. package/modern/PieChart/PieArcLabelPlot.js +1 -0
  157. package/modern/PieChart/PieArcPlot.js +1 -0
  158. package/modern/PieChart/PieChart.js +42 -41
  159. package/modern/PieChart/legend.js +1 -0
  160. package/modern/ScatterChart/ScatterChart.js +21 -11
  161. package/modern/ScatterChart/legend.js +1 -0
  162. package/modern/ScatterChart/useScatterChartProps.js +15 -2
  163. package/modern/SparkLineChart/SparkLineChart.js +1 -4
  164. package/modern/constants/index.js +2 -1
  165. package/modern/hooks/index.js +2 -1
  166. package/{ChartsLegend/utils.js → modern/hooks/useLegend.js} +20 -1
  167. package/modern/index.js +2 -1
  168. package/modern/internals/calculateMargins.js +25 -0
  169. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
  170. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
  171. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
  172. package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
  173. package/modern/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
  174. package/modern/internals/components/ChartsWrapper/index.js +1 -0
  175. package/modern/internals/consumeSlots.js +101 -0
  176. package/modern/internals/consumeThemeProps.js +18 -27
  177. package/modern/internals/index.js +1 -0
  178. package/node/BarChart/AnimatedBarElement.js +1 -0
  179. package/node/BarChart/BarChart.js +17 -7
  180. package/node/BarChart/legend.js +1 -0
  181. package/node/BarChart/useBarChartProps.js +15 -3
  182. package/node/ChartsLabel/ChartsLabel.js +3 -18
  183. package/node/ChartsLabel/ChartsLabelGradient.js +21 -18
  184. package/node/ChartsLabel/ChartsLabelMark.js +5 -2
  185. package/node/ChartsLabel/index.js +26 -0
  186. package/node/ChartsLabel/labelGradientClasses.js +3 -2
  187. package/node/ChartsLabel/labelMarkClasses.js +3 -2
  188. package/node/ChartsLegend/ChartsLegend.js +99 -108
  189. package/node/ChartsLegend/ContinuousColorLegend.js +199 -322
  190. package/node/ChartsLegend/PiecewiseColorLegend.js +201 -111
  191. package/node/ChartsLegend/chartsLegendClasses.js +17 -3
  192. package/node/ChartsLegend/colorLegend.types.js +5 -0
  193. package/node/ChartsLegend/continuousColorLegendClasses.js +31 -0
  194. package/node/ChartsLegend/direction.js +5 -0
  195. package/node/ChartsLegend/index.js +80 -16
  196. package/node/ChartsLegend/legendContext.types.js +5 -0
  197. package/node/ChartsLegend/onClickContextBuilder.js +14 -0
  198. package/node/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +15 -0
  199. package/node/ChartsLegend/piecewiseColorLegend.types.js +5 -0
  200. package/node/ChartsLegend/piecewiseColorLegendClasses.js +31 -0
  201. package/node/ChartsSurface/ChartsSurface.js +0 -1
  202. package/node/LineChart/AnimatedArea.js +1 -0
  203. package/node/LineChart/AnimatedLine.js +1 -0
  204. package/node/LineChart/AppearingMask.js +1 -0
  205. package/node/LineChart/CircleMarkElement.js +1 -0
  206. package/node/LineChart/LineChart.js +20 -10
  207. package/node/LineChart/MarkElement.js +3 -1
  208. package/node/LineChart/legend.js +1 -0
  209. package/node/LineChart/useLineChartProps.js +14 -2
  210. package/node/PieChart/PieArc.js +3 -1
  211. package/node/PieChart/PieArcLabel.js +13 -9
  212. package/node/PieChart/PieArcLabelPlot.js +1 -0
  213. package/node/PieChart/PieArcPlot.js +1 -0
  214. package/node/PieChart/PieChart.js +42 -41
  215. package/node/PieChart/legend.js +1 -0
  216. package/node/ScatterChart/ScatterChart.js +21 -11
  217. package/node/ScatterChart/legend.js +1 -0
  218. package/node/ScatterChart/useScatterChartProps.js +14 -2
  219. package/node/SparkLineChart/SparkLineChart.js +1 -4
  220. package/node/constants/index.js +3 -2
  221. package/node/hooks/index.js +13 -1
  222. package/node/{ChartsLegend/utils.js → hooks/useLegend.js} +19 -1
  223. package/node/index.js +12 -1
  224. package/node/internals/calculateMargins.js +33 -0
  225. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +61 -16
  226. package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
  227. package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +69 -0
  228. package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
  229. package/node/internals/components/ChartsWrapper/ChartsWrapper.js +72 -0
  230. package/node/internals/components/ChartsWrapper/index.js +16 -0
  231. package/node/internals/consumeSlots.js +109 -0
  232. package/node/internals/consumeThemeProps.js +18 -27
  233. package/node/internals/index.js +12 -0
  234. package/package.json +4 -4
  235. package/ChartsLegend/ChartsLegendItem.d.ts +0 -26
  236. package/ChartsLegend/ChartsLegendItem.js +0 -65
  237. package/ChartsLegend/DefaultChartsLegend.d.ts +0 -25
  238. package/ChartsLegend/DefaultChartsLegend.js +0 -112
  239. package/ChartsLegend/LegendPerItem.d.ts +0 -65
  240. package/ChartsLegend/LegendPerItem.js +0 -129
  241. package/ChartsLegend/legendItemsPlacement.d.ts +0 -3
  242. package/ChartsLegend/legendItemsPlacement.js +0 -72
  243. package/ChartsLegend/utils.d.ts +0 -2
  244. package/modern/ChartsLegend/ChartsLegendItem.js +0 -65
  245. package/modern/ChartsLegend/DefaultChartsLegend.js +0 -112
  246. package/modern/ChartsLegend/LegendPerItem.js +0 -129
  247. package/modern/ChartsLegend/legendItemsPlacement.js +0 -72
  248. package/node/ChartsLegend/ChartsLegendItem.js +0 -72
  249. package/node/ChartsLegend/DefaultChartsLegend.js +0 -118
  250. package/node/ChartsLegend/LegendPerItem.js +0 -137
  251. package/node/ChartsLegend/legendItemsPlacement.js +0 -79
@@ -7,16 +7,25 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.ChartsAxesGradients = ChartsAxesGradients;
9
9
  exports.useChartGradient = useChartGradient;
10
+ exports.useChartGradientObjectBound = useChartGradientObjectBound;
10
11
  var React = _interopRequireWildcard(require("react"));
11
12
  var _CartesianProvider = require("../../../context/CartesianProvider");
12
13
  var _hooks = require("../../../hooks");
13
14
  var _ChartsPiecewiseGradient = _interopRequireDefault(require("./ChartsPiecewiseGradient"));
14
15
  var _ChartsContinuousGradient = _interopRequireDefault(require("./ChartsContinuousGradient"));
16
+ var _ChartsContinuousGradientObjectBound = _interopRequireDefault(require("./ChartsContinuousGradientObjectBound"));
17
+ var _useZAxis = require("../../../hooks/useZAxis");
15
18
  var _jsxRuntime = require("react/jsx-runtime");
16
19
  function useChartGradient() {
17
20
  const chartId = (0, _hooks.useChartId)();
18
21
  return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
19
22
  }
23
+
24
+ // TODO: make public?
25
+ function useChartGradientObjectBound() {
26
+ const chartId = (0, _hooks.useChartId)();
27
+ return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}-object-bound`, [chartId]);
28
+ }
20
29
  function ChartsAxesGradients() {
21
30
  const {
22
31
  top,
@@ -29,20 +38,27 @@ function ChartsAxesGradients() {
29
38
  const svgHeight = top + height + bottom;
30
39
  const svgWidth = left + width + right;
31
40
  const getGradientId = useChartGradient();
41
+ const getObjectBoundGradientId = useChartGradientObjectBound();
32
42
  const {
33
43
  xAxisIds,
34
44
  xAxis,
35
45
  yAxisIds,
36
46
  yAxis
37
47
  } = (0, _CartesianProvider.useCartesianContext)();
48
+ const {
49
+ zAxisIds,
50
+ zAxis
51
+ } = (0, _useZAxis.useZAxis)();
38
52
  const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
39
53
  const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
40
- if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0) {
54
+ const filteredZAxisIds = zAxisIds.filter(axisId => zAxis[axisId].colorMap !== undefined);
55
+ if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0 && filteredZAxisIds.length === 0) {
41
56
  return null;
42
57
  }
43
58
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("defs", {
44
59
  children: [filteredYAxisIds.map(axisId => {
45
60
  const gradientId = getGradientId(axisId, 'y');
61
+ const objectBoundGradientId = getObjectBoundGradientId(axisId, 'y');
46
62
  const {
47
63
  colorMap,
48
64
  scale,
@@ -60,19 +76,27 @@ function ChartsAxesGradients() {
60
76
  }, gradientId);
61
77
  }
62
78
  if (colorMap?.type === 'continuous') {
63
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
64
- isReversed: !reverse,
65
- scale: scale,
66
- colorScale: colorScale,
67
- colorMap: colorMap,
68
- size: svgHeight,
69
- gradientId: gradientId,
70
- direction: "y"
79
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
80
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
81
+ isReversed: !reverse,
82
+ scale: scale,
83
+ colorScale: colorScale,
84
+ colorMap: colorMap,
85
+ size: svgHeight,
86
+ gradientId: gradientId,
87
+ direction: "y"
88
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradientObjectBound.default, {
89
+ isReversed: reverse,
90
+ colorScale: colorScale,
91
+ colorMap: colorMap,
92
+ gradientId: objectBoundGradientId
93
+ })]
71
94
  }, gradientId);
72
95
  }
73
96
  return null;
74
97
  }), filteredXAxisIds.map(axisId => {
75
98
  const gradientId = getGradientId(axisId, 'x');
99
+ const objectBoundGradientId = getObjectBoundGradientId(axisId, 'x');
76
100
  const {
77
101
  colorMap,
78
102
  scale,
@@ -90,15 +114,36 @@ function ChartsAxesGradients() {
90
114
  }, gradientId);
91
115
  }
92
116
  if (colorMap?.type === 'continuous') {
93
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
94
- isReversed: reverse,
95
- scale: scale,
117
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
118
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
119
+ isReversed: reverse,
120
+ scale: scale,
121
+ colorScale: colorScale,
122
+ colorMap: colorMap,
123
+ size: svgWidth,
124
+ gradientId: gradientId,
125
+ direction: "x"
126
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradientObjectBound.default, {
127
+ isReversed: reverse,
128
+ colorScale: colorScale,
129
+ colorMap: colorMap,
130
+ gradientId: objectBoundGradientId
131
+ })]
132
+ }, gradientId);
133
+ }
134
+ return null;
135
+ }), filteredZAxisIds.map(axisId => {
136
+ const objectBoundGradientId = getObjectBoundGradientId(axisId, 'z');
137
+ const {
138
+ colorMap,
139
+ colorScale
140
+ } = zAxis[axisId];
141
+ if (colorMap?.type === 'continuous') {
142
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradientObjectBound.default, {
96
143
  colorScale: colorScale,
97
144
  colorMap: colorMap,
98
- size: svgWidth,
99
- gradientId: gradientId,
100
- direction: "x"
101
- }, gradientId);
145
+ gradientId: objectBoundGradientId
146
+ }, objectBoundGradientId);
102
147
  }
103
148
  return null;
104
149
  })]
@@ -20,14 +20,14 @@ function ChartsContinuousGradient(props) {
20
20
  colorScale,
21
21
  colorMap
22
22
  } = props;
23
- const extremValues = [colorMap.min ?? 0, colorMap.max ?? 100];
24
- const extremPositions = extremValues.map(scale).filter(p => p !== undefined);
25
- if (extremPositions.length !== 2) {
23
+ const extremumValues = [colorMap.min ?? 0, colorMap.max ?? 100];
24
+ const extremumPositions = extremumValues.map(scale).filter(p => p !== undefined);
25
+ if (extremumPositions.length !== 2) {
26
26
  return null;
27
27
  }
28
- const interpolator = typeof extremValues[0] === 'number' ? (0, _d3Interpolate.interpolateNumber)(extremValues[0], extremValues[1]) : (0, _d3Interpolate.interpolateDate)(extremValues[0], extremValues[1]);
29
- const numberOfPoints = Math.round((Math.max(...extremPositions) - Math.min(...extremPositions)) / PX_PRECISION);
30
- const keyPrefix = `${extremValues[0]}-${extremValues[1]}-`;
28
+ const interpolator = typeof extremumValues[0] === 'number' ? (0, _d3Interpolate.interpolateNumber)(extremumValues[0], extremumValues[1]) : (0, _d3Interpolate.interpolateDate)(extremumValues[0], extremumValues[1]);
29
+ const numberOfPoints = Math.round((Math.max(...extremumPositions) - Math.min(...extremumPositions)) / PX_PRECISION);
30
+ const keyPrefix = `${extremumValues[0]}-${extremumValues[1]}-`;
31
31
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("linearGradient", {
32
32
  id: gradientId,
33
33
  x1: "0",
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = ChartsContinuousGradientObjectBound;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ const PX_PRECISION = 10;
14
+ const getDirection = isReversed => {
15
+ if (isReversed) {
16
+ return {
17
+ x1: '1',
18
+ x2: '0',
19
+ y1: '0',
20
+ y2: '0'
21
+ };
22
+ }
23
+ return {
24
+ x1: '0',
25
+ x2: '1',
26
+ y1: '0',
27
+ y2: '0'
28
+ };
29
+ };
30
+
31
+ /**
32
+ * Generates gradients to be used in tooltips and legends.
33
+ */
34
+ function ChartsContinuousGradientObjectBound(props) {
35
+ const {
36
+ isReversed,
37
+ gradientId,
38
+ colorScale,
39
+ colorMap
40
+ } = props;
41
+ const extremumValues = [colorMap.min ?? 0, colorMap.max ?? 100];
42
+ const interpolator = typeof extremumValues[0] === 'number' ? (0, _d3Interpolate.interpolateNumber)(extremumValues[0], extremumValues[1]) : (0, _d3Interpolate.interpolateDate)(extremumValues[0], extremumValues[1]);
43
+ const numberOfPoints = PX_PRECISION;
44
+ const keyPrefix = `${extremumValues[0]}-${extremumValues[1]}-`;
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("linearGradient", (0, _extends2.default)({
46
+ id: gradientId
47
+ }, getDirection(isReversed), {
48
+ gradientUnits: 'objectBoundingBox' // Use the SVG coordinate instead of the component ones.
49
+ ,
50
+ children: Array.from({
51
+ length: numberOfPoints + 1
52
+ }, (_, index) => {
53
+ const offset = index / numberOfPoints;
54
+ const value = interpolator(offset);
55
+ if (value === undefined) {
56
+ return null;
57
+ }
58
+ const color = colorScale(value);
59
+ if (color === null) {
60
+ return null;
61
+ }
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("stop", {
63
+ offset: offset,
64
+ stopColor: color,
65
+ stopOpacity: 1
66
+ }, keyPrefix + index);
67
+ })
68
+ }));
69
+ }
@@ -31,6 +31,9 @@ function ChartsPiecewiseGradient(props) {
31
31
  return null;
32
32
  }
33
33
  const offset = isReversed ? 1 - x / size : x / size;
34
+ if (Number.isNaN(offset)) {
35
+ return null;
36
+ }
34
37
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
35
38
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("stop", {
36
39
  offset: offset,
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChartsWrapper = ChartsWrapper;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _styles = require("@mui/material/styles");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ const getDirection = (direction, position) => {
12
+ if (direction === 'vertical') {
13
+ if (position?.horizontal === 'left') {
14
+ return 'row';
15
+ }
16
+ return 'row-reverse';
17
+ }
18
+ if (position?.vertical === 'bottom') {
19
+ return 'column-reverse';
20
+ }
21
+ return 'column';
22
+ };
23
+ const getAlign = (direction, position) => {
24
+ if (direction === 'vertical') {
25
+ if (position?.vertical === 'top') {
26
+ return 'flex-start';
27
+ }
28
+ if (position?.vertical === 'bottom') {
29
+ return 'flex-end';
30
+ }
31
+ }
32
+ if (direction === 'horizontal') {
33
+ if (position?.horizontal === 'left') {
34
+ return 'flex-start';
35
+ }
36
+ if (position?.horizontal === 'right') {
37
+ return 'flex-end';
38
+ }
39
+ }
40
+ return 'center';
41
+ };
42
+ const Root = (0, _styles.styled)('div', {
43
+ name: 'MuiChartsWrapper',
44
+ slot: 'Root',
45
+ overridesResolver: (props, styles) => styles.root
46
+ })(({
47
+ ownerState
48
+ }) => ({
49
+ display: 'flex',
50
+ flexDirection: getDirection(ownerState.legendDirection, ownerState.legendPosition),
51
+ flex: 1,
52
+ justifyContent: 'center',
53
+ alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition)
54
+ }));
55
+
56
+ /**
57
+ * @ignore - internal component.
58
+ *
59
+ * Wrapper for the charts components.
60
+ * Its main purpose is to position the HTML legend in the correct place.
61
+ */
62
+ function ChartsWrapper(props) {
63
+ const {
64
+ children,
65
+ sx
66
+ } = props;
67
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
68
+ ownerState: props,
69
+ sx: sx,
70
+ children: children
71
+ });
72
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _ChartsWrapper = require("./ChartsWrapper");
7
+ Object.keys(_ChartsWrapper).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ChartsWrapper[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _ChartsWrapper[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.consumeSlots = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
13
+ var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
14
+ var React = _interopRequireWildcard(require("react"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ const _excluded = ["slots", "slotProps"],
17
+ _excluded2 = ["ownerState"];
18
+ /**
19
+ * A higher order component that consumes a slot from the props and renders the component provided in the slot.
20
+ *
21
+ * This HOC will wrap a single component, and will render the component provided in the slot, if it exists.
22
+ *
23
+ * If you need to render multiple components, you can manually consume the slots from the props and render them in your component instead of using this HOC.
24
+ *
25
+ * In the example below, `MyComponent` will render the component provided in `mySlot` slot, if it exists. Otherwise, it will render the `DefaultComponent`.
26
+ *
27
+ * @example
28
+ *
29
+ * ```tsx
30
+ * type MyComponentProps = {
31
+ * direction: 'row' | 'column';
32
+ * slots?: {
33
+ * mySlot?: React.JSXElementConstructor<{ direction: 'row' | 'column' }>;
34
+ * }
35
+ * };
36
+ *
37
+ * const MyComponent = consumeSlots(
38
+ * 'MuiMyComponent',
39
+ * 'mySlot',
40
+ * function DefaultComponent(props: MyComponentProps) {
41
+ * return (
42
+ * <div className={props.classes.root}>
43
+ * {props.direction}
44
+ * </div>
45
+ * );
46
+ * }
47
+ * );
48
+ * ```
49
+ *
50
+ * @param {string} name The mui component name.
51
+ * @param {string} slotPropName The name of the prop to retrieve the slot from.
52
+ * @param {object} options Options for the HOC.
53
+ * @param {boolean} options.propagateSlots Whether to propagate the slots to the component, this is always false if the slot is provided.
54
+ * @param {Record<string, any>} options.defaultProps A set of defaults for the component, will be deep merged with the props.
55
+ * @param {Array<keyof Props>} options.omitProps An array of props to omit from the component.
56
+ * @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
57
+ * @param InComponent The component to render if the slot is not provided.
58
+ */
59
+ const consumeSlots = (name, slotPropName, options, InComponent) => {
60
+ function ConsumeSlotsInternal(props, ref) {
61
+ const themedProps = (0, _styles.useThemeProps)({
62
+ props,
63
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
64
+ name
65
+ });
66
+ const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
67
+ const defaultizedProps = (0, _resolveProps.default)(defaultProps, themedProps);
68
+ const _ref = defaultizedProps,
69
+ {
70
+ slots,
71
+ slotProps
72
+ } = _ref,
73
+ other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
74
+ const theme = (0, _styles.useTheme)();
75
+ const classes = options.classesResolver?.(defaultizedProps, theme);
76
+
77
+ // Can be a function component or a forward ref component.
78
+ const Component = slots?.[slotPropName] ?? InComponent;
79
+ const propagateSlots = options.propagateSlots && !slots?.[slotPropName];
80
+ const _useSlotProps = (0, _useSlotProps2.default)({
81
+ elementType: Component,
82
+ externalSlotProps: slotProps?.[slotPropName],
83
+ additionalProps: (0, _extends2.default)({}, other, {
84
+ classes
85
+ }, propagateSlots && {
86
+ slots,
87
+ slotProps
88
+ }),
89
+ ownerState: {}
90
+ }),
91
+ originalOutProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
92
+ const outProps = (0, _extends2.default)({}, originalOutProps);
93
+ for (const prop of options.omitProps ?? []) {
94
+ delete outProps[prop];
95
+ }
96
+
97
+ // Component can be wrapped in React.forwardRef or just a function that accepts (props, ref).
98
+ // If it is a plain function which accepts two arguments, we need to wrap it in React.forwardRef.
99
+ const OutComponent = Component.length >= 2 ? /*#__PURE__*/React.forwardRef(Component) : Component;
100
+ if (process.env.NODE_ENV !== 'production') {
101
+ OutComponent.displayName = `${name}.slots.${slotPropName}`;
102
+ }
103
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutComponent, (0, _extends2.default)({}, outProps, {
104
+ ref: ref
105
+ }));
106
+ }
107
+ return /*#__PURE__*/React.forwardRef(ConsumeSlotsInternal);
108
+ };
109
+ exports.consumeSlots = consumeSlots;
@@ -10,7 +10,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _styles = require("@mui/material/styles");
11
11
  var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
- var ReactIs = _interopRequireWildcard(require("react-is"));
14
13
  var _jsxRuntime = require("react/jsx-runtime");
15
14
  /**
16
15
  * A higher order component that consumes and merges the theme `defaultProps` and handles the `classes` and renders the component.
@@ -57,31 +56,23 @@ var _jsxRuntime = require("react/jsx-runtime");
57
56
  * @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
58
57
  * @param InComponent The component to render if the slot is not provided.
59
58
  */
60
- const consumeThemeProps = (name, options, InComponent) => {
61
- function InternalComponent(props, ref) {
62
- const themedProps = (0, _styles.useThemeProps)({
63
- props,
64
- // eslint-disable-next-line material-ui/mui-name-matches-component-name
65
- name
66
- });
67
- const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
68
- const outProps = (0, _resolveProps.default)(defaultProps, themedProps);
69
- const theme = (0, _styles.useTheme)();
70
- const classes = options.classesResolver?.(outProps, theme);
71
- if (process.env.NODE_ENV !== 'production') {
72
- // eslint-disable-next-line react-compiler/react-compiler
73
- InComponent.displayName = name;
74
- }
75
- const OutComponent = ReactIs.isForwardRef(InComponent) ? InComponent :
76
- /*#__PURE__*/
77
- // InComponent needs to be a function that accepts `(props, ref)`
78
- // @ts-expect-error
79
- React.forwardRef(InComponent);
80
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutComponent, (0, _extends2.default)({}, outProps, {
81
- classes: classes,
82
- ref: ref
83
- }));
59
+ const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/React.forwardRef(function ConsumeThemeInternal(props, ref) {
60
+ const themedProps = (0, _styles.useThemeProps)({
61
+ props,
62
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
63
+ name
64
+ });
65
+ const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
66
+ const outProps = (0, _resolveProps.default)(defaultProps, themedProps);
67
+ const theme = (0, _styles.useTheme)();
68
+ const classes = options.classesResolver?.(outProps, theme);
69
+ const OutComponent = /*#__PURE__*/React.forwardRef(InComponent);
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ OutComponent.displayName = `consumeThemeProps(${name})`;
84
72
  }
85
- return /*#__PURE__*/React.forwardRef(InternalComponent);
86
- };
73
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutComponent, (0, _extends2.default)({}, outProps, {
74
+ classes: classes,
75
+ ref: ref
76
+ }));
77
+ });
87
78
  exports.consumeThemeProps = consumeThemeProps;
@@ -73,6 +73,18 @@ Object.keys(_ChartsAxesGradients).forEach(function (key) {
73
73
  }
74
74
  });
75
75
  });
76
+ var _ChartsWrapper = require("./components/ChartsWrapper");
77
+ Object.keys(_ChartsWrapper).forEach(function (key) {
78
+ if (key === "default" || key === "__esModule") return;
79
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
80
+ if (key in exports && exports[key] === _ChartsWrapper[key]) return;
81
+ Object.defineProperty(exports, key, {
82
+ enumerable: true,
83
+ get: function () {
84
+ return _ChartsWrapper[key];
85
+ }
86
+ });
87
+ });
76
88
  var _useSeries = require("../hooks/useSeries");
77
89
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
78
90
  var _useDrawingArea = require("../hooks/useDrawingArea");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.0.0-alpha.5",
3
+ "version": "8.0.0-alpha.7",
4
4
  "description": "The community edition of the Charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -35,11 +35,11 @@
35
35
  "@react-spring/web": "^9.7.5",
36
36
  "clsx": "^2.1.1",
37
37
  "prop-types": "^15.8.1",
38
- "react-is": "^18.3.1",
38
+ "react-is": "^18.3.1 || ^19.0.0",
39
39
  "reselect": "^5.1.1",
40
40
  "use-sync-external-store": "^1.4.0",
41
- "@mui/x-charts-vendor": "8.0.0-alpha.4",
42
- "@mui/x-internals": "8.0.0-alpha.5"
41
+ "@mui/x-charts-vendor": "8.0.0-alpha.7",
42
+ "@mui/x-internals": "8.0.0-alpha.7"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@emotion/react": "^11.9.0",
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- import { ChartsTextStyle } from '../ChartsText';
3
- import { LegendItemParams } from './chartsLegend.types';
4
- import { ChartsLegendClasses } from './chartsLegendClasses';
5
- export interface ChartsLegendItemProps extends LegendItemParams {
6
- positionY: number;
7
- label: string;
8
- positionX: number;
9
- innerHeight: number;
10
- innerWidth: number;
11
- color: string;
12
- gapX: number;
13
- gapY: number;
14
- legendWidth: number;
15
- itemMarkHeight: number;
16
- itemMarkWidth: number;
17
- markGap: number;
18
- labelStyle: ChartsTextStyle;
19
- classes?: Omit<Partial<ChartsLegendClasses>, 'column' | 'row' | 'label'>;
20
- onClick?: (event: React.MouseEvent<SVGRectElement, MouseEvent>) => void;
21
- }
22
- /**
23
- * @ignore - internal component.
24
- */
25
- declare function ChartsLegendItem(props: ChartsLegendItemProps): React.JSX.Element;
26
- export { ChartsLegendItem };
@@ -1,65 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import clsx from 'clsx';
4
- import { useRtl } from '@mui/system/RtlProvider';
5
- import { ChartsText } from "../ChartsText/index.js";
6
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- /**
8
- * @ignore - internal component.
9
- */
10
- function ChartsLegendItem(props) {
11
- const isRTL = useRtl();
12
- const {
13
- id,
14
- positionY,
15
- label,
16
- positionX,
17
- innerHeight,
18
- innerWidth,
19
- legendWidth,
20
- color,
21
- gapX,
22
- gapY,
23
- itemMarkHeight,
24
- itemMarkWidth,
25
- markGap,
26
- labelStyle,
27
- classes,
28
- onClick
29
- } = props;
30
- return /*#__PURE__*/_jsxs("g", {
31
- className: clsx(classes?.series, `${classes?.series}-${id}`),
32
- transform: `translate(${gapX + (isRTL ? legendWidth - positionX : positionX)} ${gapY + positionY})`,
33
- children: [/*#__PURE__*/_jsx("rect", {
34
- x: isRTL ? -(innerWidth + 2) : -2,
35
- y: -itemMarkHeight / 2 - 2,
36
- width: innerWidth + 4,
37
- height: innerHeight + 4,
38
- fill: "transparent",
39
- className: classes?.itemBackground,
40
- onClick: onClick,
41
- style: {
42
- pointerEvents: onClick ? 'all' : 'none',
43
- cursor: onClick ? 'pointer' : 'unset'
44
- }
45
- }), /*#__PURE__*/_jsx("rect", {
46
- className: classes?.mark,
47
- x: isRTL ? -itemMarkWidth : 0,
48
- y: -itemMarkHeight / 2,
49
- width: itemMarkWidth,
50
- height: itemMarkHeight,
51
- fill: color,
52
- style: {
53
- pointerEvents: 'none'
54
- }
55
- }), /*#__PURE__*/_jsx(ChartsText, {
56
- style: _extends({
57
- pointerEvents: 'none'
58
- }, labelStyle),
59
- text: label,
60
- x: (isRTL ? -1 : 1) * (itemMarkWidth + markGap),
61
- y: 0
62
- })]
63
- });
64
- }
65
- export { ChartsLegendItem };
@@ -1,25 +0,0 @@
1
- import * as React from 'react';
2
- import { FormattedSeries } from '../context/SeriesProvider';
3
- import { LegendPerItemProps } from './LegendPerItem';
4
- import { SeriesLegendItemContext } from './chartsLegend.types';
5
- export interface LegendRendererProps extends Omit<LegendPerItemProps, 'itemsToDisplay' | 'onItemClick'> {
6
- series: FormattedSeries;
7
- seriesToDisplay: LegendPerItemProps['itemsToDisplay'];
8
- /**
9
- * Callback fired when a legend item is clicked.
10
- * @param {React.MouseEvent<SVGRectElement, MouseEvent>} event The click event.
11
- * @param {SeriesLegendItemContext} legendItem The legend item data.
12
- * @param {number} index The index of the clicked legend item.
13
- */
14
- onItemClick?: (event: React.MouseEvent<SVGRectElement, MouseEvent>, legendItem: SeriesLegendItemContext, index: number) => void;
15
- /**
16
- * Set to true to hide the legend.
17
- * @default false
18
- */
19
- hidden?: boolean;
20
- }
21
- declare function DefaultChartsLegend(props: LegendRendererProps): React.JSX.Element | null;
22
- declare namespace DefaultChartsLegend {
23
- var propTypes: any;
24
- }
25
- export { DefaultChartsLegend };