@mui/x-charts 7.0.0-beta.1 → 7.0.0-beta.3

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 (234) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +37 -13
  3. package/BarChart/BarElement.d.ts +20 -13
  4. package/BarChart/BarElement.js +1 -0
  5. package/BarChart/BarPlot.d.ts +3 -5
  6. package/BarChart/BarPlot.js +9 -10
  7. package/CHANGELOG.md +223 -1
  8. package/ChartContainer/ChartContainer.js +6 -4
  9. package/ChartsAxis/ChartsAxis.js +4 -4
  10. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  11. package/ChartsGrid/ChartsGrid.js +128 -0
  12. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  13. package/ChartsGrid/chartsGridClasses.js +14 -0
  14. package/ChartsGrid/index.d.ts +2 -0
  15. package/ChartsGrid/index.js +27 -0
  16. package/ChartsGrid/package.json +6 -0
  17. package/ChartsLegend/ChartsLegend.d.ts +5 -54
  18. package/ChartsLegend/ChartsLegend.js +2 -307
  19. package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
  20. package/ChartsLegend/DefaultChartsLegend.js +294 -0
  21. package/ChartsLegend/index.d.ts +1 -0
  22. package/ChartsLegend/index.js +11 -0
  23. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  24. package/ChartsReferenceLine/common.d.ts +2 -1
  25. package/ChartsSurface.js +6 -4
  26. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  27. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  28. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  29. package/ChartsTooltip/utils.d.ts +1 -0
  30. package/ChartsTooltip/utils.js +7 -0
  31. package/ChartsXAxis/ChartsXAxis.js +15 -11
  32. package/ChartsYAxis/ChartsYAxis.js +3 -3
  33. package/Gauge/Gauge.d.ts +13 -0
  34. package/Gauge/Gauge.js +156 -0
  35. package/Gauge/GaugeContainer.d.ts +19 -0
  36. package/Gauge/GaugeContainer.js +216 -0
  37. package/Gauge/GaugeProvider.d.ts +117 -0
  38. package/Gauge/GaugeProvider.js +96 -0
  39. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  40. package/Gauge/GaugeReferenceArc.js +44 -0
  41. package/Gauge/GaugeValueArc.d.ts +2 -0
  42. package/Gauge/GaugeValueArc.js +51 -0
  43. package/Gauge/GaugeValueText.d.ts +15 -0
  44. package/Gauge/GaugeValueText.js +77 -0
  45. package/Gauge/gaugeClasses.d.ts +14 -0
  46. package/Gauge/gaugeClasses.js +15 -0
  47. package/Gauge/index.d.ts +7 -0
  48. package/Gauge/index.js +87 -0
  49. package/Gauge/package.json +6 -0
  50. package/Gauge/utils.d.ts +19 -0
  51. package/Gauge/utils.js +75 -0
  52. package/LineChart/AnimatedArea.js +1 -1
  53. package/LineChart/AnimatedLine.js +1 -1
  54. package/LineChart/AreaElement.d.ts +2 -1
  55. package/LineChart/AreaElement.js +1 -1
  56. package/LineChart/LineChart.d.ts +24 -5
  57. package/LineChart/LineChart.js +41 -13
  58. package/LineChart/LineElement.d.ts +2 -1
  59. package/LineChart/LineElement.js +1 -1
  60. package/LineChart/LineHighlightElement.d.ts +3 -2
  61. package/LineChart/LineHighlightElement.js +2 -1
  62. package/LineChart/MarkElement.d.ts +3 -2
  63. package/LineChart/MarkElement.js +1 -0
  64. package/PieChart/PieArc.d.ts +7 -6
  65. package/PieChart/PieArc.js +10 -9
  66. package/PieChart/PieArcLabel.d.ts +3 -2
  67. package/PieChart/PieArcLabel.js +1 -0
  68. package/PieChart/PieArcLabelPlot.js +14 -14
  69. package/PieChart/PieArcPlot.js +1 -1
  70. package/PieChart/PieChart.d.ts +22 -0
  71. package/PieChart/PieChart.js +32 -8
  72. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  73. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  74. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  75. package/ScatterChart/ScatterChart.d.ts +18 -0
  76. package/ScatterChart/ScatterChart.js +35 -8
  77. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  78. package/SparkLineChart/SparkLineChart.js +5 -4
  79. package/context/CartesianContextProvider.js +8 -6
  80. package/esm/BarChart/BarChart.js +37 -13
  81. package/esm/BarChart/BarElement.js +1 -0
  82. package/esm/BarChart/BarPlot.js +8 -10
  83. package/esm/ChartContainer/ChartContainer.js +6 -4
  84. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  85. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  86. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  87. package/esm/ChartsGrid/index.js +2 -0
  88. package/esm/ChartsLegend/ChartsLegend.js +2 -307
  89. package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
  90. package/esm/ChartsLegend/index.js +1 -0
  91. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  92. package/esm/ChartsSurface.js +6 -4
  93. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  94. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  95. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  96. package/esm/ChartsTooltip/utils.js +6 -0
  97. package/esm/ChartsXAxis/ChartsXAxis.js +14 -10
  98. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  99. package/esm/Gauge/Gauge.js +149 -0
  100. package/esm/Gauge/GaugeContainer.js +211 -0
  101. package/esm/Gauge/GaugeProvider.js +85 -0
  102. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  103. package/esm/Gauge/GaugeValueArc.js +42 -0
  104. package/esm/Gauge/GaugeValueText.js +69 -0
  105. package/esm/Gauge/gaugeClasses.js +7 -0
  106. package/esm/Gauge/index.js +7 -0
  107. package/esm/Gauge/utils.js +68 -0
  108. package/esm/LineChart/AnimatedArea.js +1 -1
  109. package/esm/LineChart/AnimatedLine.js +1 -1
  110. package/esm/LineChart/AreaElement.js +1 -1
  111. package/esm/LineChart/LineChart.js +41 -13
  112. package/esm/LineChart/LineElement.js +1 -1
  113. package/esm/LineChart/LineHighlightElement.js +2 -1
  114. package/esm/LineChart/MarkElement.js +1 -0
  115. package/esm/PieChart/PieArc.js +10 -9
  116. package/esm/PieChart/PieArcLabel.js +1 -0
  117. package/esm/PieChart/PieArcLabelPlot.js +14 -14
  118. package/esm/PieChart/PieArcPlot.js +1 -1
  119. package/esm/PieChart/PieChart.js +32 -8
  120. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  121. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  122. package/esm/ScatterChart/ScatterChart.js +35 -8
  123. package/esm/SparkLineChart/SparkLineChart.js +5 -4
  124. package/esm/context/CartesianContextProvider.js +8 -6
  125. package/esm/hooks/useTicks.js +2 -3
  126. package/esm/index.js +2 -0
  127. package/hooks/useTicks.d.ts +1 -2
  128. package/hooks/useTicks.js +2 -3
  129. package/index.d.ts +2 -0
  130. package/index.js +23 -1
  131. package/internals/defaultizeColor.d.ts +16 -16
  132. package/internals/defaultizeValueFormatter.d.ts +4 -7
  133. package/internals/stackSeries.d.ts +4 -7
  134. package/legacy/BarChart/BarChart.js +37 -13
  135. package/legacy/BarChart/BarElement.js +1 -0
  136. package/legacy/BarChart/BarPlot.js +10 -10
  137. package/legacy/ChartContainer/ChartContainer.js +6 -4
  138. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  139. package/legacy/ChartsGrid/ChartsGrid.js +119 -0
  140. package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
  141. package/legacy/ChartsGrid/index.js +2 -0
  142. package/legacy/ChartsLegend/ChartsLegend.js +2 -323
  143. package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
  144. package/legacy/ChartsLegend/index.js +1 -0
  145. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  146. package/legacy/ChartsSurface.js +5 -3
  147. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  148. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  149. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  150. package/legacy/ChartsTooltip/utils.js +6 -0
  151. package/legacy/ChartsXAxis/ChartsXAxis.js +13 -9
  152. package/legacy/ChartsYAxis/ChartsYAxis.js +2 -2
  153. package/legacy/Gauge/Gauge.js +146 -0
  154. package/legacy/Gauge/GaugeContainer.js +215 -0
  155. package/legacy/Gauge/GaugeProvider.js +87 -0
  156. package/legacy/Gauge/GaugeReferenceArc.js +37 -0
  157. package/legacy/Gauge/GaugeValueArc.js +44 -0
  158. package/legacy/Gauge/GaugeValueText.js +66 -0
  159. package/legacy/Gauge/gaugeClasses.js +7 -0
  160. package/legacy/Gauge/index.js +7 -0
  161. package/legacy/Gauge/utils.js +84 -0
  162. package/legacy/LineChart/AnimatedArea.js +1 -1
  163. package/legacy/LineChart/AnimatedLine.js +1 -1
  164. package/legacy/LineChart/AreaElement.js +1 -1
  165. package/legacy/LineChart/LineChart.js +41 -13
  166. package/legacy/LineChart/LineElement.js +1 -1
  167. package/legacy/LineChart/LineHighlightElement.js +2 -1
  168. package/legacy/LineChart/MarkElement.js +1 -0
  169. package/legacy/PieChart/PieArc.js +11 -10
  170. package/legacy/PieChart/PieArcLabel.js +1 -0
  171. package/legacy/PieChart/PieArcLabelPlot.js +15 -15
  172. package/legacy/PieChart/PieArcPlot.js +1 -1
  173. package/legacy/PieChart/PieChart.js +32 -8
  174. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -81
  175. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
  176. package/legacy/ScatterChart/ScatterChart.js +35 -8
  177. package/legacy/SparkLineChart/SparkLineChart.js +6 -5
  178. package/legacy/context/CartesianContextProvider.js +8 -6
  179. package/legacy/hooks/useTicks.js +2 -3
  180. package/legacy/index.js +3 -1
  181. package/models/axis.d.ts +7 -2
  182. package/models/seriesType/common.d.ts +2 -1
  183. package/models/seriesType/config.d.ts +7 -12
  184. package/models/seriesType/line.d.ts +2 -2
  185. package/models/seriesType/pie.d.ts +7 -3
  186. package/models/seriesType/scatter.d.ts +5 -2
  187. package/modern/BarChart/BarChart.js +37 -13
  188. package/modern/BarChart/BarElement.js +1 -0
  189. package/modern/BarChart/BarPlot.js +8 -10
  190. package/modern/ChartContainer/ChartContainer.js +6 -4
  191. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  192. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  193. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  194. package/modern/ChartsGrid/index.js +2 -0
  195. package/modern/ChartsLegend/ChartsLegend.js +2 -307
  196. package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
  197. package/modern/ChartsLegend/index.js +1 -0
  198. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  199. package/modern/ChartsSurface.js +6 -4
  200. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  201. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  202. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  203. package/modern/ChartsTooltip/utils.js +6 -0
  204. package/modern/ChartsXAxis/ChartsXAxis.js +14 -10
  205. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  206. package/modern/Gauge/Gauge.js +149 -0
  207. package/modern/Gauge/GaugeContainer.js +208 -0
  208. package/modern/Gauge/GaugeProvider.js +85 -0
  209. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  210. package/modern/Gauge/GaugeValueArc.js +42 -0
  211. package/modern/Gauge/GaugeValueText.js +69 -0
  212. package/modern/Gauge/gaugeClasses.js +7 -0
  213. package/modern/Gauge/index.js +7 -0
  214. package/modern/Gauge/utils.js +68 -0
  215. package/modern/LineChart/AnimatedArea.js +1 -1
  216. package/modern/LineChart/AnimatedLine.js +1 -1
  217. package/modern/LineChart/AreaElement.js +1 -1
  218. package/modern/LineChart/LineChart.js +41 -13
  219. package/modern/LineChart/LineElement.js +1 -1
  220. package/modern/LineChart/LineHighlightElement.js +2 -1
  221. package/modern/LineChart/MarkElement.js +1 -0
  222. package/modern/PieChart/PieArc.js +10 -9
  223. package/modern/PieChart/PieArcLabel.js +1 -0
  224. package/modern/PieChart/PieArcLabelPlot.js +14 -14
  225. package/modern/PieChart/PieArcPlot.js +1 -1
  226. package/modern/PieChart/PieChart.js +32 -8
  227. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
  228. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  229. package/modern/ScatterChart/ScatterChart.js +35 -8
  230. package/modern/SparkLineChart/SparkLineChart.js +5 -4
  231. package/modern/context/CartesianContextProvider.js +8 -6
  232. package/modern/hooks/useTicks.js +2 -3
  233. package/modern/index.js +3 -1
  234. package/package.json +4 -4
