@mui/x-charts 6.0.0-alpha.13 → 6.0.0-alpha.15

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 (139) hide show
  1. package/BarChart/BarChart.d.ts +6 -3
  2. package/BarChart/BarChart.js +7 -10
  3. package/BarChart/BarElement.js +2 -4
  4. package/BarChart/formatter.js +1 -2
  5. package/BarChart/legend.js +1 -2
  6. package/CHANGELOG.md +165 -1
  7. package/ChartContainer/index.js +2 -3
  8. package/ChartsAxis/axisClasses.js +1 -2
  9. package/ChartsLegend/ChartsLegend.d.ts +43 -24
  10. package/ChartsLegend/ChartsLegend.js +186 -148
  11. package/ChartsLegend/chartsLegendClasses.js +1 -2
  12. package/ChartsLegend/utils.d.ts +1 -6
  13. package/ChartsSurface.js +5 -14
  14. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
  15. package/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  16. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
  17. package/ChartsTooltip/ChartsItemTooltipContent.js +16 -6
  18. package/ChartsTooltip/ChartsTooltip.d.ts +23 -0
  19. package/ChartsTooltip/ChartsTooltip.js +47 -13
  20. package/ChartsTooltip/ChartsTooltipTable.js +6 -11
  21. package/ChartsTooltip/tooltipClasses.js +1 -2
  22. package/ChartsXAxis/ChartsXAxis.js +48 -25
  23. package/ChartsYAxis/ChartsYAxis.js +47 -26
  24. package/LineChart/AreaElement.js +2 -4
  25. package/LineChart/LineChart.d.ts +6 -3
  26. package/LineChart/LineChart.js +11 -11
  27. package/LineChart/LineElement.js +2 -4
  28. package/LineChart/LineHighlightElement.js +1 -2
  29. package/LineChart/MarkElement.js +1 -2
  30. package/LineChart/formatter.js +1 -2
  31. package/LineChart/legend.js +1 -2
  32. package/PieChart/PieArc.d.ts +1 -0
  33. package/PieChart/PieArc.js +6 -4
  34. package/PieChart/PieArcLabel.js +1 -2
  35. package/PieChart/PieChart.d.ts +8 -4
  36. package/PieChart/PieChart.js +11 -10
  37. package/PieChart/PiePlot.d.ts +8 -0
  38. package/PieChart/PiePlot.js +21 -5
  39. package/PieChart/formatter.js +1 -2
  40. package/PieChart/legend.js +1 -2
  41. package/ResponsiveChartContainer/index.js +2 -3
  42. package/ScatterChart/ScatterChart.d.ts +6 -3
  43. package/ScatterChart/ScatterChart.js +7 -10
  44. package/ScatterChart/formatter.js +1 -2
  45. package/ScatterChart/legend.js +1 -2
  46. package/SparkLineChart/SparkLineChart.d.ts +3 -3
  47. package/SparkLineChart/SparkLineChart.js +7 -3
  48. package/colorPalettes/colorPalettes.js +6 -12
  49. package/constants.js +5 -8
  50. package/context/CartesianContextProvider.js +11 -12
  51. package/context/DrawingProvider.d.ts +2 -0
  52. package/context/DrawingProvider.js +4 -4
  53. package/context/HighlightProvider.js +1 -2
  54. package/context/InteractionProvider.js +1 -2
  55. package/context/SeriesContextProvider.js +1 -2
  56. package/esm/BarChart/BarChart.js +6 -8
  57. package/esm/ChartsLegend/ChartsLegend.js +184 -142
  58. package/esm/ChartsSurface.js +3 -11
  59. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  60. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
  61. package/esm/ChartsTooltip/ChartsTooltip.js +47 -12
  62. package/esm/ChartsXAxis/ChartsXAxis.js +47 -24
  63. package/esm/ChartsYAxis/ChartsYAxis.js +46 -25
  64. package/esm/LineChart/LineChart.js +10 -9
  65. package/esm/PieChart/PieArc.js +5 -2
  66. package/esm/PieChart/PieChart.js +11 -10
  67. package/esm/PieChart/PiePlot.js +17 -2
  68. package/esm/ScatterChart/ScatterChart.js +6 -8
  69. package/esm/SparkLineChart/SparkLineChart.js +6 -1
  70. package/esm/constants.js +1 -1
  71. package/esm/context/CartesianContextProvider.js +11 -11
  72. package/esm/context/DrawingProvider.js +2 -0
  73. package/esm/hooks/useChartDimensions.js +2 -0
  74. package/esm/hooks/useTicks.js +5 -5
  75. package/esm/internals/components/AxisSharedComponents.js +15 -70
  76. package/esm/internals/components/ChartsText.js +71 -0
  77. package/esm/internals/domUtils.js +113 -0
  78. package/hooks/useChartDimensions.d.ts +2 -0
  79. package/hooks/useChartDimensions.js +3 -2
  80. package/hooks/useTicks.d.ts +2 -3
  81. package/hooks/useTicks.js +7 -8
  82. package/index.js +1 -1
  83. package/internals/components/AxisSharedComponents.d.ts +0 -4
  84. package/internals/components/AxisSharedComponents.js +18 -78
  85. package/internals/components/ChartsText.d.ts +32 -0
  86. package/internals/components/ChartsText.js +81 -0
  87. package/internals/defaultizeValueFormatter.js +1 -2
  88. package/internals/domUtils.d.ts +14 -0
  89. package/internals/domUtils.js +122 -0
  90. package/internals/stackSeries.js +2 -4
  91. package/legacy/BarChart/BarChart.js +6 -8
  92. package/legacy/ChartsLegend/ChartsLegend.js +196 -140
  93. package/legacy/ChartsSurface.js +2 -11
  94. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  95. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
  96. package/legacy/ChartsTooltip/ChartsTooltip.js +50 -12
  97. package/legacy/ChartsXAxis/ChartsXAxis.js +47 -24
  98. package/legacy/ChartsYAxis/ChartsYAxis.js +46 -25
  99. package/legacy/LineChart/LineChart.js +10 -9
  100. package/legacy/PieChart/PieArc.js +4 -1
  101. package/legacy/PieChart/PieChart.js +11 -10
  102. package/legacy/PieChart/PiePlot.js +17 -2
  103. package/legacy/ScatterChart/ScatterChart.js +6 -8
  104. package/legacy/SparkLineChart/SparkLineChart.js +6 -1
  105. package/legacy/constants.js +1 -1
  106. package/legacy/context/CartesianContextProvider.js +11 -11
  107. package/legacy/context/DrawingProvider.js +2 -0
  108. package/legacy/hooks/useChartDimensions.js +2 -0
  109. package/legacy/hooks/useTicks.js +5 -5
  110. package/legacy/index.js +1 -1
  111. package/legacy/internals/components/AxisSharedComponents.js +9 -63
  112. package/legacy/internals/components/ChartsText.js +77 -0
  113. package/legacy/internals/domUtils.js +121 -0
  114. package/models/axis.d.ts +6 -5
  115. package/models/layout.d.ts +7 -6
  116. package/modern/BarChart/BarChart.js +6 -8
  117. package/modern/ChartsLegend/ChartsLegend.js +184 -142
  118. package/modern/ChartsSurface.js +3 -11
  119. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  120. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
  121. package/modern/ChartsTooltip/ChartsTooltip.js +46 -12
  122. package/modern/ChartsXAxis/ChartsXAxis.js +47 -24
  123. package/modern/ChartsYAxis/ChartsYAxis.js +46 -25
  124. package/modern/LineChart/LineChart.js +10 -9
  125. package/modern/PieChart/PieArc.js +5 -2
  126. package/modern/PieChart/PieChart.js +11 -10
  127. package/modern/PieChart/PiePlot.js +17 -2
  128. package/modern/ScatterChart/ScatterChart.js +6 -8
  129. package/modern/SparkLineChart/SparkLineChart.js +6 -1
  130. package/modern/constants.js +1 -1
  131. package/modern/context/CartesianContextProvider.js +11 -11
  132. package/modern/context/DrawingProvider.js +2 -0
  133. package/modern/hooks/useChartDimensions.js +2 -0
  134. package/modern/hooks/useTicks.js +5 -5
  135. package/modern/index.js +1 -1
  136. package/modern/internals/components/AxisSharedComponents.js +15 -70
  137. package/modern/internals/components/ChartsText.js +71 -0
  138. package/modern/internals/domUtils.js +113 -0
  139. package/package.json +3 -3
