@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
|
@@ -147,7 +147,8 @@ function CartesianContextProvider(_ref) {
|
|
|
147
147
|
var scaleType = (_axis$scaleType = axis.scaleType) != null ? _axis$scaleType : 'linear';
|
|
148
148
|
var extremums = [(_axis$min = axis.min) != null ? _axis$min : minData, (_axis$max = axis.max) != null ? _axis$max : maxData];
|
|
149
149
|
var ticksNumber = getTicksNumber(_extends({}, axis, {
|
|
150
|
-
range: range
|
|
150
|
+
range: range,
|
|
151
|
+
domain: extremums
|
|
151
152
|
}));
|
|
152
153
|
var niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
|
|
153
154
|
var niceDomain = niceScale.domain();
|
|
@@ -202,7 +203,8 @@ function CartesianContextProvider(_ref) {
|
|
|
202
203
|
var scaleType = (_axis$scaleType2 = axis.scaleType) != null ? _axis$scaleType2 : 'linear';
|
|
203
204
|
var extremums = [(_axis$min3 = axis.min) != null ? _axis$min3 : minData, (_axis$max3 = axis.max) != null ? _axis$max3 : maxData];
|
|
204
205
|
var ticksNumber = getTicksNumber(_extends({}, axis, {
|
|
205
|
-
range: range
|
|
206
|
+
range: range,
|
|
207
|
+
domain: extremums
|
|
206
208
|
}));
|
|
207
209
|
var niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
|
|
208
210
|
var niceDomain = niceScale.domain();
|
|
@@ -253,15 +255,17 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
253
255
|
label: PropTypes.string,
|
|
254
256
|
labelFontSize: PropTypes.number,
|
|
255
257
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
256
|
-
maxTicks: PropTypes.number,
|
|
257
258
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
258
|
-
minTicks: PropTypes.number,
|
|
259
259
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
260
260
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
261
|
+
slotProps: PropTypes.object,
|
|
262
|
+
slots: PropTypes.object,
|
|
261
263
|
stroke: PropTypes.string,
|
|
262
264
|
tickFontSize: PropTypes.number,
|
|
265
|
+
tickMaxStep: PropTypes.number,
|
|
266
|
+
tickMinStep: PropTypes.number,
|
|
267
|
+
tickNumber: PropTypes.number,
|
|
263
268
|
tickSize: PropTypes.number,
|
|
264
|
-
tickSpacing: PropTypes.number,
|
|
265
269
|
valueFormatter: PropTypes.func
|
|
266
270
|
})),
|
|
267
271
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -277,15 +281,17 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
277
281
|
label: PropTypes.string,
|
|
278
282
|
labelFontSize: PropTypes.number,
|
|
279
283
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
280
|
-
maxTicks: PropTypes.number,
|
|
281
284
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
282
|
-
minTicks: PropTypes.number,
|
|
283
285
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
284
286
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
287
|
+
slotProps: PropTypes.object,
|
|
288
|
+
slots: PropTypes.object,
|
|
285
289
|
stroke: PropTypes.string,
|
|
286
290
|
tickFontSize: PropTypes.number,
|
|
291
|
+
tickMaxStep: PropTypes.number,
|
|
292
|
+
tickMinStep: PropTypes.number,
|
|
293
|
+
tickNumber: PropTypes.number,
|
|
287
294
|
tickSize: PropTypes.number,
|
|
288
|
-
tickSpacing: PropTypes.number,
|
|
289
295
|
valueFormatter: PropTypes.func
|
|
290
296
|
}))
|
|
291
297
|
} : void 0;
|
package/legacy/hooks/useTicks.js
CHANGED
|
@@ -2,15 +2,15 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { isBandScale } from '../internals/isBandScale';
|
|
4
4
|
export function getTicksNumber(params) {
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
return Math.min(maxTicks, Math.max(minTicks,
|
|
5
|
+
var tickMaxStep = params.tickMaxStep,
|
|
6
|
+
tickMinStep = params.tickMinStep,
|
|
7
|
+
tickNumber = params.tickNumber,
|
|
8
|
+
range = params.range,
|
|
9
|
+
domain = params.domain;
|
|
10
|
+
var maxTicks = tickMinStep === undefined ? 999 : Math.floor(Math.abs(domain[1] - domain[0]) / tickMinStep);
|
|
11
|
+
var minTicks = tickMaxStep === undefined ? 2 : Math.ceil(Math.abs(domain[1] - domain[0]) / tickMaxStep);
|
|
12
|
+
var defaultizedTickNumber = tickNumber != null ? tickNumber : Math.floor(Math.abs(range[1] - range[0]) / 50);
|
|
13
|
+
return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
|
|
14
14
|
}
|
|
15
15
|
function useTicks(options) {
|
|
16
16
|
var scale = options.scale,
|
package/legacy/index.js
CHANGED
|
@@ -10,24 +10,24 @@ export var AxisRoot = styled('g', {
|
|
|
10
10
|
return styles.root;
|
|
11
11
|
}
|
|
12
12
|
})((_styled = {}, _defineProperty(_styled, "&.".concat(axisClasses.directionY), (_$concat = {}, _defineProperty(_$concat, ".".concat(axisClasses.tickLabel), {
|
|
13
|
-
|
|
13
|
+
dominantBaseline: 'middle'
|
|
14
14
|
}), _defineProperty(_$concat, ".".concat(axisClasses.label), {
|
|
15
|
-
|
|
15
|
+
dominantBaseline: 'auto',
|
|
16
16
|
textAnchor: 'middle'
|
|
17
17
|
}), _$concat)), _defineProperty(_styled, "&.".concat(axisClasses.left), _defineProperty({}, ".".concat(axisClasses.tickLabel), {
|
|
18
|
-
|
|
18
|
+
dominantBaseline: 'central',
|
|
19
19
|
textAnchor: 'end'
|
|
20
20
|
})), _defineProperty(_styled, "&.".concat(axisClasses.right), _defineProperty({}, ".".concat(axisClasses.tickLabel), {
|
|
21
|
-
|
|
21
|
+
dominantBaseline: 'central',
|
|
22
22
|
textAnchor: 'start'
|
|
23
23
|
})), _defineProperty(_styled, "&.".concat(axisClasses.bottom), _defineProperty({}, ".".concat(axisClasses.tickLabel, ", .").concat(axisClasses.label), {
|
|
24
|
-
|
|
24
|
+
dominantBaseline: 'hanging',
|
|
25
25
|
textAnchor: 'middle'
|
|
26
26
|
})), _defineProperty(_styled, "&.".concat(axisClasses.top), _defineProperty({}, ".".concat(axisClasses.tickLabel, ", .").concat(axisClasses.label), {
|
|
27
|
-
|
|
27
|
+
dominantBaseline: 'baseline',
|
|
28
28
|
textAnchor: 'middle'
|
|
29
29
|
})), _styled));
|
|
30
|
-
export var
|
|
30
|
+
export var ChartsLine = styled('line', {
|
|
31
31
|
name: 'MuiChartsAxis',
|
|
32
32
|
slot: 'Line',
|
|
33
33
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -41,7 +41,7 @@ export var Line = styled('line', {
|
|
|
41
41
|
strokeWidth: 1
|
|
42
42
|
};
|
|
43
43
|
});
|
|
44
|
-
export var
|
|
44
|
+
export var ChartsTick = styled('line', {
|
|
45
45
|
name: 'MuiChartsAxis',
|
|
46
46
|
slot: 'Tick',
|
|
47
47
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -54,7 +54,7 @@ export var Tick = styled('line', {
|
|
|
54
54
|
shapeRendering: 'crispEdges'
|
|
55
55
|
};
|
|
56
56
|
});
|
|
57
|
-
export var
|
|
57
|
+
export var ChartsTickLabel = styled('text', {
|
|
58
58
|
name: 'MuiChartsAxis',
|
|
59
59
|
slot: 'TickLabel',
|
|
60
60
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -66,7 +66,7 @@ export var TickLabel = styled('text', {
|
|
|
66
66
|
fill: theme.palette.text.primary
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
|
-
export var
|
|
69
|
+
export var ChartsLabel = styled('text', {
|
|
70
70
|
name: 'MuiChartsAxis',
|
|
71
71
|
slot: 'Label',
|
|
72
72
|
overridesResolver: function overridesResolver(props, styles) {
|
package/models/axis.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, ScalePoint } from 'd3-scale';
|
|
2
3
|
import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
|
|
3
4
|
import type { TickParams } from '../hooks/useTicks';
|
|
4
5
|
export type D3Scale = ScaleBand<any> | ScaleLogarithmic<any, any> | ScalePoint<any> | ScalePower<any, any> | ScaleTime<any, any> | ScaleLinear<any, any>;
|
|
5
6
|
export type D3ContinuouseScale = ScaleLogarithmic<any, any> | ScalePower<any, any> | ScaleTime<any, any> | ScaleLinear<any, any>;
|
|
6
|
-
export interface
|
|
7
|
+
export interface ChartsAxisSlotsComponent {
|
|
8
|
+
axisLine?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
|
|
9
|
+
axisTick?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
|
|
10
|
+
axisTickLabel?: React.JSXElementConstructor<React.SVGAttributes<SVGTextElement>>;
|
|
11
|
+
axisLabel?: React.JSXElementConstructor<React.SVGAttributes<SVGTextElement>>;
|
|
12
|
+
}
|
|
13
|
+
export interface ChartsAxisSlotComponentProps {
|
|
14
|
+
axisLine?: Partial<React.SVGAttributes<SVGPathElement>>;
|
|
15
|
+
axisTick?: Partial<React.SVGAttributes<SVGPathElement>>;
|
|
16
|
+
axisTickLabel?: Partial<React.SVGAttributes<SVGTextElement>>;
|
|
17
|
+
axisLabel?: Partial<React.SVGAttributes<SVGTextElement>>;
|
|
18
|
+
}
|
|
19
|
+
export interface ChartsAxisProps extends TickParams {
|
|
7
20
|
/**
|
|
8
21
|
* Id of the axis to render.
|
|
9
22
|
*/
|
|
@@ -51,6 +64,16 @@ export interface ChartsAxisProps {
|
|
|
51
64
|
* Override or extend the styles applied to the component.
|
|
52
65
|
*/
|
|
53
66
|
classes?: Partial<ChartsAxisClasses>;
|
|
67
|
+
/**
|
|
68
|
+
* Overridable component slots.
|
|
69
|
+
* @default {}
|
|
70
|
+
*/
|
|
71
|
+
slots?: Partial<ChartsAxisSlotsComponent>;
|
|
72
|
+
/**
|
|
73
|
+
* The props used for each component slot.
|
|
74
|
+
* @default {}
|
|
75
|
+
*/
|
|
76
|
+
slotProps?: Partial<ChartsAxisSlotComponentProps>;
|
|
54
77
|
}
|
|
55
78
|
export interface ChartsYAxisProps extends ChartsAxisProps {
|
|
56
79
|
/**
|
|
@@ -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`;
|
|
@@ -56,15 +58,26 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
56
58
|
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
57
59
|
children: [/*#__PURE__*/_jsx("g", {
|
|
58
60
|
clipPath: `url(#${clipPathId})`,
|
|
59
|
-
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
61
|
+
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
62
|
+
slots: slots,
|
|
63
|
+
slotProps: slotProps
|
|
64
|
+
})
|
|
60
65
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
61
66
|
topAxis: topAxis,
|
|
62
67
|
leftAxis: leftAxis,
|
|
63
68
|
rightAxis: rightAxis,
|
|
64
|
-
bottomAxis: bottomAxis
|
|
65
|
-
|
|
69
|
+
bottomAxis: bottomAxis,
|
|
70
|
+
slots: slots,
|
|
71
|
+
slotProps: slotProps
|
|
72
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
73
|
+
slots: slots,
|
|
74
|
+
slotProps: slotProps
|
|
75
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
66
76
|
x: "band"
|
|
67
|
-
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
77
|
+
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
78
|
+
slots: slots,
|
|
79
|
+
slotProps: slotProps
|
|
80
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
68
81
|
id: clipPathId
|
|
69
82
|
}), children]
|
|
70
83
|
});
|
|
@@ -92,8 +105,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
92
105
|
label: PropTypes.string,
|
|
93
106
|
labelFontSize: PropTypes.number,
|
|
94
107
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
108
|
+
slotProps: PropTypes.object,
|
|
109
|
+
slots: PropTypes.object,
|
|
95
110
|
stroke: PropTypes.string,
|
|
96
111
|
tickFontSize: PropTypes.number,
|
|
112
|
+
tickMaxStep: PropTypes.number,
|
|
113
|
+
tickMinStep: PropTypes.number,
|
|
114
|
+
tickNumber: PropTypes.number,
|
|
97
115
|
tickSize: PropTypes.number
|
|
98
116
|
}), PropTypes.string]),
|
|
99
117
|
children: PropTypes.node,
|
|
@@ -120,8 +138,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
120
138
|
label: PropTypes.string,
|
|
121
139
|
labelFontSize: PropTypes.number,
|
|
122
140
|
position: PropTypes.oneOf(['left', 'right']),
|
|
141
|
+
slotProps: PropTypes.object,
|
|
142
|
+
slots: PropTypes.object,
|
|
123
143
|
stroke: PropTypes.string,
|
|
124
144
|
tickFontSize: PropTypes.number,
|
|
145
|
+
tickMaxStep: PropTypes.number,
|
|
146
|
+
tickMinStep: PropTypes.number,
|
|
147
|
+
tickNumber: PropTypes.number,
|
|
125
148
|
tickSize: PropTypes.number
|
|
126
149
|
}), PropTypes.string]),
|
|
127
150
|
legend: PropTypes.shape({
|
|
@@ -138,6 +161,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
138
161
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
139
162
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
140
163
|
}),
|
|
164
|
+
slotProps: PropTypes.object,
|
|
165
|
+
slots: PropTypes.object,
|
|
141
166
|
spacing: PropTypes.number
|
|
142
167
|
}),
|
|
143
168
|
margin: PropTypes.shape({
|
|
@@ -160,8 +185,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
160
185
|
label: PropTypes.string,
|
|
161
186
|
labelFontSize: PropTypes.number,
|
|
162
187
|
position: PropTypes.oneOf(['left', 'right']),
|
|
188
|
+
slotProps: PropTypes.object,
|
|
189
|
+
slots: PropTypes.object,
|
|
163
190
|
stroke: PropTypes.string,
|
|
164
191
|
tickFontSize: PropTypes.number,
|
|
192
|
+
tickMaxStep: PropTypes.number,
|
|
193
|
+
tickMinStep: PropTypes.number,
|
|
194
|
+
tickNumber: PropTypes.number,
|
|
165
195
|
tickSize: PropTypes.number
|
|
166
196
|
}), PropTypes.string]),
|
|
167
197
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -182,6 +212,16 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
182
212
|
xAxisKey: PropTypes.string,
|
|
183
213
|
yAxisKey: PropTypes.string
|
|
184
214
|
})).isRequired,
|
|
215
|
+
/**
|
|
216
|
+
* The props used for each component slot.
|
|
217
|
+
* @default {}
|
|
218
|
+
*/
|
|
219
|
+
slotProps: PropTypes.object,
|
|
220
|
+
/**
|
|
221
|
+
* Overridable component slots.
|
|
222
|
+
* @default {}
|
|
223
|
+
*/
|
|
224
|
+
slots: PropTypes.object,
|
|
185
225
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
186
226
|
title: PropTypes.string,
|
|
187
227
|
tooltip: PropTypes.shape({
|
|
@@ -204,8 +244,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
204
244
|
label: PropTypes.string,
|
|
205
245
|
labelFontSize: PropTypes.number,
|
|
206
246
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
247
|
+
slotProps: PropTypes.object,
|
|
248
|
+
slots: PropTypes.object,
|
|
207
249
|
stroke: PropTypes.string,
|
|
208
250
|
tickFontSize: PropTypes.number,
|
|
251
|
+
tickMaxStep: PropTypes.number,
|
|
252
|
+
tickMinStep: PropTypes.number,
|
|
253
|
+
tickNumber: PropTypes.number,
|
|
209
254
|
tickSize: PropTypes.number
|
|
210
255
|
}), PropTypes.string]),
|
|
211
256
|
viewBox: PropTypes.shape({
|
|
@@ -228,15 +273,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
228
273
|
label: PropTypes.string,
|
|
229
274
|
labelFontSize: PropTypes.number,
|
|
230
275
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
231
|
-
maxTicks: PropTypes.number,
|
|
232
276
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
233
|
-
minTicks: PropTypes.number,
|
|
234
277
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
235
278
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
279
|
+
slotProps: PropTypes.object,
|
|
280
|
+
slots: PropTypes.object,
|
|
236
281
|
stroke: PropTypes.string,
|
|
237
282
|
tickFontSize: PropTypes.number,
|
|
283
|
+
tickMaxStep: PropTypes.number,
|
|
284
|
+
tickMinStep: PropTypes.number,
|
|
285
|
+
tickNumber: PropTypes.number,
|
|
238
286
|
tickSize: PropTypes.number,
|
|
239
|
-
tickSpacing: PropTypes.number,
|
|
240
287
|
valueFormatter: PropTypes.func
|
|
241
288
|
})),
|
|
242
289
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -252,15 +299,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
252
299
|
label: PropTypes.string,
|
|
253
300
|
labelFontSize: PropTypes.number,
|
|
254
301
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
255
|
-
maxTicks: PropTypes.number,
|
|
256
302
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
257
|
-
minTicks: PropTypes.number,
|
|
258
303
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
259
304
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
305
|
+
slotProps: PropTypes.object,
|
|
306
|
+
slots: PropTypes.object,
|
|
260
307
|
stroke: PropTypes.string,
|
|
261
308
|
tickFontSize: PropTypes.number,
|
|
309
|
+
tickMaxStep: PropTypes.number,
|
|
310
|
+
tickMinStep: PropTypes.number,
|
|
311
|
+
tickNumber: PropTypes.number,
|
|
262
312
|
tickSize: PropTypes.number,
|
|
263
|
-
tickSpacing: PropTypes.number,
|
|
264
313
|
valueFormatter: PropTypes.func
|
|
265
314
|
}))
|
|
266
315
|
} : 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
|
|
@@ -43,7 +44,9 @@ export function BarElement(props) {
|
|
|
43
44
|
dataIndex,
|
|
44
45
|
classes: innerClasses,
|
|
45
46
|
color,
|
|
46
|
-
highlightScope
|
|
47
|
+
highlightScope,
|
|
48
|
+
slots,
|
|
49
|
+
slotProps
|
|
47
50
|
} = props,
|
|
48
51
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
49
52
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -69,12 +72,18 @@ export function BarElement(props) {
|
|
|
69
72
|
isHighlighted
|
|
70
73
|
};
|
|
71
74
|
const classes = useUtilityClasses(ownerState);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const Bar = slots?.bar ?? BarElementPath;
|
|
76
|
+
const barProps = useSlotProps({
|
|
77
|
+
elementType: Bar,
|
|
78
|
+
externalSlotProps: slotProps?.bar,
|
|
79
|
+
additionalProps: _extends({}, other, getInteractionItemProps({
|
|
80
|
+
type: 'bar',
|
|
81
|
+
seriesId: id,
|
|
82
|
+
dataIndex
|
|
83
|
+
}), {
|
|
84
|
+
className: classes.root
|
|
85
|
+
}),
|
|
86
|
+
ownerState
|
|
87
|
+
});
|
|
88
|
+
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
80
89
|
}
|
|
@@ -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) {
|
|
@@ -87,7 +89,7 @@ export function BarPlot() {
|
|
|
87
89
|
return stackedData.map((values, dataIndex) => {
|
|
88
90
|
const baseline = Math.min(...values);
|
|
89
91
|
const value = Math.max(...values);
|
|
90
|
-
return /*#__PURE__*/_jsx(BarElement, {
|
|
92
|
+
return /*#__PURE__*/_jsx(BarElement, _extends({
|
|
91
93
|
id: seriesId,
|
|
92
94
|
dataIndex: dataIndex,
|
|
93
95
|
x: xScale(xAxis[xAxisKey].data?.[dataIndex]) + groupIndex * (barWidth + offset),
|
|
@@ -96,9 +98,26 @@ export function BarPlot() {
|
|
|
96
98
|
width: barWidth,
|
|
97
99
|
color: color,
|
|
98
100
|
highlightScope: series[seriesId].highlightScope
|
|
99
|
-
}, `${seriesId}-${dataIndex}`);
|
|
101
|
+
}, props), `${seriesId}-${dataIndex}`);
|
|
100
102
|
});
|
|
101
103
|
});
|
|
102
104
|
})
|
|
103
105
|
});
|
|
104
|
-
}
|
|
106
|
+
}
|
|
107
|
+
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
108
|
+
// ----------------------------- Warning --------------------------------
|
|
109
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
110
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
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
|
|
122
|
+
} : void 0;
|
|
123
|
+
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?.slots),
|
|
21
|
+
slotProps: _extends({}, slotProps, 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;
|