@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.
- package/BarChart/BarChart.d.ts +18 -2
- package/BarChart/BarChart.js +60 -11
- package/BarChart/BarElement.d.ts +22 -0
- package/BarChart/BarElement.js +21 -10
- package/BarChart/BarPlot.d.ts +14 -1
- package/BarChart/BarPlot.js +23 -4
- package/CHANGELOG.md +62 -0
- package/ChartsAxis/ChartsAxis.d.ts +11 -1
- package/ChartsAxis/ChartsAxis.js +51 -6
- package/ChartsLegend/ChartsLegend.d.ts +25 -2
- package/ChartsLegend/ChartsLegend.js +49 -17
- package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
- package/ChartsXAxis/ChartsXAxis.js +44 -9
- package/ChartsYAxis/ChartsYAxis.js +44 -9
- package/LineChart/AreaElement.d.ts +22 -0
- package/LineChart/AreaElement.js +31 -11
- package/LineChart/AreaPlot.d.ts +14 -1
- package/LineChart/AreaPlot.js +29 -3
- package/LineChart/LineChart.d.ts +20 -2
- package/LineChart/LineChart.js +62 -10
- package/LineChart/LineElement.d.ts +22 -0
- package/LineChart/LineElement.js +31 -10
- package/LineChart/LinePlot.d.ts +14 -1
- package/LineChart/LinePlot.js +35 -4
- package/LineChart/MarkPlot.d.ts +24 -1
- package/LineChart/MarkPlot.js +25 -3
- package/PieChart/PieArcLabel.js +0 -1
- package/PieChart/PieChart.d.ts +14 -2
- package/PieChart/PieChart.js +51 -9
- package/PieChart/PiePlot.d.ts +27 -1
- package/PieChart/PiePlot.js +29 -6
- package/ScatterChart/ScatterChart.d.ts +18 -2
- package/ScatterChart/ScatterChart.js +55 -9
- package/ScatterChart/ScatterPlot.d.ts +24 -1
- package/ScatterChart/ScatterPlot.js +28 -4
- package/SparkLineChart/SparkLineChart.d.ts +18 -0
- package/SparkLineChart/SparkLineChart.js +28 -5
- package/colorPalettes/colorPalettes.js +2 -2
- package/context/CartesianContextProvider.js +14 -8
- package/esm/BarChart/BarChart.js +60 -11
- package/esm/BarChart/BarElement.js +21 -11
- package/esm/BarChart/BarPlot.js +23 -4
- package/esm/ChartsAxis/ChartsAxis.js +51 -6
- package/esm/ChartsLegend/ChartsLegend.js +47 -14
- package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
- package/esm/LineChart/AreaElement.js +31 -11
- package/esm/LineChart/AreaPlot.js +31 -4
- package/esm/LineChart/LineChart.js +62 -10
- package/esm/LineChart/LineElement.js +31 -11
- package/esm/LineChart/LinePlot.js +43 -8
- package/esm/LineChart/MarkPlot.js +28 -4
- package/esm/PieChart/PieArcLabel.js +0 -1
- package/esm/PieChart/PieChart.js +51 -9
- package/esm/PieChart/PiePlot.js +31 -6
- package/esm/ScatterChart/ScatterChart.js +55 -9
- package/esm/ScatterChart/ScatterPlot.js +29 -4
- package/esm/SparkLineChart/SparkLineChart.js +28 -5
- package/esm/colorPalettes/colorPalettes.js +2 -2
- package/esm/context/CartesianContextProvider.js +14 -8
- package/esm/hooks/useTicks.js +9 -6
- package/esm/internals/components/AxisSharedComponents.js +10 -10
- package/hooks/useTicks.d.ts +20 -5
- package/hooks/useTicks.js +9 -6
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +4 -4
- package/internals/components/AxisSharedComponents.js +15 -15
- package/legacy/BarChart/BarChart.js +60 -11
- package/legacy/BarChart/BarElement.js +20 -10
- package/legacy/BarChart/BarPlot.js +23 -4
- package/legacy/ChartsAxis/ChartsAxis.js +51 -6
- package/legacy/ChartsLegend/ChartsLegend.js +46 -15
- package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
- package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
- package/legacy/LineChart/AreaElement.js +30 -10
- package/legacy/LineChart/AreaPlot.js +29 -4
- package/legacy/LineChart/LineChart.js +62 -10
- package/legacy/LineChart/LineElement.js +30 -10
- package/legacy/LineChart/LinePlot.js +36 -5
- package/legacy/LineChart/MarkPlot.js +26 -4
- package/legacy/PieChart/PieArcLabel.js +0 -1
- package/legacy/PieChart/PieChart.js +51 -9
- package/legacy/PieChart/PiePlot.js +29 -6
- package/legacy/ScatterChart/ScatterChart.js +55 -9
- package/legacy/ScatterChart/ScatterPlot.js +27 -4
- package/legacy/SparkLineChart/SparkLineChart.js +28 -5
- package/legacy/colorPalettes/colorPalettes.js +2 -2
- package/legacy/context/CartesianContextProvider.js +14 -8
- package/legacy/hooks/useTicks.js +9 -9
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +10 -10
- package/models/axis.d.ts +24 -1
- package/modern/BarChart/BarChart.js +60 -11
- package/modern/BarChart/BarElement.js +20 -11
- package/modern/BarChart/BarPlot.js +23 -4
- package/modern/ChartsAxis/ChartsAxis.js +51 -6
- package/modern/ChartsLegend/ChartsLegend.js +46 -14
- package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
- package/modern/LineChart/AreaElement.js +30 -11
- package/modern/LineChart/AreaPlot.js +31 -4
- package/modern/LineChart/LineChart.js +62 -10
- package/modern/LineChart/LineElement.js +30 -11
- package/modern/LineChart/LinePlot.js +37 -5
- package/modern/LineChart/MarkPlot.js +27 -4
- package/modern/PieChart/PieArcLabel.js +0 -1
- package/modern/PieChart/PieChart.js +51 -9
- package/modern/PieChart/PiePlot.js +30 -6
- package/modern/ScatterChart/ScatterChart.js +55 -9
- package/modern/ScatterChart/ScatterPlot.js +28 -4
- package/modern/SparkLineChart/SparkLineChart.js +28 -5
- package/modern/colorPalettes/colorPalettes.js +2 -2
- package/modern/context/CartesianContextProvider.js +14 -8
- package/modern/hooks/useTicks.js +9 -6
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +10 -10
- package/package.json +2 -2
- package/themeAugmentation/components.d.ts +0 -10
- package/themeAugmentation/overrides.d.ts +0 -2
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -30,7 +30,9 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
30
30
|
leftAxis,
|
|
31
31
|
rightAxis,
|
|
32
32
|
bottomAxis,
|
|
33
|
-
children
|
|
33
|
+
children,
|
|
34
|
+
slots,
|
|
35
|
+
slotProps
|
|
34
36
|
} = props;
|
|
35
37
|
const id = useId();
|
|
36
38
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -59,15 +61,26 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
59
61
|
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
|
|
60
62
|
children: [/*#__PURE__*/_jsx("g", {
|
|
61
63
|
clipPath: `url(#${clipPathId})`,
|
|
62
|
-
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
64
|
+
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
65
|
+
slots: slots,
|
|
66
|
+
slotProps: slotProps
|
|
67
|
+
})
|
|
63
68
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
64
69
|
topAxis: topAxis,
|
|
65
70
|
leftAxis: leftAxis,
|
|
66
71
|
rightAxis: rightAxis,
|
|
67
|
-
bottomAxis: bottomAxis
|
|
68
|
-
|
|
72
|
+
bottomAxis: bottomAxis,
|
|
73
|
+
slots: slots,
|
|
74
|
+
slotProps: slotProps
|
|
75
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
76
|
+
slots: slots,
|
|
77
|
+
slotProps: slotProps
|
|
78
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
69
79
|
x: "band"
|
|
70
|
-
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
80
|
+
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
81
|
+
slots: slots,
|
|
82
|
+
slotProps: slotProps
|
|
83
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
71
84
|
id: clipPathId
|
|
72
85
|
}), children]
|
|
73
86
|
});
|
|
@@ -95,8 +108,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
95
108
|
label: PropTypes.string,
|
|
96
109
|
labelFontSize: PropTypes.number,
|
|
97
110
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
111
|
+
slotProps: PropTypes.object,
|
|
112
|
+
slots: PropTypes.object,
|
|
98
113
|
stroke: PropTypes.string,
|
|
99
114
|
tickFontSize: PropTypes.number,
|
|
115
|
+
tickMaxStep: PropTypes.number,
|
|
116
|
+
tickMinStep: PropTypes.number,
|
|
117
|
+
tickNumber: PropTypes.number,
|
|
100
118
|
tickSize: PropTypes.number
|
|
101
119
|
}), PropTypes.string]),
|
|
102
120
|
children: PropTypes.node,
|
|
@@ -123,8 +141,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
123
141
|
label: PropTypes.string,
|
|
124
142
|
labelFontSize: PropTypes.number,
|
|
125
143
|
position: PropTypes.oneOf(['left', 'right']),
|
|
144
|
+
slotProps: PropTypes.object,
|
|
145
|
+
slots: PropTypes.object,
|
|
126
146
|
stroke: PropTypes.string,
|
|
127
147
|
tickFontSize: PropTypes.number,
|
|
148
|
+
tickMaxStep: PropTypes.number,
|
|
149
|
+
tickMinStep: PropTypes.number,
|
|
150
|
+
tickNumber: PropTypes.number,
|
|
128
151
|
tickSize: PropTypes.number
|
|
129
152
|
}), PropTypes.string]),
|
|
130
153
|
legend: PropTypes.shape({
|
|
@@ -141,6 +164,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
141
164
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
142
165
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
143
166
|
}),
|
|
167
|
+
slotProps: PropTypes.object,
|
|
168
|
+
slots: PropTypes.object,
|
|
144
169
|
spacing: PropTypes.number
|
|
145
170
|
}),
|
|
146
171
|
margin: PropTypes.shape({
|
|
@@ -163,8 +188,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
163
188
|
label: PropTypes.string,
|
|
164
189
|
labelFontSize: PropTypes.number,
|
|
165
190
|
position: PropTypes.oneOf(['left', 'right']),
|
|
191
|
+
slotProps: PropTypes.object,
|
|
192
|
+
slots: PropTypes.object,
|
|
166
193
|
stroke: PropTypes.string,
|
|
167
194
|
tickFontSize: PropTypes.number,
|
|
195
|
+
tickMaxStep: PropTypes.number,
|
|
196
|
+
tickMinStep: PropTypes.number,
|
|
197
|
+
tickNumber: PropTypes.number,
|
|
168
198
|
tickSize: PropTypes.number
|
|
169
199
|
}), PropTypes.string]),
|
|
170
200
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -185,6 +215,16 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
185
215
|
xAxisKey: PropTypes.string,
|
|
186
216
|
yAxisKey: PropTypes.string
|
|
187
217
|
})).isRequired,
|
|
218
|
+
/**
|
|
219
|
+
* The props used for each component slot.
|
|
220
|
+
* @default {}
|
|
221
|
+
*/
|
|
222
|
+
slotProps: PropTypes.object,
|
|
223
|
+
/**
|
|
224
|
+
* Overridable component slots.
|
|
225
|
+
* @default {}
|
|
226
|
+
*/
|
|
227
|
+
slots: PropTypes.object,
|
|
188
228
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
189
229
|
title: PropTypes.string,
|
|
190
230
|
tooltip: PropTypes.shape({
|
|
@@ -207,8 +247,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
207
247
|
label: PropTypes.string,
|
|
208
248
|
labelFontSize: PropTypes.number,
|
|
209
249
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
250
|
+
slotProps: PropTypes.object,
|
|
251
|
+
slots: PropTypes.object,
|
|
210
252
|
stroke: PropTypes.string,
|
|
211
253
|
tickFontSize: PropTypes.number,
|
|
254
|
+
tickMaxStep: PropTypes.number,
|
|
255
|
+
tickMinStep: PropTypes.number,
|
|
256
|
+
tickNumber: PropTypes.number,
|
|
212
257
|
tickSize: PropTypes.number
|
|
213
258
|
}), PropTypes.string]),
|
|
214
259
|
viewBox: PropTypes.shape({
|
|
@@ -231,15 +276,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
231
276
|
label: PropTypes.string,
|
|
232
277
|
labelFontSize: PropTypes.number,
|
|
233
278
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
234
|
-
maxTicks: PropTypes.number,
|
|
235
279
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
236
|
-
minTicks: PropTypes.number,
|
|
237
280
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
238
281
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
282
|
+
slotProps: PropTypes.object,
|
|
283
|
+
slots: PropTypes.object,
|
|
239
284
|
stroke: PropTypes.string,
|
|
240
285
|
tickFontSize: PropTypes.number,
|
|
286
|
+
tickMaxStep: PropTypes.number,
|
|
287
|
+
tickMinStep: PropTypes.number,
|
|
288
|
+
tickNumber: PropTypes.number,
|
|
241
289
|
tickSize: PropTypes.number,
|
|
242
|
-
tickSpacing: PropTypes.number,
|
|
243
290
|
valueFormatter: PropTypes.func
|
|
244
291
|
})),
|
|
245
292
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -255,15 +302,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
255
302
|
label: PropTypes.string,
|
|
256
303
|
labelFontSize: PropTypes.number,
|
|
257
304
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
258
|
-
maxTicks: PropTypes.number,
|
|
259
305
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
260
|
-
minTicks: PropTypes.number,
|
|
261
306
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
262
307
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
308
|
+
slotProps: PropTypes.object,
|
|
309
|
+
slots: PropTypes.object,
|
|
263
310
|
stroke: PropTypes.string,
|
|
264
311
|
tickFontSize: PropTypes.number,
|
|
312
|
+
tickMaxStep: PropTypes.number,
|
|
313
|
+
tickMinStep: PropTypes.number,
|
|
314
|
+
tickNumber: PropTypes.number,
|
|
265
315
|
tickSize: PropTypes.number,
|
|
266
|
-
tickSpacing: PropTypes.number,
|
|
267
316
|
valueFormatter: PropTypes.func
|
|
268
317
|
}))
|
|
269
318
|
} : void 0;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope"];
|
|
3
|
+
const _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';
|
|
@@ -24,7 +25,7 @@ const useUtilityClasses = ownerState => {
|
|
|
24
25
|
};
|
|
25
26
|
return composeClasses(slots, getBarElementUtilityClass, classes);
|
|
26
27
|
};
|
|
27
|
-
const BarElementPath = styled('rect', {
|
|
28
|
+
export const BarElementPath = styled('rect', {
|
|
28
29
|
name: 'MuiBarElement',
|
|
29
30
|
slot: 'Root',
|
|
30
31
|
overridesResolver: (_, styles) => styles.root
|
|
@@ -38,12 +39,15 @@ const BarElementPath = styled('rect', {
|
|
|
38
39
|
opacity: ownerState.isFaded && 0.3 || 1
|
|
39
40
|
}));
|
|
40
41
|
export function BarElement(props) {
|
|
42
|
+
var _slots$bar;
|
|
41
43
|
const {
|
|
42
44
|
id,
|
|
43
45
|
dataIndex,
|
|
44
46
|
classes: innerClasses,
|
|
45
47
|
color,
|
|
46
|
-
highlightScope
|
|
48
|
+
highlightScope,
|
|
49
|
+
slots,
|
|
50
|
+
slotProps
|
|
47
51
|
} = props,
|
|
48
52
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
49
53
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -69,12 +73,18 @@ export function BarElement(props) {
|
|
|
69
73
|
isHighlighted
|
|
70
74
|
};
|
|
71
75
|
const classes = useUtilityClasses(ownerState);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
const Bar = (_slots$bar = slots == null ? void 0 : slots.bar) != null ? _slots$bar : BarElementPath;
|
|
77
|
+
const barProps = useSlotProps({
|
|
78
|
+
elementType: Bar,
|
|
79
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.bar,
|
|
80
|
+
additionalProps: _extends({}, other, getInteractionItemProps({
|
|
81
|
+
type: 'bar',
|
|
82
|
+
seriesId: id,
|
|
83
|
+
dataIndex
|
|
84
|
+
}), {
|
|
85
|
+
className: classes.root
|
|
86
|
+
}),
|
|
87
|
+
ownerState
|
|
88
|
+
});
|
|
89
|
+
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
80
90
|
}
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
2
4
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
3
5
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
4
6
|
import { BarElement } from './BarElement';
|
|
@@ -32,7 +34,7 @@ function getBandSize({
|
|
|
32
34
|
offset
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
function BarPlot(props) {
|
|
36
38
|
const seriesData = React.useContext(SeriesContext).bar;
|
|
37
39
|
const axisData = React.useContext(CartesianContext);
|
|
38
40
|
if (seriesData === undefined) {
|
|
@@ -89,7 +91,7 @@ export function BarPlot() {
|
|
|
89
91
|
var _xAxis$xAxisKey$data;
|
|
90
92
|
const baseline = Math.min(...values);
|
|
91
93
|
const value = Math.max(...values);
|
|
92
|
-
return /*#__PURE__*/_jsx(BarElement, {
|
|
94
|
+
return /*#__PURE__*/_jsx(BarElement, _extends({
|
|
93
95
|
id: seriesId,
|
|
94
96
|
dataIndex: dataIndex,
|
|
95
97
|
x: xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + groupIndex * (barWidth + offset),
|
|
@@ -98,9 +100,26 @@ export function BarPlot() {
|
|
|
98
100
|
width: barWidth,
|
|
99
101
|
color: color,
|
|
100
102
|
highlightScope: series[seriesId].highlightScope
|
|
101
|
-
}, `${seriesId}-${dataIndex}`);
|
|
103
|
+
}, props), `${seriesId}-${dataIndex}`);
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
})
|
|
105
107
|
});
|
|
106
|
-
}
|
|
108
|
+
}
|
|
109
|
+
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
110
|
+
// ----------------------------- Warning --------------------------------
|
|
111
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
112
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
113
|
+
// ----------------------------------------------------------------------
|
|
114
|
+
/**
|
|
115
|
+
* The props used for each component slot.
|
|
116
|
+
* @default {}
|
|
117
|
+
*/
|
|
118
|
+
slotProps: PropTypes.object,
|
|
119
|
+
/**
|
|
120
|
+
* Overridable component slots.
|
|
121
|
+
* @default {}
|
|
122
|
+
*/
|
|
123
|
+
slots: PropTypes.object
|
|
124
|
+
} : void 0;
|
|
125
|
+
export { BarPlot };
|
|
@@ -15,12 +15,23 @@ const getAxisId = propsValue => {
|
|
|
15
15
|
}
|
|
16
16
|
return propsValue;
|
|
17
17
|
};
|
|
18
|
+
const mergeProps = (axisConfig, slots, slotProps) => {
|
|
19
|
+
return typeof axisConfig === 'object' ? _extends({}, axisConfig, {
|
|
20
|
+
slots: _extends({}, slots, axisConfig == null ? void 0 : axisConfig.slots),
|
|
21
|
+
slotProps: _extends({}, slotProps, axisConfig == null ? void 0 : axisConfig.slotProps)
|
|
22
|
+
}) : {
|
|
23
|
+
slots,
|
|
24
|
+
slotProps
|
|
25
|
+
};
|
|
26
|
+
};
|
|
18
27
|
function ChartsAxis(props) {
|
|
19
28
|
const {
|
|
20
29
|
topAxis,
|
|
21
30
|
leftAxis,
|
|
22
31
|
rightAxis,
|
|
23
|
-
bottomAxis
|
|
32
|
+
bottomAxis,
|
|
33
|
+
slots,
|
|
34
|
+
slotProps
|
|
24
35
|
} = props;
|
|
25
36
|
const {
|
|
26
37
|
xAxis,
|
|
@@ -48,20 +59,24 @@ function ChartsAxis(props) {
|
|
|
48
59
|
if (bottomId !== null && !xAxis[bottomId]) {
|
|
49
60
|
throw Error(`MUI: id used for bottom axis "${bottomId}" is not defined`);
|
|
50
61
|
}
|
|
62
|
+
const topAxisProps = mergeProps(topAxis, slots, slotProps);
|
|
63
|
+
const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
|
|
64
|
+
const leftAxisProps = mergeProps(leftAxis, slots, slotProps);
|
|
65
|
+
const rightAxisProps = mergeProps(rightAxis, slots, slotProps);
|
|
51
66
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
52
|
-
children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
|
|
67
|
+
children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({}, topAxisProps, {
|
|
53
68
|
position: "top",
|
|
54
69
|
axisId: topId
|
|
55
|
-
}
|
|
70
|
+
})), bottomId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({}, bottomAxisProps, {
|
|
56
71
|
position: "bottom",
|
|
57
72
|
axisId: bottomId
|
|
58
|
-
}
|
|
73
|
+
})), leftId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({}, leftAxisProps, {
|
|
59
74
|
position: "left",
|
|
60
75
|
axisId: leftId
|
|
61
|
-
}
|
|
76
|
+
})), rightId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({}, rightAxisProps, {
|
|
62
77
|
position: "right",
|
|
63
78
|
axisId: rightId
|
|
64
|
-
}
|
|
79
|
+
}))]
|
|
65
80
|
});
|
|
66
81
|
}
|
|
67
82
|
process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
@@ -83,8 +98,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
83
98
|
label: PropTypes.string,
|
|
84
99
|
labelFontSize: PropTypes.number,
|
|
85
100
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
101
|
+
slotProps: PropTypes.object,
|
|
102
|
+
slots: PropTypes.object,
|
|
86
103
|
stroke: PropTypes.string,
|
|
87
104
|
tickFontSize: PropTypes.number,
|
|
105
|
+
tickMaxStep: PropTypes.number,
|
|
106
|
+
tickMinStep: PropTypes.number,
|
|
107
|
+
tickNumber: PropTypes.number,
|
|
88
108
|
tickSize: PropTypes.number
|
|
89
109
|
}), PropTypes.string]),
|
|
90
110
|
/**
|
|
@@ -101,8 +121,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
101
121
|
label: PropTypes.string,
|
|
102
122
|
labelFontSize: PropTypes.number,
|
|
103
123
|
position: PropTypes.oneOf(['left', 'right']),
|
|
124
|
+
slotProps: PropTypes.object,
|
|
125
|
+
slots: PropTypes.object,
|
|
104
126
|
stroke: PropTypes.string,
|
|
105
127
|
tickFontSize: PropTypes.number,
|
|
128
|
+
tickMaxStep: PropTypes.number,
|
|
129
|
+
tickMinStep: PropTypes.number,
|
|
130
|
+
tickNumber: PropTypes.number,
|
|
106
131
|
tickSize: PropTypes.number
|
|
107
132
|
}), PropTypes.string]),
|
|
108
133
|
/**
|
|
@@ -119,10 +144,25 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
119
144
|
label: PropTypes.string,
|
|
120
145
|
labelFontSize: PropTypes.number,
|
|
121
146
|
position: PropTypes.oneOf(['left', 'right']),
|
|
147
|
+
slotProps: PropTypes.object,
|
|
148
|
+
slots: PropTypes.object,
|
|
122
149
|
stroke: PropTypes.string,
|
|
123
150
|
tickFontSize: PropTypes.number,
|
|
151
|
+
tickMaxStep: PropTypes.number,
|
|
152
|
+
tickMinStep: PropTypes.number,
|
|
153
|
+
tickNumber: PropTypes.number,
|
|
124
154
|
tickSize: PropTypes.number
|
|
125
155
|
}), PropTypes.string]),
|
|
156
|
+
/**
|
|
157
|
+
* The props used for each component slot.
|
|
158
|
+
* @default {}
|
|
159
|
+
*/
|
|
160
|
+
slotProps: PropTypes.object,
|
|
161
|
+
/**
|
|
162
|
+
* Overridable component slots.
|
|
163
|
+
* @default {}
|
|
164
|
+
*/
|
|
165
|
+
slots: PropTypes.object,
|
|
126
166
|
/**
|
|
127
167
|
* Indicate which axis to display the top of the charts.
|
|
128
168
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
@@ -137,8 +177,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
137
177
|
label: PropTypes.string,
|
|
138
178
|
labelFontSize: PropTypes.number,
|
|
139
179
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
180
|
+
slotProps: PropTypes.object,
|
|
181
|
+
slots: PropTypes.object,
|
|
140
182
|
stroke: PropTypes.string,
|
|
141
183
|
tickFontSize: PropTypes.number,
|
|
184
|
+
tickMaxStep: PropTypes.number,
|
|
185
|
+
tickMinStep: PropTypes.number,
|
|
186
|
+
tickNumber: PropTypes.number,
|
|
142
187
|
tickSize: PropTypes.number
|
|
143
188
|
}), PropTypes.string])
|
|
144
189
|
} : 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';
|
|
@@ -126,7 +127,7 @@ export const ChartsLegendLabel = styled('text', {
|
|
|
126
127
|
calc(0.5 * var(--ChartsLegend-itemMarkSize))
|
|
127
128
|
)`,
|
|
128
129
|
fill: theme.palette.text.primary,
|
|
129
|
-
|
|
130
|
+
dominantBaseline: 'central'
|
|
130
131
|
}));
|
|
131
132
|
const defaultProps = {
|
|
132
133
|
position: {
|
|
@@ -138,27 +139,20 @@ const defaultProps = {
|
|
|
138
139
|
itemWidth: 100,
|
|
139
140
|
spacing: 2
|
|
140
141
|
};
|
|
141
|
-
|
|
142
|
-
const props = useThemeProps({
|
|
143
|
-
props: _extends({}, defaultProps, inProps),
|
|
144
|
-
name: 'MuiChartsLegend'
|
|
145
|
-
});
|
|
142
|
+
function DefaultChartsLegend(props) {
|
|
146
143
|
const {
|
|
144
|
+
hidden,
|
|
147
145
|
position,
|
|
148
146
|
direction,
|
|
149
147
|
offset,
|
|
150
|
-
|
|
148
|
+
series,
|
|
149
|
+
seriesToDisplay,
|
|
150
|
+
drawingArea,
|
|
151
|
+
classes
|
|
151
152
|
} = props;
|
|
152
|
-
const theme = useTheme();
|
|
153
|
-
const classes = useUtilityClasses(_extends({}, props, {
|
|
154
|
-
theme
|
|
155
|
-
}));
|
|
156
|
-
const drawingArea = React.useContext(DrawingContext);
|
|
157
|
-
const series = React.useContext(SeriesContext);
|
|
158
153
|
if (hidden) {
|
|
159
154
|
return null;
|
|
160
155
|
}
|
|
161
|
-
const seriesToDisplay = getSeriesToDisplay(series);
|
|
162
156
|
return /*#__PURE__*/_jsx(ChartsLegendRoot, {
|
|
163
157
|
ownerState: {
|
|
164
158
|
direction,
|
|
@@ -190,4 +184,43 @@ export function ChartsLegend(inProps) {
|
|
|
190
184
|
})]
|
|
191
185
|
}, id))
|
|
192
186
|
});
|
|
187
|
+
}
|
|
188
|
+
export function ChartsLegend(inProps) {
|
|
189
|
+
var _slots$legend;
|
|
190
|
+
const props = useThemeProps({
|
|
191
|
+
props: _extends({}, defaultProps, inProps),
|
|
192
|
+
name: 'MuiChartsLegend'
|
|
193
|
+
});
|
|
194
|
+
const {
|
|
195
|
+
position,
|
|
196
|
+
direction,
|
|
197
|
+
offset,
|
|
198
|
+
hidden,
|
|
199
|
+
slots,
|
|
200
|
+
slotProps
|
|
201
|
+
} = props;
|
|
202
|
+
const theme = useTheme();
|
|
203
|
+
const classes = useUtilityClasses(_extends({}, props, {
|
|
204
|
+
theme
|
|
205
|
+
}));
|
|
206
|
+
const drawingArea = React.useContext(DrawingContext);
|
|
207
|
+
const series = React.useContext(SeriesContext);
|
|
208
|
+
const seriesToDisplay = getSeriesToDisplay(series);
|
|
209
|
+
const ChartLegendRender = (_slots$legend = slots == null ? void 0 : slots.legend) != null ? _slots$legend : DefaultChartsLegend;
|
|
210
|
+
const chartLegendRenderProps = useSlotProps({
|
|
211
|
+
elementType: ChartLegendRender,
|
|
212
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.legend,
|
|
213
|
+
additionalProps: {
|
|
214
|
+
position,
|
|
215
|
+
direction,
|
|
216
|
+
offset,
|
|
217
|
+
classes,
|
|
218
|
+
drawingArea,
|
|
219
|
+
series,
|
|
220
|
+
hidden,
|
|
221
|
+
seriesToDisplay
|
|
222
|
+
},
|
|
223
|
+
ownerState: {}
|
|
224
|
+
});
|
|
225
|
+
return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
|
|
193
226
|
}
|
|
@@ -9,7 +9,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
9
9
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
10
|
import useTicks from '../hooks/useTicks';
|
|
11
11
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
12
|
-
import {
|
|
12
|
+
import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
const useUtilityClasses = ownerState => {
|
|
@@ -36,6 +36,7 @@ const defaultProps = {
|
|
|
36
36
|
tickSize: 6
|
|
37
37
|
};
|
|
38
38
|
function ChartsXAxis(inProps) {
|
|
39
|
+
var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
39
40
|
const props = useThemeProps({
|
|
40
41
|
props: _extends({}, defaultProps, inProps),
|
|
41
42
|
name: 'MuiChartsXAxis'
|
|
@@ -60,7 +61,9 @@ function ChartsXAxis(inProps) {
|
|
|
60
61
|
label,
|
|
61
62
|
labelFontSize,
|
|
62
63
|
tickSize: tickSizeProp,
|
|
63
|
-
valueFormatter
|
|
64
|
+
valueFormatter,
|
|
65
|
+
slots,
|
|
66
|
+
slotProps
|
|
64
67
|
} = defaultizedProps;
|
|
65
68
|
const theme = useTheme();
|
|
66
69
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
@@ -83,14 +86,18 @@ function ChartsXAxis(inProps) {
|
|
|
83
86
|
x: left + width / 2,
|
|
84
87
|
y: positionSigne * (tickFontSize + tickSize + 10)
|
|
85
88
|
};
|
|
89
|
+
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
|
|
90
|
+
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
|
|
91
|
+
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
|
|
92
|
+
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
|
|
86
93
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
87
94
|
transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
|
|
88
95
|
className: classes.root,
|
|
89
|
-
children: [!disableLine && /*#__PURE__*/_jsx(Line, {
|
|
96
|
+
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
90
97
|
x1: xScale.range()[0],
|
|
91
98
|
x2: xScale.range()[1],
|
|
92
99
|
className: classes.line
|
|
93
|
-
}), xTicks.map(({
|
|
100
|
+
}, slotProps == null ? void 0 : slotProps.axisLine)), xTicks.map(({
|
|
94
101
|
formattedValue,
|
|
95
102
|
offset,
|
|
96
103
|
labelOffset
|
|
@@ -100,26 +107,28 @@ function ChartsXAxis(inProps) {
|
|
|
100
107
|
return /*#__PURE__*/_jsxs("g", {
|
|
101
108
|
transform: `translate(${offset}, 0)`,
|
|
102
109
|
className: classes.tickContainer,
|
|
103
|
-
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, {
|
|
110
|
+
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
104
111
|
y2: positionSigne * tickSize,
|
|
105
112
|
className: classes.tick
|
|
106
|
-
}), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, {
|
|
113
|
+
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
107
114
|
x: xTickLabel,
|
|
108
115
|
y: yTickLabel,
|
|
109
116
|
"transform-origin": `${xTickLabel}px ${yTickLabel}px`,
|
|
110
117
|
sx: {
|
|
111
118
|
fontSize: tickFontSize
|
|
112
119
|
},
|
|
113
|
-
className: classes.tickLabel
|
|
120
|
+
className: classes.tickLabel
|
|
121
|
+
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
114
122
|
children: formattedValue
|
|
115
|
-
})]
|
|
123
|
+
}))]
|
|
116
124
|
}, index);
|
|
117
125
|
}), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
|
|
118
126
|
sx: {
|
|
119
127
|
fontSize: labelFontSize,
|
|
120
128
|
transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
|
|
121
129
|
},
|
|
122
|
-
className: classes.label
|
|
130
|
+
className: classes.label
|
|
131
|
+
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
123
132
|
children: label
|
|
124
133
|
}))]
|
|
125
134
|
});
|
|
@@ -165,6 +174,16 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
165
174
|
* Position of the axis.
|
|
166
175
|
*/
|
|
167
176
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
177
|
+
/**
|
|
178
|
+
* The props used for each component slot.
|
|
179
|
+
* @default {}
|
|
180
|
+
*/
|
|
181
|
+
slotProps: PropTypes.object,
|
|
182
|
+
/**
|
|
183
|
+
* Overridable component slots.
|
|
184
|
+
* @default {}
|
|
185
|
+
*/
|
|
186
|
+
slots: PropTypes.object,
|
|
168
187
|
/**
|
|
169
188
|
* The stroke color of the axis line.
|
|
170
189
|
* @default 'currentColor'
|
|
@@ -175,6 +194,23 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
175
194
|
* @default 12
|
|
176
195
|
*/
|
|
177
196
|
tickFontSize: PropTypes.number,
|
|
197
|
+
/**
|
|
198
|
+
* Maximal step between two ticks.
|
|
199
|
+
* When using time data, the value is assumed to be in ms.
|
|
200
|
+
* Not supported by categorical axis (band, points).
|
|
201
|
+
*/
|
|
202
|
+
tickMaxStep: PropTypes.number,
|
|
203
|
+
/**
|
|
204
|
+
* Maximal step between two ticks.
|
|
205
|
+
* When using time data, the value is assumed to be in ms.
|
|
206
|
+
* Not supported by categorical axis (band, points).
|
|
207
|
+
*/
|
|
208
|
+
tickMinStep: PropTypes.number,
|
|
209
|
+
/**
|
|
210
|
+
* The number of ticks. This number is not guaranted.
|
|
211
|
+
* Not supported by categorical axis (band, points).
|
|
212
|
+
*/
|
|
213
|
+
tickNumber: PropTypes.number,
|
|
178
214
|
/**
|
|
179
215
|
* The size of the ticks.
|
|
180
216
|
* @default 6
|