@mui/x-charts 6.0.0-alpha.14 → 6.0.0-alpha.16
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 +16 -2
- package/BarChart/BarChart.js +49 -11
- package/BarChart/BarElement.d.ts +1318 -3
- package/BarChart/BarElement.js +10 -8
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/CHANGELOG.md +169 -0
- package/ChartContainer/index.js +5 -2
- package/ChartsAxis/ChartsAxis.js +18 -2
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/ChartsClipPath/ChartsClipPath.js +2 -2
- package/ChartsLegend/ChartsLegend.d.ts +44 -24
- package/ChartsLegend/ChartsLegend.js +191 -145
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.js +5 -13
- package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsTooltip.js +2 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +151 -40
- package/ChartsYAxis/ChartsYAxis.js +76 -33
- package/LineChart/AreaElement.d.ts +10 -0
- package/LineChart/AreaElement.js +12 -2
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +13 -2
- package/LineChart/LineChart.d.ts +13 -0
- package/LineChart/LineChart.js +40 -10
- package/LineChart/LineElement.d.ts +10 -0
- package/LineChart/LineElement.js +12 -2
- package/LineChart/LineHighlightElement.d.ts +10 -0
- package/LineChart/LineHighlightElement.js +12 -2
- package/LineChart/LineHighlightPlot.d.ts +10 -0
- package/LineChart/LineHighlightPlot.js +12 -2
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +12 -2
- package/LineChart/MarkElement.d.ts +10 -0
- package/LineChart/MarkElement.js +12 -2
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +12 -2
- package/PieChart/PieArc.js +2 -2
- package/PieChart/PieArcLabel.js +2 -2
- package/PieChart/PieChart.d.ts +13 -0
- package/PieChart/PieChart.js +41 -10
- package/PieChart/PiePlot.d.ts +10 -0
- package/PieChart/PiePlot.js +12 -2
- package/ResponsiveChartContainer/index.js +4 -4
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +13 -0
- package/ScatterChart/ScatterChart.js +40 -10
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/SparkLineChart/SparkLineChart.d.ts +9 -0
- package/SparkLineChart/SparkLineChart.js +16 -2
- package/constants.js +1 -1
- package/context/CartesianContextProvider.js +20 -12
- package/context/DrawingProvider.d.ts +2 -0
- package/context/DrawingProvider.js +4 -2
- package/context/HighlightProvider.js +2 -2
- package/context/InteractionProvider.js +2 -2
- package/context/SeriesContextProvider.js +2 -2
- package/esm/BarChart/BarChart.js +47 -9
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +16 -0
- package/esm/ChartsLegend/ChartsLegend.js +188 -142
- package/esm/ChartsSurface.js +3 -11
- package/esm/ChartsXAxis/ChartsXAxis.js +148 -37
- package/esm/ChartsYAxis/ChartsYAxis.js +73 -30
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +11 -0
- package/esm/LineChart/LineChart.js +38 -8
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +10 -0
- package/esm/LineChart/LineHighlightPlot.js +10 -0
- package/esm/LineChart/LinePlot.js +10 -0
- package/esm/LineChart/MarkElement.js +10 -0
- package/esm/LineChart/MarkPlot.js +10 -0
- package/esm/PieChart/PieChart.js +39 -8
- package/esm/PieChart/PiePlot.js +10 -0
- package/esm/ResponsiveChartContainer/index.js +2 -2
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +38 -8
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +14 -0
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +19 -11
- package/esm/context/DrawingProvider.js +2 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +15 -9
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +75 -0
- package/esm/internals/domUtils.js +113 -0
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +4 -2
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +19 -11
- package/hooks/useTicks.js +18 -12
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +16 -71
- package/internals/components/ChartsText.d.ts +35 -0
- package/internals/components/ChartsText.js +85 -0
- package/internals/defaultizeColor.d.ts +1 -1
- package/internals/domUtils.d.ts +13 -0
- package/internals/domUtils.js +122 -0
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/legacy/BarChart/BarChart.js +47 -9
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +16 -0
- package/legacy/ChartsLegend/ChartsLegend.js +203 -140
- package/legacy/ChartsSurface.js +2 -11
- package/legacy/ChartsXAxis/ChartsXAxis.js +152 -39
- package/legacy/ChartsYAxis/ChartsYAxis.js +73 -30
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +11 -0
- package/legacy/LineChart/LineChart.js +38 -8
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +10 -0
- package/legacy/LineChart/LineHighlightPlot.js +10 -0
- package/legacy/LineChart/LinePlot.js +10 -0
- package/legacy/LineChart/MarkElement.js +10 -0
- package/legacy/LineChart/MarkPlot.js +10 -0
- package/legacy/PieChart/PieChart.js +39 -8
- package/legacy/PieChart/PiePlot.js +10 -0
- package/legacy/ResponsiveChartContainer/index.js +2 -2
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +38 -8
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +14 -0
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +19 -11
- package/legacy/context/DrawingProvider.js +2 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +16 -9
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +9 -63
- package/legacy/internals/components/ChartsText.js +77 -0
- package/legacy/internals/domUtils.js +121 -0
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +25 -7
- package/models/layout.d.ts +7 -6
- package/models/seriesType/line.d.ts +2 -2
- package/modern/BarChart/BarChart.js +47 -9
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +16 -0
- package/modern/ChartsLegend/ChartsLegend.js +188 -142
- package/modern/ChartsSurface.js +3 -11
- package/modern/ChartsXAxis/ChartsXAxis.js +148 -37
- package/modern/ChartsYAxis/ChartsYAxis.js +73 -30
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +11 -0
- package/modern/LineChart/LineChart.js +38 -8
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +10 -0
- package/modern/LineChart/LineHighlightPlot.js +10 -0
- package/modern/LineChart/LinePlot.js +10 -0
- package/modern/LineChart/MarkElement.js +10 -0
- package/modern/LineChart/MarkPlot.js +10 -0
- package/modern/PieChart/PieChart.js +39 -8
- package/modern/PieChart/PiePlot.js +10 -0
- package/modern/ResponsiveChartContainer/index.js +2 -2
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +38 -8
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +14 -0
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +19 -11
- package/modern/context/DrawingProvider.js +2 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +15 -9
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +75 -0
- package/modern/internals/domUtils.js +113 -0
- package/modern/internals/geometry.js +36 -0
- package/package.json +5 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
3
|
+
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
6
|
import { useSlotProps } from '@mui/base/utils';
|
|
@@ -8,13 +8,14 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import { color as d3Color } from 'd3-color';
|
|
10
10
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
11
|
+
import { animated } from '@react-spring/web';
|
|
11
12
|
import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
12
13
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
export function getBarElementUtilityClass(slot) {
|
|
15
16
|
return generateUtilityClass('MuiBarElement', slot);
|
|
16
17
|
}
|
|
17
|
-
export const
|
|
18
|
+
export const barElementClasses = generateUtilityClasses('MuiBarElement', ['root']);
|
|
18
19
|
const useUtilityClasses = ownerState => {
|
|
19
20
|
const {
|
|
20
21
|
classes,
|
|
@@ -25,7 +26,7 @@ const useUtilityClasses = ownerState => {
|
|
|
25
26
|
};
|
|
26
27
|
return composeClasses(slots, getBarElementUtilityClass, classes);
|
|
27
28
|
};
|
|
28
|
-
export const BarElementPath = styled(
|
|
29
|
+
export const BarElementPath = styled(animated.rect, {
|
|
29
30
|
name: 'MuiBarElement',
|
|
30
31
|
slot: 'Root',
|
|
31
32
|
overridesResolver: (_, styles) => styles.root
|
|
@@ -46,7 +47,8 @@ export function BarElement(props) {
|
|
|
46
47
|
color,
|
|
47
48
|
highlightScope,
|
|
48
49
|
slots,
|
|
49
|
-
slotProps
|
|
50
|
+
slotProps,
|
|
51
|
+
style
|
|
50
52
|
} = props,
|
|
51
53
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
52
54
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -81,6 +83,7 @@ export function BarElement(props) {
|
|
|
81
83
|
seriesId: id,
|
|
82
84
|
dataIndex
|
|
83
85
|
}), {
|
|
86
|
+
style,
|
|
84
87
|
className: classes.root
|
|
85
88
|
}),
|
|
86
89
|
ownerState
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["skipAnimation"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useTransition } from '@react-spring/web';
|
|
4
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
5
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
6
9
|
import { BarElement } from './BarElement';
|
|
7
10
|
import { isBandScaleConfig } from '../models/axis';
|
|
8
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
12
|
/**
|
|
10
13
|
* Solution of the equations
|
|
11
14
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -15,7 +18,6 @@ import { isBandScaleConfig } from '../models/axis';
|
|
|
15
18
|
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
16
19
|
* @returns The bar width and the offset between bars.
|
|
17
20
|
*/
|
|
18
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
21
|
function getBandSize({
|
|
20
22
|
bandWidth: W,
|
|
21
23
|
numberOfGroups: N,
|
|
@@ -34,12 +36,13 @@ function getBandSize({
|
|
|
34
36
|
offset
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
const seriesData = React.useContext(SeriesContext).bar
|
|
39
|
+
const useCompletedData = () => {
|
|
40
|
+
const seriesData = React.useContext(SeriesContext).bar ?? {
|
|
41
|
+
series: {},
|
|
42
|
+
stackingGroups: [],
|
|
43
|
+
seriesOrder: []
|
|
44
|
+
};
|
|
39
45
|
const axisData = React.useContext(CartesianContext);
|
|
40
|
-
if (seriesData === undefined) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
46
|
const {
|
|
44
47
|
series,
|
|
45
48
|
stackingGroups
|
|
@@ -52,66 +55,142 @@ function BarPlot(props) {
|
|
|
52
55
|
} = axisData;
|
|
53
56
|
const defaultXAxisId = xAxisIds[0];
|
|
54
57
|
const defaultYAxisId = yAxisIds[0];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw new Error(`Axis with id "${yAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
|
|
77
|
-
}
|
|
78
|
-
if (yAxis[yAxisKey].data === undefined) {
|
|
79
|
-
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
80
|
-
}
|
|
81
|
-
baseScaleConfig = yAxisConfig;
|
|
58
|
+
const data = stackingGroups.flatMap(({
|
|
59
|
+
ids: groupIds
|
|
60
|
+
}, groupIndex) => {
|
|
61
|
+
return groupIds.flatMap(seriesId => {
|
|
62
|
+
const xAxisKey = series[seriesId].xAxisKey ?? defaultXAxisId;
|
|
63
|
+
const yAxisKey = series[seriesId].yAxisKey ?? defaultYAxisId;
|
|
64
|
+
const xAxisConfig = xAxis[xAxisKey];
|
|
65
|
+
const yAxisConfig = yAxis[yAxisKey];
|
|
66
|
+
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
67
|
+
let baseScaleConfig;
|
|
68
|
+
if (verticalLayout) {
|
|
69
|
+
if (!isBandScaleConfig(xAxisConfig)) {
|
|
70
|
+
throw new Error(`Axis with id "${xAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
|
|
71
|
+
}
|
|
72
|
+
if (xAxis[xAxisKey].data === undefined) {
|
|
73
|
+
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
74
|
+
}
|
|
75
|
+
baseScaleConfig = xAxisConfig;
|
|
76
|
+
} else {
|
|
77
|
+
if (!isBandScaleConfig(yAxisConfig)) {
|
|
78
|
+
throw new Error(`Axis with id "${yAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
|
|
82
79
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
80
|
+
if (yAxis[yAxisKey].data === undefined) {
|
|
81
|
+
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
82
|
+
}
|
|
83
|
+
baseScaleConfig = yAxisConfig;
|
|
84
|
+
}
|
|
85
|
+
const xScale = xAxisConfig.scale;
|
|
86
|
+
const yScale = yAxisConfig.scale;
|
|
87
|
+
const bandWidth = baseScaleConfig.scale.bandwidth();
|
|
88
|
+
const {
|
|
89
|
+
barWidth,
|
|
90
|
+
offset
|
|
91
|
+
} = getBandSize({
|
|
92
|
+
bandWidth,
|
|
93
|
+
numberOfGroups: stackingGroups.length,
|
|
94
|
+
gapRatio: baseScaleConfig.barGapRatio
|
|
95
|
+
});
|
|
96
|
+
const barOffset = groupIndex * (barWidth + offset);
|
|
97
|
+
const {
|
|
98
|
+
stackedData,
|
|
99
|
+
color
|
|
100
|
+
} = series[seriesId];
|
|
101
|
+
return stackedData.map((values, dataIndex) => {
|
|
102
|
+
const bottom = Math.min(...values);
|
|
103
|
+
const top = Math.max(...values);
|
|
104
|
+
return {
|
|
105
|
+
bottom,
|
|
106
|
+
top,
|
|
107
|
+
seriesId,
|
|
108
|
+
dataIndex,
|
|
109
|
+
layout: series[seriesId].layout,
|
|
110
|
+
x: verticalLayout ? xScale(xAxis[xAxisKey].data?.[dataIndex]) + barOffset : xScale(bottom),
|
|
111
|
+
y: verticalLayout ? yScale(top) : yScale(yAxis[yAxisKey].data?.[dataIndex]) + barOffset,
|
|
112
|
+
xOrigin: xScale(0),
|
|
113
|
+
yOrigin: yScale(0),
|
|
114
|
+
height: verticalLayout ? Math.abs(yScale(bottom) - yScale(top)) : barWidth,
|
|
115
|
+
width: verticalLayout ? barWidth : Math.abs(xScale(bottom) - xScale(top)),
|
|
116
|
+
color,
|
|
117
|
+
highlightScope: series[seriesId].highlightScope
|
|
118
|
+
};
|
|
113
119
|
});
|
|
114
|
-
})
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return data;
|
|
123
|
+
};
|
|
124
|
+
const getOutStyle = ({
|
|
125
|
+
layout,
|
|
126
|
+
yOrigin,
|
|
127
|
+
x,
|
|
128
|
+
width,
|
|
129
|
+
y,
|
|
130
|
+
xOrigin,
|
|
131
|
+
height
|
|
132
|
+
}) => _extends({}, layout === 'vertical' ? {
|
|
133
|
+
y: yOrigin,
|
|
134
|
+
x,
|
|
135
|
+
height: 0,
|
|
136
|
+
width
|
|
137
|
+
} : {
|
|
138
|
+
y,
|
|
139
|
+
x: xOrigin,
|
|
140
|
+
height,
|
|
141
|
+
width: 0
|
|
142
|
+
});
|
|
143
|
+
const getInStyle = ({
|
|
144
|
+
x,
|
|
145
|
+
width,
|
|
146
|
+
y,
|
|
147
|
+
height
|
|
148
|
+
}) => ({
|
|
149
|
+
y,
|
|
150
|
+
x,
|
|
151
|
+
height,
|
|
152
|
+
width
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Demos:
|
|
157
|
+
*
|
|
158
|
+
* - [Bars](https://mui.com/x/react-charts/bars/)
|
|
159
|
+
* - [Bar demonstration](https://mui.com/x/react-charts/bar-demo/)
|
|
160
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
161
|
+
*
|
|
162
|
+
* API:
|
|
163
|
+
*
|
|
164
|
+
* - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
|
|
165
|
+
*/
|
|
166
|
+
function BarPlot(props) {
|
|
167
|
+
const completedData = useCompletedData();
|
|
168
|
+
const {
|
|
169
|
+
skipAnimation
|
|
170
|
+
} = props,
|
|
171
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
172
|
+
const transition = useTransition(completedData, {
|
|
173
|
+
keys: bar => `${bar.seriesId}-${bar.dataIndex}`,
|
|
174
|
+
from: getOutStyle,
|
|
175
|
+
leave: getOutStyle,
|
|
176
|
+
enter: getInStyle,
|
|
177
|
+
update: getInStyle,
|
|
178
|
+
immediate: skipAnimation
|
|
179
|
+
});
|
|
180
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
181
|
+
children: transition((style, {
|
|
182
|
+
seriesId,
|
|
183
|
+
dataIndex,
|
|
184
|
+
color,
|
|
185
|
+
highlightScope
|
|
186
|
+
}) => /*#__PURE__*/_jsx(BarElement, _extends({
|
|
187
|
+
id: seriesId,
|
|
188
|
+
dataIndex: dataIndex,
|
|
189
|
+
highlightScope: highlightScope,
|
|
190
|
+
color: color
|
|
191
|
+
}, other, {
|
|
192
|
+
style: style
|
|
193
|
+
})))
|
|
115
194
|
});
|
|
116
195
|
}
|
|
117
196
|
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
@@ -119,6 +198,11 @@ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
|
119
198
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
120
199
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
121
200
|
// ----------------------------------------------------------------------
|
|
201
|
+
/**
|
|
202
|
+
* If `true`, animations are skiped.
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
skipAnimation: PropTypes.bool,
|
|
122
206
|
/**
|
|
123
207
|
* The props used for each component slot.
|
|
124
208
|
* @default {}
|
|
@@ -3,6 +3,7 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
3
3
|
import { DrawingProvider } from '../context/DrawingProvider';
|
|
4
4
|
import { SeriesContextProvider } from '../context/SeriesContextProvider';
|
|
5
5
|
import { InteractionProvider } from '../context/InteractionProvider';
|
|
6
|
+
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
6
7
|
import { ChartsSurface } from '../ChartsSurface';
|
|
7
8
|
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
8
9
|
import { HighlightProvider } from '../context/HighlightProvider';
|
|
@@ -25,6 +26,8 @@ export const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContai
|
|
|
25
26
|
} = props;
|
|
26
27
|
const svgRef = React.useRef(null);
|
|
27
28
|
const handleRef = useForkRef(ref, svgRef);
|
|
29
|
+
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
30
|
+
|
|
28
31
|
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
29
32
|
width: width,
|
|
30
33
|
height: height,
|
|
@@ -97,11 +97,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
97
97
|
fill: PropTypes.string,
|
|
98
98
|
label: PropTypes.string,
|
|
99
99
|
labelFontSize: PropTypes.number,
|
|
100
|
+
labelStyle: PropTypes.object,
|
|
100
101
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
101
102
|
slotProps: PropTypes.object,
|
|
102
103
|
slots: PropTypes.object,
|
|
103
104
|
stroke: PropTypes.string,
|
|
104
105
|
tickFontSize: PropTypes.number,
|
|
106
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
107
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
108
|
+
tickLabelStyle: PropTypes.object,
|
|
105
109
|
tickMaxStep: PropTypes.number,
|
|
106
110
|
tickMinStep: PropTypes.number,
|
|
107
111
|
tickNumber: PropTypes.number,
|
|
@@ -120,11 +124,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
120
124
|
fill: PropTypes.string,
|
|
121
125
|
label: PropTypes.string,
|
|
122
126
|
labelFontSize: PropTypes.number,
|
|
127
|
+
labelStyle: PropTypes.object,
|
|
123
128
|
position: PropTypes.oneOf(['left', 'right']),
|
|
124
129
|
slotProps: PropTypes.object,
|
|
125
130
|
slots: PropTypes.object,
|
|
126
131
|
stroke: PropTypes.string,
|
|
127
132
|
tickFontSize: PropTypes.number,
|
|
133
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
134
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
135
|
+
tickLabelStyle: PropTypes.object,
|
|
128
136
|
tickMaxStep: PropTypes.number,
|
|
129
137
|
tickMinStep: PropTypes.number,
|
|
130
138
|
tickNumber: PropTypes.number,
|
|
@@ -143,11 +151,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
143
151
|
fill: PropTypes.string,
|
|
144
152
|
label: PropTypes.string,
|
|
145
153
|
labelFontSize: PropTypes.number,
|
|
154
|
+
labelStyle: PropTypes.object,
|
|
146
155
|
position: PropTypes.oneOf(['left', 'right']),
|
|
147
156
|
slotProps: PropTypes.object,
|
|
148
157
|
slots: PropTypes.object,
|
|
149
158
|
stroke: PropTypes.string,
|
|
150
159
|
tickFontSize: PropTypes.number,
|
|
160
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
161
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
162
|
+
tickLabelStyle: PropTypes.object,
|
|
151
163
|
tickMaxStep: PropTypes.number,
|
|
152
164
|
tickMinStep: PropTypes.number,
|
|
153
165
|
tickNumber: PropTypes.number,
|
|
@@ -176,11 +188,15 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
176
188
|
fill: PropTypes.string,
|
|
177
189
|
label: PropTypes.string,
|
|
178
190
|
labelFontSize: PropTypes.number,
|
|
191
|
+
labelStyle: PropTypes.object,
|
|
179
192
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
180
193
|
slotProps: PropTypes.object,
|
|
181
194
|
slots: PropTypes.object,
|
|
182
195
|
stroke: PropTypes.string,
|
|
183
196
|
tickFontSize: PropTypes.number,
|
|
197
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
198
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
199
|
+
tickLabelStyle: PropTypes.object,
|
|
184
200
|
tickMaxStep: PropTypes.number,
|
|
185
201
|
tickMinStep: PropTypes.number,
|
|
186
202
|
tickNumber: PropTypes.number,
|