@mui/x-charts 6.18.0 → 7.0.0-alpha.0

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 (132) hide show
  1. package/BarChart/BarChart.d.ts +15 -8
  2. package/BarChart/BarChart.js +41 -4
  3. package/BarChart/BarPlot.d.ts +2 -2
  4. package/CHANGELOG.md +212 -5
  5. package/ChartsAxis/ChartsAxis.d.ts +3 -3
  6. package/ChartsAxis/ChartsAxis.js +5 -5
  7. package/ChartsAxis/axisClasses.d.ts +2 -2
  8. package/ChartsLegend/ChartsLegend.d.ts +10 -6
  9. package/ChartsLegend/ChartsLegend.js +137 -2
  10. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  11. package/ChartsLegend/chartsLegendClasses.js +2 -2
  12. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
  13. package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
  14. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
  15. package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
  16. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
  17. package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
  18. package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
  19. package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
  20. package/ChartsReferenceLine/common.d.ts +41 -0
  21. package/ChartsReferenceLine/common.js +27 -0
  22. package/ChartsReferenceLine/index.d.ts +2 -0
  23. package/ChartsReferenceLine/index.js +27 -0
  24. package/ChartsReferenceLine/package.json +6 -0
  25. package/ChartsSurface.d.ts +11 -0
  26. package/ChartsTooltip/ChartsTooltip.d.ts +4 -4
  27. package/ChartsXAxis/ChartsXAxis.js +9 -5
  28. package/ChartsYAxis/ChartsYAxis.js +9 -5
  29. package/LineChart/AreaPlot.d.ts +2 -2
  30. package/LineChart/LineChart.d.ts +18 -11
  31. package/LineChart/LineChart.js +41 -4
  32. package/LineChart/LineHighlightPlot.d.ts +4 -4
  33. package/LineChart/LineHighlightPlot.js +1 -1
  34. package/LineChart/LinePlot.d.ts +2 -2
  35. package/LineChart/MarkPlot.d.ts +4 -4
  36. package/LineChart/MarkPlot.js +2 -1
  37. package/PieChart/PieArcLabelPlot.d.ts +4 -4
  38. package/PieChart/PieArcPlot.d.ts +4 -4
  39. package/PieChart/PieChart.d.ts +8 -8
  40. package/PieChart/PieChart.js +34 -4
  41. package/PieChart/PiePlot.d.ts +6 -6
  42. package/ResponsiveChartContainer/index.d.ts +13 -3
  43. package/ScatterChart/ScatterChart.d.ts +8 -8
  44. package/ScatterChart/ScatterChart.js +34 -4
  45. package/ScatterChart/ScatterPlot.d.ts +4 -4
  46. package/SparkLineChart/SparkLineChart.d.ts +10 -10
  47. package/SparkLineChart/SparkLineChart.js +22 -0
  48. package/context/CartesianContextProvider.d.ts +21 -1
  49. package/context/CartesianContextProvider.js +11 -0
  50. package/context/DrawingProvider.d.ts +18 -0
  51. package/context/DrawingProvider.js +6 -0
  52. package/context/HighlightProvider.d.ts +17 -0
  53. package/context/InteractionProvider.d.ts +6 -0
  54. package/context/SeriesContextProvider.d.ts +5 -0
  55. package/esm/BarChart/BarChart.js +41 -4
  56. package/esm/ChartsAxis/ChartsAxis.js +6 -5
  57. package/esm/ChartsLegend/ChartsLegend.js +140 -4
  58. package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
  59. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  60. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  61. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  62. package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  63. package/esm/ChartsReferenceLine/common.js +20 -0
  64. package/esm/ChartsReferenceLine/index.js +2 -0
  65. package/esm/ChartsXAxis/ChartsXAxis.js +10 -6
  66. package/esm/ChartsYAxis/ChartsYAxis.js +10 -6
  67. package/esm/LineChart/LineChart.js +41 -4
  68. package/esm/LineChart/LineHighlightPlot.js +1 -1
  69. package/esm/LineChart/MarkPlot.js +2 -1
  70. package/esm/PieChart/PieChart.js +34 -4
  71. package/esm/ScatterChart/ScatterChart.js +34 -4
  72. package/esm/SparkLineChart/SparkLineChart.js +22 -0
  73. package/esm/context/CartesianContextProvider.js +11 -0
  74. package/esm/context/DrawingProvider.js +6 -0
  75. package/esm/index.js +2 -0
  76. package/esm/internals/geometry.js +2 -2
  77. package/hooks/useScale.d.ts +2 -2
  78. package/index.d.ts +2 -0
  79. package/index.js +23 -1
  80. package/internals/components/ChartsText.d.ts +1 -1
  81. package/internals/geometry.d.ts +2 -2
  82. package/internals/geometry.js +2 -2
  83. package/internals/isBandScale.d.ts +3 -1
  84. package/internals/utils.d.ts +5 -0
  85. package/legacy/BarChart/BarChart.js +41 -4
  86. package/legacy/ChartsAxis/ChartsAxis.js +6 -5
  87. package/legacy/ChartsLegend/ChartsLegend.js +140 -4
  88. package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
  89. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  90. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  91. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  92. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  93. package/legacy/ChartsReferenceLine/common.js +20 -0
  94. package/legacy/ChartsReferenceLine/index.js +2 -0
  95. package/legacy/ChartsXAxis/ChartsXAxis.js +15 -12
  96. package/legacy/ChartsYAxis/ChartsYAxis.js +15 -12
  97. package/legacy/LineChart/LineChart.js +41 -4
  98. package/legacy/LineChart/LineHighlightPlot.js +1 -1
  99. package/legacy/LineChart/MarkPlot.js +2 -1
  100. package/legacy/PieChart/PieChart.js +34 -4
  101. package/legacy/ScatterChart/ScatterChart.js +34 -4
  102. package/legacy/SparkLineChart/SparkLineChart.js +22 -0
  103. package/legacy/context/CartesianContextProvider.js +11 -0
  104. package/legacy/context/DrawingProvider.js +6 -0
  105. package/legacy/index.js +3 -1
  106. package/legacy/internals/geometry.js +2 -2
  107. package/models/axis.d.ts +37 -17
  108. package/models/layout.d.ts +6 -0
  109. package/models/seriesType/common.d.ts +16 -0
  110. package/modern/BarChart/BarChart.js +41 -4
  111. package/modern/ChartsAxis/ChartsAxis.js +5 -5
  112. package/modern/ChartsLegend/ChartsLegend.js +140 -4
  113. package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
  114. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  115. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
  116. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
  117. package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  118. package/modern/ChartsReferenceLine/common.js +20 -0
  119. package/modern/ChartsReferenceLine/index.js +2 -0
  120. package/modern/ChartsXAxis/ChartsXAxis.js +9 -5
  121. package/modern/ChartsYAxis/ChartsYAxis.js +9 -5
  122. package/modern/LineChart/LineChart.js +41 -4
  123. package/modern/LineChart/LineHighlightPlot.js +1 -1
  124. package/modern/LineChart/MarkPlot.js +2 -1
  125. package/modern/PieChart/PieChart.js +34 -4
  126. package/modern/ScatterChart/ScatterChart.js +34 -4
  127. package/modern/SparkLineChart/SparkLineChart.js +22 -0
  128. package/modern/context/CartesianContextProvider.js +11 -0
  129. package/modern/context/DrawingProvider.js +6 -0
  130. package/modern/index.js +3 -1
  131. package/modern/internals/geometry.js +2 -2
  132. package/package.json +1 -1
