@mui/x-charts 7.3.1 → 7.4.0
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 +4 -3
- package/BarChart/BarChart.js +22 -6
- package/BarChart/BarClipPath.d.ts +14 -0
- package/BarChart/BarClipPath.js +50 -0
- package/BarChart/BarPlot.d.ts +4 -0
- package/BarChart/BarPlot.js +108 -36
- package/BarChart/getRadius.d.ts +15 -0
- package/BarChart/getRadius.js +37 -0
- package/BarChart/types.d.ts +25 -0
- package/BarChart/types.js +5 -0
- package/CHANGELOG.md +141 -5
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsGrid/ChartsGrid.js +22 -11
- package/ChartsOverlay/ChartsLoadingOverlay.d.ts +3 -0
- package/ChartsOverlay/ChartsLoadingOverlay.js +43 -0
- package/ChartsOverlay/ChartsNoDataOverlay.d.ts +3 -0
- package/ChartsOverlay/ChartsNoDataOverlay.js +43 -0
- package/ChartsOverlay/ChartsOverlay.d.ts +35 -0
- package/ChartsOverlay/ChartsOverlay.js +41 -0
- package/ChartsOverlay/index.d.ts +3 -0
- package/ChartsOverlay/index.js +26 -0
- package/ChartsOverlay/package.json +6 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsTooltip.d.ts +2 -2
- package/ChartsTooltip/ChartsTooltip.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
- package/ChartsXAxis/ChartsXAxis.js +7 -0
- package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
- package/ChartsYAxis/ChartsYAxis.js +7 -0
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeProvider.d.ts +2 -2
- package/Gauge/GaugeProvider.js +1 -1
- package/Gauge/gaugeClasses.d.ts +2 -2
- package/Gauge/utils.d.ts +1 -1
- package/Gauge/utils.js +4 -4
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/LineChart.d.ts +4 -3
- package/LineChart/LineChart.js +12 -2
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +3 -3
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +3 -3
- package/PieChart/PieChart.d.ts +4 -3
- package/PieChart/PieChart.js +15 -2
- package/ScatterChart/ScatterChart.d.ts +4 -3
- package/ScatterChart/ScatterChart.js +12 -2
- package/context/SeriesContextProvider.js +1 -1
- package/esm/BarChart/BarChart.js +22 -6
- package/esm/BarChart/BarClipPath.js +42 -0
- package/esm/BarChart/BarPlot.js +109 -37
- package/esm/BarChart/getRadius.js +30 -0
- package/esm/BarChart/types.js +1 -0
- package/esm/ChartsGrid/ChartsGrid.js +23 -12
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
- package/esm/ChartsOverlay/ChartsOverlay.js +31 -0
- package/esm/ChartsOverlay/index.js +3 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltip.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +7 -0
- package/esm/Gauge/Gauge.js +1 -1
- package/esm/Gauge/GaugeContainer.js +1 -1
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/Gauge/utils.js +4 -4
- package/esm/LineChart/LineChart.js +12 -2
- package/esm/PieChart/PieArcLabel.js +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +3 -3
- package/esm/PieChart/PieArcPlot.js +3 -3
- package/esm/PieChart/PieChart.js +15 -2
- package/esm/ScatterChart/ScatterChart.js +12 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/hooks/useReducedMotion.js +1 -1
- package/esm/hooks/useScale.js +1 -1
- package/esm/hooks/useTicks.js +4 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
- package/esm/internals/utils.js +1 -1
- package/hooks/useReducedMotion.d.ts +1 -1
- package/hooks/useReducedMotion.js +1 -1
- package/hooks/useScale.d.ts +4 -4
- package/hooks/useScale.js +1 -1
- package/hooks/useTicks.js +4 -0
- package/index.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
- package/internals/utils.d.ts +1 -1
- package/internals/utils.js +1 -1
- package/models/axis.d.ts +1 -1
- package/models/seriesType/bar.d.ts +1 -1
- package/models/seriesType/line.d.ts +1 -1
- package/models/seriesType/pie.d.ts +4 -4
- package/modern/BarChart/BarChart.js +22 -6
- package/modern/BarChart/BarClipPath.js +42 -0
- package/modern/BarChart/BarPlot.js +109 -37
- package/modern/BarChart/getRadius.js +30 -0
- package/modern/BarChart/types.js +1 -0
- package/modern/ChartsGrid/ChartsGrid.js +23 -12
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
- package/modern/ChartsOverlay/ChartsOverlay.js +31 -0
- package/modern/ChartsOverlay/index.js +3 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsTooltip/ChartsTooltip.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +7 -0
- package/modern/ChartsYAxis/ChartsYAxis.js +7 -0
- package/modern/Gauge/Gauge.js +1 -1
- package/modern/Gauge/GaugeContainer.js +1 -1
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/Gauge/utils.js +4 -4
- package/modern/LineChart/LineChart.js +12 -2
- package/modern/PieChart/PieArcLabel.js +1 -1
- package/modern/PieChart/PieArcLabelPlot.js +3 -3
- package/modern/PieChart/PieArcPlot.js +3 -3
- package/modern/PieChart/PieChart.js +15 -2
- package/modern/ScatterChart/ScatterChart.js +12 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/hooks/useReducedMotion.js +1 -1
- package/modern/hooks/useScale.js +1 -1
- package/modern/hooks/useTicks.js +4 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
- package/modern/internals/utils.js +1 -1
- package/package.json +2 -2
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +2 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -15,6 +15,7 @@ import { ChartsClipPath } from '../ChartsClipPath';
|
|
|
15
15
|
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
16
16
|
import { ChartsGrid } from '../ChartsGrid';
|
|
17
17
|
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
18
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
18
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
/**
|
|
20
21
|
* Demos:
|
|
@@ -55,7 +56,8 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
55
56
|
children,
|
|
56
57
|
slots,
|
|
57
58
|
slotProps,
|
|
58
|
-
skipAnimation
|
|
59
|
+
skipAnimation,
|
|
60
|
+
loading
|
|
59
61
|
} = props;
|
|
60
62
|
const id = useId();
|
|
61
63
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -97,6 +99,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
97
99
|
slotProps: slotProps,
|
|
98
100
|
onItemClick: onLineClick,
|
|
99
101
|
skipAnimation: skipAnimation
|
|
102
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
103
|
+
loading: loading,
|
|
104
|
+
slots: slots,
|
|
105
|
+
slotProps: slotProps
|
|
100
106
|
})]
|
|
101
107
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
102
108
|
topAxis: topAxis,
|
|
@@ -116,7 +122,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
116
122
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
117
123
|
slots: slots,
|
|
118
124
|
slotProps: slotProps
|
|
119
|
-
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
125
|
+
})), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
120
126
|
slots: slots,
|
|
121
127
|
slotProps: slotProps
|
|
122
128
|
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
@@ -197,6 +203,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
197
203
|
slotProps: PropTypes.object,
|
|
198
204
|
slots: PropTypes.object
|
|
199
205
|
}),
|
|
206
|
+
/**
|
|
207
|
+
* If `true`, a loading overlay is displayed.
|
|
208
|
+
*/
|
|
209
|
+
loading: PropTypes.bool,
|
|
200
210
|
/**
|
|
201
211
|
* The margin between the SVG and the drawing area.
|
|
202
212
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -39,7 +39,7 @@ const PieArcLabelRoot = styled(animated.text, {
|
|
|
39
39
|
}));
|
|
40
40
|
/**
|
|
41
41
|
* Helper to compute label position.
|
|
42
|
-
* It's not an inline function because we need it in
|
|
42
|
+
* It's not an inline function because we need it in interpolation.
|
|
43
43
|
*/
|
|
44
44
|
const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, arcLabelRadius, cornerRadius) => {
|
|
45
45
|
if (!formattedArcLabel) {
|
|
@@ -129,7 +129,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
129
129
|
value: PropTypes.number.isRequired
|
|
130
130
|
})).isRequired,
|
|
131
131
|
/**
|
|
132
|
-
* Override the arc
|
|
132
|
+
* Override the arc attributes when it is faded.
|
|
133
133
|
* @default { additionalRadius: -5 }
|
|
134
134
|
*/
|
|
135
135
|
faded: PropTypes.shape({
|
|
@@ -142,7 +142,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
142
142
|
paddingAngle: PropTypes.number
|
|
143
143
|
}),
|
|
144
144
|
/**
|
|
145
|
-
* Override the arc
|
|
145
|
+
* Override the arc attributes when it is highlighted.
|
|
146
146
|
*/
|
|
147
147
|
highlighted: PropTypes.shape({
|
|
148
148
|
additionalRadius: PropTypes.number,
|
|
@@ -159,7 +159,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
159
159
|
}),
|
|
160
160
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
161
161
|
/**
|
|
162
|
-
* The radius between circle center and the
|
|
162
|
+
* The radius between circle center and the beginning of the arc.
|
|
163
163
|
* @default 0
|
|
164
164
|
*/
|
|
165
165
|
innerRadius: PropTypes.number,
|
|
@@ -109,7 +109,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
109
109
|
value: PropTypes.number.isRequired
|
|
110
110
|
})).isRequired,
|
|
111
111
|
/**
|
|
112
|
-
* Override the arc
|
|
112
|
+
* Override the arc attributes when it is faded.
|
|
113
113
|
* @default { additionalRadius: -5 }
|
|
114
114
|
*/
|
|
115
115
|
faded: PropTypes.shape({
|
|
@@ -122,7 +122,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
122
122
|
paddingAngle: PropTypes.number
|
|
123
123
|
}),
|
|
124
124
|
/**
|
|
125
|
-
* Override the arc
|
|
125
|
+
* Override the arc attributes when it is highlighted.
|
|
126
126
|
*/
|
|
127
127
|
highlighted: PropTypes.shape({
|
|
128
128
|
additionalRadius: PropTypes.number,
|
|
@@ -139,7 +139,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
139
139
|
}),
|
|
140
140
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
141
141
|
/**
|
|
142
|
-
* The radius between circle center and the
|
|
142
|
+
* The radius between circle center and the beginning of the arc.
|
|
143
143
|
* @default 0
|
|
144
144
|
*/
|
|
145
145
|
innerRadius: PropTypes.number,
|
|
@@ -9,6 +9,7 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
9
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
10
|
import { PiePlot } from './PiePlot';
|
|
11
11
|
import { useIsRTL } from '../internals/useIsRTL';
|
|
12
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const defaultMargin = {
|
|
14
15
|
top: 5,
|
|
@@ -59,7 +60,8 @@ function PieChart(props) {
|
|
|
59
60
|
children,
|
|
60
61
|
slots,
|
|
61
62
|
slotProps,
|
|
62
|
-
onItemClick
|
|
63
|
+
onItemClick,
|
|
64
|
+
loading
|
|
63
65
|
} = props;
|
|
64
66
|
const isRTL = useIsRTL();
|
|
65
67
|
const margin = _extends({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
|
|
@@ -98,10 +100,17 @@ function PieChart(props) {
|
|
|
98
100
|
slotProps: slotProps,
|
|
99
101
|
onItemClick: onItemClick,
|
|
100
102
|
skipAnimation: skipAnimation
|
|
103
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
104
|
+
loading: loading,
|
|
105
|
+
slots: slots,
|
|
106
|
+
slotProps: slotProps
|
|
101
107
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
102
108
|
slots: slots,
|
|
103
109
|
slotProps: slotProps
|
|
104
|
-
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
110
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
111
|
+
slots: slots,
|
|
112
|
+
slotProps: slotProps
|
|
113
|
+
})), children]
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
@@ -168,6 +177,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
168
177
|
slotProps: PropTypes.object,
|
|
169
178
|
slots: PropTypes.object
|
|
170
179
|
}),
|
|
180
|
+
/**
|
|
181
|
+
* If `true`, a loading overlay is displayed.
|
|
182
|
+
*/
|
|
183
|
+
loading: PropTypes.bool,
|
|
171
184
|
/**
|
|
172
185
|
* The margin between the SVG and the drawing area.
|
|
173
186
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -6,6 +6,7 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
|
6
6
|
import { ChartsAxis } from '../ChartsAxis';
|
|
7
7
|
import { ChartsTooltip } from '../ChartsTooltip';
|
|
8
8
|
import { ChartsLegend } from '../ChartsLegend';
|
|
9
|
+
import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
|
|
9
10
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
11
|
import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
11
12
|
import { ChartsGrid } from '../ChartsGrid';
|
|
@@ -45,7 +46,8 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
45
46
|
onItemClick,
|
|
46
47
|
children,
|
|
47
48
|
slots,
|
|
48
|
-
slotProps
|
|
49
|
+
slotProps,
|
|
50
|
+
loading
|
|
49
51
|
} = props;
|
|
50
52
|
return /*#__PURE__*/_jsx(ResponsiveChartContainer, {
|
|
51
53
|
ref: ref,
|
|
@@ -78,13 +80,17 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
78
80
|
slots: slots,
|
|
79
81
|
slotProps: slotProps,
|
|
80
82
|
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
83
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
84
|
+
loading: loading,
|
|
85
|
+
slots: slots,
|
|
86
|
+
slotProps: slotProps
|
|
81
87
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
82
88
|
slots: slots,
|
|
83
89
|
slotProps: slotProps
|
|
84
90
|
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
|
|
85
91
|
x: "none",
|
|
86
92
|
y: "none"
|
|
87
|
-
}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
93
|
+
}, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({
|
|
88
94
|
trigger: "item"
|
|
89
95
|
}, tooltip)), children]
|
|
90
96
|
})
|
|
@@ -164,6 +170,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
164
170
|
slotProps: PropTypes.object,
|
|
165
171
|
slots: PropTypes.object
|
|
166
172
|
}),
|
|
173
|
+
/**
|
|
174
|
+
* If `true`, a loading overlay is displayed.
|
|
175
|
+
*/
|
|
176
|
+
loading: PropTypes.bool,
|
|
167
177
|
/**
|
|
168
178
|
* The margin between the SVG and the drawing area.
|
|
169
179
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -50,7 +50,7 @@ const formatSeries = (series, colors, dataset) => {
|
|
|
50
50
|
seriesGroups[type].seriesOrder.push(id);
|
|
51
51
|
});
|
|
52
52
|
const formattedSeries = {};
|
|
53
|
-
// Apply
|
|
53
|
+
// Apply formatter on a type group
|
|
54
54
|
Object.keys(seriesTypeFormatter).forEach(type => {
|
|
55
55
|
if (seriesGroups[type] !== undefined) {
|
|
56
56
|
formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
|
|
@@ -5,7 +5,7 @@ import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
|
|
|
5
5
|
* set skipAnimations to the value of the user's
|
|
6
6
|
* `prefers-reduced-motion` query.
|
|
7
7
|
*
|
|
8
|
-
* The return value, post-effect, is the value of their
|
|
8
|
+
* The return value, post-effect, is the value of their preferred setting
|
|
9
9
|
*/
|
|
10
10
|
export const useReducedMotion = () => {
|
|
11
11
|
// Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
|
package/modern/hooks/useScale.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
3
3
|
import { isBandScale } from '../internals/isBandScale';
|
|
4
4
|
/**
|
|
5
5
|
* For a given scale return a function that map value to their position.
|
|
6
|
-
*
|
|
6
|
+
* Useful when dealing with specific scale such as band.
|
|
7
7
|
* @param scale The scale to use
|
|
8
8
|
* @returns (value: any) => number
|
|
9
9
|
*/
|
package/modern/hooks/useTicks.js
CHANGED
|
@@ -59,6 +59,10 @@ export function useTicks(options) {
|
|
|
59
59
|
labelOffset: 0
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
62
|
+
if (scale.domain().length === 0 || scale.domain()[0] === scale.domain()[1]) {
|
|
63
|
+
// The axis should not be visible, so ticks should also be hidden.
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
62
66
|
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
63
67
|
return ticks.map(value => ({
|
|
64
68
|
value,
|
package/modern/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export function useChartGradient() {
|
|
|
9
9
|
const {
|
|
10
10
|
chartId
|
|
11
11
|
} = React.useContext(DrawingContext);
|
|
12
|
-
return React.useCallback((axisId, direction) => `${chartId}-
|
|
12
|
+
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
13
13
|
}
|
|
14
14
|
export function ChartsAxesGradients() {
|
|
15
15
|
const {
|
|
@@ -40,7 +40,7 @@ export function ChartsAxesGradients() {
|
|
|
40
40
|
} = yAxis[axisId];
|
|
41
41
|
if (colorMap?.type === 'piecewise') {
|
|
42
42
|
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
43
|
-
|
|
43
|
+
isReversed: !reverse,
|
|
44
44
|
scale: scale,
|
|
45
45
|
colorMap: colorMap,
|
|
46
46
|
size: svgHeight,
|
|
@@ -50,7 +50,7 @@ export function ChartsAxesGradients() {
|
|
|
50
50
|
}
|
|
51
51
|
if (colorMap?.type === 'continuous') {
|
|
52
52
|
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
53
|
-
|
|
53
|
+
isReversed: !reverse,
|
|
54
54
|
scale: scale,
|
|
55
55
|
colorScale: colorScale,
|
|
56
56
|
colorMap: colorMap,
|
|
@@ -70,7 +70,7 @@ export function ChartsAxesGradients() {
|
|
|
70
70
|
} = xAxis[axisId];
|
|
71
71
|
if (colorMap?.type === 'piecewise') {
|
|
72
72
|
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
73
|
-
|
|
73
|
+
isReversed: reverse,
|
|
74
74
|
scale: scale,
|
|
75
75
|
colorMap: colorMap,
|
|
76
76
|
size: svgWidth,
|
|
@@ -80,7 +80,7 @@ export function ChartsAxesGradients() {
|
|
|
80
80
|
}
|
|
81
81
|
if (colorMap?.type === 'continuous') {
|
|
82
82
|
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
83
|
-
|
|
83
|
+
isReversed: reverse,
|
|
84
84
|
scale: scale,
|
|
85
85
|
colorScale: colorScale,
|
|
86
86
|
colorMap: colorMap,
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
const PX_PRECISION = 10;
|
|
5
5
|
export default function ChartsContinuousGradient(props) {
|
|
6
6
|
const {
|
|
7
|
-
|
|
7
|
+
isReversed,
|
|
8
8
|
gradientId,
|
|
9
9
|
size,
|
|
10
10
|
direction,
|
|
@@ -26,7 +26,7 @@ export default function ChartsContinuousGradient(props) {
|
|
|
26
26
|
x2: "0",
|
|
27
27
|
y1: "0",
|
|
28
28
|
y2: "0",
|
|
29
|
-
[`${direction}${
|
|
29
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
30
30
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
31
31
|
,
|
|
32
32
|
children: Array.from({
|
|
@@ -40,7 +40,7 @@ export default function ChartsContinuousGradient(props) {
|
|
|
40
40
|
if (x === undefined) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
const offset =
|
|
43
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
44
44
|
const color = colorScale(value);
|
|
45
45
|
if (color === null) {
|
|
46
46
|
return null;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
export default function ChartsPiecewiseGradient(props) {
|
|
4
4
|
const {
|
|
5
|
-
|
|
5
|
+
isReversed,
|
|
6
6
|
gradientId,
|
|
7
7
|
size,
|
|
8
8
|
direction,
|
|
@@ -15,7 +15,7 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
15
15
|
x2: "0",
|
|
16
16
|
y1: "0",
|
|
17
17
|
y2: "0",
|
|
18
|
-
[`${direction}${
|
|
18
|
+
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
19
19
|
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
20
20
|
,
|
|
21
21
|
children: colorMap.thresholds.map((threshold, index) => {
|
|
@@ -23,7 +23,7 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
23
23
|
if (x === undefined) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
const offset =
|
|
26
|
+
const offset = isReversed ? 1 - x / size : x / size;
|
|
27
27
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
28
28
|
children: [/*#__PURE__*/_jsx("stop", {
|
|
29
29
|
offset: offset,
|
|
@@ -4,7 +4,7 @@ export function getSymbol(shape) {
|
|
|
4
4
|
return symbolNames.indexOf(shape) || 0;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Transform mouse event position to
|
|
7
|
+
* Transform mouse event position to coordinates inside the SVG.
|
|
8
8
|
* @param svg The SVG element
|
|
9
9
|
* @param event The mouseEvent to transform
|
|
10
10
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@mui/utils": "^5.15.14",
|
|
36
36
|
"@react-spring/rafz": "^9.7.3",
|
|
37
37
|
"@react-spring/web": "^9.7.3",
|
|
38
|
-
"clsx": "^2.1.
|
|
38
|
+
"clsx": "^2.1.1",
|
|
39
39
|
"d3-color": "^3.1.0",
|
|
40
40
|
"d3-delaunay": "^6.0.4",
|
|
41
41
|
"d3-interpolate": "^3.0.1",
|
|
@@ -18,6 +18,10 @@ export interface ChartsComponents {
|
|
|
18
18
|
MuiChartsClipPath?: {
|
|
19
19
|
defaultProps?: ComponentsProps['MuiChartsClipPath'];
|
|
20
20
|
};
|
|
21
|
+
MuiChartsGrid?: {
|
|
22
|
+
defaultProps?: ComponentsProps['MuiChartsGrid'];
|
|
23
|
+
styleOverrides?: ComponentsOverrides['MuiChartsGrid'];
|
|
24
|
+
};
|
|
21
25
|
MuiChartsLegend?: {
|
|
22
26
|
defaultProps?: ComponentsProps['MuiChartsLegend'];
|
|
23
27
|
styleOverrides?: ComponentsOverrides['MuiChartsLegend'];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BarElementClassKey } from '../BarChart/BarElement';
|
|
2
2
|
import { ChartsAxisClassKey } from '../ChartsAxis';
|
|
3
3
|
import { ChartsAxisHighlightClassKey } from '../ChartsAxisHighlight';
|
|
4
|
+
import { ChartsGridClassKey } from '../ChartsGrid';
|
|
4
5
|
import { ChartsLegendClassKey } from '../ChartsLegend';
|
|
5
6
|
import { ChartsTooltipClassKey } from '../ChartsTooltip';
|
|
6
7
|
import { AreaElementClassKey, LineElementClassKey, MarkElementClassKey } from '../LineChart';
|
|
@@ -9,6 +10,7 @@ import { AreaElementClassKey, LineElementClassKey, MarkElementClassKey } from '.
|
|
|
9
10
|
export interface PickersComponentNameToClassKey {
|
|
10
11
|
MuiChartsAxis: ChartsAxisClassKey;
|
|
11
12
|
MuiChartsAxisHighlight: ChartsAxisHighlightClassKey;
|
|
13
|
+
MuiChartsGrid: ChartsGridClassKey;
|
|
12
14
|
MuiChartsLegend: ChartsLegendClassKey;
|
|
13
15
|
MuiChartsTooltip: ChartsTooltipClassKey;
|
|
14
16
|
|
|
@@ -3,6 +3,7 @@ import { BarElementProps } from '../BarChart/BarElement';
|
|
|
3
3
|
import { ChartsAxisProps } from '../ChartsAxis';
|
|
4
4
|
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
5
5
|
import { ChartsClipPathProps } from '../ChartsClipPath';
|
|
6
|
+
import { ChartsGridProps } from '../ChartsGrid';
|
|
6
7
|
import { ChartsLegendProps } from '../ChartsLegend';
|
|
7
8
|
import { ChartsSurfaceProps } from '../ChartsSurface';
|
|
8
9
|
import { ChartsTooltipProps } from '../ChartsTooltip';
|
|
@@ -18,6 +19,7 @@ export interface ChartsComponentsPropsList {
|
|
|
18
19
|
MuiChartsYAxis: ChartsYAxisProps;
|
|
19
20
|
MuiChartsAxisHighlight: ChartsAxisHighlightProps;
|
|
20
21
|
MuiChartsClipPath: ChartsClipPathProps;
|
|
22
|
+
MuiChartsGrid: ChartsGridProps;
|
|
21
23
|
MuiChartsLegend: ChartsLegendProps;
|
|
22
24
|
MuiChartsTooltip: ChartsTooltipProps;
|
|
23
25
|
MuiChartsSurface: ChartsSurfaceProps;
|