@@ -1,12 +1,16 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
1
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["label"];
2
4
  import * as React from 'react';
3
5
  import { useSlotProps } from '@mui/base/utils';
6
+ import { NoSsr } from '@mui/base/NoSsr';
4
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
5
8
  import { useThemeProps, useTheme, styled } from '@mui/material/styles';
6
9
  import { DrawingContext } from '../context/DrawingProvider';
7
10
  import { getSeriesToDisplay } from './utils';
8
11
  import { SeriesContext } from '../context/SeriesContextProvider';
9
12
  import { getChartsLegendUtilityClass } from './chartsLegendClasses';
13
+ import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
10
14
  import { jsx as _jsx } from "react/jsx-runtime";
11
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
16
  const useUtilityClasses = ownerState => {
@@ -22,167 +26,207 @@ const useUtilityClasses = ownerState => {
22
26
  };
23
27
  return composeClasses(slots, getChartsLegendUtilityClass, classes);
24
28
  };
25
- function getTranslePosition({
26
- position,
27
- drawingArea
28
- }) {
29
- let xValue;
30
- switch (position.horizontal) {
31
- case 'left':
32
- xValue = `calc(var(--ChartsLegend-rootOffsetX, 0px) + ${drawingArea.left}px - var(--ChartsLegend-rootWidth))`;
33
- break;
34
- case 'middle':
35
- xValue = `calc(var(--ChartsLegend-rootOffsetX, 0px) + ${drawingArea.left + drawingArea.width / 2}px - 0.5 * var(--ChartsLegend-rootWidth))`;
36
- break;
37
- default:
38
- xValue = `calc(var(--ChartsLegend-rootOffsetX, 0px) + ${drawingArea.left + drawingArea.width}px)`;
39
- break;
40
- }
41
- let yValue;
42
- switch (position.vertical) {
43
- case 'top':
44
- yValue = `calc(var(--ChartsLegend-rootOffsetY, 0px) + ${drawingArea.top}px - var(--ChartsLegend-rootHeight))`;
45
- break;
46
- case 'middle':
47
- yValue = `calc(var(--ChartsLegend-rootOffsetY, 0px) + ${drawingArea.top + drawingArea.height / 2}px - 0.5 * var(--ChartsLegend-rootHeight))`;
48
- break;
49
- default:
50
- yValue = `calc(var(--ChartsLegend-rootOffsetY, 0px) + ${drawingArea.top + drawingArea.height}px)`;
51
- break;
52
- }
53
- return {
54
- transform: `translate(${xValue}, ${yValue})`
55
- };
56
- }
57
29
  export const ChartsLegendRoot = styled('g', {
58
30
  name: 'MuiChartsLegend',
59
31
  slot: 'Root',
60
32
  overridesResolver: (props, styles) => styles.root
61
- })(({
62
- ownerState
63
- }) => {
64
- const {
65
- direction,
66
- drawingArea,
67
- offsetX,
68
- offsetY,
69
- seriesNumber,
70
- position
71
- } = ownerState;
72
- return _extends({
73
- '--ChartsLegend-rootOffsetX': typeof offsetX === 'number' ? `${offsetX}px` : undefined,
74
- '--ChartsLegend-rootOffsetY': typeof offsetY === 'number' ? `${offsetY}px` : undefined,
75
- '--ChartsLegend-rootWidth': direction === 'row' ? `calc(var(--ChartsLegend-itemWidth) * ${seriesNumber} + var(--ChartsLegend-rootSpacing) * ${seriesNumber - 1} )` : 'var(--ChartsLegend-itemWidth)',
76
- '--ChartsLegend-rootHeight': direction === 'row' ? 'var(--ChartsLegend-itemMarkSize)' : `calc(var(--ChartsLegend-itemMarkSize) * ${seriesNumber} + var(--ChartsLegend-rootSpacing) * ${seriesNumber - 1} )`
77
- }, getTranslePosition({
78
- position,
79
- drawingArea,
80
- offsetX,
81
- offsetY
82
- }));
83
- });
84
- export const ChartsSeriesLegendGroup = styled('g', {
85
- name: 'MuiChartsLegend',
86
- slot: 'ChartsSeriesLegendGroup',
87
- overridesResolver: (props, styles) => styles.series
88
- })(({
89
- ownerState
90
- }) => {
91
- const {
92
- direction,
93
- seriesIndex
94
- } = ownerState;
95
- if (direction === 'row') {
96
- return {
97
- transform: `translate(calc(${seriesIndex} * (var(--ChartsLegend-itemWidth) + var(--ChartsLegend-rootSpacing))), 0)`
98
- };
99
- }
100
- return {
101
- transform: `translate(0, calc(${seriesIndex} * (var(--ChartsLegend-itemMarkSize) + var(--ChartsLegend-rootSpacing))))`
102
- };
103
- });
104
- export const ChartsLegendMark = styled('rect', {
105
- name: 'MuiChartsLegend',
106
- slot: 'Mark',
107
- overridesResolver: (props, styles) => styles.mark
108
- })(({
109
- ownerState
110
- }) => ({
111
- x: 0,
112
- y: 0,
113
- width: 'var(--ChartsLegend-itemMarkSize)',
114
- height: 'var(--ChartsLegend-itemMarkSize)',
115
- fill: ownerState.color
116
- }));
117
- export const ChartsLegendLabel = styled('text', {
118
- name: 'MuiChartsLegend',
119
- slot: 'Label',
120
- overridesResolver: (props, styles) => styles.label
121
- })(({
122
- theme
123
- }) => _extends({}, theme.typography.body1, {
124
- color: 'inherit',
125
- transform: `translate(
126
- calc(var(--ChartsLegend-itemMarkSize) + var(--ChartsLegend-labelSpacing)),
127
- calc(0.5 * var(--ChartsLegend-itemMarkSize))
128
- )`,
129
- fill: (theme.vars || theme).palette.text.primary,
130
- dominantBaseline: 'central'
131
- }));
33
+ })({});
132
34
  const defaultProps = {
133
35
  position: {
134
36
  horizontal: 'middle',
135
37
  vertical: 'top'
136
38
  },
137
- direction: 'row',
138
- markSize: 20,
139
- itemWidth: 100,
140
- spacing: 2
39
+ direction: 'row'
40
+ };
41
+ /**
42
+ * Transforms number or partial padding object to a defaultized padding object.
43
+ */
44
+ const getStandardizedPadding = padding => {
45
+ if (typeof padding === 'number') {
46
+ return {
47
+ left: padding,
48
+ right: padding,
49
+ top: padding,
50
+ bottom: padding
51
+ };
52
+ }
53
+ return _extends({
54
+ left: 0,
55
+ right: 0,
56
+ top: 0,
57
+ bottom: 0
58
+ }, padding);
141
59
  };