@@ -118,6 +118,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
118
118
  // | These PropTypes are generated from the TypeScript type definitions |
119
119
  // | To update them edit the TypeScript types and run "yarn proptypes" |
120
120
  // ----------------------------------------------------------------------
121
+ /**
122
+ * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
123
+ * The two properties accept the following values:
124
+ * - 'none': display nothing.
125
+ * - 'line': display a line at the current mouse position.
126
+ * - 'band': display a band at the current mouse position. Only available with band scale.
127
+ */
121
128
  axisHighlight: PropTypes.shape({
122
129
  x: PropTypes.oneOf(['band', 'line', 'none']),
123
130
  y: PropTypes.oneOf(['band', 'line', 'none'])
@@ -128,7 +135,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
128
135
  * @default xAxisIds[0] The id of the first provided axis
129
136
  */
130
137
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
131
- axisId: PropTypes.string.isRequired,
138
+ axisId: PropTypes.string,
132
139
  classes: PropTypes.object,
133
140
  disableLine: PropTypes.bool,
134
141
  disableTicks: PropTypes.bool,
@@ -155,13 +162,25 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
155
162
  * Color palette used to colorize multiple series.
156
163
  */
157
164
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
165
+ /**
166
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
167
+ */
158
168
  dataset: PropTypes.arrayOf(PropTypes.object),
159
169
  desc: PropTypes.string,
170
+ /**
171
+ * If `true`, the charts will not listen to the mouse move event.
172
+ * It might break interactive features, but will improve performance.
173
+ * @default false
174
+ */
160
175
  disableAxisListener: PropTypes.bool,
161
176
  /**
162
177
  * If `true`, render the line highlight item.
163
178
  */
164
179
  disableLineItemHighlight: PropTypes.bool,
180
+ /**
181
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
182
+ * @default undefined
183
+ */
165
184
  height: PropTypes.number,
166
185
  /**
167
186
  * Indicate which axis to display the left of the charts.
@@ -169,7 +188,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
169
188
  * @default yAxisIds[0] The id of the first provided axis
170
189
  */
171
190
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
172
- axisId: PropTypes.string.isRequired,
191
+ axisId: PropTypes.string,
173
192
  classes: PropTypes.object,
174
193
  disableLine: PropTypes.bool,
175
194
  disableTicks: PropTypes.bool,
@@ -204,6 +223,12 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
204
223
  slotProps: PropTypes.object,
205
224
  slots: PropTypes.object
206
225
  }),
