@mui/x-charts 6.0.0-alpha.6 → 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 (119) hide show
  1. package/BarChart/BarChart.d.ts +18 -2
  2. package/BarChart/BarChart.js +60 -11
  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/CHANGELOG.md +62 -0
  8. package/ChartsAxis/ChartsAxis.d.ts +11 -1
  9. package/ChartsAxis/ChartsAxis.js +51 -6
  10. package/ChartsLegend/ChartsLegend.d.ts +25 -2
  11. package/ChartsLegend/ChartsLegend.js +49 -17
  12. package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
  13. package/ChartsXAxis/ChartsXAxis.js +44 -9
  14. package/ChartsYAxis/ChartsYAxis.js +44 -9
  15. package/LineChart/AreaElement.d.ts +22 -0
  16. package/LineChart/AreaElement.js +31 -11
  17. package/LineChart/AreaPlot.d.ts +14 -1
  18. package/LineChart/AreaPlot.js +29 -3
  19. package/LineChart/LineChart.d.ts +20 -2
  20. package/LineChart/LineChart.js +62 -10
  21. package/LineChart/LineElement.d.ts +22 -0
  22. package/LineChart/LineElement.js +31 -10
  23. package/LineChart/LinePlot.d.ts +14 -1
  24. package/LineChart/LinePlot.js +35 -4
  25. package/LineChart/MarkPlot.d.ts +24 -1
  26. package/LineChart/MarkPlot.js +25 -3
  27. package/PieChart/PieArcLabel.js +0 -1
  28. package/PieChart/PieChart.d.ts +14 -2
  29. package/PieChart/PieChart.js +51 -9
  30. package/PieChart/PiePlot.d.ts +27 -1
  31. package/PieChart/PiePlot.js +29 -6
  32. package/ScatterChart/ScatterChart.d.ts +18 -2
  33. package/ScatterChart/ScatterChart.js +55 -9
  34. package/ScatterChart/ScatterPlot.d.ts +24 -1
  35. package/ScatterChart/ScatterPlot.js +28 -4
  36. package/SparkLineChart/SparkLineChart.d.ts +18 -0
  37. package/SparkLineChart/SparkLineChart.js +28 -5
  38. package/colorPalettes/colorPalettes.js +2 -2
  39. package/context/CartesianContextProvider.js +14 -8
  40. package/esm/BarChart/BarChart.js +60 -11
  41. package/esm/BarChart/BarElement.js +21 -11
  42. package/esm/BarChart/BarPlot.js +23 -4
  43. package/esm/ChartsAxis/ChartsAxis.js +51 -6
  44. package/esm/ChartsLegend/ChartsLegend.js +47 -14
  45. package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
  46. package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
  47. package/esm/LineChart/AreaElement.js +31 -11
  48. package/esm/LineChart/AreaPlot.js +31 -4
  49. package/esm/LineChart/LineChart.js +62 -10
  50. package/esm/LineChart/LineElement.js +31 -11
  51. package/esm/LineChart/LinePlot.js +43 -8
  52. package/esm/LineChart/MarkPlot.js +28 -4
  53. package/esm/PieChart/PieArcLabel.js +0 -1
  54. package/esm/PieChart/PieChart.js +51 -9
  55. package/esm/PieChart/PiePlot.js +31 -6
  56. package/esm/ScatterChart/ScatterChart.js +55 -9
  57. package/esm/ScatterChart/ScatterPlot.js +29 -4
  58. package/esm/SparkLineChart/SparkLineChart.js +28 -5
  59. package/esm/colorPalettes/colorPalettes.js +2 -2
  60. package/esm/context/CartesianContextProvider.js +14 -8
  61. package/esm/hooks/useTicks.js +9 -6
  62. package/esm/internals/components/AxisSharedComponents.js +10 -10
  63. package/hooks/useTicks.d.ts +20 -5
  64. package/hooks/useTicks.js +9 -6
  65. package/index.js +1 -1
  66. package/internals/components/AxisSharedComponents.d.ts +4 -4
  67. package/internals/components/AxisSharedComponents.js +15 -15
  68. package/legacy/BarChart/BarChart.js +60 -11
  69. package/legacy/BarChart/BarElement.js +20 -10
  70. package/legacy/BarChart/BarPlot.js +23 -4
  71. package/legacy/ChartsAxis/ChartsAxis.js +51 -6
  72. package/legacy/ChartsLegend/ChartsLegend.js +46 -15
  73. package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
  74. package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
  75. package/legacy/LineChart/AreaElement.js +30 -10
  76. package/legacy/LineChart/AreaPlot.js +29 -4
  77. package/legacy/LineChart/LineChart.js +62 -10
  78. package/legacy/LineChart/LineElement.js +30 -10
  79. package/legacy/LineChart/LinePlot.js +36 -5
  80. package/legacy/LineChart/MarkPlot.js +26 -4
  81. package/legacy/PieChart/PieArcLabel.js +0 -1
  82. package/legacy/PieChart/PieChart.js +51 -9
  83. package/legacy/PieChart/PiePlot.js +29 -6
  84. package/legacy/ScatterChart/ScatterChart.js +55 -9
  85. package/legacy/ScatterChart/ScatterPlot.js +27 -4
  86. package/legacy/SparkLineChart/SparkLineChart.js +28 -5
  87. package/legacy/colorPalettes/colorPalettes.js +2 -2
  88. package/legacy/context/CartesianContextProvider.js +14 -8
  89. package/legacy/hooks/useTicks.js +9 -9
  90. package/legacy/index.js +1 -1
  91. package/legacy/internals/components/AxisSharedComponents.js +10 -10
  92. package/models/axis.d.ts +24 -1
  93. package/modern/BarChart/BarChart.js +60 -11
  94. package/modern/BarChart/BarElement.js +20 -11
  95. package/modern/BarChart/BarPlot.js +23 -4
  96. package/modern/ChartsAxis/ChartsAxis.js +51 -6
  97. package/modern/ChartsLegend/ChartsLegend.js +46 -14
  98. package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
  99. package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
  100. package/modern/LineChart/AreaElement.js +30 -11
  101. package/modern/LineChart/AreaPlot.js +31 -4
  102. package/modern/LineChart/LineChart.js +62 -10
  103. package/modern/LineChart/LineElement.js +30 -11
  104. package/modern/LineChart/LinePlot.js +37 -5
  105. package/modern/LineChart/MarkPlot.js +27 -4
  106. package/modern/PieChart/PieArcLabel.js +0 -1
  107. package/modern/PieChart/PieChart.js +51 -9
  108. package/modern/PieChart/PiePlot.js +30 -6
  109. package/modern/ScatterChart/ScatterChart.js +55 -9
  110. package/modern/ScatterChart/ScatterPlot.js +28 -4
  111. package/modern/SparkLineChart/SparkLineChart.js +28 -5
  112. package/modern/colorPalettes/colorPalettes.js +2 -2
  113. package/modern/context/CartesianContextProvider.js +14 -8
  114. package/modern/hooks/useTicks.js +9 -6
  115. package/modern/index.js +1 -1
  116. package/modern/internals/components/AxisSharedComponents.js +10 -10
  117. package/package.json +2 -2
  118. package/themeAugmentation/components.d.ts +0 -10
  119. package/themeAugmentation/overrides.d.ts +0 -2
