@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
@@ -114,6 +114,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
114
114
  // | These PropTypes are generated from the TypeScript type definitions |
115
115
  // | To update them edit the TypeScript types and run "yarn proptypes" |
116
116
  // ----------------------------------------------------------------------
117
+ /**
118
+ * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
119
+ * The two properties accept the following values:
120
+ * - 'none': display nothing.
121
+ * - 'line': display a line at the current mouse position.
122
+ * - 'band': display a band at the current mouse position. Only available with band scale.
123
+ */
117
124
  axisHighlight: PropTypes.shape({
118
125
  x: PropTypes.oneOf(['band', 'line', 'none']),
119
126
  y: PropTypes.oneOf(['band', 'line', 'none'])
@@ -124,7 +131,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
124
131
  * @default xAxisIds[0] The id of the first provided axis
125
132
  */
126
133
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
127
- axisId: PropTypes.string.isRequired,
134
+ axisId: PropTypes.string,
128
135
  classes: PropTypes.object,
129
136
  disableLine: PropTypes.bool,
130
137
  disableTicks: PropTypes.bool,
@@ -151,13 +158,25 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
151
158
  * Color palette used to colorize multiple series.
152
159
  */
153
160
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
161
+ /**
162
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
163
+ */
154
164
  dataset: PropTypes.arrayOf(PropTypes.object),
155
165
  desc: PropTypes.string,
166
+ /**
167
+ * If `true`, the charts will not listen to the mouse move event.
168
+ * It might break interactive features, but will improve performance.
169
+ * @default false
170
+ */
156
171
  disableAxisListener: PropTypes.bool,
157
172
  /**
158
173
  * If `true`, render the line highlight item.
159
174
  */
160
175
  disableLineItemHighlight: PropTypes.bool,
176
+ /**
177
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
178
+ * @default undefined
179
+ */
161
180
  height: PropTypes.number,
162
181
  /**
163
182
  * Indicate which axis to display the left of the charts.
@@ -165,7 +184,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
165
184
  * @default yAxisIds[0] The id of the first provided axis
166
185
  */
167
186
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
168
- axisId: PropTypes.string.isRequired,
187
+ axisId: PropTypes.string,
169
188
  classes: PropTypes.object,
170
189
  disableLine: PropTypes.bool,
171
190
  disableTicks: PropTypes.bool,
@@ -200,6 +219,12 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
200
219
  slotProps: PropTypes.object,
201
220
  slots: PropTypes.object
202
221
  }),
