@mui/x-charts 6.0.0-alpha.5 → 6.0.0-alpha.7

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 (163) hide show
  1. package/BarChart/BarChart.d.ts +18 -2
  2. package/BarChart/BarChart.js +74 -17
  3. package/BarChart/BarElement.d.ts +22 -0
  4. package/BarChart/BarElement.js +21 -10
  5. package/BarChart/BarPlot.d.ts +14 -1
  6. package/BarChart/BarPlot.js +23 -4
  7. package/BarChart/formatter.js +23 -12
  8. package/CHANGELOG.md +154 -0
  9. package/ChartContainer/index.js +3 -0
  10. package/ChartsAxis/ChartsAxis.d.ts +11 -1
  11. package/ChartsAxis/ChartsAxis.js +51 -6
  12. package/ChartsLegend/ChartsLegend.d.ts +25 -2
  13. package/ChartsLegend/ChartsLegend.js +49 -17
  14. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
  16. package/ChartsXAxis/ChartsXAxis.js +44 -9
  17. package/ChartsYAxis/ChartsYAxis.js +44 -9
  18. package/LineChart/AreaElement.d.ts +22 -0
  19. package/LineChart/AreaElement.js +31 -11
  20. package/LineChart/AreaPlot.d.ts +14 -1
  21. package/LineChart/AreaPlot.js +32 -5
  22. package/LineChart/LineChart.d.ts +20 -2
  23. package/LineChart/LineChart.js +76 -16
  24. package/LineChart/LineElement.d.ts +22 -0
  25. package/LineChart/LineElement.js +31 -10
  26. package/LineChart/LinePlot.d.ts +14 -1
  27. package/LineChart/LinePlot.js +38 -6
  28. package/LineChart/MarkElement.js +1 -1
  29. package/LineChart/MarkPlot.d.ts +24 -1
  30. package/LineChart/MarkPlot.js +30 -6
  31. package/LineChart/formatter.js +23 -12
  32. package/PieChart/PieArcLabel.js +0 -1
  33. package/PieChart/PieChart.d.ts +14 -2
  34. package/PieChart/PieChart.js +60 -13
  35. package/PieChart/PiePlot.d.ts +27 -1
  36. package/PieChart/PiePlot.js +29 -6
  37. package/ScatterChart/ScatterChart.d.ts +18 -2
  38. package/ScatterChart/ScatterChart.js +64 -13
  39. package/ScatterChart/ScatterPlot.d.ts +24 -1
  40. package/ScatterChart/ScatterPlot.js +28 -4
  41. package/SparkLineChart/SparkLineChart.d.ts +73 -0
  42. package/SparkLineChart/SparkLineChart.js +218 -0
  43. package/SparkLineChart/index.d.ts +1 -0
  44. package/SparkLineChart/index.js +12 -0
  45. package/SparkLineChart/package.json +6 -0
  46. package/colorPalettes/colorPalettes.js +2 -2
  47. package/context/CartesianContextProvider.d.ts +3 -1
  48. package/context/CartesianContextProvider.js +50 -14
  49. package/context/SeriesContextProvider.d.ts +3 -2
  50. package/context/SeriesContextProvider.js +5 -3
  51. package/esm/BarChart/BarChart.js +77 -17
  52. package/esm/BarChart/BarElement.js +21 -11
  53. package/esm/BarChart/BarPlot.js +23 -4
  54. package/esm/BarChart/formatter.js +23 -12
  55. package/esm/ChartContainer/index.js +3 -0
  56. package/esm/ChartsAxis/ChartsAxis.js +51 -6
  57. package/esm/ChartsLegend/ChartsLegend.js +47 -14
  58. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  59. package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
  60. package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
  61. package/esm/LineChart/AreaElement.js +31 -11
  62. package/esm/LineChart/AreaPlot.js +33 -5
  63. package/esm/LineChart/LineChart.js +79 -16
  64. package/esm/LineChart/LineElement.js +31 -11
  65. package/esm/LineChart/LinePlot.js +45 -9
  66. package/esm/LineChart/MarkElement.js +1 -1
  67. package/esm/LineChart/MarkPlot.js +31 -6
  68. package/esm/LineChart/formatter.js +23 -13
  69. package/esm/PieChart/PieArcLabel.js +0 -1
  70. package/esm/PieChart/PieChart.js +60 -13
  71. package/esm/PieChart/PiePlot.js +31 -6
  72. package/esm/ScatterChart/ScatterChart.js +64 -13
  73. package/esm/ScatterChart/ScatterPlot.js +29 -4
  74. package/esm/SparkLineChart/SparkLineChart.js +210 -0
  75. package/esm/SparkLineChart/index.js +1 -0
  76. package/esm/colorPalettes/colorPalettes.js +2 -2
  77. package/esm/context/CartesianContextProvider.js +50 -14
  78. package/esm/context/SeriesContextProvider.js +5 -3
  79. package/esm/hooks/useTicks.js +9 -6
  80. package/esm/index.js +1 -0
  81. package/esm/internals/components/AxisSharedComponents.js +10 -10
  82. package/esm/models/index.js +3 -1
  83. package/hooks/useTicks.d.ts +20 -5
  84. package/hooks/useTicks.js +9 -6
  85. package/index.d.ts +1 -0
  86. package/index.js +12 -1
  87. package/internals/components/AxisSharedComponents.d.ts +4 -4
  88. package/internals/components/AxisSharedComponents.js +15 -15
  89. package/internals/defaultizeColor.d.ts +4 -2
  90. package/legacy/BarChart/BarChart.js +75 -17
  91. package/legacy/BarChart/BarElement.js +20 -10
  92. package/legacy/BarChart/BarPlot.js +23 -4
  93. package/legacy/BarChart/formatter.js +23 -10
  94. package/legacy/ChartContainer/index.js +3 -0
  95. package/legacy/ChartsAxis/ChartsAxis.js +51 -6
  96. package/legacy/ChartsLegend/ChartsLegend.js +46 -15
  97. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  98. package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
  99. package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
  100. package/legacy/LineChart/AreaElement.js +30 -10
  101. package/legacy/LineChart/AreaPlot.js +31 -5
  102. package/legacy/LineChart/LineChart.js +77 -16
  103. package/legacy/LineChart/LineElement.js +30 -10
  104. package/legacy/LineChart/LinePlot.js +38 -6
  105. package/legacy/LineChart/MarkElement.js +1 -1
  106. package/legacy/LineChart/MarkPlot.js +29 -6
  107. package/legacy/LineChart/formatter.js +23 -11
  108. package/legacy/PieChart/PieArcLabel.js +0 -1
  109. package/legacy/PieChart/PieChart.js +60 -13
  110. package/legacy/PieChart/PiePlot.js +29 -6
  111. package/legacy/ScatterChart/ScatterChart.js +64 -13
  112. package/legacy/ScatterChart/ScatterPlot.js +27 -4
  113. package/legacy/SparkLineChart/SparkLineChart.js +214 -0
  114. package/legacy/SparkLineChart/index.js +1 -0
  115. package/legacy/colorPalettes/colorPalettes.js +2 -2
  116. package/legacy/context/CartesianContextProvider.js +59 -15
  117. package/legacy/context/SeriesContextProvider.js +6 -4
  118. package/legacy/hooks/useTicks.js +9 -9
  119. package/legacy/index.js +2 -1
  120. package/legacy/internals/components/AxisSharedComponents.js +10 -10
  121. package/legacy/models/index.js +3 -1
  122. package/models/axis.d.ts +34 -3
  123. package/models/index.d.ts +2 -0
  124. package/models/index.js +11 -0
  125. package/models/seriesType/bar.d.ts +8 -1
  126. package/models/seriesType/common.d.ts +2 -2
  127. package/models/seriesType/config.d.ts +4 -1
  128. package/models/seriesType/line.d.ts +8 -1
  129. package/modern/BarChart/BarChart.js +74 -17
  130. package/modern/BarChart/BarElement.js +20 -11
  131. package/modern/BarChart/BarPlot.js +23 -4
  132. package/modern/BarChart/formatter.js +23 -12
  133. package/modern/ChartContainer/index.js +3 -0
  134. package/modern/ChartsAxis/ChartsAxis.js +51 -6
  135. package/modern/ChartsLegend/ChartsLegend.js +46 -14
  136. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  137. package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
  138. package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
  139. package/modern/LineChart/AreaElement.js +30 -11
  140. package/modern/LineChart/AreaPlot.js +33 -5
  141. package/modern/LineChart/LineChart.js +76 -16
  142. package/modern/LineChart/LineElement.js +30 -11
  143. package/modern/LineChart/LinePlot.js +39 -6
  144. package/modern/LineChart/MarkElement.js +1 -1
  145. package/modern/LineChart/MarkPlot.js +30 -6
  146. package/modern/LineChart/formatter.js +23 -13
  147. package/modern/PieChart/PieArcLabel.js +0 -1
  148. package/modern/PieChart/PieChart.js +60 -13
  149. package/modern/PieChart/PiePlot.js +30 -6
  150. package/modern/ScatterChart/ScatterChart.js +64 -13
  151. package/modern/ScatterChart/ScatterPlot.js +28 -4
  152. package/modern/SparkLineChart/SparkLineChart.js +210 -0
  153. package/modern/SparkLineChart/index.js +1 -0
  154. package/modern/colorPalettes/colorPalettes.js +2 -2
  155. package/modern/context/CartesianContextProvider.js +50 -14
  156. package/modern/context/SeriesContextProvider.js +5 -3
  157. package/modern/hooks/useTicks.js +9 -6
  158. package/modern/index.js +2 -1
  159. package/modern/internals/components/AxisSharedComponents.js +10 -10
  160. package/modern/models/index.js +3 -1
  161. package/package.json +4 -2
  162. package/themeAugmentation/components.d.ts +0 -10
  163. package/themeAugmentation/overrides.d.ts +0 -2
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TickLabel = exports.Tick = exports.Line = exports.Label = exports.AxisRoot = void 0;
7
+ exports.ChartsTickLabel = exports.ChartsTick = exports.ChartsLine = exports.ChartsLabel = exports.AxisRoot = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _styles = require("@mui/material/styles");
10
10
  var _axisClasses = require("../../ChartsAxis/axisClasses");