@@ -1,11 +1,26 @@
1
1
  import { D3Scale } from '../models/axis';
2
- export type TickParams = {
3
- maxTicks?: number;
4
- minTicks?: number;
5
- tickSpacing?: number;
6
- };
2
+ export interface TickParams {
3
+ /**
4
+ * Maximal step between two ticks.
5
+ * When using time data, the value is assumed to be in ms.
6
+ * Not supported by categorical axis (band, points).
7
+ */
8
+ tickMaxStep?: number;
9
+ /**
10
+ * Maximal step between two ticks.
11
+ * When using time data, the value is assumed to be in ms.
12
+ * Not supported by categorical axis (band, points).
13
+ */
14
+ tickMinStep?: number;
15
+ /**
16
+ * The number of ticks. This number is not guaranted.
17
+ * Not supported by categorical axis (band, points).
18
+ */
19
+ tickNumber?: number;
20
+ }
7
21
  export declare function getTicksNumber(params: TickParams & {
8
22
  range: any[];
23
+ domain: any[];
9
24
  }): number;
10
25
  declare function useTicks(options: {
11
26
  scale: D3Scale;
package/hooks/useTicks.js CHANGED
@@ -11,13 +11,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
11
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
12
  function getTicksNumber(params) {
13
13
  const {
14
- maxTicks = 999,
15
- minTicks = 2,
16
- tickSpacing = 50,
17
- range
14
+ tickMaxStep,
15
+ tickMinStep,
16
+ tickNumber,
17
+ range,
18
+ domain
18
19
  } = params;
19
- const estimatedTickNumber = Math.floor(Math.abs(range[1] - range[0]) / tickSpacing);
20
- return Math.min(maxTicks, Math.max(minTicks, estimatedTickNumber));
20
+ const maxTicks = tickMinStep === undefined ? 999 : Math.floor(Math.abs(domain[1] - domain[0]) / tickMinStep);
21
+ const minTicks = tickMaxStep === undefined ? 2 : Math.ceil(Math.abs(domain[1] - domain[0]) / tickMaxStep);
22
+ const defaultizedTickNumber = tickNumber ?? Math.floor(Math.abs(range[1] - range[0]) / 50);
23
+ return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
21
24
  }
22
25
  function useTicks(options) {
23
26
  const {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.0.0-alpha.6
2
+ * @mui/x-charts v6.0.0-alpha.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
3
- export declare const Line: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGLineElementAttributes<SVGLineElement>, keyof import("react").SVGLineElementAttributes<SVGLineElement>>, {}>;
4
- export declare const Tick: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGLineElementAttributes<SVGLineElement>, keyof import("react").SVGLineElementAttributes<SVGLineElement>>, {}>;
5
- export declare const TickLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGTextElementAttributes<SVGTextElement>, keyof import("react").SVGTextElementAttributes<SVGTextElement>>, {}>;
6
- export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGTextElementAttributes<SVGTextElement>, keyof import("react").SVGTextElementAttributes<SVGTextElement>>, {}>;
3
+ export declare const ChartsLine: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGLineElementAttributes<SVGLineElement>, keyof import("react").SVGLineElementAttributes<SVGLineElement>>, {}>;
4
+ export declare const ChartsTick: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGLineElementAttributes<SVGLineElement>, keyof import("react").SVGLineElementAttributes<SVGLineElement>>, {}>;
5
+ export declare const ChartsTickLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGTextElementAttributes<SVGTextElement>, keyof import("react").SVGTextElementAttributes<SVGTextElement>>, {}>;
6
+ export declare const ChartsLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGTextElementAttributes<SVGTextElement>, keyof import("react").SVGTextElementAttributes<SVGTextElement>>, {}>;
@@ -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;
@@ -30,7 +30,9 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
30
30
  leftAxis = props.leftAxis,
31
31
  rightAxis = props.rightAxis,
32
32
  bottomAxis = props.bottomAxis,
33
- children = props.children;
33
+ children = props.children,
34
+ slots = props.slots,
35
+ slotProps = props.slotProps;
34
36
  var id = useId();
35
37
  var clipPathId = "".concat(id, "-clip-path");
36
38
  return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
@@ -62,15 +64,26 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
62
64
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
63
65
  children: [/*#__PURE__*/_jsx("g", {
64
66
  clipPath: "url(#".concat(clipPathId, ")"),
65
- children: /*#__PURE__*/_jsx(BarPlot, {})
67
+ children: /*#__PURE__*/_jsx(BarPlot, {
68
+ slots: slots,
69
+ slotProps: slotProps
70
+ })
66
71
  }), /*#__PURE__*/_jsx(ChartsAxis, {
67
72
  topAxis: topAxis,
68
73
  leftAxis: leftAxis,
69
74
  rightAxis: rightAxis,
70
- bottomAxis: bottomAxis
71
- }), /*#__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({
72
82
  x: "band"
73
- }, 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, {
74
87
  id: clipPathId
75
88
  }), children]
76
89
  });
@@ -98,8 +111,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
98
111
  label: PropTypes.string,
99
112
  labelFontSize: PropTypes.number,
100
113
  position: PropTypes.oneOf(['bottom', 'top']),
114
+ slotProps: PropTypes.object,
115
+ slots: PropTypes.object,
101
116
  stroke: PropTypes.string,
102
117
  tickFontSize: PropTypes.number,
118
+ tickMaxStep: PropTypes.number,
119
+ tickMinStep: PropTypes.number,
120
+ tickNumber: PropTypes.number,
103
121
  tickSize: PropTypes.number
104
122
  }), PropTypes.string]),
105
123
  children: PropTypes.node,
@@ -126,8 +144,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
126
144
  label: PropTypes.string,
127
145
  labelFontSize: PropTypes.number,
128
146
  position: PropTypes.oneOf(['left', 'right']),
147
+ slotProps: PropTypes.object,
148
+ slots: PropTypes.object,
129
149
  stroke: PropTypes.string,
130
150
  tickFontSize: PropTypes.number,
151
+ tickMaxStep: PropTypes.number,
152
+ tickMinStep: PropTypes.number,
153
+ tickNumber: PropTypes.number,
131
154
  tickSize: PropTypes.number
132
155
  }), PropTypes.string]),
133
156
  legend: PropTypes.shape({
@@ -144,6 +167,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
144
167
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
145
168
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
146
169
  }),
170
+ slotProps: PropTypes.object,
171
+ slots: PropTypes.object,
147
172
  spacing: PropTypes.number
148
173
  }),
149
174
  margin: PropTypes.shape({
@@ -166,8 +191,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
166
191
  label: PropTypes.string,
167
192
  labelFontSize: PropTypes.number,
168
193
  position: PropTypes.oneOf(['left', 'right']),
194
+ slotProps: PropTypes.object,
195
+ slots: PropTypes.object,
169
196
  stroke: PropTypes.string,
170
197
  tickFontSize: PropTypes.number,
198
+ tickMaxStep: PropTypes.number,
199
+ tickMinStep: PropTypes.number,
200
+ tickNumber: PropTypes.number,
171
201
  tickSize: PropTypes.number
172
202
  }), PropTypes.string]),
173
203
  series: PropTypes.arrayOf(PropTypes.shape({
@@ -188,6 +218,16 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
188
218
  xAxisKey: PropTypes.string,
189
219
  yAxisKey: PropTypes.string
190
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,
191
231
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
192
232
  title: PropTypes.string,
193
233
  tooltip: PropTypes.shape({
@@ -210,8 +250,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
210
250
  label: PropTypes.string,
211
251
  labelFontSize: PropTypes.number,
212
252
  position: PropTypes.oneOf(['bottom', 'top']),
253
+ slotProps: PropTypes.object,
254
+ slots: PropTypes.object,
213
255
  stroke: PropTypes.string,
214
256
  tickFontSize: PropTypes.number,
257
+ tickMaxStep: PropTypes.number,
258
+ tickMinStep: PropTypes.number,
259
+ tickNumber: PropTypes.number,
215
260
  tickSize: PropTypes.number
216
261
  }), PropTypes.string]),
217
262
  viewBox: PropTypes.shape({
@@ -234,15 +279,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
234
279
  label: PropTypes.string,
235
280
  labelFontSize: PropTypes.number,
236
281
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
237
- maxTicks: PropTypes.number,
238
282
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
239
- minTicks: PropTypes.number,
240
283
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
241
284
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
285
+ slotProps: PropTypes.object,
286
+ slots: PropTypes.object,
242
287
  stroke: PropTypes.string,
243
288
  tickFontSize: PropTypes.number,
289
+ tickMaxStep: PropTypes.number,
290
+ tickMinStep: PropTypes.number,
291
+ tickNumber: PropTypes.number,
244
292
  tickSize: PropTypes.number,
245
- tickSpacing: PropTypes.number,
246
293
  valueFormatter: PropTypes.func
247
294
  })),
248
295
  yAxis: PropTypes.arrayOf(PropTypes.shape({
@@ -258,15 +305,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
258
305
  label: PropTypes.string,
259
306
  labelFontSize: PropTypes.number,
260
307
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
261
- maxTicks: PropTypes.number,
262
308
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
263
- minTicks: PropTypes.number,
264
309
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
265
310
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
311
+ slotProps: PropTypes.object,
312
+ slots: PropTypes.object,
266
313
  stroke: PropTypes.string,
267
314
  tickFontSize: PropTypes.number,
315
+ tickMaxStep: PropTypes.number,
316
+ tickMinStep: PropTypes.number,
317
+ tickNumber: PropTypes.number,
268
318
  tickSize: PropTypes.number,
269
- tickSpacing: PropTypes.number,
270
319
  valueFormatter: PropTypes.func
271
320
  }))
272
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 };
@@ -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;
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import { useSlotProps } from '@mui/base/utils';
3
4
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
5
  import { useThemeProps, useTheme, styled } from '@mui/material/styles';
5
6
  import { DrawingContext } from '../context/DrawingProvider';
@@ -123,7 +124,7 @@ export var ChartsLegendLabel = styled('text', {
123
124
  color: 'inherit',
124
125
  transform: "translate(\n calc(var(--ChartsLegend-itemMarkSize) + var(--ChartsLegend-labelSpacing)),\n calc(0.5 * var(--ChartsLegend-itemMarkSize))\n )",
125
126
  fill: theme.palette.text.primary,
126
- alignmentBaseline: 'central'
127
+ dominantBaseline: 'central'
127
128
  });
128
129
  });
129
130
  var defaultProps = {
@@ -136,25 +137,18 @@ var defaultProps = {
136
137
  itemWidth: 100,
137
138
  spacing: 2
138
139
  };
139
- export function ChartsLegend(inProps) {
140
- var props = useThemeProps({
141
- props: _extends({}, defaultProps, inProps),
142
- name: 'MuiChartsLegend'
143
- });
144
- var position = props.position,
140
+ function DefaultChartsLegend(props) {
141
+ var hidden = props.hidden,
142
+ position = props.position,
145
143
  direction = props.direction,
146
144
  offset = props.offset,
147
- hidden = props.hidden;
148
- var theme = useTheme();
149
- var classes = useUtilityClasses(_extends({}, props, {
150
- theme: theme
151
- }));
152
- var drawingArea = React.useContext(DrawingContext);
153
- var series = React.useContext(SeriesContext);
145
+ series = props.series,
146
+ seriesToDisplay = props.seriesToDisplay,
147
+ drawingArea = props.drawingArea,
148
+ classes = props.classes;
154
149
  if (hidden) {
155
150
  return null;
156
151
  }
157
- var seriesToDisplay = getSeriesToDisplay(series);
158
152
  return /*#__PURE__*/_jsx(ChartsLegendRoot, {
159
153
  ownerState: {
160
154
  direction: direction,
@@ -187,4 +181,41 @@ export function ChartsLegend(inProps) {
187
181
  }, id);
188
182
  })
189
183
  });
184
+ }
185
+ export function ChartsLegend(inProps) {
186
+ var _slots$legend;
187
+ var props = useThemeProps({
188
+ props: _extends({}, defaultProps, inProps),
189
+ name: 'MuiChartsLegend'
190
+ });
191
+ var position = props.position,
192
+ direction = props.direction,
193
+ offset = props.offset,
194
+ hidden = props.hidden,
195
+ slots = props.slots,
196
+ slotProps = props.slotProps;
197
+ var theme = useTheme();
198
+ var classes = useUtilityClasses(_extends({}, props, {
199
+ theme: theme
200
+ }));
201
+ var drawingArea = React.useContext(DrawingContext);
202
+ var series = React.useContext(SeriesContext);
203
+ var seriesToDisplay = getSeriesToDisplay(series);
204
+ var ChartLegendRender = (_slots$legend = slots == null ? void 0 : slots.legend) != null ? _slots$legend : DefaultChartsLegend;
205
+ var chartLegendRenderProps = useSlotProps({
206
+ elementType: ChartLegendRender,
207
+ externalSlotProps: slotProps == null ? void 0 : slotProps.legend,
208
+ additionalProps: {
209
+ position: position,
210
+ direction: direction,
211
+ offset: offset,
212
+ classes: classes,
213
+ drawingArea: drawingArea,
214
+ series: series,
215
+ hidden: hidden,
216
+ seriesToDisplay: seriesToDisplay
217
+ },
218
+ ownerState: {}
219
+ });
220
+ return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
190
221
  }