222
+ /**
223
+ * The margin between the SVG and the drawing area.
224
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
225
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
226
+ * @default object Depends on the charts type.
227
+ */
203
228
  margin: PropTypes.shape({
204
229
  bottom: PropTypes.number,
205
230
  left: PropTypes.number,
@@ -212,7 +237,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
212
237
  * @default null
213
238
  */
214
239
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
215
- axisId: PropTypes.string.isRequired,
240
+ axisId: PropTypes.string,
216
241
  classes: PropTypes.object,
217
242
  disableLine: PropTypes.bool,
218
243
  disableTicks: PropTypes.bool,
@@ -282,7 +307,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
282
307
  * @default null
283
308
  */
284
309
  topAxis: PropTypes.oneOfType([PropTypes.shape({
285
- axisId: PropTypes.string.isRequired,
310
+ axisId: PropTypes.string,
286
311
  classes: PropTypes.object,
287
312
  disableLine: PropTypes.bool,
288
313
  disableTicks: PropTypes.bool,
@@ -309,7 +334,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
309
334
  x: PropTypes.number,
310
335
  y: PropTypes.number
311
336
  }),
337
+ /**
338
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
339
+ * @default undefined
340
+ */
312
341
  width: PropTypes.number,
342
+ /**
343
+ * The configuration of the x-axes.
344
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
345
+ */
313
346
  xAxis: PropTypes.arrayOf(PropTypes.shape({
314
347
  axisId: PropTypes.string,
315
348
  classes: PropTypes.object,
@@ -340,6 +373,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
340
373
  tickSize: PropTypes.number,
341
374
  valueFormatter: PropTypes.func
342
375
  })),
376
+ /**
377
+ * The configuration of the y-axes.
378
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
379
+ */
343
380
  yAxis: PropTypes.arrayOf(PropTypes.shape({
344
381
  axisId: PropTypes.string,
345
382
  classes: PropTypes.object,
@@ -73,7 +73,7 @@ function LineHighlightPlot(props) {
73
73
  throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
74
74
  }
75
75
  const x = xScale(xData[highlightedIndex]);
76
- const y = yScale(stackedData[highlightedIndex][1]);
76
+ const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
77
77
  return /*#__PURE__*/_jsx(Element, _extends({
78
78
  id: seriesId,
79
79
  color: series[seriesId].color,
@@ -126,7 +126,8 @@ function MarkPlot(props) {
126
126
  shape: "circle",
127
127
  color: series[seriesId].color,
128
128
  x: x,
129
- y: y,
129
+ y: y // Don't knwo why TS don't get from the filter that y can't be null
130
+ ,
130
131
  highlightScope: series[seriesId].highlightScope
131
132
  }, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`);
132
133
  });
@@ -111,7 +111,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
111
111
  * @default xAxisIds[0] The id of the first provided axis
112
112
  */
113
113
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
114
- axisId: PropTypes.string.isRequired,
114
+ axisId: PropTypes.string,
115
115
  classes: PropTypes.object,
116
116
  disableLine: PropTypes.bool,
117
117
  disableTicks: PropTypes.bool,
@@ -138,9 +138,21 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
138
138
  * Color palette used to colorize multiple series.
139
139
  */
140
140
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
141
+ /**
142
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
143
+ */
141
144
  dataset: PropTypes.arrayOf(PropTypes.object),
142
145
  desc: PropTypes.string,
146
+ /**
147
+ * If `true`, the charts will not listen to the mouse move event.
148
+ * It might break interactive features, but will improve performance.
149
+ * @default false
150
+ */
143
151
  disableAxisListener: PropTypes.bool,
152
+ /**
153
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
154
+ * @default undefined
155
+ */
144
156
  height: PropTypes.number,
145
157
  /**
146
158
  * Indicate which axis to display the left of the charts.
@@ -148,7 +160,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
148
160
  * @default yAxisIds[0] The id of the first provided axis
149
161
  */
150
162
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
151
- axisId: PropTypes.string.isRequired,
163
+ axisId: PropTypes.string,
152
164
  classes: PropTypes.object,
153
165
  disableLine: PropTypes.bool,
154
166
  disableTicks: PropTypes.bool,
@@ -183,6 +195,12 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
183
195
  slotProps: PropTypes.object,
184
196
  slots: PropTypes.object
185
197
  }),
198
+ /**
199
+ * The margin between the SVG and the drawing area.
200
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
201
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
202
+ * @default object Depends on the charts type.
203
+ */
186
204
  margin: PropTypes.shape({
187
205
  bottom: PropTypes.number,
188
206
  left: PropTypes.number,
@@ -196,7 +214,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
196
214
  * @default null
197
215
  */
198
216
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
199
- axisId: PropTypes.string.isRequired,
217
+ axisId: PropTypes.string,
200
218
  classes: PropTypes.object,
201
219
  disableLine: PropTypes.bool,
202
220
  disableTicks: PropTypes.bool,
@@ -287,7 +305,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
287
305
  * @default null
288
306
  */
289
307
  topAxis: PropTypes.oneOfType([PropTypes.shape({
290
- axisId: PropTypes.string.isRequired,
308
+ axisId: PropTypes.string,
291
309
  classes: PropTypes.object,
292
310
  disableLine: PropTypes.bool,
293
311
  disableTicks: PropTypes.bool,
@@ -314,7 +332,15 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
314
332
  x: PropTypes.number,
315
333
  y: PropTypes.number
316
334
  }),
335
+ /**
336
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
337
+ * @default undefined
338
+ */
317
339
  width: PropTypes.number,
340
+ /**
341
+ * The configuration of the x-axes.
342
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
343
+ */
318
344
  xAxis: PropTypes.arrayOf(PropTypes.shape({
319
345
  axisId: PropTypes.string,
320
346
  classes: PropTypes.object,
@@ -345,6 +371,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
345
371
  tickSize: PropTypes.number,
346
372
  valueFormatter: PropTypes.func
347
373
  })),
374
+ /**
375
+ * The configuration of the y-axes.
376
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
377
+ */
348
378
  yAxis: PropTypes.arrayOf(PropTypes.shape({
349
379
  axisId: PropTypes.string,
350
380
  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,
@@ -129,10 +129,28 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
129
129
  * Data to plot.
130
130
  */
131
131
  data: PropTypes.arrayOf(PropTypes.number).isRequired,
132
+ /**
133
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
134
+ */
132
135
  dataset: PropTypes.arrayOf(PropTypes.object),
133
136
  desc: PropTypes.string,
137
+ /**
138
+ * If `true`, the charts will not listen to the mouse move event.
139
+ * It might break interactive features, but will improve performance.
140
+ * @default false
141
+ */
134
142
  disableAxisListener: PropTypes.bool,
143
+ /**
144
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
145
+ * @default undefined
146
+ */
135
147
  height: PropTypes.number,
148
+ /**
149
+ * The margin between the SVG and the drawing area.
150
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
151
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
152
+ * @default object Depends on the charts type.
153
+ */
136
154
  margin: PropTypes.shape({
137
155
  bottom: PropTypes.number,
138
156
  left: PropTypes.number,
@@ -188,6 +206,10 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
188
206
  x: PropTypes.number,
189
207
  y: PropTypes.number
190
208
  }),
209
+ /**
210
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
211
+ * @default undefined
212
+ */
191
213
  width: PropTypes.number,
192
214
  /**
193
215
  * The xAxis configuration.
@@ -221,7 +221,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
221
221
  // | To update them edit the TypeScript types and run "yarn proptypes" |
222
222
  // ----------------------------------------------------------------------
223
223
  children: PropTypes.node,
224
+ /**
225
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
226
+ */
224
227
  dataset: PropTypes.arrayOf(PropTypes.object),
228
+ /**
229
+ * The configuration of the x-axes.
230
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
231
+ */
225
232
  xAxis: PropTypes.arrayOf(PropTypes.shape({
226
233
  axisId: PropTypes.string,
227
234
  classes: PropTypes.object,
@@ -252,6 +259,10 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
252
259
  tickSize: PropTypes.number,
253
260
  valueFormatter: PropTypes.func
254
261
  })),
262
+ /**
263
+ * The configuration of the y-axes.
264
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
265
+ */
255
266
  yAxis: PropTypes.arrayOf(PropTypes.shape({
256
267
  axisId: PropTypes.string,
257
268
  classes: PropTypes.object,
@@ -46,6 +46,12 @@ process.env.NODE_ENV !== "production" ? DrawingProvider.propTypes = {
46
46
  // ----------------------------------------------------------------------
47
47
  children: PropTypes.node,
48
48
  height: PropTypes.number.isRequired,
49
+ /**
50
+ * The margin between the SVG and the drawing area.
51
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
52
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
53
+ * @default object Depends on the charts type.
54
+ */
49
55
  margin: PropTypes.shape({
50
56
  bottom: PropTypes.number,
51
57
  left: PropTypes.number,
package/esm/index.js CHANGED
@@ -4,10 +4,12 @@ export * from './hooks';
4
4
  export * from './colorPalettes';
5
5
  export * from './models';
6
6
  export * from './ChartsClipPath';
7
+ export * from './ChartsReferenceLine';
7
8
  export * from './ChartsAxis';
8
9
  export * from './ChartsXAxis';
9
10
  export * from './ChartsYAxis';
10
11
  export * from './ChartsTooltip';
12
+ export * from './ChartsLegend';
11
13
  export * from './ChartsAxisHighlight';
12
14
  export * from './BarChart';
13
15
  export * from './LineChart';
@@ -6,8 +6,8 @@ let 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, angle = 0) {
@@ -6,5 +6,5 @@ import { D3Scale } from '../models/axis';
6
6
  * @returns (value: any) => number
7
7
  */
8
8
  export declare function getValueToPositionMapper(scale: D3Scale): (value: any) => number;
9
- export declare function useXScale(identifier?: number | string): import("d3-scale").ScaleBand<any> | import("d3-scale").ScalePoint<any> | import("d3-scale").ScaleLinear<any, any, never> | import("d3-scale").ScaleTime<any, any, never> | import("d3-scale").ScaleLogarithmic<any, any, never> | import("d3-scale").ScalePower<any, any, never>;
10
- export declare function useYScale(identifier?: number | string): import("d3-scale").ScaleBand<any> | import("d3-scale").ScalePoint<any> | import("d3-scale").ScaleLinear<any, any, never> | import("d3-scale").ScaleTime<any, any, never> | import("d3-scale").ScaleLogarithmic<any, any, never> | import("d3-scale").ScalePower<any, any, never>;
9
+ export declare function useXScale(identifier?: number | string): import("d3-scale").ScaleBand<string | number | Date> | import("d3-scale").ScalePoint<string | number | Date> | import("d3-scale").ScaleLogarithmic<number, number, never> | import("d3-scale").ScalePower<number, number, never> | import("d3-scale").ScaleTime<number, number, never> | import("d3-scale").ScaleLinear<number, number, never>;
10
+ export declare function useYScale(identifier?: number | string): import("d3-scale").ScaleBand<string | number | Date> | import("d3-scale").ScalePoint<string | number | Date> | import("d3-scale").ScaleLogarithmic<number, number, never> | import("d3-scale").ScalePower<number, number, never> | import("d3-scale").ScaleTime<number, number, never> | import("d3-scale").ScaleLinear<number, number, never>;
package/index.d.ts CHANGED
@@ -4,10 +4,12 @@ export * from './hooks';
4
4
  export * from './colorPalettes';
5
5
  export * from './models';
6
6
  export * from './ChartsClipPath';
7
+ export * from './ChartsReferenceLine';
7
8
  export * from './ChartsAxis';
8
9
  export * from './ChartsXAxis';
9
10
  export * from './ChartsYAxis';
10
11
  export * from './ChartsTooltip';
12
+ export * from './ChartsLegend';
11
13
  export * from './ChartsAxisHighlight';
12
14
  export * from './BarChart';
13
15
  export * from './LineChart';
package/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
@@ -76,6 +76,17 @@ Object.keys(_ChartsClipPath).forEach(function (key) {
76
76
  }
77
77
  });
78
78
  });
79
+ var _ChartsReferenceLine = require("./ChartsReferenceLine");
80
+ Object.keys(_ChartsReferenceLine).forEach(function (key) {
81
+ if (key === "default" || key === "__esModule") return;
82
+ if (key in exports && exports[key] === _ChartsReferenceLine[key]) return;
83
+ Object.defineProperty(exports, key, {
84
+ enumerable: true,
85
+ get: function () {
86
+ return _ChartsReferenceLine[key];
87
+ }
88
+ });
89
+ });
79
90
  var _ChartsAxis = require("./ChartsAxis");
80
91
  Object.keys(_ChartsAxis).forEach(function (key) {
81
92
  if (key === "default" || key === "__esModule") return;
@@ -120,6 +131,17 @@ Object.keys(_ChartsTooltip).forEach(function (key) {
120
131
  }
121
132
  });
122
133
  });
134
+ var _ChartsLegend = require("./ChartsLegend");
135
+ Object.keys(_ChartsLegend).forEach(function (key) {
136
+ if (key === "default" || key === "__esModule") return;
137
+ if (key in exports && exports[key] === _ChartsLegend[key]) return;
138
+ Object.defineProperty(exports, key, {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _ChartsLegend[key];
142
+ }
143
+ });
144
+ });
123
145
  var _ChartsAxisHighlight = require("./ChartsAxisHighlight");
124
146
  Object.keys(_ChartsAxisHighlight).forEach(function (key) {
125
147
  if (key === "default" || key === "__esModule") return;
@@ -18,7 +18,7 @@ interface GetWordsByLinesParams {
18
18
  */
19
19
  style?: ChartsTextStyle;
20
20
  /**
21
- * If true, the line width is computed.
21
+ * If `true`, the line width is computed.
22
22
  * @default false
23
23
  */
24
24
  needsComputation?: boolean;
@@ -2,8 +2,8 @@
2
2
  * Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
3
3
  * This assumes that all rectangles have the same height and angle between -90 and 90.
4
4
  * Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
5
- * @param width the side along the x axis.
6
- * @param height the side along the y axis.
5
+ * @param width the side along the x-axis.
6
+ * @param height the side along the y-axis.
7
7
  * @param angle the rotation in degrees.
8
8
  */
9
9
  export declare function getMinXTranslation(width: number, height: number, angle?: number): number;
@@ -12,8 +12,8 @@ let warnedOnce = false;
12
12
  * Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
13
13
  * This assumes that all rectangles have the same height and angle between -90 and 90.
14
14
  * Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
15
- * @param width the side along the x axis.
16
- * @param height the side along the y axis.
15
+ * @param width the side along the x-axis.
16
+ * @param height the side along the y-axis.
17
17
  * @param angle the rotation in degrees.
18
18
  */
19
19
  function getMinXTranslation(width, height, angle = 0) {
@@ -1,3 +1,5 @@
1
1
  import type { ScaleBand, ScalePoint } from 'd3-scale';
2
2
  import { D3Scale } from '../models/axis';
3
- export declare function isBandScale(scale: D3Scale): scale is ScaleBand<any> | ScalePoint<any>;
3
+ export declare function isBandScale<T extends {
4
+ toString(): string;
5
+ }>(scale: D3Scale<T>): scale is ScaleBand<T> | ScalePoint<T>;
@@ -1,2 +1,7 @@
1
1
  export type SymbolsTypes = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
2
2
  export declare function getSymbol(shape: SymbolsTypes): number;
3
+ type Without<T, U> = {
4
+ [P in Exclude<keyof T, keyof U>]?: never;
5
+ };
6
+ export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
7
+ export {};
@@ -119,6 +119,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
119
119
  // | These PropTypes are generated from the TypeScript type definitions |
120
120
  // | To update them edit the TypeScript types and run "yarn proptypes" |
121
121
  // ----------------------------------------------------------------------
122
+ /**
123
+ * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
124
+ * The two properties accept the following values:
125
+ * - 'none': display nothing.
126
+ * - 'line': display a line at the current mouse position.
127
+ * - 'band': display a band at the current mouse position. Only available with band scale.
128
+ */
122
129
  axisHighlight: PropTypes.shape({
123
130
  x: PropTypes.oneOf(['band', 'line', 'none']),
124
131
  y: PropTypes.oneOf(['band', 'line', 'none'])
@@ -129,7 +136,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
129
136
  * @default xAxisIds[0] The id of the first provided axis
130
137
  */
131
138
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
132
- axisId: PropTypes.string.isRequired,
139
+ axisId: PropTypes.string,
133
140
  classes: PropTypes.object,
134
141
  disableLine: PropTypes.bool,
135
142
  disableTicks: PropTypes.bool,
@@ -156,9 +163,21 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
156
163
  * Color palette used to colorize multiple series.
157
164
  */
158
165
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
166
+ /**
167
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
168
+ */
159
169
  dataset: PropTypes.arrayOf(PropTypes.object),
160
170
  desc: PropTypes.string,
171
+ /**
172
+ * If `true`, the charts will not listen to the mouse move event.
173
+ * It might break interactive features, but will improve performance.
174
+ * @default false
175
+ */
161
176
  disableAxisListener: PropTypes.bool,
177
+ /**
178
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
179
+ * @default undefined
180
+ */
162
181
  height: PropTypes.number,
163
182
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
164
183
  /**
@@ -167,7 +186,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
167
186
  * @default yAxisIds[0] The id of the first provided axis
168
187
  */
169
188
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
170
- axisId: PropTypes.string.isRequired,
189
+ axisId: PropTypes.string,
171
190
  classes: PropTypes.object,
172
191
  disableLine: PropTypes.bool,
173
192
  disableTicks: PropTypes.bool,
@@ -202,6 +221,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
202
221
  slotProps: PropTypes.object,
203
222
  slots: PropTypes.object
204
223
  }),
224
+ /**
225
+ * The margin between the SVG and the drawing area.
226
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
227
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
228
+ * @default object Depends on the charts type.
229
+ */
205
230
  margin: PropTypes.shape({
206
231
  bottom: PropTypes.number,
207
232
  left: PropTypes.number,
@@ -214,7 +239,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
214
239
  * @default null
215
240
  */
216
241
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
217
- axisId: PropTypes.string.isRequired,
242
+ axisId: PropTypes.string,
218
243
  classes: PropTypes.object,
219
244
  disableLine: PropTypes.bool,
220
245
  disableTicks: PropTypes.bool,
@@ -285,7 +310,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
285
310
  * @default null
286
311
  */
287
312
  topAxis: PropTypes.oneOfType([PropTypes.shape({
288
- axisId: PropTypes.string.isRequired,
313
+ axisId: PropTypes.string,
289
314
  classes: PropTypes.object,
290
315
  disableLine: PropTypes.bool,
291
316
  disableTicks: PropTypes.bool,
@@ -312,7 +337,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
312
337
  x: PropTypes.number,
313
338
  y: PropTypes.number
314
339
  }),
340
+ /**
341
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
342
+ * @default undefined
343
+ */
315
344
  width: PropTypes.number,
345
+ /**
346
+ * The configuration of the x-axes.
347
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
348
+ */
316
349
  xAxis: PropTypes.arrayOf(PropTypes.shape({
317
350
  axisId: PropTypes.string,
318
351
  classes: PropTypes.object,
@@ -343,6 +376,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
343
376
  tickSize: PropTypes.number,
344
377
  valueFormatter: PropTypes.func
345
378
  })),
379
+ /**
380
+ * The configuration of the y-axes.
381
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
382
+ */
346
383
  yAxis: PropTypes.arrayOf(PropTypes.shape({
347
384
  axisId: PropTypes.string,
348
385
  classes: PropTypes.object,