@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
|
@@ -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,42 @@ export function ChartsLegend(inProps) {
|
|
|
190
184
|
})]
|
|
191
185
|
}, id))
|
|
192
186
|
});
|
|
187
|
+
}
|
|
188
|
+
export function ChartsLegend(inProps) {
|
|
189
|
+
const props = useThemeProps({
|
|
190
|
+
props: _extends({}, defaultProps, inProps),
|
|
191
|
+
name: 'MuiChartsLegend'
|
|
192
|
+
});
|
|
193
|
+
const {
|
|
194
|
+
position,
|
|
195
|
+
direction,
|
|
196
|
+
offset,
|
|
197
|
+
hidden,
|
|
198
|
+
slots,
|
|
199
|
+
slotProps
|
|
200
|
+
} = props;
|
|
201
|
+
const theme = useTheme();
|
|
202
|
+
const classes = useUtilityClasses(_extends({}, props, {
|
|
203
|
+
theme
|
|
204
|
+
}));
|
|
205
|
+
const drawingArea = React.useContext(DrawingContext);
|
|
206
|
+
const series = React.useContext(SeriesContext);
|
|
207
|
+
const seriesToDisplay = getSeriesToDisplay(series);
|
|
208
|
+
const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
|
|
209
|
+
const chartLegendRenderProps = useSlotProps({
|
|
210
|
+
elementType: ChartLegendRender,
|
|
211
|
+
externalSlotProps: slotProps?.legend,
|
|
212
|
+
additionalProps: {
|
|
213
|
+
position,
|
|
214
|
+
direction,
|
|
215
|
+
offset,
|
|
216
|
+
classes,
|
|
217
|
+
drawingArea,
|
|
218
|
+
series,
|
|
219
|
+
hidden,
|
|
220
|
+
seriesToDisplay
|
|
221
|
+
},
|
|
222
|
+
ownerState: {}
|
|
223
|
+
});
|
|
224
|
+
return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
|
|
193
225
|
}
|
|
@@ -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 => {
|
|
@@ -60,7 +60,9 @@ function ChartsXAxis(inProps) {
|
|
|
60
60
|
label,
|
|
61
61
|
labelFontSize,
|
|
62
62
|
tickSize: tickSizeProp,
|
|
63
|
-
valueFormatter
|
|
63
|
+
valueFormatter,
|
|
64
|
+
slots,
|
|
65
|
+
slotProps
|
|
64
66
|
} = defaultizedProps;
|
|
65
67
|
const theme = useTheme();
|
|
66
68
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
@@ -83,14 +85,18 @@ function ChartsXAxis(inProps) {
|
|
|
83
85
|
x: left + width / 2,
|
|
84
86
|
y: positionSigne * (tickFontSize + tickSize + 10)
|
|
85
87
|
};
|
|
88
|
+
const Line = slots?.axisLine ?? ChartsLine;
|
|
89
|
+
const Tick = slots?.axisTick ?? ChartsTick;
|
|
90
|
+
const TickLabel = slots?.axisTickLabel ?? ChartsTickLabel;
|
|
91
|
+
const Label = slots?.axisLabel ?? ChartsLabel;
|
|
86
92
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
87
93
|
transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
|
|
88
94
|
className: classes.root,
|
|
89
|
-
children: [!disableLine && /*#__PURE__*/_jsx(Line, {
|
|
95
|
+
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
90
96
|
x1: xScale.range()[0],
|
|
91
97
|
x2: xScale.range()[1],
|
|
92
98
|
className: classes.line
|
|
93
|
-
}), xTicks.map(({
|
|
99
|
+
}, slotProps?.axisLine)), xTicks.map(({
|
|
94
100
|
formattedValue,
|
|
95
101
|
offset,
|
|
96
102
|
labelOffset
|
|
@@ -100,26 +106,28 @@ function ChartsXAxis(inProps) {
|
|
|
100
106
|
return /*#__PURE__*/_jsxs("g", {
|
|
101
107
|
transform: `translate(${offset}, 0)`,
|
|
102
108
|
className: classes.tickContainer,
|
|
103
|
-
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, {
|
|
109
|
+
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
104
110
|
y2: positionSigne * tickSize,
|
|
105
111
|
className: classes.tick
|
|
106
|
-
}), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, {
|
|
112
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
107
113
|
x: xTickLabel,
|
|
108
114
|
y: yTickLabel,
|
|
109
115
|
"transform-origin": `${xTickLabel}px ${yTickLabel}px`,
|
|
110
116
|
sx: {
|
|
111
117
|
fontSize: tickFontSize
|
|
112
118
|
},
|
|
113
|
-
className: classes.tickLabel
|
|
119
|
+
className: classes.tickLabel
|
|
120
|
+
}, slotProps?.axisTickLabel, {
|
|
114
121
|
children: formattedValue
|
|
115
|
-
})]
|
|
122
|
+
}))]
|
|
116
123
|
}, index);
|
|
117
124
|
}), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
|
|
118
125
|
sx: {
|
|
119
126
|
fontSize: labelFontSize,
|
|
120
127
|
transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
|
|
121
128
|
},
|
|
122
|
-
className: classes.label
|
|
129
|
+
className: classes.label
|
|
130
|
+
}, slotProps?.axisLabel, {
|
|
123
131
|
children: label
|
|
124
132
|
}))]
|
|
125
133
|
});
|
|
@@ -165,6 +173,16 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
165
173
|
* Position of the axis.
|
|
166
174
|
*/
|
|
167
175
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
176
|
+
/**
|
|
177
|
+
* The props used for each component slot.
|
|
178
|
+
* @default {}
|
|
179
|
+
*/
|
|
180
|
+
slotProps: PropTypes.object,
|
|
181
|
+
/**
|
|
182
|
+
* Overridable component slots.
|
|
183
|
+
* @default {}
|
|
184
|
+
*/
|
|
185
|
+
slots: PropTypes.object,
|
|
168
186
|
/**
|
|
169
187
|
* The stroke color of the axis line.
|
|
170
188
|
* @default 'currentColor'
|
|
@@ -175,6 +193,23 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
175
193
|
* @default 12
|
|
176
194
|
*/
|
|
177
195
|
tickFontSize: PropTypes.number,
|
|
196
|
+
/**
|
|
197
|
+
* Maximal step between two ticks.
|
|
198
|
+
* When using time data, the value is assumed to be in ms.
|
|
199
|
+
* Not supported by categorical axis (band, points).
|
|
200
|
+
*/
|
|
201
|
+
tickMaxStep: PropTypes.number,
|
|
202
|
+
/**
|
|
203
|
+
* Maximal step between two ticks.
|
|
204
|
+
* When using time data, the value is assumed to be in ms.
|
|
205
|
+
* Not supported by categorical axis (band, points).
|
|
206
|
+
*/
|
|
207
|
+
tickMinStep: PropTypes.number,
|
|
208
|
+
/**
|
|
209
|
+
* The number of ticks. This number is not guaranted.
|
|
210
|
+
* Not supported by categorical axis (band, points).
|
|
211
|
+
*/
|
|
212
|
+
tickNumber: PropTypes.number,
|
|
178
213
|
/**
|
|
179
214
|
* The size of the ticks.
|
|
180
215
|
* @default 6
|
|
@@ -8,7 +8,7 @@ import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
|
8
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
9
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
10
|
import useTicks from '../hooks/useTicks';
|
|
11
|
-
import {
|
|
11
|
+
import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
12
12
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -60,7 +60,9 @@ function ChartsYAxis(inProps) {
|
|
|
60
60
|
label,
|
|
61
61
|
labelFontSize,
|
|
62
62
|
tickSize: tickSizeProp,
|
|
63
|
-
valueFormatter
|
|
63
|
+
valueFormatter,
|
|
64
|
+
slots,
|
|
65
|
+
slotProps
|
|
64
66
|
} = defaultizedProps;
|
|
65
67
|
const theme = useTheme();
|
|
66
68
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
@@ -83,14 +85,18 @@ function ChartsYAxis(inProps) {
|
|
|
83
85
|
x: positionSigne * (tickFontSize + tickSize + 10),
|
|
84
86
|
y: top + height / 2
|
|
85
87
|
};
|
|
88
|
+
const Line = slots?.axisLine ?? ChartsLine;
|
|
89
|
+
const Tick = slots?.axisTick ?? ChartsTick;
|
|
90
|
+
const TickLabel = slots?.axisTickLabel ?? ChartsTickLabel;
|
|
91
|
+
const Label = slots?.axisLabel ?? ChartsLabel;
|
|
86
92
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
87
93
|
transform: `translate(${position === 'right' ? left + width : left}, 0)`,
|
|
88
94
|
className: classes.root,
|
|
89
|
-
children: [!disableLine && /*#__PURE__*/_jsx(Line, {
|
|
95
|
+
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
90
96
|
y1: yScale.range()[0],
|
|
91
97
|
y2: yScale.range()[1],
|
|
92
98
|
className: classes.line
|
|
93
|
-
}), yTicks.map(({
|
|
99
|
+
}, slotProps?.axisLine)), yTicks.map(({
|
|
94
100
|
formattedValue,
|
|
95
101
|
offset,
|
|
96
102
|
labelOffset
|
|
@@ -100,19 +106,20 @@ function ChartsYAxis(inProps) {
|
|
|
100
106
|
return /*#__PURE__*/_jsxs("g", {
|
|
101
107
|
transform: `translate(0, ${offset})`,
|
|
102
108
|
className: classes.tickContainer,
|
|
103
|
-
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, {
|
|
109
|
+
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
104
110
|
x2: positionSigne * tickSize,
|
|
105
111
|
className: classes.tick
|
|
106
|
-
}), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, {
|
|
112
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
107
113
|
x: xTickLabel,
|
|
108
114
|
y: yTickLabel,
|
|
109
115
|
"transform-origin": `${xTickLabel}px ${yTickLabel}px`,
|
|
110
116
|
sx: {
|
|
111
117
|
fontSize: tickFontSize
|
|
112
118
|
},
|
|
113
|
-
className: classes.tickLabel
|
|
119
|
+
className: classes.tickLabel
|
|
120
|
+
}, slotProps?.axisTickLabel, {
|
|
114
121
|
children: formattedValue.toLocaleString()
|
|
115
|
-
})]
|
|
122
|
+
}))]
|
|
116
123
|
}, index);
|
|
117
124
|
}), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
|
|
118
125
|
sx: {
|
|
@@ -120,7 +127,8 @@ function ChartsYAxis(inProps) {
|
|
|
120
127
|
transform: `rotate(${positionSigne * 90}deg)`,
|
|
121
128
|
transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
|
|
122
129
|
},
|
|
123
|
-
className: classes.label
|
|
130
|
+
className: classes.label
|
|
131
|
+
}, slotProps?.axisLabel, {
|
|
124
132
|
children: label
|
|
125
133
|
}))]
|
|
126
134
|
});
|
|
@@ -166,6 +174,16 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
166
174
|
* Position of the axis.
|
|
167
175
|
*/
|
|
168
176
|
position: PropTypes.oneOf(['left', 'right']),
|
|
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,
|
|
169
187
|
/**
|
|
170
188
|
* The stroke color of the axis line.
|
|
171
189
|
* @default 'currentColor'
|
|
@@ -176,6 +194,23 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
176
194
|
* @default 12
|
|
177
195
|
*/
|
|
178
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,
|
|
179
214
|
/**
|
|
180
215
|
* The size of the ticks.
|
|
181
216
|
* @default 6
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "classes", "color", "highlightScope"];
|
|
3
|
+
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
7
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
8
9
|
import { styled } from '@mui/material/styles';
|
|
9
10
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
@@ -27,7 +28,7 @@ const useUtilityClasses = ownerState => {
|
|
|
27
28
|
};
|
|
28
29
|
return composeClasses(slots, getAreaElementUtilityClass, classes);
|
|
29
30
|
};
|
|
30
|
-
const AreaElementPath = styled('path', {
|
|
31
|
+
export const AreaElementPath = styled('path', {
|
|
31
32
|
name: 'MuiAreaElement',
|
|
32
33
|
slot: 'Root',
|
|
33
34
|
overridesResolver: (_, styles) => styles.root
|
|
@@ -59,7 +60,9 @@ function AreaElement(props) {
|
|
|
59
60
|
id,
|
|
60
61
|
classes: innerClasses,
|
|
61
62
|
color,
|
|
62
|
-
highlightScope
|
|
63
|
+
highlightScope,
|
|
64
|
+
slots,
|
|
65
|
+
slotProps
|
|
63
66
|
} = props,
|
|
64
67
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
65
68
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -82,13 +85,19 @@ function AreaElement(props) {
|
|
|
82
85
|
isHighlighted
|
|
83
86
|
};
|
|
84
87
|
const classes = useUtilityClasses(ownerState);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const Area = slots?.area ?? AreaElementPath;
|
|
89
|
+
const areaProps = useSlotProps({
|
|
90
|
+
elementType: Area,
|
|
91
|
+
externalSlotProps: slotProps?.area,
|
|
92
|
+
additionalProps: _extends({}, other, getInteractionItemProps({
|
|
93
|
+
type: 'line',
|
|
94
|
+
seriesId: id
|
|
95
|
+
}), {
|
|
96
|
+
className: classes.root
|
|
97
|
+
}),
|
|
98
|
+
ownerState
|
|
99
|
+
});
|
|
100
|
+
return /*#__PURE__*/_jsx(Area, _extends({}, areaProps));
|
|
92
101
|
}
|
|
93
102
|
process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
94
103
|
// ----------------------------- Warning --------------------------------
|
|
@@ -99,6 +108,16 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
|
99
108
|
highlightScope: PropTypes.shape({
|
|
100
109
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
101
110
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
102
|
-
})
|
|
111
|
+
}),
|
|
112
|
+
/**
|
|
113
|
+
* The props used for each component slot.
|
|
114
|
+
* @default {}
|
|
115
|
+
*/
|
|
116
|
+
slotProps: PropTypes.object,
|
|
117
|
+
/**
|
|
118
|
+
* Overridable component slots.
|
|
119
|
+
* @default {}
|
|
120
|
+
*/
|
|
121
|
+
slots: PropTypes.object
|
|
103
122
|
} : void 0;
|
|
104
123
|
export { AreaElement };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["slots", "slotProps"];
|
|
2
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
3
6
|
import { area as d3Area } from 'd3-shape';
|
|
4
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
5
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
@@ -7,7 +10,12 @@ import { AreaElement } from './AreaElement';
|
|
|
7
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
8
11
|
import getCurveFactory from '../internals/getCurve';
|
|
9
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
|
|
13
|
+
function AreaPlot(props) {
|
|
14
|
+
const {
|
|
15
|
+
slots,
|
|
16
|
+
slotProps
|
|
17
|
+
} = props,
|
|
18
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
11
19
|
const seriesData = React.useContext(SeriesContext).line;
|
|
12
20
|
const axisData = React.useContext(CartesianContext);
|
|
13
21
|
if (seriesData === undefined) {
|
|
@@ -25,7 +33,7 @@ export function AreaPlot(props) {
|
|
|
25
33
|
} = axisData;
|
|
26
34
|
const defaultXAxisId = xAxisIds[0];
|
|
27
35
|
const defaultYAxisId = yAxisIds[0];
|
|
28
|
-
return /*#__PURE__*/_jsx("g", _extends({},
|
|
36
|
+
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
29
37
|
children: stackingGroups.flatMap(({
|
|
30
38
|
ids: groupIds
|
|
31
39
|
}) => {
|
|
@@ -51,9 +59,28 @@ export function AreaPlot(props) {
|
|
|
51
59
|
id: seriesId,
|
|
52
60
|
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
53
61
|
color: series[seriesId].color,
|
|
54
|
-
highlightScope: series[seriesId].highlightScope
|
|
62
|
+
highlightScope: series[seriesId].highlightScope,
|
|
63
|
+
slots: slots,
|
|
64
|
+
slotProps: slotProps
|
|
55
65
|
}, seriesId);
|
|
56
66
|
});
|
|
57
67
|
})
|
|
58
68
|
}));
|
|
59
|
-
}
|
|
69
|
+
}
|
|
70
|
+
process.env.NODE_ENV !== "production" ? AreaPlot.propTypes = {
|
|
71
|
+
// ----------------------------- Warning --------------------------------
|
|
72
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
73
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
74
|
+
// ----------------------------------------------------------------------
|
|
75
|
+
/**
|
|
76
|
+
* The props used for each component slot.
|
|
77
|
+
* @default {}
|
|
78
|
+
*/
|
|
79
|
+
slotProps: PropTypes.object,
|
|
80
|
+
/**
|
|
81
|
+
* Overridable component slots.
|
|
82
|
+
* @default {}
|
|
83
|
+
*/
|
|
84
|
+
slots: PropTypes.object
|
|
85
|
+
} : void 0;
|
|
86
|
+
export { AreaPlot };
|
|
@@ -34,7 +34,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
34
34
|
leftAxis,
|
|
35
35
|
rightAxis,
|
|
36
36
|
bottomAxis,
|
|
37
|
-
children
|
|
37
|
+
children,
|
|
38
|
+
slots,
|
|
39
|
+
slotProps
|
|
38
40
|
} = props;
|
|
39
41
|
const id = useId();
|
|
40
42
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -60,13 +62,27 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
60
62
|
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
61
63
|
children: [/*#__PURE__*/_jsxs("g", {
|
|
62
64
|
clipPath: `url(#${clipPathId})`,
|
|
63
|
-
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
65
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
66
|
+
slots: slots,
|
|
67
|
+
slotProps: slotProps
|
|
68
|
+
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
69
|
+
slots: slots,
|
|
70
|
+
slotProps: slotProps
|
|
71
|
+
})]
|
|
64
72
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
65
73
|
topAxis: topAxis,
|
|
66
74
|
leftAxis: leftAxis,
|
|
67
75
|
rightAxis: rightAxis,
|
|
68
|
-
bottomAxis: bottomAxis
|
|
69
|
-
|
|
76
|
+
bottomAxis: bottomAxis,
|
|
77
|
+
slots: slots,
|
|
78
|
+
slotProps: slotProps
|
|
79
|
+
}), /*#__PURE__*/_jsx(MarkPlot, {
|
|
80
|
+
slots: slots,
|
|
81
|
+
slotProps: slotProps
|
|
82
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
83
|
+
slots: slots,
|
|
84
|
+
slotProps: slotProps
|
|
85
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
70
86
|
id: clipPathId
|
|
71
87
|
}), children]
|
|
72
88
|
});
|
|
@@ -94,8 +110,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
94
110
|
label: PropTypes.string,
|
|
95
111
|
labelFontSize: PropTypes.number,
|
|
96
112
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
113
|
+
slotProps: PropTypes.object,
|
|
114
|
+
slots: PropTypes.object,
|
|
97
115
|
stroke: PropTypes.string,
|
|
98
116
|
tickFontSize: PropTypes.number,
|
|
117
|
+
tickMaxStep: PropTypes.number,
|
|
118
|
+
tickMinStep: PropTypes.number,
|
|
119
|
+
tickNumber: PropTypes.number,
|
|
99
120
|
tickSize: PropTypes.number
|
|
100
121
|
}), PropTypes.string]),
|
|
101
122
|
children: PropTypes.node,
|
|
@@ -122,8 +143,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
122
143
|
label: PropTypes.string,
|
|
123
144
|
labelFontSize: PropTypes.number,
|
|
124
145
|
position: PropTypes.oneOf(['left', 'right']),
|
|
146
|
+
slotProps: PropTypes.object,
|
|
147
|
+
slots: PropTypes.object,
|
|
125
148
|
stroke: PropTypes.string,
|
|
126
149
|
tickFontSize: PropTypes.number,
|
|
150
|
+
tickMaxStep: PropTypes.number,
|
|
151
|
+
tickMinStep: PropTypes.number,
|
|
152
|
+
tickNumber: PropTypes.number,
|
|
127
153
|
tickSize: PropTypes.number
|
|
128
154
|
}), PropTypes.string]),
|
|
129
155
|
legend: PropTypes.shape({
|
|
@@ -140,6 +166,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
140
166
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
141
167
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
142
168
|
}),
|
|
169
|
+
slotProps: PropTypes.object,
|
|
170
|
+
slots: PropTypes.object,
|
|
143
171
|
spacing: PropTypes.number
|
|
144
172
|
}),
|
|
145
173
|
margin: PropTypes.shape({
|
|
@@ -162,8 +190,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
162
190
|
label: PropTypes.string,
|
|
163
191
|
labelFontSize: PropTypes.number,
|
|
164
192
|
position: PropTypes.oneOf(['left', 'right']),
|
|
193
|
+
slotProps: PropTypes.object,
|
|
194
|
+
slots: PropTypes.object,
|
|
165
195
|
stroke: PropTypes.string,
|
|
166
196
|
tickFontSize: PropTypes.number,
|
|
197
|
+
tickMaxStep: PropTypes.number,
|
|
198
|
+
tickMinStep: PropTypes.number,
|
|
199
|
+
tickNumber: PropTypes.number,
|
|
167
200
|
tickSize: PropTypes.number
|
|
168
201
|
}), PropTypes.string]),
|
|
169
202
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -186,6 +219,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
186
219
|
xAxisKey: PropTypes.string,
|
|
187
220
|
yAxisKey: PropTypes.string
|
|
188
221
|
})).isRequired,
|
|
222
|
+
/**
|
|
223
|
+
* The props used for each component slot.
|
|
224
|
+
* @default {}
|
|
225
|
+
*/
|
|
226
|
+
slotProps: PropTypes.object,
|
|
227
|
+
/**
|
|
228
|
+
* Overridable component slots.
|
|
229
|
+
* @default {}
|
|
230
|
+
*/
|
|
231
|
+
slots: PropTypes.object,
|
|
189
232
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
190
233
|
title: PropTypes.string,
|
|
191
234
|
tooltip: PropTypes.shape({
|
|
@@ -208,8 +251,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
208
251
|
label: PropTypes.string,
|
|
209
252
|
labelFontSize: PropTypes.number,
|
|
210
253
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
254
|
+
slotProps: PropTypes.object,
|
|
255
|
+
slots: PropTypes.object,
|
|
211
256
|
stroke: PropTypes.string,
|
|
212
257
|
tickFontSize: PropTypes.number,
|
|
258
|
+
tickMaxStep: PropTypes.number,
|
|
259
|
+
tickMinStep: PropTypes.number,
|
|
260
|
+
tickNumber: PropTypes.number,
|
|
213
261
|
tickSize: PropTypes.number
|
|
214
262
|
}), PropTypes.string]),
|
|
215
263
|
viewBox: PropTypes.shape({
|
|
@@ -232,15 +280,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
232
280
|
label: PropTypes.string,
|
|
233
281
|
labelFontSize: PropTypes.number,
|
|
234
282
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
235
|
-
maxTicks: PropTypes.number,
|
|
236
283
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
237
|
-
minTicks: PropTypes.number,
|
|
238
284
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
239
285
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
286
|
+
slotProps: PropTypes.object,
|
|
287
|
+
slots: PropTypes.object,
|
|
240
288
|
stroke: PropTypes.string,
|
|
241
289
|
tickFontSize: PropTypes.number,
|
|
290
|
+
tickMaxStep: PropTypes.number,
|
|
291
|
+
tickMinStep: PropTypes.number,
|
|
292
|
+
tickNumber: PropTypes.number,
|
|
242
293
|
tickSize: PropTypes.number,
|
|
243
|
-
tickSpacing: PropTypes.number,
|
|
244
294
|
valueFormatter: PropTypes.func
|
|
245
295
|
})),
|
|
246
296
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -256,15 +306,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
256
306
|
label: PropTypes.string,
|
|
257
307
|
labelFontSize: PropTypes.number,
|
|
258
308
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
259
|
-
maxTicks: PropTypes.number,
|
|
260
309
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
261
|
-
minTicks: PropTypes.number,
|
|
262
310
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
263
311
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
312
|
+
slotProps: PropTypes.object,
|
|
313
|
+
slots: PropTypes.object,
|
|
264
314
|
stroke: PropTypes.string,
|
|
265
315
|
tickFontSize: PropTypes.number,
|
|
316
|
+
tickMaxStep: PropTypes.number,
|
|
317
|
+
tickMinStep: PropTypes.number,
|
|
318
|
+
tickNumber: PropTypes.number,
|
|
266
319
|
tickSize: PropTypes.number,
|
|
267
|
-
tickSpacing: PropTypes.number,
|
|
268
320
|
valueFormatter: PropTypes.func
|
|
269
321
|
}))
|
|
270
322
|
} : void 0;
|