@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
@@ -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,6 +4,7 @@ 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';
@@ -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,6 +4,7 @@ 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';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.18.0
2
+ * @mui/x-charts v6.18.2
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;
@@ -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,
@@ -12,7 +12,8 @@ var getAxisId = function getAxisId(propsValue) {
12
12
  return null;
13
13
  }
14
14
  if (_typeof(propsValue) === 'object') {
15
- return propsValue.axisId;
15
+ var _propsValue$axisId;
16
+ return (_propsValue$axisId = propsValue.axisId) != null ? _propsValue$axisId : null;
16
17
  }
17
18
  return propsValue;
18
19
  };
@@ -98,7 +99,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
98
99
  * @default xAxisIds[0] The id of the first provided axis
99
100
  */
100
101
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
101
- axisId: PropTypes.string.isRequired,
102
+ axisId: PropTypes.string,
102
103
  classes: PropTypes.object,
103
104
  disableLine: PropTypes.bool,
104
105
  disableTicks: PropTypes.bool,
@@ -125,7 +126,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
125
126
  * @default yAxisIds[0] The id of the first provided axis
126
127
  */
127
128
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
128
- axisId: PropTypes.string.isRequired,
129
+ axisId: PropTypes.string,
129
130
  classes: PropTypes.object,
130
131
  disableLine: PropTypes.bool,
131
132
  disableTicks: PropTypes.bool,
@@ -152,7 +153,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
152
153
  * @default null
153
154
  */
154
155
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
155
- axisId: PropTypes.string.isRequired,
156
+ axisId: PropTypes.string,
156
157
  classes: PropTypes.object,
157
158
  disableLine: PropTypes.bool,
158
159
  disableTicks: PropTypes.bool,
@@ -189,7 +190,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
189
190
  * @default null
190
191
  */