@@ -15,40 +15,40 @@ const AxisRoot = (0, _styles.styled)('g', {
15
15
  })({
16
16
  [`&.${_axisClasses.axisClasses.directionY}`]: {
17
17
  [`.${_axisClasses.axisClasses.tickLabel}`]: {
18
- alignmentBaseline: 'middle'
18
+ dominantBaseline: 'middle'
19
19
  },
20
20
  [`.${_axisClasses.axisClasses.label}`]: {
21
- alignmentBaseline: 'baseline',
21
+ dominantBaseline: 'auto',
22
22
  textAnchor: 'middle'
23
23
  }
24
24
  },
25
25
  [`&.${_axisClasses.axisClasses.left}`]: {
26
26
  [`.${_axisClasses.axisClasses.tickLabel}`]: {
27
- alignmentBaseline: 'central',
27
+ dominantBaseline: 'central',
28
28
  textAnchor: 'end'
29
29
  }
30
30
  },
31
31
  [`&.${_axisClasses.axisClasses.right}`]: {
32
32
  [`.${_axisClasses.axisClasses.tickLabel}`]: {
33
- alignmentBaseline: 'central',
33
+ dominantBaseline: 'central',
34
34
  textAnchor: 'start'
35
35
  }
36
36
  },
37
37
  [`&.${_axisClasses.axisClasses.bottom}`]: {
38
38
  [`.${_axisClasses.axisClasses.tickLabel}, .${_axisClasses.axisClasses.label}`]: {
39
- alignmentBaseline: 'hanging',
39
+ dominantBaseline: 'hanging',
40
40
  textAnchor: 'middle'
41
41
  }
42
42
  },
43
43
  [`&.${_axisClasses.axisClasses.top}`]: {
44
44
  [`.${_axisClasses.axisClasses.tickLabel}, .${_axisClasses.axisClasses.label}`]: {
45
- alignmentBaseline: 'baseline',
45
+ dominantBaseline: 'baseline',
46
46
  textAnchor: 'middle'
47
47
  }
48
48
  }
49
49
  });
