@mui/x-charts 6.18.0 → 6.18.2

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 (182) hide show
  1. package/BarChart/BarChart.d.ts +7 -0
  2. package/BarChart/BarChart.js +41 -4
  3. package/CHANGELOG.md +116 -5
  4. package/ChartsAxis/ChartsAxis.js +5 -5
  5. package/ChartsAxis/axisClasses.d.ts +2 -2
  6. package/ChartsLegend/ChartsLegend.d.ts +1 -0
  7. package/ChartsLegend/ChartsLegend.js +1 -1
  8. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  9. package/ChartsLegend/chartsLegendClasses.js +2 -2
  10. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
  11. package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
  12. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
  13. package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
  14. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
  15. package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
  16. package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
  17. package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
  18. package/ChartsReferenceLine/common.d.ts +41 -0
  19. package/ChartsReferenceLine/common.js +27 -0
  20. package/ChartsReferenceLine/index.d.ts +2 -0
  21. package/ChartsReferenceLine/index.js +27 -0
  22. package/ChartsReferenceLine/package.json +6 -0
  23. package/ChartsSurface.d.ts +11 -0
  24. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -1
  25. package/ChartsTooltip/ChartsAxisTooltipContent.js +8 -4
  26. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +1 -1
  27. package/ChartsTooltip/ChartsItemTooltipContent.js +8 -4
  28. package/ChartsTooltip/ChartsTooltip.d.ts +1 -1
  29. package/ChartsTooltip/ChartsTooltip.js +13 -5
  30. package/ChartsTooltip/ChartsTooltipTable.js +3 -3
  31. package/ChartsTooltip/chartsTooltipClasses.d.ts +21 -0
  32. package/ChartsTooltip/chartsTooltipClasses.js +12 -0
  33. package/ChartsTooltip/index.d.ts +1 -0
  34. package/ChartsTooltip/index.js +11 -0
  35. package/ChartsTooltip/utils.d.ts +1 -1
  36. package/ChartsTooltip/utils.js +2 -2
  37. package/ChartsXAxis/ChartsXAxis.js +9 -5
  38. package/ChartsYAxis/ChartsYAxis.js +9 -5
  39. package/LineChart/LineChart.d.ts +7 -0
  40. package/LineChart/LineChart.js +41 -4
  41. package/LineChart/LineHighlightPlot.js +1 -1
  42. package/LineChart/MarkPlot.js +2 -1
  43. package/PieChart/PieArc.d.ts +5 -2
  44. package/PieChart/PieArc.js +17 -2
  45. package/PieChart/PieArcLabel.d.ts +1 -1
  46. package/PieChart/PieArcLabel.js +5 -10
  47. package/PieChart/PieArcLabelPlot.js +2 -2
  48. package/PieChart/PieArcPlot.js +2 -2
  49. package/PieChart/PieChart.js +34 -4
  50. package/PieChart/index.d.ts +4 -2
  51. package/PieChart/index.js +37 -27
  52. package/ResponsiveChartContainer/index.d.ts +13 -3
  53. package/ScatterChart/ScatterChart.js +34 -4
  54. package/SparkLineChart/SparkLineChart.js +22 -0
  55. package/context/CartesianContextProvider.d.ts +21 -1
  56. package/context/CartesianContextProvider.js +11 -0
  57. package/context/DrawingProvider.d.ts +18 -0
  58. package/context/DrawingProvider.js +6 -0
  59. package/context/HighlightProvider.d.ts +17 -0
  60. package/context/InteractionProvider.d.ts +6 -0
  61. package/context/SeriesContextProvider.d.ts +5 -0
  62. package/esm/BarChart/BarChart.js +41 -4
  63. package/esm/ChartsAxis/ChartsAxis.js +6 -5
  64. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  65. package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
  66. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  67. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  68. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  69. package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  70. package/esm/ChartsReferenceLine/common.js +20 -0
  71. package/esm/ChartsReferenceLine/index.js +2 -0
  72. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -4
  73. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +8 -4
  74. package/esm/ChartsTooltip/ChartsTooltip.js +15 -7
  75. package/esm/ChartsTooltip/ChartsTooltipTable.js +3 -3
  76. package/esm/ChartsTooltip/chartsTooltipClasses.js +5 -0
  77. package/esm/ChartsTooltip/index.js +2 -1
  78. package/esm/ChartsTooltip/utils.js +1 -1
  79. package/esm/ChartsXAxis/ChartsXAxis.js +10 -6
  80. package/esm/ChartsYAxis/ChartsYAxis.js +10 -6
  81. package/esm/LineChart/LineChart.js +41 -4
  82. package/esm/LineChart/LineHighlightPlot.js +1 -1
  83. package/esm/LineChart/MarkPlot.js +2 -1
  84. package/esm/PieChart/PieArc.js +18 -2
  85. package/esm/PieChart/PieArcLabel.js +7 -11
  86. package/esm/PieChart/PieArcLabelPlot.js +1 -1
  87. package/esm/PieChart/PieArcPlot.js +1 -1
  88. package/esm/PieChart/PieChart.js +34 -4
  89. package/esm/PieChart/index.js +2 -2
  90. package/esm/ScatterChart/ScatterChart.js +34 -4
  91. package/esm/SparkLineChart/SparkLineChart.js +22 -0
  92. package/esm/context/CartesianContextProvider.js +11 -0
  93. package/esm/context/DrawingProvider.js +6 -0
  94. package/esm/index.js +1 -0
  95. package/esm/internals/geometry.js +2 -2
  96. package/hooks/useScale.d.ts +2 -2
  97. package/index.d.ts +1 -0
  98. package/index.js +12 -1
  99. package/internals/components/ChartsText.d.ts +1 -1
  100. package/internals/geometry.d.ts +2 -2
  101. package/internals/geometry.js +2 -2
  102. package/internals/isBandScale.d.ts +3 -1
  103. package/internals/utils.d.ts +5 -0
  104. package/legacy/BarChart/BarChart.js +41 -4
  105. package/legacy/ChartsAxis/ChartsAxis.js +6 -5
  106. package/legacy/ChartsLegend/ChartsLegend.js +2 -2
  107. package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
  108. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  109. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  110. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  111. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  112. package/legacy/ChartsReferenceLine/common.js +20 -0
  113. package/legacy/ChartsReferenceLine/index.js +2 -0
  114. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +8 -4
  115. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +8 -4
  116. package/legacy/ChartsTooltip/ChartsTooltip.js +20 -12
  117. package/legacy/ChartsTooltip/ChartsTooltipTable.js +3 -3
  118. package/legacy/ChartsTooltip/chartsTooltipClasses.js +5 -0
  119. package/legacy/ChartsTooltip/index.js +2 -1
  120. package/legacy/ChartsTooltip/utils.js +1 -1
  121. package/legacy/ChartsXAxis/ChartsXAxis.js +15 -12
  122. package/legacy/ChartsYAxis/ChartsYAxis.js +15 -12
  123. package/legacy/LineChart/LineChart.js +41 -4
  124. package/legacy/LineChart/LineHighlightPlot.js +1 -1
  125. package/legacy/LineChart/MarkPlot.js +2 -1
  126. package/legacy/PieChart/PieArc.js +18 -2
  127. package/legacy/PieChart/PieArcLabel.js +7 -11
  128. package/legacy/PieChart/PieArcLabelPlot.js +1 -1
  129. package/legacy/PieChart/PieArcPlot.js +1 -1
  130. package/legacy/PieChart/PieChart.js +34 -4
  131. package/legacy/PieChart/index.js +2 -2
  132. package/legacy/ScatterChart/ScatterChart.js +34 -4
  133. package/legacy/SparkLineChart/SparkLineChart.js +22 -0
  134. package/legacy/context/CartesianContextProvider.js +11 -0
  135. package/legacy/context/DrawingProvider.js +6 -0
  136. package/legacy/index.js +2 -1
  137. package/legacy/internals/geometry.js +2 -2
  138. package/models/axis.d.ts +33 -13
  139. package/models/layout.d.ts +6 -0
  140. package/models/seriesType/common.d.ts +16 -0
  141. package/modern/BarChart/BarChart.js +41 -4
  142. package/modern/ChartsAxis/ChartsAxis.js +5 -5
  143. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  144. package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
  145. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  146. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
  147. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
  148. package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  149. package/modern/ChartsReferenceLine/common.js +20 -0
  150. package/modern/ChartsReferenceLine/index.js +2 -0
  151. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -4
  152. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +8 -4
  153. package/modern/ChartsTooltip/ChartsTooltip.js +15 -7
  154. package/modern/ChartsTooltip/ChartsTooltipTable.js +3 -3
  155. package/modern/ChartsTooltip/chartsTooltipClasses.js +5 -0
  156. package/modern/ChartsTooltip/index.js +2 -1
  157. package/modern/ChartsTooltip/utils.js +1 -1
  158. package/modern/ChartsXAxis/ChartsXAxis.js +9 -5
  159. package/modern/ChartsYAxis/ChartsYAxis.js +9 -5
  160. package/modern/LineChart/LineChart.js +41 -4
  161. package/modern/LineChart/LineHighlightPlot.js +1 -1
  162. package/modern/LineChart/MarkPlot.js +2 -1
  163. package/modern/PieChart/PieArc.js +18 -2
  164. package/modern/PieChart/PieArcLabel.js +7 -11
  165. package/modern/PieChart/PieArcLabelPlot.js +1 -1
  166. package/modern/PieChart/PieArcPlot.js +1 -1
  167. package/modern/PieChart/PieChart.js +34 -4
  168. package/modern/PieChart/index.js +2 -2
  169. package/modern/ScatterChart/ScatterChart.js +34 -4
  170. package/modern/SparkLineChart/SparkLineChart.js +22 -0
  171. package/modern/context/CartesianContextProvider.js +11 -0
  172. package/modern/context/DrawingProvider.js +6 -0
  173. package/modern/index.js +2 -1
  174. package/modern/internals/geometry.js +2 -2
  175. package/package.json +1 -1
  176. package/themeAugmentation/components.d.ts +1 -0
  177. package/themeAugmentation/overrides.d.ts +2 -0
  178. package/ChartsTooltip/tooltipClasses.d.ts +0 -13
  179. package/ChartsTooltip/tooltipClasses.js +0 -12
  180. package/esm/ChartsTooltip/tooltipClasses.js +0 -5
  181. package/legacy/ChartsTooltip/tooltipClasses.js +0 -5
  182. package/modern/ChartsTooltip/tooltipClasses.js +0 -5