191
192
  topAxis: PropTypes.oneOfType([PropTypes.shape({
192
- axisId: PropTypes.string.isRequired,
193
+ axisId: PropTypes.string,
193
194
  classes: PropTypes.object,
194
195
  disableLine: PropTypes.bool,
195
196
  disableTicks: PropTypes.bool,
@@ -11,7 +11,7 @@ import { useThemeProps, useTheme, styled } from '@mui/material/styles';
11
11
  import { DrawingContext } from '../context/DrawingProvider';
12
12
  import { getSeriesToDisplay } from './utils';
13
13
  import { SeriesContext } from '../context/SeriesContextProvider';
14
- import { getChartsLegendUtilityClass } from './chartsLegendClasses';
14
+ import { getLegendUtilityClass } from './chartsLegendClasses';
15
15
  import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -24,7 +24,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
24
24
  label: ['label'],
25
25
  series: ['series']
26
26
  };
27
- return composeClasses(slots, getChartsLegendUtilityClass, classes);
27
+ return composeClasses(slots, getLegendUtilityClass, classes);
28
28
  };
29
29
  export var ChartsLegendRoot = styled('g', {
30
30
  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 var 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 _typeof from "@babel/runtime/helpers/esm/typeof";
3
+ import * as React from 'react';
4
+ import composeClasses from '@mui/utils/composeClasses';
5
+ import { useDrawingArea, useXScale } from '../hooks';
6
+ import { ReferenceLineRoot } from './common';
7
+ import { ChartsText } from '../internals/components/ChartsText';
8
+ import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ var getTextParams = function getTextParams(_ref) {
12
+ var top = _ref.top,
13
+ height = _ref.height,
14
+ spacingY = _ref.spacingY,
15
+ _ref$labelAlign = _ref.labelAlign,
16
+ labelAlign = _ref$labelAlign === void 0 ? 'middle' : _ref$labelAlign;
17
+ switch (labelAlign) {
18
+ case 'start':
19
+ return {
20
+ y: top + spacingY,
21
+ style: {
22
+ dominantBaseline: 'hanging',
23
+ textAnchor: 'start'
24
+ }
25
+ };
26
+ case 'end':
27
+ return {
28
+ y: top + height - spacingY,
29
+ style: {
30
+ dominantBaseline: 'auto',
31
+ textAnchor: 'start'
32
+ }
33
+ };
34
+ default:
35
+ return {
36
+ y: top + height / 2,
37
+ style: {
38
+ dominantBaseline: 'central',
39
+ textAnchor: 'start'
40
+ }
41
+ };
42
+ }
43
+ };
44
+ export function getXReferenceLineClasses(classes) {
45
+ return composeClasses({
46
+ root: ['root', 'vertical'],
47
+ line: ['line'],
48
+ label: ['label']
49
+ }, getReferenceLineUtilityClass, classes);
50
+ }
51
+ var warnedOnce = false;
52
+ function ChartsXReferenceLine(props) {
53
+ var _spacing$x, _spacing$y;
54
+ var x = props.x,
55
+ _props$label = props.label,
56
+ label = _props$label === void 0 ? '' : _props$label,
57
+ _props$spacing = props.spacing,
58
+ spacing = _props$spacing === void 0 ? 5 : _props$spacing,
59
+ inClasses = props.classes,
60
+ labelAlign = props.labelAlign,
61
+ lineStyle = props.lineStyle,
62
+ labelStyle = props.labelStyle,
63
+ axisId = props.axisId;
64
+ var _useDrawingArea = useDrawingArea(),
65
+ top = _useDrawingArea.top,
66
+ height = _useDrawingArea.height;
67
+ var xAxisScale = useXScale(axisId);
68
+ var 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 ".concat(x, " does not exist in the data of x axis with id ").concat(axisId, "."));
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ var d = "M ".concat(xPosition, " ").concat(top, " l 0 ").concat(height);
79
+ var classes = getXReferenceLineClasses(inClasses);
80
+ var spacingX = _typeof(spacing) === 'object' ? (_spacing$x = spacing.x) != null ? _spacing$x : 0 : spacing;
81
+ var spacingY = _typeof(spacing) === 'object' ? (_spacing$y = spacing.y) != null ? _spacing$y : 0 : spacing;
82
+ var textParams = _extends({
83
+ x: xPosition + spacingX,
84
+ text: label,
85
+ fontSize: 12
86
+ }, getTextParams({
87
+ top: top,
88
+ height: height,
89
+ spacingY: spacingY,
90
+ labelAlign: 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 _typeof from "@babel/runtime/helpers/esm/typeof";
3
+ import * as React from 'react';
4
+ import composeClasses from '@mui/utils/composeClasses';
5
+ import { useDrawingArea, useYScale } from '../hooks';
6
+ import { ReferenceLineRoot } from './common';
7
+ import { ChartsText } from '../internals/components/ChartsText';
8
+ import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ var getTextParams = function getTextParams(_ref) {
12
+ var left = _ref.left,
13
+ width = _ref.width,
14
+ spacingX = _ref.spacingX,
15
+ _ref$labelAlign = _ref.labelAlign,
16
+ labelAlign = _ref$labelAlign === void 0 ? 'middle' : _ref$labelAlign;
17
+ switch (labelAlign) {
18
+ case 'start':
19
+ return {
20
+ x: left + spacingX,
21
+ style: {
22
+ dominantBaseline: 'auto',
23
+ textAnchor: 'start'
24
+ }
25
+ };
26
+ case 'end':
27
+ return {
28
+ x: left + width - spacingX,
29
+ style: {
30
+ dominantBaseline: 'auto',
31
+ textAnchor: 'end'
32
+ }
33
+ };
34
+ default:
35
+ return {
36
+ x: left + width / 2,
37
+ style: {
38
+ dominantBaseline: 'auto',
39
+ textAnchor: 'middle'
40
+ }
41
+ };
42
+ }
43
+ };
44
+ var warnedOnce = false;
45
+ export function getYReferenceLineClasses(classes) {
46
+ return composeClasses({
47
+ root: ['root', 'horizontal'],
48
+ line: ['line'],
49
+ label: ['label']
50
+ }, getReferenceLineUtilityClass, classes);
51
+ }
52
+ function ChartsYReferenceLine(props) {
53
+ var _spacing$x, _spacing$y;
54
+ var y = props.y,
55
+ _props$label = props.label,
56
+ label = _props$label === void 0 ? '' : _props$label,
57
+ _props$spacing = props.spacing,
58
+ spacing = _props$spacing === void 0 ? 5 : _props$spacing,
59
+ inClasses = props.classes,
60
+ labelAlign = props.labelAlign,
61
+ lineStyle = props.lineStyle,
62
+ labelStyle = props.labelStyle,
63
+ axisId = props.axisId;
64
+ var _useDrawingArea = useDrawingArea(),
65
+ left = _useDrawingArea.left,
66
+ width = _useDrawingArea.width;
67
+ var yAxisScale = useYScale(axisId);
68
+ var 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 ".concat(y, " does not exist in the data of y axis with id ").concat(axisId, "."));
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ var d = "M ".concat(left, " ").concat(yPosition, " l ").concat(width, " 0");
79
+ var classes = getYReferenceLineClasses(inClasses);
80
+ var spacingX = _typeof(spacing) === 'object' ? (_spacing$x = spacing.x) != null ? _spacing$x : 0 : spacing;
81
+ var spacingY = _typeof(spacing) === 'object' ? (_spacing$y = spacing.y) != null ? _spacing$y : 0 : spacing;
82
+ var textParams = _extends({
83
+ y: yPosition - spacingY,
84
+ text: label,
85
+ fontSize: 12
86
+ }, getTextParams({
87
+ left: left,
88
+ width: width,
89
+ spacingX: spacingX,
90
+ labelAlign: 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 };