@@ -11,6 +11,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
11
11
  import { ChartsLegend } from '../ChartsLegend';
12
12
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
13
13
  import { ChartsClipPath } from '../ChartsClipPath';
14
+ import { ChartsGrid } from '../ChartsGrid';
14
15
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -39,6 +40,7 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
39
40
  tooltip = props.tooltip,
40
41
  axisHighlight = props.axisHighlight,
41
42
  legend = props.legend,
43
+ grid = props.grid,
42
44
  topAxis = props.topAxis,
43
45
  leftAxis = props.leftAxis,
44
46
  rightAxis = props.rightAxis,
@@ -94,6 +96,9 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
94
96
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
95
97
  children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
96
98
  onAxisClick: onAxisClick
99
+ }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
100
+ vertical: grid.vertical,
101
+ horizontal: grid.horizontal
97
102
  }), /*#__PURE__*/_jsx("g", {
98
103
  clipPath: "url(#".concat(clipPathId, ")"),
99
104
  children: /*#__PURE__*/_jsx(BarPlot, {
@@ -126,11 +131,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
126
131
  // | To update them edit the TypeScript types and run "yarn proptypes" |
127
132
  // ----------------------------------------------------------------------
128
133
  /**
129
- * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
130
- * The two properties accept the following values:
131
- * - 'none': display nothing.
132
- * - 'line': display a line at the current mouse position.
133
- * - 'band': display a band at the current mouse position. Only available with band scale.
134
+ * The configuration of axes highlight.
135
+ * Default is set to 'band' in the bar direction.
136
+ * Depends on `layout` prop.
137
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
134
138
  */
135
139
  axisHighlight: PropTypes.shape({
136
140
  x: PropTypes.oneOf(['band', 'line', 'none']),
@@ -142,7 +146,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
142
146
  * @default xAxisIds[0] The id of the first provided axis
143
147
  */
144
148
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
145
- axisId: PropTypes.string,
149
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
146
150
  classes: PropTypes.object,
147
151
  disableLine: PropTypes.bool,
148
152
  disableTicks: PropTypes.bool,
@@ -181,11 +185,22 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
181
185
  * @default false
182
186
  */
183
187
  disableAxisListener: PropTypes.bool,
188
+ /**
189
+ * Option to display a cartesian grid in the background.
190
+ */
191
+ grid: PropTypes.shape({
192
+ horizontal: PropTypes.bool,
193
+ vertical: PropTypes.bool
194
+ }),
184
195
  /**
185
196
  * The height of the chart in px. If not defined, it takes the height of the parent element.
186
197
  * @default undefined
187
198
  */
188
199
  height: PropTypes.number,
200
+ /**
201
+ * The direction of the bar elements.
202
+ * @default 'vertical'
203
+ */
189
204
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
190
205
  /**
191
206
  * Indicate which axis to display the left of the charts.
@@ -193,7 +208,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
193
208
  * @default yAxisIds[0] The id of the first provided axis
194
209
  */
195
210
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
196
- axisId: PropTypes.string,
211
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
197
212
  classes: PropTypes.object,
198
213
  disableLine: PropTypes.bool,
199
214
  disableTicks: PropTypes.bool,
@@ -259,7 +274,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
259
274
  * @default null
260
275
  */
261
276
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
262
- axisId: PropTypes.string,
277
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
263
278
  classes: PropTypes.object,
264
279
  disableLine: PropTypes.bool,
265
280
  disableTicks: PropTypes.bool,
@@ -280,6 +295,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
280
295
  tickNumber: PropTypes.number,
281
296
  tickSize: PropTypes.number
282
297
  }), PropTypes.string]),
298
+ /**
299
+ * The series to display in the bar chart.
300
+ */
283
301
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
284
302
  /**
285
303
  * If `true`, animations are skipped.
@@ -298,6 +316,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
298
316
  slots: PropTypes.object,
299
317
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
300
318
  title: PropTypes.string,
319
+ /**
320
+ * The configuration of the tooltip.
321
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
322
+ */
301
323
  tooltip: PropTypes.shape({
302
324
  axisContent: PropTypes.elementType,
303
325
  classes: PropTypes.object,
@@ -312,7 +334,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
312
334
  * @default null
313
335
  */
314
336
  topAxis: PropTypes.oneOfType([PropTypes.shape({
315
- axisId: PropTypes.string,
337
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
316
338
  classes: PropTypes.object,
317
339
  disableLine: PropTypes.bool,
318
340
  disableTicks: PropTypes.bool,
@@ -349,7 +371,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
349
371
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
350
372
  */
351
373
  xAxis: PropTypes.arrayOf(PropTypes.shape({
352
- axisId: PropTypes.string,
374
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
353
375
  classes: PropTypes.object,
354
376
  data: PropTypes.array,
355
377
  dataKey: PropTypes.string,
@@ -357,13 +379,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
357
379
  disableTicks: PropTypes.bool,
358
380
  fill: PropTypes.string,
359
381
  hideTooltip: PropTypes.bool,
360
- id: PropTypes.string,
382
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
361
383
  label: PropTypes.string,
362
384
  labelFontSize: PropTypes.number,
363
385
  labelStyle: PropTypes.object,
364
386
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
365
387
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
366
388
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
389
+ reverse: PropTypes.bool,
367
390
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
368
391
  slotProps: PropTypes.object,
369
392
  slots: PropTypes.object,
@@ -383,7 +406,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
383
406
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
384
407
  */
385
408
  yAxis: PropTypes.arrayOf(PropTypes.shape({
386
- axisId: PropTypes.string,
409
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
387
410
  classes: PropTypes.object,
388
411
  data: PropTypes.array,
389
412
  dataKey: PropTypes.string,
@@ -391,13 +414,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
391
414
  disableTicks: PropTypes.bool,
392
415
  fill: PropTypes.string,
393
416
  hideTooltip: PropTypes.bool,
394
- id: PropTypes.string,
417
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
395
418
  label: PropTypes.string,
396
419
  labelFontSize: PropTypes.number,
397
420
  labelStyle: PropTypes.object,
398
421
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
399
422
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
400
423
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
424
+ reverse: PropTypes.bool,
401
425
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
402
426
  slotProps: PropTypes.object,
403
427
  slots: PropTypes.object,
@@ -104,6 +104,7 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
104
104
  faded: PropTypes.oneOf(['global', 'none', 'series']),
105
105
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
106
106
  }),
107
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
107
108
  /**
108
109
  * The props used for each component slot.
109
110
  * @default {}
@@ -10,7 +10,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { BarElement } from './BarElement';
11
11
  import { isBandScaleConfig } from '../models/axis';
12
12
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
13
-
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  /**
15
15
  * Solution of the equations
16
16
  * W = barWidth * N + offset * (N-1)
@@ -20,7 +20,6 @@ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
20
20
  * @param gapRatio The ratio of the gap between bars over the bar width.
21
21
  * @returns The bar width and the offset between bars.
22
22
  */
23
- import { jsx as _jsx } from "react/jsx-runtime";
24
23
  function getBandSize(_ref) {
25
24
  var W = _ref.bandWidth,
26
25
  N = _ref.numberOfGroups,
@@ -97,20 +96,21 @@ var useAggregatedData = function useAggregatedData() {
97
96
  color = _series$seriesId.color;
98
97
  return stackedData.map(function (values, dataIndex) {
99
98
  var _xAxis$xAxisKey$data, _yAxis$yAxisKey$data;
100
- var bottom = Math.min.apply(Math, _toConsumableArray(values));
101
- var top = Math.max.apply(Math, _toConsumableArray(values));
99
+ var valueCoordinates = values.map(function (v) {
100
+ return verticalLayout ? yScale(v) : xScale(v);
101
+ });
102
+ var minValueCoord = Math.min.apply(Math, _toConsumableArray(valueCoordinates));
103
+ var maxValueCoord = Math.max.apply(Math, _toConsumableArray(valueCoordinates));
102
104
  return {
103
- bottom: bottom,
104
- top: top,
105
105
  seriesId: seriesId,
106
106
  dataIndex: dataIndex,
107
107
  layout: series[seriesId].layout,
108
- x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset : xScale(bottom),
109
- y: verticalLayout ? yScale(top) : yScale((_yAxis$yAxisKey$data = yAxis[yAxisKey].data) == null ? void 0 : _yAxis$yAxisKey$data[dataIndex]) + barOffset,
108
+ x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset : minValueCoord,
109
+ y: verticalLayout ? minValueCoord : yScale((_yAxis$yAxisKey$data = yAxis[yAxisKey].data) == null ? void 0 : _yAxis$yAxisKey$data[dataIndex]) + barOffset,
110
110
  xOrigin: xScale(0),
111
111
  yOrigin: yScale(0),
112
- height: verticalLayout ? Math.abs(yScale(bottom) - yScale(top)) : barWidth,
113
- width: verticalLayout ? barWidth : Math.abs(xScale(bottom) - xScale(top)),
112
+ height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
113
+ width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
114
114
  color: color,
115
115
  highlightScope: series[seriesId].highlightScope
116
116
  };
@@ -120,7 +120,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
120
120
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
121
121
  */
122
122
  xAxis: PropTypes.arrayOf(PropTypes.shape({
123
- axisId: PropTypes.string,
123
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
124
124
  classes: PropTypes.object,
125
125
  data: PropTypes.array,
126
126
  dataKey: PropTypes.string,
@@ -128,13 +128,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
128
128
  disableTicks: PropTypes.bool,
129
129
  fill: PropTypes.string,
130
130
  hideTooltip: PropTypes.bool,
131
- id: PropTypes.string,
131
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
132
132
  label: PropTypes.string,
133
133
  labelFontSize: PropTypes.number,
134
134
  labelStyle: PropTypes.object,
135
135
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
136
136
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
137
137
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
138
+ reverse: PropTypes.bool,
138
139
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
139
140
  slotProps: PropTypes.object,
140
141
  slots: PropTypes.object,
@@ -154,7 +155,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
154
155
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
155
156
  */
156
157
  yAxis: PropTypes.arrayOf(PropTypes.shape({
157
- axisId: PropTypes.string,
158
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
158
159
  classes: PropTypes.object,
159
160
  data: PropTypes.array,
160
161
  dataKey: PropTypes.string,
@@ -162,13 +163,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
162
163
  disableTicks: PropTypes.bool,
163
164
  fill: PropTypes.string,
164
165
  hideTooltip: PropTypes.bool,
165
- id: PropTypes.string,
166
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
166
167
  label: PropTypes.string,
167
168
  labelFontSize: PropTypes.number,
168
169
  labelStyle: PropTypes.object,
169
170
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
170
171
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
171
172
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
173
+ reverse: PropTypes.bool,
172
174
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
173
175
  slotProps: PropTypes.object,
174
176
  slots: PropTypes.object,
@@ -99,7 +99,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
99
99
  * @default xAxisIds[0] The id of the first provided axis
100
100
  */
101
101
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
102
- axisId: PropTypes.string,
102
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
103
103
  classes: PropTypes.object,
104
104
  disableLine: PropTypes.bool,
105
105
  disableTicks: PropTypes.bool,
@@ -126,7 +126,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
126
126
  * @default yAxisIds[0] The id of the first provided axis
127
127
  */
128
128
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
129
- axisId: PropTypes.string,
129
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
130
130
  classes: PropTypes.object,
131
131
  disableLine: PropTypes.bool,
132
132
  disableTicks: PropTypes.bool,
@@ -153,7 +153,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
153
153
  * @default null
154
154
  */
155
155
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
156
- axisId: PropTypes.string,
156
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
157
157
  classes: PropTypes.object,
158
158
  disableLine: PropTypes.bool,
159
159
  disableTicks: PropTypes.bool,
@@ -190,7 +190,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
190
190
  * @default null
191
191
  */
192
192
  topAxis: PropTypes.oneOfType([PropTypes.shape({
193
- axisId: PropTypes.string,
193
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
194
194
  classes: PropTypes.object,
195
195
  disableLine: PropTypes.bool,
196
196
  disableTicks: PropTypes.bool,
@@ -0,0 +1,119 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ var _excluded = ["vertical", "horizontal"];
5
+ import * as React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import composeClasses from '@mui/utils/composeClasses';
8
+ import { styled } from '@mui/material/styles';
9
+ import { CartesianContext } from '../context/CartesianContextProvider';
10
+ import { useTicks } from '../hooks/useTicks';
11
+ import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ var GridRoot = styled('g', {
15
+ name: 'MuiChartsGrid',
16
+ slot: 'Root',
17
+ overridesResolver: function overridesResolver(props, styles) {
18
+ return styles.root;
19
+ }
20
+ })(function (_ref) {
21
+ var theme = _ref.theme;
22
+ return _defineProperty({}, "& .".concat(chartsGridClasses.line), {
23
+ stroke: (theme.vars || theme).palette.divider,
24
+ shapeRendering: 'crispEdges',
25
+ strokeWidth: 1
26
+ });
27
+ });
28
+ var useUtilityClasses = function useUtilityClasses(_ref3) {
29
+ var classes = _ref3.classes;
30
+ var slots = {
31
+ root: ['root'],
32
+ verticalLine: ['line', 'verticalLine'],
33
+ horizontalLine: ['line', 'horizontalLine']
34
+ };
35
+ return composeClasses(slots, getChartsGridUtilityClass, classes);
36
+ };
37
+ /**
38
+ * Demos:
39
+ *
40
+ * - [Axis](https://mui.com/x/react-charts/axis/)
41
+ *
42
+ * API:
43
+ *
44
+ * - [ChartsGrid API](https://mui.com/x/api/charts/charts-axis/)
45
+ */
46
+ function ChartsGrid(props) {
47
+ var vertical = props.vertical,
48
+ horizontal = props.horizontal,
49
+ other = _objectWithoutProperties(props, _excluded);
50
+ var _React$useContext = React.useContext(CartesianContext),
51
+ xAxis = _React$useContext.xAxis,
52
+ xAxisIds = _React$useContext.xAxisIds,
53
+ yAxis = _React$useContext.yAxis,
54
+ yAxisIds = _React$useContext.yAxisIds;
55
+ var classes = useUtilityClasses(props);
56
+ var horizontalAxisId = yAxisIds[0];
57
+ var verticalAxisId = xAxisIds[0];
58
+ var _xAxis$verticalAxisId = xAxis[verticalAxisId],
59
+ xScale = _xAxis$verticalAxisId.scale,
60
+ xTickNumber = _xAxis$verticalAxisId.tickNumber,
61
+ xTickInterval = _xAxis$verticalAxisId.tickInterval;
62
+ var _yAxis$horizontalAxis = yAxis[horizontalAxisId],
63
+ yScale = _yAxis$horizontalAxis.scale,
64
+ yTickNumber = _yAxis$horizontalAxis.tickNumber,
65
+ yTickInterval = _yAxis$horizontalAxis.tickInterval;
66
+ var xTicks = useTicks({
67
+ scale: xScale,
68
+ tickNumber: xTickNumber,
69
+ tickInterval: xTickInterval
70
+ });
71
+ var yTicks = useTicks({
72
+ scale: yScale,
73
+ tickNumber: yTickNumber,
74
+ tickInterval: yTickInterval
75
+ });
76
+ return /*#__PURE__*/_jsxs(GridRoot, _extends({}, other, {
77
+ className: classes.root,
78
+ children: [vertical && xTicks.map(function (_ref4) {
79
+ var formattedValue = _ref4.formattedValue,
80
+ offset = _ref4.offset;
81
+ return /*#__PURE__*/_jsx("line", {
82
+ y1: yScale.range()[0],
83
+ y2: yScale.range()[1],
84
+ x1: offset,
85
+ x2: offset,
86
+ className: classes.verticalLine
87
+ }, formattedValue);
88
+ }), horizontal && yTicks.map(function (_ref5) {
89
+ var formattedValue = _ref5.formattedValue,
90
+ offset = _ref5.offset;
91
+ return /*#__PURE__*/_jsx("line", {
92
+ y1: offset,
93
+ y2: offset,
94
+ x1: xScale.range()[0],
95
+ x2: xScale.range()[1],
96
+ className: classes.horizontalLine
97
+ }, formattedValue);
98
+ })]
99
+ }));
100
+ }
101
+ process.env.NODE_ENV !== "production" ? ChartsGrid.propTypes = {
102
+ // ----------------------------- Warning --------------------------------
103
+ // | These PropTypes are generated from the TypeScript type definitions |
104
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
105
+ // ----------------------------------------------------------------------
106
+ /**
107
+ * Override or extend the styles applied to the component.
108
+ */
109
+ classes: PropTypes.object,
110
+ /**
111
+ * Displays horizontal grid.
112
+ */
113
+ horizontal: PropTypes.bool,
114
+ /**
115
+ * Displays vertical grid.
116
+ */
117
+ vertical: PropTypes.bool
118
+ } : void 0;
119
+ export { ChartsGrid };
@@ -0,0 +1,6 @@
1
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
2
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
3
+ export function getChartsGridUtilityClass(slot) {
4
+ return generateUtilityClass('MuiChartsGrid', slot);
5
+ }
6
+ export var chartsGridClasses = generateUtilityClasses('MuiChartsGrid', ['root', 'line', 'horizontalLine', 'verticalLine']);
@@ -0,0 +1,2 @@
1
+ export * from './ChartsGrid';
2
+ export * from './chartsGridClasses';