@@ -225,7 +225,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
225
225
  // | To update them edit the TypeScript types and run "yarn proptypes" |
226
226
  // ----------------------------------------------------------------------
227
227
  children: _propTypes.default.node,
228
+ /**
229
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
230
+ */
228
231
  dataset: _propTypes.default.arrayOf(_propTypes.default.object),
232
+ /**
233
+ * The configuration of the x-axes.
234
+ * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
235
+ */
229
236
  xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
230
237
  axisId: _propTypes.default.string,
231
238
  classes: _propTypes.default.object,
@@ -256,6 +263,10 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
256
263
  tickSize: _propTypes.default.number,
257
264
  valueFormatter: _propTypes.default.func
258
265
  })),
266
+ /**
267
+ * The configuration of the y-axes.
268
+ * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
269
+ */
259
270
  yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
260
271
  axisId: _propTypes.default.string,
261
272
  classes: _propTypes.default.object,
@@ -8,11 +8,29 @@ export interface DrawingProviderProps extends LayoutConfig {
8
8
  * Defines the area in which it is possible to draw the charts.
9
9
  */
10
10
  export type DrawingArea = {
11
+ /**
12
+ * The gap between the left border of the SVG and the drawing area.
13
+ */
11
14
  left: number;
15
+ /**
16
+ * The gap between the top border of the SVG and the drawing area.
17
+ */
12
18
  top: number;
19
+ /**
20
+ * The gap between the bottom border of the SVG and the drawing area.
21
+ */
13
22
  bottom: number;
23
+ /**
24
+ * The gap between the right border of the SVG and the drawing area.
25
+ */
14
26
  right: number;
27
+ /**
28
+ * The width of the drawing area.
29
+ */
15
30
  width: number;
31
+ /**
32
+ * The height of the drawing area.
33
+ */
16
34
  height: number;
17
35
  };
18
36
  export declare const DrawingContext: React.Context<DrawingArea>;
@@ -57,6 +57,12 @@ process.env.NODE_ENV !== "production" ? DrawingProvider.propTypes = {
57
57
  // ----------------------------------------------------------------------
58
58
  children: _propTypes.default.node,
59
59
  height: _propTypes.default.number.isRequired,
60
+ /**
61
+ * The margin between the SVG and the drawing area.
62
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
63
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
64
+ * @default object Depends on the charts type.
65
+ */
60
66
  margin: _propTypes.default.shape({
61
67
  bottom: _propTypes.default.number,
62
68
  left: _propTypes.default.number,
@@ -7,7 +7,21 @@ export type ItemHighlighData<T extends ChartSeriesType> = ChartItemIdentifier<T>
7
7
  export type HighlightOptions = 'none' | 'item' | 'series';
8
8
  export type FadeOptions = 'none' | 'series' | 'global';
9
9
  export type HighlightScope = {
10
+ /**
11
+ * The scope of highlighted elements.
12
+ * - 'none': no highlight.
13
+ * - 'item': only highlight the item.
14
+ * - 'series': highlight all elements of the same series.
15
+ * @default 'none'
16
+ */
10
17
  highlighted: HighlightOptions;
18
+ /**
19
+ * The scope of faded elements.
20
+ * - 'none': no fading.
21
+ * - 'series': only fade element of the same series.
22
+ * - 'global': fade all elements that are not highlighted.
23
+ * @default 'none'
24
+ */
11
25
  faded: FadeOptions;
12
26
  };
13
27
  type HighlighActions<T extends ChartSeriesType = ChartSeriesType> = {
@@ -19,6 +33,9 @@ type HighlighActions<T extends ChartSeriesType = ChartSeriesType> = {
19
33
  item: ItemHighlighData<T>;
20
34
  };
21
35
  type HighlighState = {
36
+ /**
37
+ * The item that triggers the highlight state.
38
+ */
22
39
  item: null | ItemHighlighData<ChartSeriesType>;
23
40
  scope: HighlightScope;
24
41
  dispatch: React.Dispatch<HighlighActions>;
@@ -25,7 +25,13 @@ type InteractionActions<T extends ChartSeriesType = ChartSeriesType> = {
25
25
  data: AxisInteractionData;
26
26
  };
27
27
  type InteractionState = {
28
+ /**
29
+ * The item currently interacting.
30
+ */
28
31
  item: null | ItemInteractionData<ChartSeriesType>;
32
+ /**
33
+ * The x- and y-axes currently interacting.
34
+ */
29
35
  axis: AxisInteractionData;
30
36
  dispatch: React.Dispatch<InteractionActions>;
31
37
  };
@@ -4,6 +4,11 @@ import { ChartSeriesType, DatasetType, FormatterResult } from '../models/seriesT
4
4
  import { ChartsColorPalette } from '../colorPalettes';
5
5
  export type SeriesContextProviderProps = {
6
6
  dataset?: DatasetType;
7
+ /**
8
+ * The array of series to display.
9
+ * Each type of series has its own specificity.
10
+ * Please refer to the appropriate docs page to learn more about it.
11
+ */
7
12
  series: AllSeriesType[];
8
13
  /**
9
14
  * Color palette used to colorize multiple series.
@@ -114,6 +114,13 @@ process.env.NODE_ENV !== "production" ? BarChart.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" ? BarChart.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,9 +158,21 @@ process.env.NODE_ENV !== "production" ? BarChart.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,
172
+ /**
173
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
174
+ * @default undefined
175
+ */
157
176
  height: PropTypes.number,
158
177
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
159
178
  /**
@@ -162,7 +181,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
162
181
  * @default yAxisIds[0] The id of the first provided axis
163
182
  */
164
183
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
165
- axisId: PropTypes.string.isRequired,
184
+ axisId: PropTypes.string,
166
185
  classes: PropTypes.object,
167
186
  disableLine: PropTypes.bool,
168
187
  disableTicks: PropTypes.bool,
@@ -197,6 +216,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
197
216
  slotProps: PropTypes.object,
198
217
  slots: PropTypes.object
199
218
  }),
219
+ /**
220
+ * The margin between the SVG and the drawing area.
221
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
222
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
223
+ * @default object Depends on the charts type.
224
+ */
200
225
  margin: PropTypes.shape({
201
226
  bottom: PropTypes.number,
202
227
  left: PropTypes.number,
@@ -209,7 +234,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
209
234
  * @default null
210
235
  */
211
236
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
212
- axisId: PropTypes.string.isRequired,
237
+ axisId: PropTypes.string,
213
238
  classes: PropTypes.object,
214
239
  disableLine: PropTypes.bool,
215
240
  disableTicks: PropTypes.bool,
@@ -280,7 +305,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
280
305
  * @default null
281
306
  */
282
307
  topAxis: PropTypes.oneOfType([PropTypes.shape({
283
- axisId: PropTypes.string.isRequired,
308
+ axisId: PropTypes.string,
284
309
  classes: PropTypes.object,
285
310
  disableLine: PropTypes.bool,
286
311
  disableTicks: PropTypes.bool,
@@ -307,7 +332,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
307
332
  x: PropTypes.number,
308
333
  y: PropTypes.number
309
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
+ */
310
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
+ */
311
344
  xAxis: PropTypes.arrayOf(PropTypes.shape({
312
345
  axisId: PropTypes.string,
313
346
  classes: PropTypes.object,
@@ -338,6 +371,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
338
371
  tickSize: PropTypes.number,
339
372
  valueFormatter: PropTypes.func
340
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
+ */
341
378
  yAxis: PropTypes.arrayOf(PropTypes.shape({
342
379
  axisId: PropTypes.string,
343
380
  classes: PropTypes.object,
@@ -11,7 +11,8 @@ const getAxisId = propsValue => {
11
11
  return null;
12
12
  }
13
13
  if (typeof propsValue === 'object') {
14
- return propsValue.axisId;
14
+ var _propsValue$axisId;
15
+ return (_propsValue$axisId = propsValue.axisId) != null ? _propsValue$axisId : null;
15
16
  }
16
17
  return propsValue;
17
18
  };
@@ -100,7 +101,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
100
101
  * @default xAxisIds[0] The id of the first provided axis
101
102
  */
102
103
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
103
- axisId: PropTypes.string.isRequired,
104
+ axisId: PropTypes.string,
104
105
  classes: PropTypes.object,
105
106
  disableLine: PropTypes.bool,
106
107
  disableTicks: PropTypes.bool,
@@ -127,7 +128,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
127
128
  * @default yAxisIds[0] The id of the first provided axis
128
129
  */
129
130
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
130
- axisId: PropTypes.string.isRequired,
131
+ axisId: PropTypes.string,
131
132
  classes: PropTypes.object,
132
133
  disableLine: PropTypes.bool,
133
134
  disableTicks: PropTypes.bool,
@@ -154,7 +155,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
154
155
  * @default null
155
156
  */
156
157
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
157
- axisId: PropTypes.string.isRequired,
158
+ axisId: PropTypes.string,
158
159
  classes: PropTypes.object,
159
160
  disableLine: PropTypes.bool,
160
161
  disableTicks: PropTypes.bool,
@@ -191,7 +192,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
191
192
  * @default null
192
193
  */
193
194
  topAxis: PropTypes.oneOfType([PropTypes.shape({
194
- axisId: PropTypes.string.isRequired,
195
+ axisId: PropTypes.string,
195
196
  classes: PropTypes.object,
196
197
  disableLine: PropTypes.bool,
197
198
  disableTicks: PropTypes.bool,
@@ -10,7 +10,7 @@ import { useThemeProps, useTheme, styled } from '@mui/material/styles';
10
10
  import { DrawingContext } from '../context/DrawingProvider';
11
11
  import { getSeriesToDisplay } from './utils';
12
12
  import { SeriesContext } from '../context/SeriesContextProvider';
13
- import { getChartsLegendUtilityClass } from './chartsLegendClasses';
13
+ import { getLegendUtilityClass } from './chartsLegendClasses';
14
14
  import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -25,7 +25,7 @@ const useUtilityClasses = ownerState => {
25
25
  label: ['label'],
26
26
  series: ['series']
27
27
  };
28
- return composeClasses(slots, getChartsLegendUtilityClass, classes);
28
+ return composeClasses(slots, getLegendUtilityClass, classes);
29
29
  };
30
30
  export const ChartsLegendRoot = styled('g', {
31
31
  name: 'MuiChartsLegend',
@@ -1,5 +1,5 @@
1
1
  import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
- export function getChartsLegendUtilityClass(slot) {
2
+ export function getLegendUtilityClass(slot) {
3
3
  return generateUtilityClass('MuiChartsLegend', slot);
4
4
  }
5
5
  export const legendClasses = generateUtilityClasses('MuiChartsLegend', ['root', 'series', 'mark', 'label', 'column', 'row']);
@@ -0,0 +1,70 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { ChartsXReferenceLine } from './ChartsXReferenceLine';
5
+ import { ChartsYReferenceLine } from './ChartsYReferenceLine';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ function ChartsReferenceLine(props) {
8
+ if (props.x !== undefined && props.y !== undefined) {
9
+ throw new Error('MUI-X: The ChartsReferenceLine can not have both `x` and `y` props set.');
10
+ }
11
+ if (props.x === undefined && props.y === undefined) {
12
+ throw new Error('MUI-X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
13
+ }
14
+ if (props.x !== undefined) {
15
+ return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
16
+ }
17
+ return /*#__PURE__*/_jsx(ChartsYReferenceLine, _extends({}, props));
18
+ }
19
+ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
20
+ // ----------------------------- Warning --------------------------------
21
+ // | These PropTypes are generated from the TypeScript type definitions |
22
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
23
+ // ----------------------------------------------------------------------
24
+ /**
25
+ * The id of the axis used for the reference value.
26
+ * @default The `id` of the first defined axis.
27
+ */
28
+ axisId: PropTypes.string,
29
+ /**
30
+ * Override or extend the styles applied to the component.
31
+ */
32
+ classes: PropTypes.object,
33
+ /**
34
+ * The label to display along the reference line.
35
+ */
36
+ label: PropTypes.string,
37
+ /**
38
+ * The alignment if the label is in the chart drawing area.
39
+ * @default 'middle'
40
+ */
41
+ labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
42
+ /**
43
+ * The style applied to the label.
44
+ */
45
+ labelStyle: PropTypes.object,
46
+ /**
47
+ * The style applied to the line.
48
+ */
49
+ lineStyle: PropTypes.object,
50
+ /**
51
+ * Additional space arround the label in px.
52
+ * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
53
+ * @default 5
54
+ */
55
+ spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
56
+ x: PropTypes.number,
57
+ y: PropTypes.number
58
+ })]),
59
+ /**
60
+ * The x value associated with the reference line.
61
+ * If defined the reference line will be vertical.
62
+ */
63
+ x: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]),
64
+ /**
65
+ * The y value associated with the reference line.
66
+ * If defined the reference line will be horizontal.
67
+ */
68
+ y: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string])
69
+ } : void 0;
70
+ export { ChartsReferenceLine };
@@ -0,0 +1,105 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import composeClasses from '@mui/utils/composeClasses';
4
+ import { useDrawingArea, useXScale } from '../hooks';
5
+ import { ReferenceLineRoot } from './common';
6
+ import { ChartsText } from '../internals/components/ChartsText';
7
+ import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ const getTextParams = ({
11
+ top,
12
+ height,
13
+ spacingY,
14
+ labelAlign = 'middle'
15
+ }) => {
16
+ switch (labelAlign) {
17
+ case 'start':
18
+ return {
19
+ y: top + spacingY,
20
+ style: {
21
+ dominantBaseline: 'hanging',
22
+ textAnchor: 'start'
23
+ }
24
+ };
25
+ case 'end':
26
+ return {
27
+ y: top + height - spacingY,
28
+ style: {
29
+ dominantBaseline: 'auto',
30
+ textAnchor: 'start'
31
+ }
32
+ };
33
+ default:
34
+ return {
35
+ y: top + height / 2,
36
+ style: {
37
+ dominantBaseline: 'central',
38
+ textAnchor: 'start'
39
+ }
40
+ };
41
+ }
42
+ };
43
+ export function getXReferenceLineClasses(classes) {
44
+ return composeClasses({
45
+ root: ['root', 'vertical'],
46
+ line: ['line'],
47
+ label: ['label']
48
+ }, getReferenceLineUtilityClass, classes);
49
+ }
50
+ let warnedOnce = false;
51
+ function ChartsXReferenceLine(props) {
52
+ var _spacing$x, _spacing$y;
53
+ const {
54
+ x,
55
+ label = '',
56
+ spacing = 5,
57
+ classes: inClasses,
58
+ labelAlign,
59
+ lineStyle,
60
+ labelStyle,
61
+ axisId
62
+ } = props;
63
+ const {
64
+ top,
65
+ height
66
+ } = useDrawingArea();
67
+ const xAxisScale = useXScale(axisId);
68
+ const xPosition = xAxisScale(x);
69
+ if (xPosition === undefined) {
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ if (!warnedOnce) {
72
+ warnedOnce = true;
73
+ console.error(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`);
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ const d = `M ${xPosition} ${top} l 0 ${height}`;
79
+ const classes = getXReferenceLineClasses(inClasses);
80
+ const spacingX = typeof spacing === 'object' ? (_spacing$x = spacing.x) != null ? _spacing$x : 0 : spacing;
81
+ const spacingY = typeof spacing === 'object' ? (_spacing$y = spacing.y) != null ? _spacing$y : 0 : spacing;
82
+ const textParams = _extends({
83
+ x: xPosition + spacingX,
84
+ text: label,
85
+ fontSize: 12
86
+ }, getTextParams({
87
+ top,
88
+ height,
89
+ spacingY,
90
+ labelAlign
91
+ }), {
92
+ className: classes.label
93
+ });
94
+ return /*#__PURE__*/_jsxs(ReferenceLineRoot, {
95
+ className: classes.root,
96
+ children: [/*#__PURE__*/_jsx("path", {
97
+ d: d,
98
+ className: classes.line,
99
+ style: lineStyle
100
+ }), /*#__PURE__*/_jsx(ChartsText, _extends({}, textParams, {
101
+ style: _extends({}, textParams.style, labelStyle)
102
+ }))]
103
+ });
104
+ }
105
+ export { ChartsXReferenceLine };
@@ -0,0 +1,105 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import composeClasses from '@mui/utils/composeClasses';
4
+ import { useDrawingArea, useYScale } from '../hooks';
5
+ import { ReferenceLineRoot } from './common';
6
+ import { ChartsText } from '../internals/components/ChartsText';
7
+ import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ const getTextParams = ({
11
+ left,
12
+ width,
13
+ spacingX,
14
+ labelAlign = 'middle'
15
+ }) => {
16
+ switch (labelAlign) {
17
+ case 'start':
18
+ return {
19
+ x: left + spacingX,
20
+ style: {
21
+ dominantBaseline: 'auto',
22
+ textAnchor: 'start'
23
+ }
24
+ };
25
+ case 'end':
26
+ return {
27
+ x: left + width - spacingX,
28
+ style: {
29
+ dominantBaseline: 'auto',
30
+ textAnchor: 'end'
31
+ }
32
+ };
33
+ default:
34
+ return {
35
+ x: left + width / 2,
36
+ style: {
37
+ dominantBaseline: 'auto',
38
+ textAnchor: 'middle'
39
+ }
40
+ };
41
+ }
42
+ };
43
+ let warnedOnce = false;
44
+ export function getYReferenceLineClasses(classes) {
45
+ return composeClasses({
46
+ root: ['root', 'horizontal'],
47
+ line: ['line'],
48
+ label: ['label']
49
+ }, getReferenceLineUtilityClass, classes);
50
+ }
51
+ function ChartsYReferenceLine(props) {
52
+ var _spacing$x, _spacing$y;
53
+ const {
54
+ y,
55
+ label = '',
56
+ spacing = 5,
57
+ classes: inClasses,
58
+ labelAlign,
59
+ lineStyle,
60
+ labelStyle,
61
+ axisId
62
+ } = props;
63
+ const {
64
+ left,
65
+ width
66
+ } = useDrawingArea();
67
+ const yAxisScale = useYScale(axisId);
68
+ const yPosition = yAxisScale(y);
69
+ if (yPosition === undefined) {
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ if (!warnedOnce) {
72
+ warnedOnce = true;
73
+ console.error(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`);
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ const d = `M ${left} ${yPosition} l ${width} 0`;
79
+ const classes = getYReferenceLineClasses(inClasses);
80
+ const spacingX = typeof spacing === 'object' ? (_spacing$x = spacing.x) != null ? _spacing$x : 0 : spacing;
81
+ const spacingY = typeof spacing === 'object' ? (_spacing$y = spacing.y) != null ? _spacing$y : 0 : spacing;
82
+ const textParams = _extends({
83
+ y: yPosition - spacingY,
84
+ text: label,
85
+ fontSize: 12
86
+ }, getTextParams({
87
+ left,
88
+ width,
89
+ spacingX,
90
+ labelAlign
91
+ }), {
92
+ className: classes.label
93
+ });
94
+ return /*#__PURE__*/_jsxs(ReferenceLineRoot, {
95
+ className: classes.root,
96
+ children: [/*#__PURE__*/_jsx("path", {
97
+ d: d,
98
+ className: classes.line,
99
+ style: lineStyle
100
+ }), /*#__PURE__*/_jsx(ChartsText, _extends({}, textParams, {
101
+ style: _extends({}, textParams.style, labelStyle)
102
+ }))]
103
+ });
104
+ }
105
+ export { ChartsYReferenceLine };
@@ -0,0 +1,6 @@
1
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
2
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
3
+ export function getReferenceLineUtilityClass(slot) {
4
+ return generateUtilityClass('MuiChartsReferenceLine', slot);
5
+ }
6
+ export const referenceLineClasses = generateUtilityClasses('MuiChartsReferenceLine', ['root', 'vertical', 'horizontal', 'line', 'label']);
@@ -0,0 +1,20 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { styled } from '@mui/material/styles';
3
+ import { referenceLineClasses } from './chartsReferenceLineClasses';
4
+ export const ReferenceLineRoot = styled('g')(({
5
+ theme
6
+ }) => ({
7
+ [`& .${referenceLineClasses.line}`]: {
8
+ fill: 'none',
9
+ stroke: (theme.vars || theme).palette.text.primary,
10
+ shapeRendering: 'crispEdges',
11
+ strokeWidth: 1,
12
+ pointerEvents: 'none'
13
+ },
14
+ [`& .${referenceLineClasses.label}`]: _extends({
15
+ fill: (theme.vars || theme).palette.text.primary,
16
+ stroke: 'none',
17
+ pointerEvents: 'none',
18
+ fontSize: 12
19
+ }, theme.typography.body1)
20
+ }));
@@ -0,0 +1,2 @@
1
+ export * from './ChartsReferenceLine';
2
+ export * from './chartsReferenceLineClasses';
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import clsx from 'clsx';
3
4
  import Typography from '@mui/material/Typography';
4
5
  import { useSlotProps } from '@mui/base/utils';
5
6
  import { SeriesContext } from '../context/SeriesContextProvider';
@@ -25,6 +26,7 @@ export function DefaultChartsAxisContent(props) {
25
26
  sx: sx,
26
27
  className: classes.root,
27
28
  children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
29
+ className: classes.table,
28
30
  children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
29
31
  children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
30
32
  children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
@@ -47,21 +49,23 @@ export function DefaultChartsAxisContent(props) {
47
49
  return null;
48
50
  }
49
51
  return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
52
+ className: classes.row,
50
53
  children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
51
- className: classes.markCell,
54
+ className: clsx(classes.markCell, classes.cell),
52
55
  children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
53
56
  ownerState: {
54
57
  color
55
58
  },
56
- boxShadow: 1
59
+ boxShadow: 1,
60
+ className: classes.mark
57
61
  })
58
62
  }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
59
- className: classes.labelCell,
63
+ className: clsx(classes.labelCell, classes.cell),
60
64
  children: label ? /*#__PURE__*/_jsx(Typography, {
61
65
  children: label
62
66
  }) : null
63
67
  }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
64
- className: classes.valueCell,
68
+ className: clsx(classes.valueCell, classes.cell),
65
69
  children: /*#__PURE__*/_jsx(Typography, {
66
70
  children: formattedValue
67
71
  })