@mui/x-charts 6.18.0 → 6.18.1

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 (118) hide show
  1. package/BarChart/BarChart.d.ts +7 -0
  2. package/BarChart/BarChart.js +41 -4
  3. package/CHANGELOG.md +63 -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/ChartsXAxis/ChartsXAxis.js +9 -5
  25. package/ChartsYAxis/ChartsYAxis.js +9 -5
  26. package/LineChart/LineChart.d.ts +7 -0
  27. package/LineChart/LineChart.js +41 -4
  28. package/LineChart/LineHighlightPlot.js +1 -1
  29. package/LineChart/MarkPlot.js +2 -1
  30. package/PieChart/PieChart.js +34 -4
  31. package/ResponsiveChartContainer/index.d.ts +13 -3
  32. package/ScatterChart/ScatterChart.js +34 -4
  33. package/SparkLineChart/SparkLineChart.js +22 -0
  34. package/context/CartesianContextProvider.d.ts +21 -1
  35. package/context/CartesianContextProvider.js +11 -0
  36. package/context/DrawingProvider.d.ts +18 -0
  37. package/context/DrawingProvider.js +6 -0
  38. package/context/HighlightProvider.d.ts +17 -0
  39. package/context/InteractionProvider.d.ts +6 -0
  40. package/context/SeriesContextProvider.d.ts +5 -0
  41. package/esm/BarChart/BarChart.js +41 -4
  42. package/esm/ChartsAxis/ChartsAxis.js +6 -5
  43. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  44. package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
  45. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  46. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  47. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  48. package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  49. package/esm/ChartsReferenceLine/common.js +20 -0
  50. package/esm/ChartsReferenceLine/index.js +2 -0
  51. package/esm/ChartsXAxis/ChartsXAxis.js +10 -6
  52. package/esm/ChartsYAxis/ChartsYAxis.js +10 -6
  53. package/esm/LineChart/LineChart.js +41 -4
  54. package/esm/LineChart/LineHighlightPlot.js +1 -1
  55. package/esm/LineChart/MarkPlot.js +2 -1
  56. package/esm/PieChart/PieChart.js +34 -4
  57. package/esm/ScatterChart/ScatterChart.js +34 -4
  58. package/esm/SparkLineChart/SparkLineChart.js +22 -0
  59. package/esm/context/CartesianContextProvider.js +11 -0
  60. package/esm/context/DrawingProvider.js +6 -0
  61. package/esm/index.js +1 -0
  62. package/esm/internals/geometry.js +2 -2
  63. package/hooks/useScale.d.ts +2 -2
  64. package/index.d.ts +1 -0
  65. package/index.js +12 -1
  66. package/internals/components/ChartsText.d.ts +1 -1
  67. package/internals/geometry.d.ts +2 -2
  68. package/internals/geometry.js +2 -2
  69. package/internals/isBandScale.d.ts +3 -1
  70. package/internals/utils.d.ts +5 -0
  71. package/legacy/BarChart/BarChart.js +41 -4
  72. package/legacy/ChartsAxis/ChartsAxis.js +6 -5
  73. package/legacy/ChartsLegend/ChartsLegend.js +2 -2
  74. package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
  75. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  76. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  77. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  78. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  79. package/legacy/ChartsReferenceLine/common.js +20 -0
  80. package/legacy/ChartsReferenceLine/index.js +2 -0
  81. package/legacy/ChartsXAxis/ChartsXAxis.js +15 -12
  82. package/legacy/ChartsYAxis/ChartsYAxis.js +15 -12
  83. package/legacy/LineChart/LineChart.js +41 -4
  84. package/legacy/LineChart/LineHighlightPlot.js +1 -1
  85. package/legacy/LineChart/MarkPlot.js +2 -1
  86. package/legacy/PieChart/PieChart.js +34 -4
  87. package/legacy/ScatterChart/ScatterChart.js +34 -4
  88. package/legacy/SparkLineChart/SparkLineChart.js +22 -0
  89. package/legacy/context/CartesianContextProvider.js +11 -0
  90. package/legacy/context/DrawingProvider.js +6 -0
  91. package/legacy/index.js +2 -1
  92. package/legacy/internals/geometry.js +2 -2
  93. package/models/axis.d.ts +33 -13
  94. package/models/layout.d.ts +6 -0
  95. package/models/seriesType/common.d.ts +16 -0
  96. package/modern/BarChart/BarChart.js +41 -4
  97. package/modern/ChartsAxis/ChartsAxis.js +5 -5
  98. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  99. package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
  100. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  101. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
  102. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
  103. package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  104. package/modern/ChartsReferenceLine/common.js +20 -0
  105. package/modern/ChartsReferenceLine/index.js +2 -0
  106. package/modern/ChartsXAxis/ChartsXAxis.js +9 -5
  107. package/modern/ChartsYAxis/ChartsYAxis.js +9 -5
  108. package/modern/LineChart/LineChart.js +41 -4
  109. package/modern/LineChart/LineHighlightPlot.js +1 -1
  110. package/modern/LineChart/MarkPlot.js +2 -1
  111. package/modern/PieChart/PieChart.js +34 -4
  112. package/modern/ScatterChart/ScatterChart.js +34 -4
  113. package/modern/SparkLineChart/SparkLineChart.js +22 -0
  114. package/modern/context/CartesianContextProvider.js +11 -0
  115. package/modern/context/DrawingProvider.js +6 -0
  116. package/modern/index.js +2 -1
  117. package/modern/internals/geometry.js +2 -2
  118. package/package.json +1 -1