226
+ /**
227
+ * The margin between the SVG and the drawing area.
228
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
229
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
230
+ * @default object Depends on the charts type.
231
+ */
207
232
  margin: PropTypes.shape({
208
233
  bottom: PropTypes.number,
209
234
  left: PropTypes.number,
@@ -216,7 +241,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
216
241
  * @default null
217
242
  */
218
243
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
219
- axisId: PropTypes.string.isRequired,
244
+ axisId: PropTypes.string,
220
245
  classes: PropTypes.object,
221
246
  disableLine: PropTypes.bool,
222
247
  disableTicks: PropTypes.bool,
@@ -286,7 +311,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
286
311
  * @default null
287
312
  */
288
313
  topAxis: PropTypes.oneOfType([PropTypes.shape({
289
- axisId: PropTypes.string.isRequired,
314
+ axisId: PropTypes.string,
290
315
  classes: PropTypes.object,
291
316
  disableLine: PropTypes.bool,
292
317
  disableTicks: PropTypes.bool,
@@ -313,7 +338,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
313
338
  x: PropTypes.number,
314
339
  y: PropTypes.number
315
340
  }),
341
+ /**
342
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
343
+ * @default undefined
344
+ */
316
345
  width: PropTypes.number,
346
+ /**
347
+ * The configuration of the x-axes.
348
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
349
+ */
317
350
  xAxis: PropTypes.arrayOf(PropTypes.shape({
318
351
  axisId: PropTypes.string,
319
352
  classes: PropTypes.object,
@@ -344,6 +377,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
344
377
  tickSize: PropTypes.number,
345
378
  valueFormatter: PropTypes.func
346
379
  })),
380
+ /**
381
+ * The configuration of the y-axes.
382
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
383
+ */
347
384
  yAxis: PropTypes.arrayOf(PropTypes.shape({
348
385
  axisId: PropTypes.string,
349
386
  classes: PropTypes.object,
@@ -66,7 +66,7 @@ function LineHighlightPlot(props) {
66
66
  throw new Error("Axis of id \"".concat(xAxisKey, "\" should have data property to be able to display a line plot."));
67
67
  }
68
68
  var x = xScale(xData[highlightedIndex]);
69
- var y = yScale(stackedData[highlightedIndex][1]);
69
+ var y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
70
70
  return /*#__PURE__*/_jsx(Element, _extends({
71
71
  id: seriesId,
72
72
  color: series[seriesId].color,
@@ -119,7 +119,8 @@ function MarkPlot(props) {
119
119
  shape: "circle",
120
120
  color: series[seriesId].color,
121
121
  x: x,
122
- y: y,
122
+ y: y // Don't knwo why TS don't get from the filter that y can't be null
123
+ ,
123
124
  highlightScope: series[seriesId].highlightScope
124
125
  }, slotProps == null ? void 0 : slotProps.mark), "".concat(seriesId, "-").concat(index));
125
126
  });
@@ -123,7 +123,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
123
123
  * @default xAxisIds[0] The id of the first provided axis
124
124
  */
125
125
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
126
- axisId: PropTypes.string.isRequired,
126
+ axisId: PropTypes.string,
127
127
  classes: PropTypes.object,
128
128
  disableLine: PropTypes.bool,
129
129
  disableTicks: PropTypes.bool,
@@ -150,9 +150,21 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
150
150
  * Color palette used to colorize multiple series.
151
151
  */
152
152
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
153
+ /**
154
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
155
+ */
153
156
  dataset: PropTypes.arrayOf(PropTypes.object),
154
157
  desc: PropTypes.string,
158
+ /**
159
+ * If `true`, the charts will not listen to the mouse move event.
160
+ * It might break interactive features, but will improve performance.
161
+ * @default false
162
+ */
155
163
  disableAxisListener: PropTypes.bool,
164
+ /**
165
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
166
+ * @default undefined
167
+ */
156
168
  height: PropTypes.number,
157
169
  /**
158
170
  * Indicate which axis to display the left of the charts.
@@ -160,7 +172,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
160
172
  * @default yAxisIds[0] The id of the first provided axis
161
173
  */
162
174
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
163
- axisId: PropTypes.string.isRequired,
175
+ axisId: PropTypes.string,
164
176
  classes: PropTypes.object,
165
177
  disableLine: PropTypes.bool,
166
178
  disableTicks: PropTypes.bool,
@@ -195,6 +207,12 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
195
207
  slotProps: PropTypes.object,
196
208
  slots: PropTypes.object
197
209
  }),
210
+ /**
211
+ * The margin between the SVG and the drawing area.
212
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
213
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
214
+ * @default object Depends on the charts type.
215
+ */
198
216
  margin: PropTypes.shape({
199
217
  bottom: PropTypes.number,
200
218
  left: PropTypes.number,
@@ -208,7 +226,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
208
226
  * @default null
209
227
  */
210
228
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
211
- axisId: PropTypes.string.isRequired,
229
+ axisId: PropTypes.string,
212
230
  classes: PropTypes.object,
213
231
  disableLine: PropTypes.bool,
214
232
  disableTicks: PropTypes.bool,
@@ -299,7 +317,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
299
317
  * @default null
300
318
  */
301
319
  topAxis: PropTypes.oneOfType([PropTypes.shape({
302
- axisId: PropTypes.string.isRequired,
320
+ axisId: PropTypes.string,
303
321
  classes: PropTypes.object,
304
322
  disableLine: PropTypes.bool,
305
323
  disableTicks: PropTypes.bool,
@@ -326,7 +344,15 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
326
344
  x: PropTypes.number,
327
345
  y: PropTypes.number
328
346
  }),
347
+ /**
348
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
349
+ * @default undefined
350
+ */
329
351
  width: PropTypes.number,
352
+ /**
353
+ * The configuration of the x-axes.
354
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
355
+ */
330
356
  xAxis: PropTypes.arrayOf(PropTypes.shape({
331
357
  axisId: PropTypes.string,
332
358
  classes: PropTypes.object,
@@ -357,6 +383,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
357
383
  tickSize: PropTypes.number,
358
384
  valueFormatter: PropTypes.func
359
385
  })),
386
+ /**
387
+ * The configuration of the y-axes.
388
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
389
+ */
360
390
  yAxis: PropTypes.arrayOf(PropTypes.shape({
361
391
  axisId: PropTypes.string,
362
392
  classes: PropTypes.object,
@@ -88,7 +88,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
88
88
  * @default xAxisIds[0] The id of the first provided axis
89
89
  */
90
90
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
91
- axisId: PropTypes.string.isRequired,
91
+ axisId: PropTypes.string,
92
92
  classes: PropTypes.object,
93
93
  disableLine: PropTypes.bool,
94
94
  disableTicks: PropTypes.bool,
@@ -115,9 +115,21 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
115
115
  * Color palette used to colorize multiple series.
116
116
  */
117
117
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
118
+ /**
119
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
120
+ */
118
121
  dataset: PropTypes.arrayOf(PropTypes.object),
119
122
  desc: PropTypes.string,
123
+ /**
124
+ * If `true`, the charts will not listen to the mouse move event.
125
+ * It might break interactive features, but will improve performance.
126
+ * @default false
127
+ */
120
128
  disableAxisListener: PropTypes.bool,
129
+ /**
130
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
131
+ * @default undefined
132
+ */
121
133
  height: PropTypes.number,
122
134
  /**
123
135
  * Indicate which axis to display the left of the charts.
@@ -125,7 +137,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
125
137
  * @default yAxisIds[0] The id of the first provided axis
126
138
  */
127
139
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
128
- axisId: PropTypes.string.isRequired,
140
+ axisId: PropTypes.string,
129
141
  classes: PropTypes.object,
130
142
  disableLine: PropTypes.bool,
131
143
  disableTicks: PropTypes.bool,
@@ -160,6 +172,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
160
172
  slotProps: PropTypes.object,
161
173
  slots: PropTypes.object
162
174
  }),
175
+ /**
176
+ * The margin between the SVG and the drawing area.
177
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
178
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
179
+ * @default object Depends on the charts type.
180
+ */
163
181
  margin: PropTypes.shape({
164
182
  bottom: PropTypes.number,
165
183
  left: PropTypes.number,
@@ -172,7 +190,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
172
190
  * @default null
173
191
  */
174
192
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
175
- axisId: PropTypes.string.isRequired,
193
+ axisId: PropTypes.string,
176
194
  classes: PropTypes.object,
177
195
  disableLine: PropTypes.bool,
178
196
  disableTicks: PropTypes.bool,
@@ -238,7 +256,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
238
256
  * @default null
239
257
  */
240
258
  topAxis: PropTypes.oneOfType([PropTypes.shape({
241
- axisId: PropTypes.string.isRequired,
259
+ axisId: PropTypes.string,
242
260
  classes: PropTypes.object,
243
261
  disableLine: PropTypes.bool,
244
262
  disableTicks: PropTypes.bool,
@@ -265,7 +283,15 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
265
283
  x: PropTypes.number,
266
284
  y: PropTypes.number
267
285
  }),
286
+ /**
287
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
288
+ * @default undefined
289
+ */
268
290
  width: PropTypes.number,
291
+ /**
292
+ * The configuration of the x-axes.
293
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
294
+ */
269
295
  xAxis: PropTypes.arrayOf(PropTypes.shape({
270
296
  axisId: PropTypes.string,
271
297
  classes: PropTypes.object,
@@ -296,6 +322,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
296
322
  tickSize: PropTypes.number,
297
323
  valueFormatter: PropTypes.func
298
324
  })),
325
+ /**
326
+ * The configuration of the y-axes.
327
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
328
+ */
299
329
  yAxis: PropTypes.arrayOf(PropTypes.shape({
300
330
  axisId: PropTypes.string,
301
331
  classes: PropTypes.object,
@@ -135,10 +135,28 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
135
135
  * Data to plot.
136
136
  */
137
137
  data: PropTypes.arrayOf(PropTypes.number).isRequired,
138
+ /**
139
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
140
+ */
138
141
  dataset: PropTypes.arrayOf(PropTypes.object),
139
142
  desc: PropTypes.string,
143
+ /**
144
+ * If `true`, the charts will not listen to the mouse move event.
145
+ * It might break interactive features, but will improve performance.
146
+ * @default false
147
+ */
140
148
  disableAxisListener: PropTypes.bool,
149
+ /**
150
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
151
+ * @default undefined
152
+ */
141
153
  height: PropTypes.number,
154
+ /**
155
+ * The margin between the SVG and the drawing area.
156
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
157
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
158
+ * @default object Depends on the charts type.
159
+ */
142
160
  margin: PropTypes.shape({
143
161
  bottom: PropTypes.number,
144
162
  left: PropTypes.number,
@@ -194,6 +212,10 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
194
212
  x: PropTypes.number,
195
213
  y: PropTypes.number
196
214
  }),
215
+ /**
216
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
217
+ * @default undefined
218
+ */
197
219
  width: PropTypes.number,
198
220
  /**
199
221
  * The xAxis configuration.
@@ -249,7 +249,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
249
249
  // | To update them edit the TypeScript types and run "yarn proptypes" |
250
250
  // ----------------------------------------------------------------------
251
251
  children: PropTypes.node,
252
+ /**
253
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
254
+ */
252
255
  dataset: PropTypes.arrayOf(PropTypes.object),
256
+ /**
257
+ * The configuration of the x-axes.
258
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
259
+ */
253
260
  xAxis: PropTypes.arrayOf(PropTypes.shape({
254
261
  axisId: PropTypes.string,
255
262
  classes: PropTypes.object,
@@ -280,6 +287,10 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
280
287
  tickSize: PropTypes.number,
281
288
  valueFormatter: PropTypes.func
282
289
  })),
290
+ /**
291
+ * The configuration of the y-axes.
292
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
293
+ */
283
294
  yAxis: PropTypes.arrayOf(PropTypes.shape({
284
295
  axisId: PropTypes.string,
285
296
  classes: PropTypes.object,
@@ -45,6 +45,12 @@ process.env.NODE_ENV !== "production" ? DrawingProvider.propTypes = {
45
45
  // ----------------------------------------------------------------------
46
46
  children: PropTypes.node,
47
47
  height: PropTypes.number.isRequired,
48
+ /**
49
+ * The margin between the SVG and the drawing area.
50
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
51
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
52
+ * @default object Depends on the charts type.
53
+ */
48
54
  margin: PropTypes.shape({
49
55
  bottom: PropTypes.number,
50
56
  left: PropTypes.number,
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.18.0
2
+ * @mui/x-charts v7.0.0-alpha.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,10 +11,12 @@ export * from './hooks';
11
11
  export * from './colorPalettes';
12
12
  export * from './models';
13
13
  export * from './ChartsClipPath';
14
+ export * from './ChartsReferenceLine';
14
15
  export * from './ChartsAxis';
15
16
  export * from './ChartsXAxis';
16
17
  export * from './ChartsYAxis';
17
18
  export * from './ChartsTooltip';
19
+ export * from './ChartsLegend';
18
20
  export * from './ChartsAxisHighlight';
19
21
  export * from './BarChart';
20
22
  export * from './LineChart';
@@ -6,8 +6,8 @@ var warnedOnce = false;
6
6
  * Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
7
7
  * This assumes that all rectangles have the same height and angle between -90 and 90.
8
8
  * Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
9
- * @param width the side along the x axis.
10
- * @param height the side along the y axis.
9
+ * @param width the side along the x-axis.
10
+ * @param height the side along the y-axis.
11
11
  * @param angle the rotation in degrees.
12
12
  */
13
13
  export function getMinXTranslation(width, height) {
package/models/axis.d.ts CHANGED
@@ -3,15 +3,17 @@ import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, S
3
3
  import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
4
4
  import type { TickParams } from '../hooks/useTicks';
5
5
  import { ChartsTextProps } from '../internals/components/ChartsText';
6
- export type D3Scale = ScaleBand<any> | ScaleLogarithmic<any, number> | ScalePoint<any> | ScalePower<any, number> | ScaleTime<any, number> | ScaleLinear<any, number>;
7
- export type D3ContinuouseScale = ScaleLogarithmic<any, number> | ScalePower<any, number> | ScaleTime<any, number> | ScaleLinear<any, number>;
8
- export interface ChartsAxisSlotsComponent {
6
+ export type D3Scale<Domain extends {
7
+ toString(): string;
8
+ } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
9
+ export type D3ContinuouseScale<Range = number, Output = number> = ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
10
+ export interface ChartsAxisSlots {
9
11
  axisLine?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
10
12
  axisTick?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
11
13
  axisTickLabel?: React.JSXElementConstructor<ChartsTextProps>;
12
14
  axisLabel?: React.JSXElementConstructor<ChartsTextProps>;
13
15
  }
14
- export interface ChartsAxisSlotComponentProps {
16
+ export interface ChartsAxisSlotProps {
15
17
  axisLine?: Partial<React.SVGAttributes<SVGPathElement>>;
16
18
  axisTick?: Partial<React.SVGAttributes<SVGPathElement>>;
17
19
  axisTickLabel?: Partial<ChartsTextProps>;
@@ -19,9 +21,10 @@ export interface ChartsAxisSlotComponentProps {
19
21
  }
20
22
  export interface ChartsAxisProps extends TickParams {
21
23
  /**
22
- * Id of the axis to render.
24
+ * The id of the axis to render.
25
+ * If undefined, it will be the first defined axis.
23
26
  */
24
- axisId: string;
27
+ axisId?: string;
25
28
  /**
26
29
  * If true, the axis line is disabled.
27
30
  * @default false
@@ -86,12 +89,12 @@ export interface ChartsAxisProps extends TickParams {
86
89
  * Overridable component slots.
87
90
  * @default {}
88
91
  */
89
- slots?: Partial<ChartsAxisSlotsComponent>;
92
+ slots?: Partial<ChartsAxisSlots>;
90
93
  /**
91
94
  * The props used for each component slot.
92
95
  * @default {}
93
96
  */
94
- slotProps?: Partial<ChartsAxisSlotComponentProps>;
97
+ slotProps?: Partial<ChartsAxisSlotProps>;
95
98
  }
96
99
  export interface ChartsYAxisProps extends ChartsAxisProps {
97
100
  /**
@@ -110,7 +113,7 @@ export type ContinuouseScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' |
110
113
  interface AxisScaleConfig {
111
114
  band: {
112
115
  scaleType: 'band';
113
- scale: ScaleBand<any>;
116
+ scale: ScaleBand<number | Date | string>;
114
117
  /**
115
118
  * The ratio between the space allocated for padding between two categories and the category width.
116
119
  * 0 means no gap, and 1 no data.
@@ -126,40 +129,54 @@ interface AxisScaleConfig {
126
129
  };
127
130
  point: {
128
131
  scaleType: 'point';
129
- scale: ScalePoint<any>;
132
+ scale: ScalePoint<number | Date | string>;
130
133
  };
131
134
  log: {
132
135
  scaleType: 'log';
133
- scale: ScaleLogarithmic<any, any>;
136
+ scale: ScaleLogarithmic<number, number>;
134
137
  };
135
138
  pow: {
136
139
  scaleType: 'pow';
137
- scale: ScalePower<any, any>;
140
+ scale: ScalePower<number, number>;
138
141
  };
139
142
  sqrt: {
140
143
  scaleType: 'sqrt';
141
- scale: ScalePower<any, any>;
144
+ scale: ScalePower<number, number>;
142
145
  };
143
146
  time: {
144
147
  scaleType: 'time';
145
- scale: ScaleTime<any, any>;
148
+ scale: ScaleTime<number, number>;
146
149
  };
147
150
  utc: {
148
151
  scaleType: 'utc';
149
- scale: ScaleTime<any, any>;
152
+ scale: ScaleTime<number, number>;
150
153
  };
151
154
  linear: {
152
155
  scaleType: 'linear';
153
- scale: ScaleLinear<any, any>;
156
+ scale: ScaleLinear<number, number>;
154
157
  };
155
158
  }
156
159
  export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
160
+ /**
161
+ * Id used to identify the axis.
162
+ */
157
163
  id: string;
164
+ /**
165
+ * The minimal value of the domain.
166
+ * If not provided, it gets computed to display the entire chart data.
167
+ */
158
168
  min?: number | Date;
169
+ /**
170
+ * The maximal value of the domain.
171
+ * If not provided, it gets computed to display the entire chart data.
172
+ */
159
173
  max?: number | Date;
174
+ /**
175
+ * The data used by `'band'` and `'point'` scales.
176
+ */
160
177
  data?: V[];
161
178
  /**
162
- * The key used to retrieve data from the dataset prop.
179
+ * The key used to retrieve `data` from the `dataset` prop.
163
180
  */
164
181
  dataKey?: string;
165
182
  valueFormatter?: (value: V) => string;
@@ -169,6 +186,9 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
169
186
  hideTooltip?: boolean;
170
187
  } & Partial<ChartsXAxisProps | ChartsYAxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
171
188
  export type AxisDefaultized<S extends ScaleName = ScaleName, V = any> = Omit<AxisConfig<S, V>, 'scaleType'> & AxisScaleConfig[S] & {
189
+ /**
190
+ * An indication of the expected number of ticks.
191
+ */
172
192
  tickNumber: number;
173
193
  };
174
194
  export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'band'> & {
@@ -7,5 +7,11 @@ export interface CardinalDirections<T> {
7
7
  export type LayoutConfig = {
8
8
  width: number;
9
9
  height: number;
10
+ /**
11
+ * The margin between the SVG and the drawing area.
12
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
13
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
14
+ * @default object Depends on the charts type.
15
+ */
10
16
  margin?: Partial<CardinalDirections<number>>;
11
17
  };
@@ -13,12 +13,28 @@ export type CommonSeriesType<TValue> = {
13
13
  };
14
14
  export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';
15
15
  export type CartesianSeriesType = {
16
+ /**
17
+ * The id of the x-axis used to render the series.
18
+ */
16
19
  xAxisKey?: string;
20
+ /**
21
+ * The id of the y-axis used to render the series.
22
+ */
17
23
  yAxisKey?: string;
18
24
  };
19
25
  export type StackableSeriesType = {
26
+ /**
27
+ * The key that identifies the stacking group.
28
+ * Series with the same `stack` property will be stacked together.
29
+ */
20
30
  stack?: string;
31
+ /**
32
+ * Defines how stacked series handle negative values.
33
+ */
21
34
  stackOffset?: StackOffsetType;
35
+ /**
36
+ * The order in which series' of the same group are stacked together.
37
+ */
22
38
  stackOrder?: StackOrderType;
23
39
  };
24
40
  export type StackOrderType = keyof typeof StackOrder;