50
50
  exports.AxisRoot = AxisRoot;
51
- const Line = (0, _styles.styled)('line', {
51
+ const ChartsLine = (0, _styles.styled)('line', {
52
52
  name: 'MuiChartsAxis',
53
53
  slot: 'Line',
54
54
  overridesResolver: (props, styles) => styles.line
@@ -59,8 +59,8 @@ const Line = (0, _styles.styled)('line', {
59
59
  shapeRendering: 'crispEdges',
60
60
  strokeWidth: 1
61
61
  }));
62
- exports.Line = Line;
63
- const Tick = (0, _styles.styled)('line', {
62
+ exports.ChartsLine = ChartsLine;
63
+ const ChartsTick = (0, _styles.styled)('line', {
64
64
  name: 'MuiChartsAxis',
65
65
  slot: 'Tick',
66
66
  overridesResolver: (props, styles) => styles.tick
@@ -70,8 +70,8 @@ const Tick = (0, _styles.styled)('line', {
70
70
  stroke: theme.palette.text.primary,
71
71
  shapeRendering: 'crispEdges'
72
72
  }));
73
- exports.Tick = Tick;
74
- const TickLabel = (0, _styles.styled)('text', {
73
+ exports.ChartsTick = ChartsTick;
74
+ const ChartsTickLabel = (0, _styles.styled)('text', {
75
75
  name: 'MuiChartsAxis',
76
76
  slot: 'TickLabel',
77
77
  overridesResolver: (props, styles) => styles.tickLabel
@@ -80,8 +80,8 @@ const TickLabel = (0, _styles.styled)('text', {
80
80
  }) => (0, _extends2.default)({}, theme.typography.caption, {
81
81
  fill: theme.palette.text.primary
82
82
  }));
83
- exports.TickLabel = TickLabel;
84
- const Label = (0, _styles.styled)('text', {
83
+ exports.ChartsTickLabel = ChartsTickLabel;
84
+ const ChartsLabel = (0, _styles.styled)('text', {
85
85
  name: 'MuiChartsAxis',
86
86
  slot: 'Label',
87
87
  overridesResolver: (props, styles) => styles.label
@@ -90,4 +90,4 @@ const Label = (0, _styles.styled)('text', {
90
90
  }) => (0, _extends2.default)({}, theme.typography.body1, {
91
91
  fill: theme.palette.text.primary
92
92
  }));
93
- exports.Label = Label;
93
+ exports.ChartsLabel = ChartsLabel;
@@ -36,7 +36,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
36
36
  highlightScope?: Partial<import("..").HighlightScope> | undefined;
37
37
  } | {
38
38
  type: "bar";
39
- data: number[];
39
+ data?: number[] | undefined;
40
+ dataKey?: string | undefined;
40
41
  label?: string | undefined;
41
42
  id?: string | undefined;
42
43
  color: string;
@@ -49,7 +50,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
49
50
  stackOrder?: "reverse" | "none" | "appearance" | "ascending" | "descending" | "insideOut" | undefined;
50
51
  } | {
51
52
  type: "line";
52
- data: number[];
53
+ data?: number[] | undefined;
54
+ dataKey?: string | undefined;
53
55
  stack?: string | undefined;
54
56
  area?: boolean | undefined;
55
57
  label?: string | undefined;
@@ -21,6 +21,7 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
21
21
  height = props.height,
22
22
  margin = props.margin,
23
23
  colors = props.colors,
24
+ dataset = props.dataset,
24
25
  sx = props.sx,
25
26
  tooltip = props.tooltip,
26
27
  axisHighlight = props.axisHighlight,
@@ -29,7 +30,9 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
29
30
  leftAxis = props.leftAxis,
30
31
  rightAxis = props.rightAxis,
31
32
  bottomAxis = props.bottomAxis,
32
- children = props.children;
33
+ children = props.children,
34
+ slots = props.slots,
35
+ slotProps = props.slotProps;
33
36
  var id = useId();
34
37
  var clipPathId = "".concat(id, "-clip-path");
35
38
  return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
@@ -47,7 +50,8 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
47
50
  scaleType: 'band',
48
51
  data: Array.from({
49
52
  length: Math.max.apply(Math, _toConsumableArray(series.map(function (s) {
50
- return s.data.length;
53
+ var _ref, _s$data;
54
+ return ((_ref = (_s$data = s.data) != null ? _s$data : dataset) != null ? _ref : []).length;
51
55
  })))
52
56
  }, function (_, index) {
53
57
  return index;
@@ -55,19 +59,31 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
55
59
  }],
56
60
  yAxis: yAxis,
57
61
  colors: colors,
62
+ dataset: dataset,
58
63
  sx: sx,
59
64
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
60
65
  children: [/*#__PURE__*/_jsx("g", {
61
66
  clipPath: "url(#".concat(clipPathId, ")"),
62
- children: /*#__PURE__*/_jsx(BarPlot, {})
67
+ children: /*#__PURE__*/_jsx(BarPlot, {
68
+ slots: slots,
69
+ slotProps: slotProps
70
+ })
63
71
  }), /*#__PURE__*/_jsx(ChartsAxis, {
64
72
  topAxis: topAxis,
65
73
  leftAxis: leftAxis,
66
74
  rightAxis: rightAxis,
67
- bottomAxis: bottomAxis
68
- }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
75
+ bottomAxis: bottomAxis,
76
+ slots: slots,
77
+ slotProps: slotProps
78
+ }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
79
+ slots: slots,
80
+ slotProps: slotProps
81
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
69
82
  x: "band"
70
- }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
83
+ }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
84
+ slots: slots,
85
+ slotProps: slotProps
86
+ })), /*#__PURE__*/_jsx(ChartsClipPath, {
71
87
  id: clipPathId
72
88
  }), children]
73
89
  });
@@ -95,8 +111,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
95
111
  label: PropTypes.string,
96
112
  labelFontSize: PropTypes.number,
97
113
  position: PropTypes.oneOf(['bottom', 'top']),
114
+ slotProps: PropTypes.object,
115
+ slots: PropTypes.object,
98
116
  stroke: PropTypes.string,
99
117
  tickFontSize: PropTypes.number,
118
+ tickMaxStep: PropTypes.number,
119
+ tickMinStep: PropTypes.number,
120
+ tickNumber: PropTypes.number,
100
121
  tickSize: PropTypes.number
101
122
  }), PropTypes.string]),
102
123
  children: PropTypes.node,
@@ -105,6 +126,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
105
126
  * Color palette used to colorize multiple series.
106
127
  */
107
128
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
129
+ dataset: PropTypes.arrayOf(PropTypes.object),
108
130
  desc: PropTypes.string,
109
131
  disableAxisListener: PropTypes.bool,
110
132
  height: PropTypes.number,
@@ -122,8 +144,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
122
144
  label: PropTypes.string,
123
145
  labelFontSize: PropTypes.number,
124
146
  position: PropTypes.oneOf(['left', 'right']),
147
+ slotProps: PropTypes.object,
148
+ slots: PropTypes.object,
125
149
  stroke: PropTypes.string,
126
150
  tickFontSize: PropTypes.number,
151
+ tickMaxStep: PropTypes.number,
152
+ tickMinStep: PropTypes.number,
153
+ tickNumber: PropTypes.number,
127
154
  tickSize: PropTypes.number
128
155
  }), PropTypes.string]),