@@ -15,6 +15,13 @@ export interface BarChartSlotComponentProps extends ChartsAxisSlotComponentProps
15
15
  export interface BarChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Pick<BarPlotProps, 'skipAnimation'> {
16
16
  series: MakeOptional<BarSeriesType, 'type'>[];
17
17
  tooltip?: ChartsTooltipProps;
18
+ /**
19
+ * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
20
+ * The two properties accept the following values:
21
+ * - 'none': display nothing.
22
+ * - 'line': display a line at the current mouse position.
23
+ * - 'band': display a band at the current mouse position. Only available with band scale.
24
+ */
18
25
  axisHighlight?: ChartsAxisHighlightProps;
19
26
  /**
20
27
  * @deprecated Consider using `slotProps.legend` instead.
@@ -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.default.shape({
123
130
  x: _propTypes.default.oneOf(['band', 'line', 'none']),
124
131
  y: _propTypes.default.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.default.oneOfType([_propTypes.default.shape({
132
- axisId: _propTypes.default.string.isRequired,
139
+ axisId: _propTypes.default.string,
133
140
  classes: _propTypes.default.object,
134
141
  disableLine: _propTypes.default.bool,
135
142
  disableTicks: _propTypes.default.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.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.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.default.arrayOf(_propTypes.default.object),
160
170
  desc: _propTypes.default.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.default.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.default.number,
163
182
  layout: _propTypes.default.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.default.oneOfType([_propTypes.default.shape({
170
- axisId: _propTypes.default.string.isRequired,
189
+ axisId: _propTypes.default.string,
171
190
  classes: _propTypes.default.object,
172
191
  disableLine: _propTypes.default.bool,
173
192
  disableTicks: _propTypes.default.bool,
@@ -202,6 +221,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
202
221
  slotProps: _propTypes.default.object,
203
222
  slots: _propTypes.default.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.default.shape({
206
231
  bottom: _propTypes.default.number,
207
232
  left: _propTypes.default.number,
@@ -214,7 +239,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
214
239
  * @default null
215
240
  */
216
241
  rightAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
217
- axisId: _propTypes.default.string.isRequired,
242
+ axisId: _propTypes.default.string,
218
243
  classes: _propTypes.default.object,
219
244
  disableLine: _propTypes.default.bool,
220
245
  disableTicks: _propTypes.default.bool,
@@ -285,7 +310,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
285
310
  * @default null
286
311
  */
287
312
  topAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
288
- axisId: _propTypes.default.string.isRequired,
313
+ axisId: _propTypes.default.string,
289
314
  classes: _propTypes.default.object,
290
315
  disableLine: _propTypes.default.bool,
291
316
  disableTicks: _propTypes.default.bool,
@@ -312,7 +337,15 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
312
337
  x: _propTypes.default.number,
313
338
  y: _propTypes.default.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.default.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.default.arrayOf(_propTypes.default.shape({
317
350
  axisId: _propTypes.default.string,
318
351
  classes: _propTypes.default.object,
@@ -343,6 +376,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
343
376
  tickSize: _propTypes.default.number,
344
377
  valueFormatter: _propTypes.default.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.default.arrayOf(_propTypes.default.shape({
347
384
  axisId: _propTypes.default.string,
348
385
  classes: _propTypes.default.object,
package/CHANGELOG.md CHANGED
@@ -3,6 +3,64 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.18.1
7
+
8
+ _Nov 9, 2023_
9
+
10
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - ✨ Fix aggregation label not showing when `renderHeader` is used (#10961) @cherniavskii
13
+ - 📘 Server side data source [early documentation](https://mui.com/x/react-data-grid/server-side-data/) published
14
+ - 📈 `<ChartsReferenceLine />` component is now available
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ ### Data Grid
19
+
20
+ #### `@mui/x-data-grid@6.18.1`
21
+
22
+ - [DataGrid] Fix cell value type in quick filtering v7 (#10884) @cherniavskii
23
+ - [DataGrid] Fix keyboard navigation for actions cell with disabled buttons (#10947) @michelengelen
24
+ - [DataGrid] Fix `undefined` slot values (#10934) @romgrk
25
+
26
+ #### `@mui/x-data-grid-pro@6.18.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
27
+
28
+ Same changes as in `@mui/x-data-grid@6.18.1`, plus:
29
+
30
+ - [DataGridPro] Add data source interface and basic documentation (#10543) @MBilalShafi
31
+
32
+ #### `@mui/x-data-grid-premium@6.18.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
33
+
34
+ Same changes as in `@mui/x-data-grid-pro@6.18.1`, plus:
35
+
36
+ - [DataGridPremium] Render aggregation label when `renderHeader` is used (#10961) @cherniavskii
37
+
38
+ ### Date Pickers
39
+
40
+ #### `@mui/x-date-pickers@6.18.1`
41
+
42
+ - [fields] Fix multi input date time field section selection (#10915) @noraleonte
43
+ - [pickers] Always use up-to-date `defaultView` (#10889) @LukasTy
44
+
45
+ #### `@mui/x-date-pickers-pro@6.18.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
46
+
47
+ Same changes as in `@mui/x-date-pickers@6.18.1`.
48
+
49
+ ### Charts / `@mui/x-charts@6.18.1`
50
+
51
+ - [charts] Add `<ChartsReferenceLine />` component (#10597) @wascou
52
+ - [charts] Improve properties JSDoc (#10931) @alexfauquette
53
+
54
+ ### Docs
55
+
56
+ - [docs] Fix charts docs as stable (#10888) @alexfauquette
57
+ - [docs] Document how to hide the legend (#10954) @alexfauquette
58
+
59
+ ### Core
60
+
61
+ - [core] Adds new alpha version to version select on the docs (#10944) @michelengelen
62
+ - [core] Fix GitHub title tag consistency @oliviertassinari
63
+
6
64
  ## 6.18.0
7
65
 
8
66
  _Nov 3, 2023_
@@ -357,7 +415,7 @@ Same changes as in `@mui/x-date-pickers@6.16.1`, plus:
357
415
 
358
416
  - [core] Fix casing consistency with legal and marketing content @oliviertassinari
359
417
  - [core] Revert the link in the priority support ticket description (#10517) @michelengelen
360
- - [CHANGELOG] Polish image @oliviertassinari
418
+ - [changelog] Polish image @oliviertassinari
361
419
 
362
420
  ## 6.16.0
363
421
 
@@ -1149,7 +1207,7 @@ Same changes as in `@mui/x-date-pickers@6.10.1`.
1149
1207
  ### Core
1150
1208
 
1151
1209
  - [core] Add `validate` command (#9714) @romgrk
1152
- - [CHANGELOG] Update generator to new format @oliviertassinari
1210
+ - [changelog] Update generator to new format @oliviertassinari
1153
1211
 
1154
1212
  ## 6.10.0
1155
1213
 
@@ -1207,7 +1265,7 @@ Same changes as in `@mui/x-date-pickers@6.10.0`.
1207
1265
 
1208
1266
  - [core] Disambiguate eslint plugin name @oliviertassinari
1209
1267
  - [core] Update priority support issue template and prompt (#9574) @DanailH
1210
- - [CHANGELOG] Clarify each plan (#9446) @oliviertassinari
1268
+ - [changelog] Clarify each plan (#9446) @oliviertassinari
1211
1269
  - [license] Fix error terminology (#9614) @oliviertassinari
1212
1270
 
1213
1271
  ## 6.9.2
@@ -1356,8 +1414,8 @@ Same changes as in `@mui/x-date-pickers@6.9.1`.
1356
1414
  - [core] Fix priority support prompt action (#9472) @DanailH
1357
1415
  - [core] Update `uses` for priority support action (#9480) @DanailH
1358
1416
  - [core] Bumb update monorepo (#9476) @alexfauquette
1359
- - [CHANGELOG] Fix media quality (#9439) @oliviertassinari
1360
- - [CHANGELOG] Remove height img attribute @oliviertassinari
1417
+ - [changelog] Fix media quality (#9439) @oliviertassinari
1418
+ - [changelog] Remove height img attribute @oliviertassinari
1361
1419
  - [test] Skip flaky row pinning tests in JSDOM (#9511) @cherniavskii
1362
1420
 
1363
1421
  ## 6.9.0
@@ -19,7 +19,7 @@ const getAxisId = propsValue => {
19
19
  return null;
20
20
  }
21
21
  if (typeof propsValue === 'object') {
22
- return propsValue.axisId;
22
+ return propsValue.axisId ?? null;
23
23
  }
24
24
  return propsValue;
25
25
  };
@@ -108,7 +108,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
108
108
  * @default xAxisIds[0] The id of the first provided axis
109
109
  */
110
110
  bottomAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
111
- axisId: _propTypes.default.string.isRequired,
111
+ axisId: _propTypes.default.string,
112
112
  classes: _propTypes.default.object,
113
113
  disableLine: _propTypes.default.bool,
114
114
  disableTicks: _propTypes.default.bool,
@@ -135,7 +135,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
135
135
  * @default yAxisIds[0] The id of the first provided axis
136
136
  */
137
137
  leftAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
138
- axisId: _propTypes.default.string.isRequired,
138
+ axisId: _propTypes.default.string,
139
139
  classes: _propTypes.default.object,
140
140
  disableLine: _propTypes.default.bool,
141
141
  disableTicks: _propTypes.default.bool,
@@ -162,7 +162,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
162
162
  * @default null
163
163
  */
164
164
  rightAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
165
- axisId: _propTypes.default.string.isRequired,
165
+ axisId: _propTypes.default.string,
166
166
  classes: _propTypes.default.object,
167
167
  disableLine: _propTypes.default.bool,
168
168
  disableTicks: _propTypes.default.bool,
@@ -199,7 +199,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
199
199
  * @default null
200
200
  */
201
201
  topAxis: _propTypes.default.oneOfType([_propTypes.default.shape({
202
- axisId: _propTypes.default.string.isRequired,
202
+ axisId: _propTypes.default.string,
203
203
  classes: _propTypes.default.object,
204
204
  disableLine: _propTypes.default.bool,
205
205
  disableTicks: _propTypes.default.bool,
@@ -11,9 +11,9 @@ export interface ChartsAxisClasses {
11
11
  tickLabel: string;
12
12
  /** Styles applied to the group containing the axis label. */
13
13
  label: string;
14
- /** Styles applied to x axes. */
14
+ /** Styles applied to x-axes. */
15
15
  directionX: string;
16
- /** Styles applied to y axes. */
16
+ /** Styles applied to y-axes. */
17
17
  directionY: string;
18
18
  /** Styles applied to the top axis. */
19
19
  top: string;
@@ -22,6 +22,7 @@ export type ChartsLegendProps = {
22
22
  classes?: Partial<ChartsLegendClasses>;
23
23
  /**
24
24
  * Set to true to hide the legend.
25
+ * @default false
25
26
  */
26
27
  hidden?: boolean;
27
28
  /**
@@ -34,7 +34,7 @@ const useUtilityClasses = ownerState => {
34
34
  label: ['label'],
35
35
  series: ['series']
36
36
  };
37
- return (0, _utils2.unstable_composeClasses)(slots, _chartsLegendClasses.getChartsLegendUtilityClass, classes);
37
+ return (0, _utils2.unstable_composeClasses)(slots, _chartsLegendClasses.getLegendUtilityClass, classes);
38
38
  };
39
39
  const ChartsLegendRoot = exports.ChartsLegendRoot = (0, _styles.styled)('g', {
40
40
  name: 'MuiChartsLegend',
@@ -13,5 +13,5 @@ export interface ChartsLegendClasses {
13
13
  row: string;
14
14
  }
15
15
  export type ChartsLegendClassKey = keyof ChartsLegendClasses;
16
- export declare function getChartsLegendUtilityClass(slot: string): string;
16
+ export declare function getLegendUtilityClass(slot: string): string;
17
17
  export declare const legendClasses: ChartsLegendClasses;
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getChartsLegendUtilityClass = getChartsLegendUtilityClass;
6
+ exports.getLegendUtilityClass = getLegendUtilityClass;
7
7
  exports.legendClasses = void 0;
8
8
  var _utils = require("@mui/utils");
9
- function getChartsLegendUtilityClass(slot) {
9
+ function getLegendUtilityClass(slot) {
10
10
  return (0, _utils.unstable_generateUtilityClass)('MuiChartsLegend', slot);
11
11
  }
12
12
  const legendClasses = exports.legendClasses = (0, _utils.unstable_generateUtilityClasses)('MuiChartsLegend', ['root', 'series', 'mark', 'label', 'column', 'row']);
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ChartsXReferenceLineProps } from './ChartsXReferenceLine';
3
+ import { ChartsYReferenceLineProps } from './ChartsYReferenceLine';
4
+ import { XOR } from '../internals/utils';
5
+ type ChartsReferenceLineProps<TValue extends string | number | Date = string | number | Date> = XOR<ChartsXReferenceLineProps<TValue>, ChartsYReferenceLineProps<TValue>>;
6
+ declare function ChartsReferenceLine(props: ChartsReferenceLineProps): React.JSX.Element;
7
+ declare namespace ChartsReferenceLine {
8
+ var propTypes: any;
9
+ }
10
+ export { ChartsReferenceLine };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChartsReferenceLine = ChartsReferenceLine;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _ChartsXReferenceLine = require("./ChartsXReferenceLine");
12
+ var _ChartsYReferenceLine = require("./ChartsYReferenceLine");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ function ChartsReferenceLine(props) {
17
+ if (props.x !== undefined && props.y !== undefined) {
18
+ throw new Error('MUI-X: The ChartsReferenceLine can not have both `x` and `y` props set.');
19
+ }
20
+ if (props.x === undefined && props.y === undefined) {
21
+ throw new Error('MUI-X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
22
+ }
23
+ if (props.x !== undefined) {
24
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXReferenceLine.ChartsXReferenceLine, (0, _extends2.default)({}, props));
25
+ }
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYReferenceLine.ChartsYReferenceLine, (0, _extends2.default)({}, props));
27
+ }
28
+ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
29
+ // ----------------------------- Warning --------------------------------
30
+ // | These PropTypes are generated from the TypeScript type definitions |
31
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
32
+ // ----------------------------------------------------------------------
33
+ /**
34
+ * The id of the axis used for the reference value.
35
+ * @default The `id` of the first defined axis.
36
+ */
37
+ axisId: _propTypes.default.string,
38
+ /**
39
+ * Override or extend the styles applied to the component.
40
+ */
41
+ classes: _propTypes.default.object,
42
+ /**
43
+ * The label to display along the reference line.
44
+ */
45
+ label: _propTypes.default.string,
46
+ /**
47
+ * The alignment if the label is in the chart drawing area.
48
+ * @default 'middle'
49
+ */
50
+ labelAlign: _propTypes.default.oneOf(['end', 'middle', 'start']),
51
+ /**
52
+ * The style applied to the label.
53
+ */
54
+ labelStyle: _propTypes.default.object,
55
+ /**
56
+ * The style applied to the line.
57
+ */
58
+ lineStyle: _propTypes.default.object,
59
+ /**
60
+ * Additional space arround the label in px.
61
+ * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
62
+ * @default 5
63
+ */
64
+ spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
65
+ x: _propTypes.default.number,
66
+ y: _propTypes.default.number
67
+ })]),
68
+ /**
69
+ * The x value associated with the reference line.
70
+ * If defined the reference line will be vertical.
71
+ */
72
+ x: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]),
73
+ /**
74
+ * The y value associated with the reference line.
75
+ * If defined the reference line will be horizontal.
76
+ */
77
+ y: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string])
78
+ } : void 0;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { CommonChartsReferenceLineProps } from './common';
3
+ import { ChartsReferenceLineClasses } from './chartsReferenceLineClasses';
4
+ export type ChartsXReferenceLineProps<TValue extends string | number | Date = string | number | Date> = CommonChartsReferenceLineProps & {
5
+ /**
6
+ * The x value associated with the reference line.
7
+ * If defined the reference line will be vertical.
8
+ */
9
+ x: TValue;
10
+ };
11
+ export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"label" | "line" | "root", string>;
12
+ declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
13
+ export { ChartsXReferenceLine };
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChartsXReferenceLine = ChartsXReferenceLine;
8
+ exports.getXReferenceLineClasses = getXReferenceLineClasses;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
12
+ var _hooks = require("../hooks");
13
+ var _common = require("./common");
14
+ var _ChartsText = require("../internals/components/ChartsText");
15
+ var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ const getTextParams = ({
20
+ top,
21
+ height,
22
+ spacingY,
23
+ labelAlign = 'middle'
24
+ }) => {
25
+ switch (labelAlign) {
26
+ case 'start':
27
+ return {
28
+ y: top + spacingY,
29
+ style: {
30
+ dominantBaseline: 'hanging',
31
+ textAnchor: 'start'
32
+ }
33
+ };
34
+ case 'end':
35
+ return {
36
+ y: top + height - spacingY,
37
+ style: {
38
+ dominantBaseline: 'auto',
39
+ textAnchor: 'start'
40
+ }
41
+ };
42
+ default:
43
+ return {
44
+ y: top + height / 2,
45
+ style: {
46
+ dominantBaseline: 'central',
47
+ textAnchor: 'start'
48
+ }
49
+ };
50
+ }
51
+ };
52
+ function getXReferenceLineClasses(classes) {
53
+ return (0, _composeClasses.default)({
54
+ root: ['root', 'vertical'],
55
+ line: ['line'],
56
+ label: ['label']
57
+ }, _chartsReferenceLineClasses.getReferenceLineUtilityClass, classes);
58
+ }
59
+ let warnedOnce = false;
60
+ function ChartsXReferenceLine(props) {
61
+ const {
62
+ x,
63
+ label = '',
64
+ spacing = 5,
65
+ classes: inClasses,
66
+ labelAlign,
67
+ lineStyle,
68
+ labelStyle,
69
+ axisId
70
+ } = props;
71
+ const {
72
+ top,
73
+ height
74
+ } = (0, _hooks.useDrawingArea)();
75
+ const xAxisScale = (0, _hooks.useXScale)(axisId);
76
+ const xPosition = xAxisScale(x);
77
+ if (xPosition === undefined) {
78
+ if (process.env.NODE_ENV !== 'production') {
79
+ if (!warnedOnce) {
80
+ warnedOnce = true;
81
+ console.error(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`);
82
+ }
83
+ }
84
+ return null;
85
+ }
86
+ const d = `M ${xPosition} ${top} l 0 ${height}`;
87
+ const classes = getXReferenceLineClasses(inClasses);
88
+ const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
89
+ const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
90
+ const textParams = (0, _extends2.default)({
91
+ x: xPosition + spacingX,
92
+ text: label,
93
+ fontSize: 12
94
+ }, getTextParams({
95
+ top,
96
+ height,
97
+ spacingY,
98
+ labelAlign
99
+ }), {
100
+ className: classes.label
101
+ });
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_common.ReferenceLineRoot, {
103
+ className: classes.root,
104
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
105
+ d: d,
106
+ className: classes.line,
107
+ style: lineStyle
108
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, (0, _extends2.default)({}, textParams, {
109
+ style: (0, _extends2.default)({}, textParams.style, labelStyle)
110
+ }))]
111
+ });
112
+ }
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { CommonChartsReferenceLineProps } from './common';
3
+ import { ChartsReferenceLineClasses } from './chartsReferenceLineClasses';
4
+ export type ChartsYReferenceLineProps<TValue extends string | number | Date = string | number | Date> = CommonChartsReferenceLineProps & {
5
+ /**
6
+ * The y value associated with the reference line.
7
+ * If defined the reference line will be horizontal.
8
+ */
9
+ y: TValue;
10
+ };
11
+ export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"label" | "line" | "root", string>;
12
+ declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
13
+ export { ChartsYReferenceLine };
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChartsYReferenceLine = ChartsYReferenceLine;
8
+ exports.getYReferenceLineClasses = getYReferenceLineClasses;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
12
+ var _hooks = require("../hooks");
13
+ var _common = require("./common");
14
+ var _ChartsText = require("../internals/components/ChartsText");
15
+ var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ const getTextParams = ({
20
+ left,
21
+ width,
22
+ spacingX,
23
+ labelAlign = 'middle'
24
+ }) => {
25
+ switch (labelAlign) {
26
+ case 'start':
27
+ return {
28
+ x: left + spacingX,
29
+ style: {
30
+ dominantBaseline: 'auto',
31
+ textAnchor: 'start'
32
+ }
33
+ };
34
+ case 'end':
35
+ return {
36
+ x: left + width - spacingX,
37
+ style: {
38
+ dominantBaseline: 'auto',
39
+ textAnchor: 'end'
40
+ }
41
+ };
42
+ default:
43
+ return {
44
+ x: left + width / 2,
45
+ style: {
46
+ dominantBaseline: 'auto',
47
+ textAnchor: 'middle'
48
+ }
49
+ };
50
+ }
51
+ };
52
+ let warnedOnce = false;
53
+ function getYReferenceLineClasses(classes) {
54
+ return (0, _composeClasses.default)({
55
+ root: ['root', 'horizontal'],
56
+ line: ['line'],
57
+ label: ['label']
58
+ }, _chartsReferenceLineClasses.getReferenceLineUtilityClass, classes);
59
+ }
60
+ function ChartsYReferenceLine(props) {
61
+ const {
62
+ y,
63
+ label = '',
64
+ spacing = 5,
65
+ classes: inClasses,
66
+ labelAlign,
67
+ lineStyle,
68
+ labelStyle,
69
+ axisId
70
+ } = props;
71
+ const {
72
+ left,
73
+ width
74
+ } = (0, _hooks.useDrawingArea)();
75
+ const yAxisScale = (0, _hooks.useYScale)(axisId);
76
+ const yPosition = yAxisScale(y);
77
+ if (yPosition === undefined) {
78
+ if (process.env.NODE_ENV !== 'production') {
79
+ if (!warnedOnce) {
80
+ warnedOnce = true;
81
+ console.error(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`);
82
+ }
83
+ }
84
+ return null;
85
+ }
86
+ const d = `M ${left} ${yPosition} l ${width} 0`;
87
+ const classes = getYReferenceLineClasses(inClasses);
88
+ const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
89
+ const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
90
+ const textParams = (0, _extends2.default)({
91
+ y: yPosition - spacingY,
92
+ text: label,
93
+ fontSize: 12
94
+ }, getTextParams({
95
+ left,
96
+ width,
97
+ spacingX,
98
+ labelAlign
99
+ }), {
100
+ className: classes.label
101
+ });
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_common.ReferenceLineRoot, {
103
+ className: classes.root,
104
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
105
+ d: d,
106
+ className: classes.line,
107
+ style: lineStyle
108
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, (0, _extends2.default)({}, textParams, {
109
+ style: (0, _extends2.default)({}, textParams.style, labelStyle)
110
+ }))]
111
+ });
112
+ }