142
60
  function DefaultChartsLegend(props) {
143
61
  const {
144
62
  hidden,
145
63
  position,
146
64
  direction,
147
- offset,
148
- series,
149
65
  seriesToDisplay,
150
66
  drawingArea,
151
- classes
67
+ classes,
68
+ itemMarkWidth = 20,
69
+ itemMarkHeight = 20,
70
+ markGap = 5,
71
+ itemGap = 10,
72
+ padding: paddingProps = 10,
73
+ labelStyle: inLabelStyle
152
74
  } = props;
75
+ const theme = useTheme();
76
+ const labelStyle = React.useMemo(() => _extends({}, theme.typography.subtitle1, {
77
+ color: 'inherit',
78
+ fill: (theme.vars || theme).palette.text.primary,
79
+ lineHeight: 1
80
+ }, inLabelStyle), [inLabelStyle, theme]);
81
+ const padding = React.useMemo(() => getStandardizedPadding(paddingProps), [paddingProps]);
82
+ const getItemSpace = React.useCallback((label, style) => {
83
+ const linesSize = getWordsByLines({
84
+ style,
85
+ needsComputation: true,
86
+ text: label
87
+ });
88
+ const innerSize = {
89
+ innerWidth: itemMarkWidth + markGap + Math.max(...linesSize.map(size => size.width)),
90
+ innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
91
+ };
92
+ return _extends({}, innerSize, {
93
+ outerWidth: innerSize.innerWidth + itemGap,
94
+ outerHeight: innerSize.innerHeight + itemGap
95
+ });
96
+ }, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
97
+ const totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
98
+ const totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
99
+ const availableWidth = totalWidth - padding.left - padding.right;
100
+ const availableHeight = totalHeight - padding.top - padding.bottom;
101
+ const seriesWithPosition = React.useMemo(() => {
102
+ // Start at 0, 0. Will be modified later by padding and position.
103
+ let x = 0;
104
+ let y = 0;
105
+
106
+ // total values used to align legend later.
107
+ let totalWidthUsed = 0;
108
+ let totalHeightUsed = 0;
109
+ let rowIndex = 0;
110
+ const rowMaxHeight = [0];
111
+ const seriesWithRawPosition = seriesToDisplay.map(_ref => {
112
+ let {
113
+ label
114
+ } = _ref,
115
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
116
+ const itemSpace = getItemSpace(label, labelStyle);
117
+ const rep = _extends({}, other, {
118
+ label,
119
+ positionX: x,
120
+ positionY: y,
121
+ innerHeight: itemSpace.innerHeight,
122
+ innerWidth: itemSpace.innerWidth,
123
+ outerHeight: itemSpace.outerHeight,
124
+ outerWidth: itemSpace.outerWidth,
125
+ rowIndex
126
+ });
127
+ if (direction === 'row') {
128
+ if (x + itemSpace.innerWidth > availableWidth) {
129
+ // This legend item would create overflow along the x-axis, so we start a new row.
130
+ x = 0;
131
+ y += rowMaxHeight[rowIndex];
132
+ rowIndex += 1;
133
+ if (rowMaxHeight.length <= rowIndex) {
134
+ rowMaxHeight.push(0);
135
+ }
136
+ rep.positionX = x;
137
+ rep.positionY = y;
138
+ rep.rowIndex = rowIndex;
139
+ }
140
+ totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
141
+ totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
142
+ rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
143
+ x += itemSpace.outerWidth;
144
+ }
145
+ if (direction === 'column') {
146
+ if (y + itemSpace.innerHeight > availableHeight) {
147
+ // This legend item would create overflow along the y-axis, so we start a new column.
148
+ x = totalWidthUsed + itemGap;
149
+ y = 0;
150
+ rowIndex = 0;
151
+ rep.positionX = x;
152
+ rep.positionY = y;
153
+ rep.rowIndex = rowIndex;
154
+ }
155
+ if (rowMaxHeight.length <= rowIndex) {
156
+ rowMaxHeight.push(0);
157
+ }
158
+ totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
159
+ totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
160
+ rowIndex += 1;
161
+ y += itemSpace.outerHeight;
162
+ }
163
+ return rep;
164
+ });
165
+
166
+ // Move the legend according to padding and position
167
+ let gapX = 0;
168
+ let gapY = 0;
169
+ switch (position.horizontal) {
170
+ case 'left':
171
+ gapX = padding.left;
172
+ break;
173
+ case 'right':
174
+ gapX = totalWidth - padding.right - totalWidthUsed;
175
+ break;
176
+ default:
177
+ gapX = (totalWidth - totalWidthUsed) / 2;
178
+ break;
179
+ }
180
+ switch (position.vertical) {
181
+ case 'top':
182
+ gapY = padding.top;
183
+ break;
184
+ case 'bottom':
185
+ gapY = totalHeight - padding.bottom - totalHeightUsed;
186
+ break;
187
+ default:
188
+ gapY = (totalHeight - totalHeightUsed) / 2;
189
+ break;
190
+ }
191
+ return seriesWithRawPosition.map(item => _extends({}, item, {
192
+ // Add the gap due to the position
193
+ positionX: item.positionX + gapX,
194
+ // Add the gap due to the position
195
+ positionY: item.positionY + gapY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
196
+ : item.outerHeight / 2) // Get the center of the item
197
+ }));
198
+ }, [seriesToDisplay, position.horizontal, position.vertical, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap, padding.left, padding.right, padding.top, padding.bottom, totalWidth, totalHeight]);
153
199
  if (hidden) {
154
200
  return null;
155
201
  }
156
- return /*#__PURE__*/_jsx(ChartsLegendRoot, {
157
- ownerState: {
158
- direction,
159
- offsetX: offset?.x,
160
- offsetY: offset?.y,
161
- seriesNumber: seriesToDisplay.length,
162
- position,
163
- drawingArea
164
- },
165
- className: classes.root,
166
- children: seriesToDisplay.map(({
167
- id,
168
- label,
169
- color
170
- }, seriesIndex) => /*#__PURE__*/_jsxs(ChartsSeriesLegendGroup, {
171
- ownerState: _extends({
172
- direction,
173
- seriesIndex
174
- }, series),
175
- className: classes.series,
176
- children: [/*#__PURE__*/_jsx(ChartsLegendMark, {
177
- ownerState: {
178
- color
179
- },
180
- className: classes.mark
181
- }), /*#__PURE__*/_jsx(ChartsLegendLabel, {
182
- className: classes.label,
183
- children: label
184
- })]
185
- }, id))
202
+ return /*#__PURE__*/_jsx(NoSsr, {
203
+ children: /*#__PURE__*/_jsx(ChartsLegendRoot, {
204
+ className: classes.root,
205
+ children: seriesWithPosition.map(({
206
+ id,
207
+ label,
208
+ color,
209
+ positionX,
210
+ positionY
211
+ }) => /*#__PURE__*/_jsxs("g", {
212
+ className: classes.series,
213
+ transform: `translate(${positionX} ${positionY})`,
214
+ children: [/*#__PURE__*/_jsx("rect", {
215
+ className: classes.mark,
216
+ y: -itemMarkHeight / 2,
217
+ width: itemMarkWidth,
218
+ height: itemMarkHeight,
219
+ fill: color
220
+ }), /*#__PURE__*/_jsx(ChartsText, {
221
+ style: labelStyle,
222
+ dominantBaseline: "central",
223
+ textAnchor: "start",
224
+ text: label,
225
+ x: itemMarkWidth + markGap,
226
+ y: 0
227
+ })]
228
+ }, id))
229
+ })
186
230
  });
187
231
  }
188
232
  export function ChartsLegend(inProps) {
@@ -193,7 +237,6 @@ export function ChartsLegend(inProps) {
193
237
  const {
194
238
  position,
195
239
  direction,
196
- offset,
197
240
  hidden,
198
241
  slots,
199
242
  slotProps
@@ -212,7 +255,6 @@ export function ChartsLegend(inProps) {
212
255
  additionalProps: {
213
256
  position,
214
257
  direction,
215
- offset,
216
258
  classes,
217
259
  drawingArea,
218
260
  series,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className", "sx"];
3
+ const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
4
4
  import { styled } from '@mui/material/styles';
5
5
  import * as React from 'react';
6
6
  import { useAxisEvents } from './hooks/useAxisEvents';
@@ -16,8 +16,7 @@ export const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurfac
16
16
  width,
17
17
  height,
18
18
  viewBox,
19
- disableAxisListener = false,
20
- sx
19
+ disableAxisListener = false
21
20
  } = props,
22
21
  other = _objectWithoutPropertiesLoose(props, _excluded);
23
22
  const svgView = _extends({
@@ -31,14 +30,7 @@ export const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurfac
31
30
  width: width,
32
31
  height: height,
33
32
  viewBox: `${svgView.x} ${svgView.y} ${svgView.width} ${svgView.height}`,
34
- ref: ref,
35
- sx: [{
36
- '--ChartsLegend-itemWidth': '100px',
37
- '--ChartsLegend-itemMarkSize': '20px',
38
- '--ChartsLegend-rootSpacing': '5px',
39
- '--ChartsLegend-labelSpacing': '5px',
40
- '--ChartsLegend-rootOffsetY': '-20px'
41
- }, ...(Array.isArray(sx) ? sx : [sx])]
33
+ ref: ref
42
34
  }, other, {
43
35
  children: [/*#__PURE__*/_jsx("title", {
44
36
  children: props.title
@@ -1,5 +1,7 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import Typography from '@mui/material/Typography';
4
+ import { useSlotProps } from '@mui/base/utils';
3
5
  import { SeriesContext } from '../context/SeriesContextProvider';
4
6
  import { CartesianContext } from '../context/CartesianContextProvider';
5
7
  import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
@@ -66,6 +68,7 @@ export function DefaultChartsAxisContent(props) {
66
68
  export function ChartsAxisTooltipContent(props) {
67
69
  const {
68
70
  content,
71
+ contentProps,
69
72
  axisData,
70
73
  sx,
71
74
  classes
@@ -98,13 +101,19 @@ export function ChartsAxisTooltipContent(props) {
98
101
  return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
99
102
  }, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
100
103
  const Content = content ?? DefaultChartsAxisContent;
101
- return /*#__PURE__*/_jsx(Content, {
102
- axisData: axisData,
103
- series: relevantSeries,
104
- axis: relevantAxis,
105
- dataIndex: dataIndex,
106
- axisValue: axisValue,
107
- sx: sx,
108
- classes: classes
104
+ const chartTooltipContentProps = useSlotProps({
105
+ elementType: Content,
106
+ externalSlotProps: contentProps,
107
+ additionalProps: {
108
+ axisData,
109
+ series: relevantSeries,
110
+ axis: relevantAxis,
111
+ dataIndex,
112
+ axisValue,
113
+ sx,
114
+ classes
115
+ },
116
+ ownerState: {}
109
117
  });
118
+ return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
110
119
  }
@@ -1,4 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
3
+ import { useSlotProps } from '@mui/base/utils';
2
4
  import { SeriesContext } from '../context/SeriesContextProvider';
3
5
  import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -57,14 +59,21 @@ export function ChartsItemTooltipContent(props) {
57
59
  content,
58
60
  itemData,
59
61
  sx,
60
- classes
62
+ classes,
63
+ contentProps
61
64
  } = props;
62
65
  const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
63
66
  const Content = content ?? DefaultChartsItemContent;
64
- return /*#__PURE__*/_jsx(Content, {
65
- itemData: itemData,
66
- series: series,
67
- sx: sx,
68
- classes: classes
67
+ const chartTooltipContentProps = useSlotProps({
68
+ elementType: Content,
69
+ externalSlotProps: contentProps,
70
+ additionalProps: {
71
+ itemData,
72
+ series,
73
+ sx,
74
+ classes
75
+ },
76
+ ownerState: {}
69
77
  });
78
+ return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
70
79
  }
@@ -1,8 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import PropTypes from 'prop-types';
3
- import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
+ import composeClasses from '@mui/utils/composeClasses';
5
+ import { styled } from '@mui/material/styles';
4
6
  import { Popper } from '@mui/base/Popper';
5
7
  import { NoSsr } from '@mui/base/NoSsr';
8
+ import { useSlotProps } from '@mui/base/utils';
6
9
  import { InteractionContext } from '../context/InteractionProvider';
7
10
  import { generateVirtualElement, useMouseTracker, getTootipHasData } from './utils';
8
11
  import { ChartsItemTooltipContent } from './ChartsItemTooltipContent';
@@ -21,11 +24,23 @@ const useUtilityClasses = ownerState => {
21
24
  };
22
25
  return composeClasses(slots, getTooltipUtilityClass, classes);
23
26
  };
27
+ const ChartsTooltipRoot = styled(Popper, {
28
+ name: 'MuiChartsTooltip',
29
+ slot: 'Root',
30
+ overridesResolver: (_, styles) => styles.root
31
+ })(({
32
+ theme
33
+ }) => ({
34
+ pointerEvents: 'none',
35
+ zIndex: theme.zIndex.modal
36
+ }));
24
37
  function ChartsTooltip(props) {
25
38
  const {
26
39
  trigger = 'axis',
27
40
  itemContent,
28
- axisContent
41
+ axisContent,
42
+ slots,
43
+ slotProps
29
44
  } = props;
30
45
  const mousePosition = useMouseTracker();
31
46
  const {
@@ -38,33 +53,40 @@ function ChartsTooltip(props) {
38
53
  const classes = useUtilityClasses({
39
54
  classes: props.classes
40
55
  });
56
+ const PopperComponent = slots?.popper ?? ChartsTooltipRoot;
57
+ const popperProps = useSlotProps({
58
+ elementType: PopperComponent,
59
+ externalSlotProps: slotProps?.popper,
60
+ additionalProps: {
61
+ open: popperOpen,
62
+ placement: 'right-start',
63
+ anchorEl: generateVirtualElement(mousePosition)
64
+ },
65
+ ownerState: {}
66
+ });
41
67
  if (trigger === 'none') {
42
68
  return null;
43
69
  }
44
70
  return /*#__PURE__*/_jsx(NoSsr, {
45
- children: popperOpen && /*#__PURE__*/_jsx(Popper, {
46
- open: popperOpen,
47
- placement: "right-start",
48
- anchorEl: generateVirtualElement(mousePosition),
49
- style: {
50
- pointerEvents: 'none'
51
- },
71
+ children: popperOpen && /*#__PURE__*/_jsx(PopperComponent, _extends({}, popperProps, {
52
72
  children: trigger === 'item' ? /*#__PURE__*/_jsx(ChartsItemTooltipContent, {
53
73
  itemData: displayedData,
54
- content: itemContent,
74
+ content: slots?.itemContent ?? itemContent,
75
+ contentProps: slotProps?.itemContent,
55
76
  sx: {
56
77
  mx: 2
57
78
  },
58
79
  classes: classes
59
80
  }) : /*#__PURE__*/_jsx(ChartsAxisTooltipContent, {
60
81
  axisData: displayedData,
61
- content: axisContent,
82
+ content: slots?.axisContent ?? axisContent,
83
+ contentProps: slotProps?.axisContent,
62
84
  sx: {
63
85
  mx: 2
64
86
  },
65
87
  classes: classes
66
88
  })
67
- })
89
+ }))
68
90
  });
69
91
  }
70
92
  process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
@@ -74,6 +96,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
74
96
  // ----------------------------------------------------------------------
75
97
  /**
76
98
  * Component to override the tooltip content when triger is set to 'axis'.
99
+ * @deprecated Use slots.axisContent instead
77
100
  */
78
101
  axisContent: PropTypes.elementType,
79
102
  /**
@@ -82,8 +105,19 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
82
105
  classes: PropTypes.object,
83
106
  /**
84
107
  * Component to override the tooltip content when triger is set to 'item'.
108
+ * @deprecated Use slots.itemContent instead
85
109
  */
86
110
  itemContent: PropTypes.elementType,
111
+ /**
112
+ * The props used for each component slot.
113
+ * @default {}
114
+ */
115
+ slotProps: PropTypes.object,
116
+ /**
117
+ * Overridable component slots.
118
+ * @default {}
119
+ */
120
+ slots: PropTypes.object,
87
121
  /**
88
122
  * Select the kind of tooltip to display
89
123
  * - 'item': Shows data about the item below the mouse.