129
156
  legend: PropTypes.shape({
@@ -140,6 +167,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
140
167
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
141
168
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
142
169
  }),
170
+ slotProps: PropTypes.object,
171
+ slots: PropTypes.object,
143
172
  spacing: PropTypes.number
144
173
  }),
145
174
  margin: PropTypes.shape({
@@ -162,13 +191,19 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
162
191
  label: PropTypes.string,
163
192
  labelFontSize: PropTypes.number,
164
193
  position: PropTypes.oneOf(['left', 'right']),
194
+ slotProps: PropTypes.object,
195
+ slots: PropTypes.object,
165
196
  stroke: PropTypes.string,
166
197
  tickFontSize: PropTypes.number,
198
+ tickMaxStep: PropTypes.number,
199
+ tickMinStep: PropTypes.number,
200
+ tickNumber: PropTypes.number,
167
201
  tickSize: PropTypes.number
168
202
  }), PropTypes.string]),
169
203
  series: PropTypes.arrayOf(PropTypes.shape({
170
204
  color: PropTypes.string,
171
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
205
+ data: PropTypes.arrayOf(PropTypes.number),
206
+ dataKey: PropTypes.string,
172
207
  highlightScope: PropTypes.shape({
173
208
  faded: PropTypes.oneOf(['global', 'none', 'series']),
174
209
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -183,6 +218,16 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
183
218
  xAxisKey: PropTypes.string,
184
219
  yAxisKey: PropTypes.string
185
220
  })).isRequired,
221
+ /**
222
+ * The props used for each component slot.
223
+ * @default {}
224
+ */
225
+ slotProps: PropTypes.object,
226
+ /**
227
+ * Overridable component slots.
228
+ * @default {}
229
+ */
230
+ slots: PropTypes.object,
186
231
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
187
232
  title: PropTypes.string,
188
233
  tooltip: PropTypes.shape({
@@ -205,8 +250,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
205
250
  label: PropTypes.string,
206
251
  labelFontSize: PropTypes.number,
207
252
  position: PropTypes.oneOf(['bottom', 'top']),
253
+ slotProps: PropTypes.object,
254
+ slots: PropTypes.object,
208
255
  stroke: PropTypes.string,
209
256
  tickFontSize: PropTypes.number,
257
+ tickMaxStep: PropTypes.number,
258
+ tickMinStep: PropTypes.number,
259
+ tickNumber: PropTypes.number,
210
260
  tickSize: PropTypes.number
211
261
  }), PropTypes.string]),
212
262
  viewBox: PropTypes.shape({
@@ -220,44 +270,52 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
220
270
  axisId: PropTypes.string,
221
271
  classes: PropTypes.object,
222
272
  data: PropTypes.array,
273
+ dataKey: PropTypes.string,
223
274
  disableLine: PropTypes.bool,
224
275
  disableTicks: PropTypes.bool,
225
276
  fill: PropTypes.string,
277
+ hideTooltip: PropTypes.bool,
226
278
  id: PropTypes.string,
227
279
  label: PropTypes.string,
228
280
  labelFontSize: PropTypes.number,
229
- max: PropTypes.number,
230
- maxTicks: PropTypes.number,
231
- min: PropTypes.number,
232
- minTicks: PropTypes.number,
281
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
282
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
233
283
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
234
284
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
285
+ slotProps: PropTypes.object,
286
+ slots: PropTypes.object,
235
287
  stroke: PropTypes.string,
236
288
  tickFontSize: PropTypes.number,
289
+ tickMaxStep: PropTypes.number,
290
+ tickMinStep: PropTypes.number,
291
+ tickNumber: PropTypes.number,
237
292
  tickSize: PropTypes.number,
238
- tickSpacing: PropTypes.number,
239
293
  valueFormatter: PropTypes.func
240
294
  })),
241
295
  yAxis: PropTypes.arrayOf(PropTypes.shape({
242
296
  axisId: PropTypes.string,
243
297
  classes: PropTypes.object,
244
298
  data: PropTypes.array,
299
+ dataKey: PropTypes.string,
245
300
  disableLine: PropTypes.bool,
246
301
  disableTicks: PropTypes.bool,
247
302
  fill: PropTypes.string,
303
+ hideTooltip: PropTypes.bool,
248
304
  id: PropTypes.string,
249
305
  label: PropTypes.string,
250
306
  labelFontSize: PropTypes.number,
251
- max: PropTypes.number,
252
- maxTicks: PropTypes.number,
253
- min: PropTypes.number,
254
- minTicks: PropTypes.number,
307
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
308
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
255
309
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
256
310
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
311
+ slotProps: PropTypes.object,
312
+ slots: PropTypes.object,
257
313
  stroke: PropTypes.string,
258
314
  tickFontSize: PropTypes.number,
315
+ tickMaxStep: PropTypes.number,
316
+ tickMinStep: PropTypes.number,
317
+ tickNumber: PropTypes.number,
259
318
  tickSize: PropTypes.number,
260
- tickSpacing: PropTypes.number,
261
319
  valueFormatter: PropTypes.func
262
320
  }))
263
321
  } : void 0;
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope"];
3
+ var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import composeClasses from '@mui/utils/composeClasses';
6
+ import { useSlotProps } from '@mui/base/utils';
6
7
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
7
8
  import { styled } from '@mui/material/styles';
8
9
  import { color as d3Color } from 'd3-color';
@@ -22,7 +23,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
22
23
  };
23
24
  return composeClasses(slots, getBarElementUtilityClass, classes);
24
25
  };
25
- var BarElementPath = styled('rect', {
26
+ export var BarElementPath = styled('rect', {
26
27
  name: 'MuiBarElement',
27
28
  slot: 'Root',
28
29
  overridesResolver: function overridesResolver(_, styles) {
@@ -39,11 +40,14 @@ var BarElementPath = styled('rect', {
39
40
  };
40
41
  });
41
42
  export function BarElement(props) {
43
+ var _slots$bar;
42
44
  var id = props.id,
43
45
  dataIndex = props.dataIndex,
44
46
  innerClasses = props.classes,
45
47
  color = props.color,
46
48
  highlightScope = props.highlightScope,
49
+ slots = props.slots,
50
+ slotProps = props.slotProps,
47
51
  other = _objectWithoutProperties(props, _excluded);
48
52
  var getInteractionItemProps = useInteractionItemProps(highlightScope);
49
53
  var _React$useContext = React.useContext(InteractionContext),
@@ -67,12 +71,18 @@ export function BarElement(props) {
67
71
  isHighlighted: isHighlighted
68
72
  };
69
73
  var classes = useUtilityClasses(ownerState);
70
- return /*#__PURE__*/_jsx(BarElementPath, _extends({}, other, {
71
- ownerState: ownerState,
72
- className: classes.root
73
- }, getInteractionItemProps({
74
- type: 'bar',
75
- seriesId: id,
76
- dataIndex: dataIndex
77
- })));
74
+ var Bar = (_slots$bar = slots == null ? void 0 : slots.bar) != null ? _slots$bar : BarElementPath;
75
+ var barProps = useSlotProps({
76
+ elementType: Bar,
77
+ externalSlotProps: slotProps == null ? void 0 : slotProps.bar,
78
+ additionalProps: _extends({}, other, getInteractionItemProps({
79
+ type: 'bar',
80
+ seriesId: id,
81
+ dataIndex: dataIndex
82
+ }), {
83
+ className: classes.root
84
+ }),
85
+ ownerState: ownerState
86
+ });
87
+ return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
78
88
  }
@@ -1,5 +1,7 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
3
  import * as React from 'react';
4
+ import PropTypes from 'prop-types';
3
5
  import { SeriesContext } from '../context/SeriesContextProvider';
4
6
  import { CartesianContext } from '../context/CartesianContextProvider';
5
7
  import { BarElement } from './BarElement';
@@ -32,7 +34,7 @@ function getBandSize(_ref) {
32
34
  offset: offset
33
35
  };
34
36
  }
35
- export function BarPlot() {
37
+ function BarPlot(props) {
36
38
  var seriesData = React.useContext(SeriesContext).bar;
37
39
  var axisData = React.useContext(CartesianContext);
38
40
  if (seriesData === undefined) {
@@ -82,7 +84,7 @@ export function BarPlot() {
82
84
  var _xAxis$xAxisKey$data;
83
85
  var baseline = Math.min.apply(Math, _toConsumableArray(values));
84
86
  var value = Math.max.apply(Math, _toConsumableArray(values));
85
- return /*#__PURE__*/_jsx(BarElement, {
87
+ return /*#__PURE__*/_jsx(BarElement, _extends({
86
88
  id: seriesId,
87
89
  dataIndex: dataIndex,
88
90
  x: xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + groupIndex * (barWidth + offset),
@@ -91,9 +93,26 @@ export function BarPlot() {
91
93
  width: barWidth,
92
94
  color: color,
93
95
  highlightScope: series[seriesId].highlightScope
94
- }, "".concat(seriesId, "-").concat(dataIndex));
96
+ }, props), "".concat(seriesId, "-").concat(dataIndex));
95
97
  });
96
98
  });
97
99
  })
98
100
  });
99
- }
101
+ }
102
+ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
103
+ // ----------------------------- Warning --------------------------------
104
+ // | These PropTypes are generated from the TypeScript type definitions |
105
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
106
+ // ----------------------------------------------------------------------
107
+ /**
108
+ * The props used for each component slot.
109
+ * @default {}
110
+ */
111
+ slotProps: PropTypes.object,
112
+ /**
113
+ * Overridable component slots.
114
+ * @default {}
115
+ */
116
+ slots: PropTypes.object
117
+ } : void 0;
118
+ export { BarPlot };
@@ -4,21 +4,26 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { stack as d3Stack } from 'd3-shape';
5
5
  import { getStackingGroups } from '../internals/stackSeries';
6
6
  import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
7
- var formatter = function formatter(params) {
7
+ var formatter = function formatter(params, dataset) {
8
8
  var seriesOrder = params.seriesOrder,
9
9
  series = params.series;
10
10
  var stackingGroups = getStackingGroups(params);
11
11
 
12
12
  // Create a data set with format adapted to d3
13
- var d3Dataset = [];
13
+ var d3Dataset = dataset != null ? dataset : [];
14
14
  seriesOrder.forEach(function (id) {
15
- series[id].data.forEach(function (value, index) {
16
- if (d3Dataset.length <= index) {
17
- d3Dataset.push(_defineProperty({}, id, value));
18
- } else {
19
- d3Dataset[index][id] = value;
20
- }
21
- });
15
+ var data = series[id].data;
16
+ if (data !== undefined) {
17
+ data.forEach(function (value, index) {
18
+ if (d3Dataset.length <= index) {
19
+ d3Dataset.push(_defineProperty({}, id, value));
20
+ } else {
21
+ d3Dataset[index][id] = value;
22
+ }
23
+ });
24
+ } else if (dataset === undefined) {
25
+ throw new Error(["MUI: bar series with id='".concat(id, "' has no data."), 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
26
+ }
22
27
  });
23
28
  var completedSeries = {};
24
29
  stackingGroups.forEach(function (stackingGroup) {
@@ -26,9 +31,17 @@ var formatter = function formatter(params) {
26
31
  stackingOffset = stackingGroup.stackingOffset,
27
32
  stackingOrder = stackingGroup.stackingOrder;
28
33
  // Get stacked values, and derive the domain
29
- var stackedSeries = d3Stack().keys(ids).order(stackingOrder).offset(stackingOffset)(d3Dataset);
34
+ var stackedSeries = d3Stack().keys(ids.map(function (id) {
35
+ // Use dataKey if needed and available
36
+ var dataKey = series[id].dataKey;
37
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
38
+ })).order(stackingOrder).offset(stackingOffset)(d3Dataset);
30
39
  ids.forEach(function (id, index) {
40
+ var dataKey = series[id].dataKey;
31
41
  completedSeries[id] = _extends({}, series[id], {
42
+ data: dataKey ? dataset.map(function (d) {
43
+ return d[dataKey];
44
+ }) : series[id].data,
32
45
  stackedData: stackedSeries[index].map(function (_ref) {
33
46
  var _ref2 = _slicedToArray(_ref, 2),
34
47
  a = _ref2[0],
@@ -15,6 +15,7 @@ export var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContaine
15
15
  xAxis = props.xAxis,
16
16
  yAxis = props.yAxis,
17
17
  colors = props.colors,
18
+ dataset = props.dataset,
18
19
  sx = props.sx,
19
20
  title = props.title,
20
21
  desc = props.desc,
@@ -30,9 +31,11 @@ export var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContaine
30
31
  children: /*#__PURE__*/_jsx(SeriesContextProvider, {
31
32
  series: series,
32
33
  colors: colors,
34
+ dataset: dataset,
33
35
  children: /*#__PURE__*/_jsx(CartesianContextProvider, {
34
36
  xAxis: xAxis,
35
37
  yAxis: yAxis,
38
+ dataset: dataset,
36
39
  children: /*#__PURE__*/_jsx(InteractionProvider, {
37
40
  children: /*#__PURE__*/_jsx(HighlightProvider, {
38
41
  children: /*#__PURE__*/_jsx(ChartsSurface, {
@@ -16,11 +16,22 @@ var getAxisId = function getAxisId(propsValue) {
16
16
  }
17
17
  return propsValue;
18
18
  };
19
+ var mergeProps = function mergeProps(axisConfig, slots, slotProps) {
20
+ return _typeof(axisConfig) === 'object' ? _extends({}, axisConfig, {
21
+ slots: _extends({}, slots, axisConfig == null ? void 0 : axisConfig.slots),
22
+ slotProps: _extends({}, slotProps, axisConfig == null ? void 0 : axisConfig.slotProps)
23
+ }) : {
24
+ slots: slots,
25
+ slotProps: slotProps
26
+ };
27
+ };
19
28
  function ChartsAxis(props) {
20
29
  var topAxis = props.topAxis,
21
30
  leftAxis = props.leftAxis,
22
31
  rightAxis = props.rightAxis,
23
- bottomAxis = props.bottomAxis;
32
+ bottomAxis = props.bottomAxis,
33
+ slots = props.slots,
34
+ slotProps = props.slotProps;
24
35
  var _React$useContext = React.useContext(CartesianContext),
25
36
  xAxis = _React$useContext.xAxis,
26
37
  xAxisIds = _React$useContext.xAxisIds,
@@ -46,20 +57,24 @@ function ChartsAxis(props) {
46
57
  if (bottomId !== null && !xAxis[bottomId]) {
47
58
  throw Error("MUI: id used for bottom axis \"".concat(bottomId, "\" is not defined"));
48
59
  }
60
+ var topAxisProps = mergeProps(topAxis, slots, slotProps);
61
+ var bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
62
+ var leftAxisProps = mergeProps(leftAxis, slots, slotProps);
63
+ var rightAxisProps = mergeProps(rightAxis, slots, slotProps);
49
64
  return /*#__PURE__*/_jsxs(React.Fragment, {
50
- children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
65
+ children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({}, topAxisProps, {
51
66
  position: "top",
52
67
  axisId: topId
53
- }, _typeof(topAxis) === 'object' ? topAxis : {})), bottomId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
68
+ })), bottomId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({}, bottomAxisProps, {
54
69
  position: "bottom",
55
70
  axisId: bottomId
56
- }, _typeof(bottomAxis) === 'object' ? bottomAxis : {})), leftId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({
71
+ })), leftId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({}, leftAxisProps, {
57
72
  position: "left",
58
73
  axisId: leftId
59
- }, _typeof(leftAxis) === 'object' ? leftAxis : {})), rightId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({
74
+ })), rightId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({}, rightAxisProps, {
60
75
  position: "right",
61
76
  axisId: rightId
62
- }, _typeof(rightAxis) === 'object' ? rightAxis : {}))]
77
+ }))]
63
78
  });
64
79
  }
65
80
  process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
@@ -81,8 +96,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
81
96
  label: PropTypes.string,
82
97
  labelFontSize: PropTypes.number,
83
98
  position: PropTypes.oneOf(['bottom', 'top']),
99
+ slotProps: PropTypes.object,
100
+ slots: PropTypes.object,
84
101
  stroke: PropTypes.string,
85
102
  tickFontSize: PropTypes.number,
103
+ tickMaxStep: PropTypes.number,
104
+ tickMinStep: PropTypes.number,
105
+ tickNumber: PropTypes.number,
86
106
  tickSize: PropTypes.number
87
107
  }), PropTypes.string]),
88
108
  /**
@@ -99,8 +119,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
99
119
  label: PropTypes.string,
100
120
  labelFontSize: PropTypes.number,
101
121
  position: PropTypes.oneOf(['left', 'right']),
122
+ slotProps: PropTypes.object,
123
+ slots: PropTypes.object,
102
124
  stroke: PropTypes.string,
103
125
  tickFontSize: PropTypes.number,
126
+ tickMaxStep: PropTypes.number,
127
+ tickMinStep: PropTypes.number,
128
+ tickNumber: PropTypes.number,
104
129
  tickSize: PropTypes.number
105
130
  }), PropTypes.string]),
106
131
  /**
@@ -117,10 +142,25 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
117
142
  label: PropTypes.string,
118
143
  labelFontSize: PropTypes.number,
119
144
  position: PropTypes.oneOf(['left', 'right']),
145
+ slotProps: PropTypes.object,
146
+ slots: PropTypes.object,
120
147
  stroke: PropTypes.string,
121
148
  tickFontSize: PropTypes.number,
149
+ tickMaxStep: PropTypes.number,
150
+ tickMinStep: PropTypes.number,
151
+ tickNumber: PropTypes.number,
122
152
  tickSize: PropTypes.number
123
153
  }), PropTypes.string]),
154
+ /**
155
+ * The props used for each component slot.
156
+ * @default {}
157
+ */
158
+ slotProps: PropTypes.object,
159
+ /**
160
+ * Overridable component slots.
161
+ * @default {}
162
+ */
163
+ slots: PropTypes.object,
124
164
  /**
125
165
  * Indicate which axis to display the top of the charts.
126
166
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
@@ -135,8 +175,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
135
175
  label: PropTypes.string,
136
176
  labelFontSize: PropTypes.number,
137
177
  position: PropTypes.oneOf(['bottom', 'top']),
178
+ slotProps: PropTypes.object,
179
+ slots: PropTypes.object,
138
180
  stroke: PropTypes.string,
139
181
  tickFontSize: PropTypes.number,
182
+ tickMaxStep: PropTypes.number,
183
+ tickMinStep: PropTypes.number,
184
+ tickNumber: PropTypes.number,
140
185
  tickSize: PropTypes.number
141
186
  }), PropTypes.string])
142
187
  } : void 0;