@mui/x-charts 8.14.0 → 8.14.1
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/useBarPlotData.js +20 -33
- package/CHANGELOG.md +95 -0
- package/Gauge/Gauge.js +2 -9
- package/Gauge/GaugeReferenceArc.d.ts +4 -1
- package/Gauge/GaugeReferenceArc.js +12 -3
- package/Gauge/GaugeValueArc.d.ts +4 -1
- package/Gauge/GaugeValueArc.js +16 -8
- package/Gauge/GaugeValueText.js +3 -1
- package/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/BarChart/useBarPlotData.js +20 -33
- package/esm/Gauge/Gauge.js +2 -9
- package/esm/Gauge/GaugeReferenceArc.d.ts +4 -1
- package/esm/Gauge/GaugeReferenceArc.js +11 -2
- package/esm/Gauge/GaugeValueArc.d.ts +4 -1
- package/esm/Gauge/GaugeValueArc.js +16 -8
- package/esm/Gauge/GaugeValueText.js +3 -1
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/Flatbush.bench.d.ts +1 -0
- package/esm/internals/Flatbush.bench.js +42 -0
- package/esm/internals/Flatbush.d.ts +63 -0
- package/esm/internals/Flatbush.js +468 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +41 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +33 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +40 -81
- package/esm/models/seriesType/scatter.d.ts +2 -0
- package/esm/themeAugmentation/components.d.ts +3 -0
- package/esm/themeAugmentation/overrides.d.ts +2 -0
- package/index.js +1 -1
- package/internals/Flatbush.bench.d.ts +1 -0
- package/internals/Flatbush.bench.js +44 -0
- package/internals/Flatbush.d.ts +63 -0
- package/internals/Flatbush.js +477 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +43 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +39 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +39 -80
- package/models/seriesType/scatter.d.ts +2 -0
- package/package.json +5 -4
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/overrides.d.ts +2 -0
|
@@ -36,6 +36,7 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
36
36
|
const xAxisConfig = xAxes[xAxisId];
|
|
37
37
|
const yAxisConfig = yAxes[yAxisId];
|
|
38
38
|
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
39
|
+
const reverse = (verticalLayout ? yAxisConfig.reverse : xAxisConfig.reverse) ?? false;
|
|
39
40
|
(0, _checkScaleErrors.checkScaleErrors)(verticalLayout, seriesId, series[seriesId], xAxisId, xAxes, yAxisId, yAxes);
|
|
40
41
|
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
41
42
|
const xScale = xAxisConfig.scale;
|
|
@@ -57,19 +58,20 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
57
58
|
layout,
|
|
58
59
|
minBarSize
|
|
59
60
|
} = series[seriesId];
|
|
60
|
-
const seriesDataPoints =
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const seriesDataPoints = [];
|
|
62
|
+
for (let dataIndex = 0; dataIndex < baseScaleConfig.data.length; dataIndex += 1) {
|
|
63
|
+
const baseValue = baseScaleConfig.data[dataIndex];
|
|
64
|
+
const seriesValue = currentSeriesData[dataIndex];
|
|
65
|
+
if (seriesValue == null) {
|
|
66
|
+
continue;
|
|
63
67
|
}
|
|
64
68
|
const values = stackedData[dataIndex];
|
|
65
69
|
const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
|
|
66
70
|
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
67
71
|
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
68
72
|
const stackId = series[seriesId].stack;
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
startCoordinate
|
|
72
|
-
} = getValueCoordinate(verticalLayout, minValueCoord, maxValueCoord, currentSeriesData[dataIndex], minBarSize);
|
|
73
|
+
const barSize = seriesValue === 0 ? 0 : Math.max(minBarSize, maxValueCoord - minValueCoord);
|
|
74
|
+
const startCoordinate = shouldInvertStartCoordinate(verticalLayout, seriesValue, reverse) ? maxValueCoord - barSize : minValueCoord;
|
|
73
75
|
const result = {
|
|
74
76
|
seriesId,
|
|
75
77
|
dataIndex,
|
|
@@ -85,7 +87,7 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
85
87
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
86
88
|
};
|
|
87
89
|
if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
|
|
88
|
-
|
|
90
|
+
continue;
|
|
89
91
|
}
|
|
90
92
|
if (!masks[result.maskId]) {
|
|
91
93
|
masks[result.maskId] = {
|
|
@@ -106,10 +108,11 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
106
108
|
mask.height = result.layout === 'vertical' ? mask.height + result.height : result.height;
|
|
107
109
|
mask.x = Math.min(mask.x === 0 ? Infinity : mask.x, result.x);
|
|
108
110
|
mask.y = Math.min(mask.y === 0 ? Infinity : mask.y, result.y);
|
|
109
|
-
|
|
110
|
-
mask.
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
const value = result.value ?? 0;
|
|
112
|
+
mask.hasNegative = mask.hasNegative || (reverse ? value > 0 : value < 0);
|
|
113
|
+
mask.hasPositive = mask.hasPositive || (reverse ? value < 0 : value > 0);
|
|
114
|
+
seriesDataPoints.push(result);
|
|
115
|
+
}
|
|
113
116
|
return {
|
|
114
117
|
seriesId,
|
|
115
118
|
data: seriesDataPoints
|
|
@@ -149,25 +152,9 @@ function getBandSize({
|
|
|
149
152
|
offset
|
|
150
153
|
};
|
|
151
154
|
}
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
const isSizeLessThanMin = maxValueCoord - minValueCoord < minBarSize;
|
|
160
|
-
const barSize = isSizeLessThanMin ? minBarSize : maxValueCoord - minValueCoord;
|
|
161
|
-
const isVerticalAndPositive = isVertical && baseValue >= 0;
|
|
162
|
-
const isHorizontalAndNegative = !isVertical && baseValue < 0;
|
|
163
|
-
if (isSizeLessThanMin && (isVerticalAndPositive || isHorizontalAndNegative)) {
|
|
164
|
-
return {
|
|
165
|
-
barSize,
|
|
166
|
-
startCoordinate: maxValueCoord - barSize
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
barSize,
|
|
171
|
-
startCoordinate: minValueCoord
|
|
172
|
-
};
|
|
155
|
+
function shouldInvertStartCoordinate(verticalLayout, baseValue, reverse) {
|
|
156
|
+
const isVerticalAndPositive = verticalLayout && baseValue > 0;
|
|
157
|
+
const isHorizontalAndNegative = !verticalLayout && baseValue < 0;
|
|
158
|
+
const invertStartCoordinate = isVerticalAndPositive || isHorizontalAndNegative;
|
|
159
|
+
return reverse ? !invertStartCoordinate : invertStartCoordinate;
|
|
173
160
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,101 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.14.1
|
|
9
|
+
|
|
10
|
+
_Oct 16, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🚀 Charts have optimized data structures for closest point calculations — initial render times reduced by ~25% for 1,000+ data points, with greater gains at larger scales (#19790) @bernardobelchior
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
- 📚 Documentation improvements
|
|
17
|
+
|
|
18
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
19
|
+
@djpremier, @jacknot, @justdoit1897, @mellis481, @sai6855
|
|
20
|
+
|
|
21
|
+
The following are all team members who have contributed to this release:
|
|
22
|
+
@arminmeh, @bernardobelchior, @brijeshb42, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @noraleonte, @siriwatknp
|
|
23
|
+
|
|
24
|
+
### Data Grid
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid@8.14.1`
|
|
27
|
+
|
|
28
|
+
- [DataGrid] Fix cell not rerendering on `isCellEditable` prop change (#19898) @cherniavskii
|
|
29
|
+
- [DataGrid] Fix virtualizer memory leaks (#19886) @cherniavskii
|
|
30
|
+
- [DataGrid] Fix tree data unable to deselect row for exclude model (#19846) @siriwatknp
|
|
31
|
+
- [l10n] Improve Italian (it-IT) locale (#19322) @jacknot and (#19940) @justdoit1897
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid@8.14.1`, plus:
|
|
36
|
+
|
|
37
|
+
- [DataGridPro] Clear cache before new request to the nested request queue after a row has been edited (#19873) @arminmeh
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-data-grid-premium@8.14.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
40
|
+
|
|
41
|
+
Same changes as in `@mui/x-data-grid-pro@8.14.1`.
|
|
42
|
+
|
|
43
|
+
### Date and Time Pickers
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-date-pickers@8.14.1`
|
|
46
|
+
|
|
47
|
+
Internal changes.
|
|
48
|
+
|
|
49
|
+
#### `@mui/x-date-pickers-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
50
|
+
|
|
51
|
+
Same changes as in `@mui/x-date-pickers@8.14.1`.
|
|
52
|
+
|
|
53
|
+
### Charts
|
|
54
|
+
|
|
55
|
+
#### `@mui/x-charts@8.14.1`
|
|
56
|
+
|
|
57
|
+
- [charts] Fix `minBarSize` when y-axis is reversed (#19932) @bernardobelchior
|
|
58
|
+
- [charts] Fix bar chart border radius when axis is reversed (#19895) @bernardobelchior
|
|
59
|
+
- [charts] Fix scatter chart `datasetKeys.id` not being optional (#19897) @bernardobelchior
|
|
60
|
+
- [charts] Use more performant data structure for closest point (#19790) @bernardobelchior
|
|
61
|
+
- [charts] Fix `GaugeValueArc` having wrong class (#19965) @bernardobelchior
|
|
62
|
+
- [charts] Fix `undefined` path when highlight empty line chart axis (#19969) @bernardobelchior
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-charts-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
65
|
+
|
|
66
|
+
Same changes as in `@mui/x-charts@8.14.1`, plus:
|
|
67
|
+
|
|
68
|
+
- [charts-pro] Add `highlighting` to Sankey chart (#19662) @JCQuintas
|
|
69
|
+
|
|
70
|
+
#### `@mui/x-charts-premium@8.14.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
71
|
+
|
|
72
|
+
Same changes as in `@mui/x-charts-pro@8.14.1`.
|
|
73
|
+
|
|
74
|
+
### Tree View
|
|
75
|
+
|
|
76
|
+
#### `@mui/x-tree-view@8.14.1`
|
|
77
|
+
|
|
78
|
+
- [tree view] Do not forward the `ownerState` to the icon (#19772) @flaviendelangle
|
|
79
|
+
|
|
80
|
+
#### `@mui/x-tree-view-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
81
|
+
|
|
82
|
+
Same changes as in `@mui/x-tree-view@8.14.1`.
|
|
83
|
+
|
|
84
|
+
### Codemod
|
|
85
|
+
|
|
86
|
+
#### `@mui/x-codemod@8.14.0`
|
|
87
|
+
|
|
88
|
+
Internal changes.
|
|
89
|
+
|
|
90
|
+
### Docs
|
|
91
|
+
|
|
92
|
+
- [docs] Add `'bumpX'` and `'bumpY'` curve types to the interpolation demo (#19676) @djpremier
|
|
93
|
+
- [docs] Add scatter chart with linear regression demo (#19900) @bernardobelchior
|
|
94
|
+
- [docs] Correctly describe Data Grid's row selection behavior (#19968) @arminmeh
|
|
95
|
+
- [docs] Fix `isExpanded` type in tree view docs (#19092) @mellis481
|
|
96
|
+
|
|
97
|
+
### Core
|
|
98
|
+
|
|
99
|
+
- [code-infra] Disable Netlify cache plugin (#19950) @Janpot
|
|
100
|
+
- [code-infra] Lint json through eslint (#19890) @Janpot
|
|
101
|
+
- [docs-infra] Use published netlify cache plugin package (#19929) @brijeshb42
|
|
102
|
+
|
|
8
103
|
## 8.14.0
|
|
9
104
|
|
|
10
105
|
_Oct 9, 2025_
|
package/Gauge/Gauge.js
CHANGED
|
@@ -25,10 +25,7 @@ const useUtilityClasses = props => {
|
|
|
25
25
|
classes
|
|
26
26
|
} = props;
|
|
27
27
|
const slots = {
|
|
28
|
-
root: ['root']
|
|
29
|
-
valueArc: ['valueArc'],
|
|
30
|
-
referenceArc: ['referenceArc'],
|
|
31
|
-
valueText: ['valueText']
|
|
28
|
+
root: ['root']
|
|
32
29
|
};
|
|
33
30
|
return (0, _composeClasses.default)(slots, _gaugeClasses.getGaugeUtilityClass, classes);
|
|
34
31
|
};
|
|
@@ -44,13 +41,9 @@ const Gauge = exports.Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props
|
|
|
44
41
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GaugeContainer.GaugeContainer, (0, _extends2.default)({}, other, {
|
|
45
42
|
className: (0, _clsx.default)(classes.root, className),
|
|
46
43
|
ref: ref,
|
|
47
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeReferenceArc.GaugeReferenceArc, {
|
|
48
|
-
className: classes.referenceArc
|
|
49
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeValueArc.GaugeValueArc, {
|
|
50
|
-
className: classes.valueArc,
|
|
44
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeReferenceArc.GaugeReferenceArc, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeValueArc.GaugeValueArc, {
|
|
51
45
|
skipAnimation: skipAnimation
|
|
52
46
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeValueText.GaugeValueText, {
|
|
53
|
-
className: classes.valueText,
|
|
54
47
|
text: text
|
|
55
48
|
}), children]
|
|
56
49
|
}));
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.GaugeReferenceArc = GaugeReferenceArc;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
12
|
var React = _interopRequireWildcard(require("react"));
|
|
12
13
|
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
13
14
|
var _styles = require("@mui/material/styles");
|
|
15
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
14
16
|
var _GaugeProvider = require("./GaugeProvider");
|
|
17
|
+
var _gaugeClasses = require("./gaugeClasses");
|
|
15
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
const _excluded = ["className"];
|
|
16
20
|
const StyledPath = (0, _styles.styled)('path', {
|
|
17
21
|
name: 'MuiGauge',
|
|
18
22
|
slot: 'ReferenceArc'
|
|
@@ -21,7 +25,11 @@ const StyledPath = (0, _styles.styled)('path', {
|
|
|
21
25
|
}) => ({
|
|
22
26
|
fill: (theme.vars || theme).palette.divider
|
|
23
27
|
}));
|
|
24
|
-
function GaugeReferenceArc(
|
|
28
|
+
function GaugeReferenceArc(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
className
|
|
31
|
+
} = _ref,
|
|
32
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
25
33
|
const {
|
|
26
34
|
startAngle,
|
|
27
35
|
endAngle,
|
|
@@ -32,6 +40,7 @@ function GaugeReferenceArc(props) {
|
|
|
32
40
|
cy
|
|
33
41
|
} = (0, _GaugeProvider.useGaugeState)();
|
|
34
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledPath, (0, _extends2.default)({
|
|
43
|
+
className: (0, _clsx.default)(_gaugeClasses.gaugeClasses.referenceArc, className),
|
|
35
44
|
transform: `translate(${cx}, ${cy})`,
|
|
36
45
|
d: (0, _d3Shape.arc)().cornerRadius(cornerRadius)({
|
|
37
46
|
startAngle,
|
|
@@ -39,5 +48,5 @@ function GaugeReferenceArc(props) {
|
|
|
39
48
|
innerRadius,
|
|
40
49
|
outerRadius
|
|
41
50
|
})
|
|
42
|
-
},
|
|
51
|
+
}, other));
|
|
43
52
|
}
|
package/Gauge/GaugeValueArc.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare function GaugeValueArc(
|
|
2
|
+
declare function GaugeValueArc({
|
|
3
|
+
className,
|
|
4
|
+
...other
|
|
5
|
+
}: React.ComponentProps<'path'> & {
|
|
3
6
|
skipAnimation?: boolean;
|
|
4
7
|
}): React.JSX.Element | null;
|
|
5
8
|
declare namespace GaugeValueArc {
|
package/Gauge/GaugeValueArc.js
CHANGED
|
@@ -7,25 +7,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.GaugeValueArc = GaugeValueArc;
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
16
|
var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
16
17
|
var _useAnimateGaugeValueArc = require("../hooks/animation/useAnimateGaugeValueArc");
|
|
17
18
|
var _GaugeProvider = require("./GaugeProvider");
|
|
19
|
+
var _gaugeClasses = require("./gaugeClasses");
|
|
18
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["
|
|
21
|
+
const _excluded = ["className"],
|
|
22
|
+
_excluded2 = ["cx", "cy", "startAngle", "endAngle", "cornerRadius", "innerRadius", "outerRadius", "skipAnimation"];
|
|
20
23
|
const StyledPath = (0, _styles.styled)('path', {
|
|
21
24
|
name: 'MuiGauge',
|
|
22
|
-
slot: '
|
|
25
|
+
slot: 'ValueArc'
|
|
23
26
|
})(({
|
|
24
27
|
theme
|
|
25
28
|
}) => ({
|
|
26
29
|
fill: (theme.vars || theme).palette.primary.main
|
|
27
30
|
}));
|
|
28
|
-
function GaugeValueArc(
|
|
31
|
+
function GaugeValueArc(_ref) {
|
|
32
|
+
let {
|
|
33
|
+
className
|
|
34
|
+
} = _ref,
|
|
35
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
29
36
|
const {
|
|
30
37
|
value,
|
|
31
38
|
valueMin,
|
|
@@ -42,7 +49,8 @@ function GaugeValueArc(props) {
|
|
|
42
49
|
return null;
|
|
43
50
|
}
|
|
44
51
|
const valueAngle = startAngle + (value - valueMin) / (valueMax - valueMin) * (endAngle - startAngle);
|
|
45
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedGaugeValueArc, (0, _extends2.default)({},
|
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedGaugeValueArc, (0, _extends2.default)({}, other, {
|
|
53
|
+
className: (0, _clsx.default)(_gaugeClasses.gaugeClasses.valueArc, className),
|
|
46
54
|
cx: cx,
|
|
47
55
|
cy: cy,
|
|
48
56
|
startAngle: startAngle,
|
|
@@ -59,7 +67,7 @@ process.env.NODE_ENV !== "production" ? GaugeValueArc.propTypes = {
|
|
|
59
67
|
// ----------------------------------------------------------------------
|
|
60
68
|
skipAnimation: _propTypes.default.bool
|
|
61
69
|
} : void 0;
|
|
62
|
-
function AnimatedGaugeValueArc(
|
|
70
|
+
function AnimatedGaugeValueArc(_ref2) {
|
|
63
71
|
let {
|
|
64
72
|
cx,
|
|
65
73
|
cy,
|
|
@@ -69,8 +77,8 @@ function AnimatedGaugeValueArc(_ref) {
|
|
|
69
77
|
innerRadius,
|
|
70
78
|
outerRadius,
|
|
71
79
|
skipAnimation: inSkipAnimation
|
|
72
|
-
} =
|
|
73
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(
|
|
80
|
+
} = _ref2,
|
|
81
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref2, _excluded2);
|
|
74
82
|
const skipAnimation = (0, _useSkipAnimation.useSkipAnimation)(inSkipAnimation);
|
|
75
83
|
const animatedProps = (0, _useAnimateGaugeValueArc.useAnimateGaugeValueArc)({
|
|
76
84
|
startAngle,
|
package/Gauge/GaugeValueText.js
CHANGED
|
@@ -11,8 +11,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
14
15
|
var _GaugeProvider = require("./GaugeProvider");
|
|
15
16
|
var _ChartsText = require("../ChartsText");
|
|
17
|
+
var _gaugeClasses = require("./gaugeClasses");
|
|
16
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
19
|
const _excluded = ["text", "className"];
|
|
18
20
|
function defaultFormatter({
|
|
@@ -42,7 +44,7 @@ function GaugeValueText(props) {
|
|
|
42
44
|
return null;
|
|
43
45
|
}
|
|
44
46
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
45
|
-
className: className,
|
|
47
|
+
className: (0, _clsx.default)(_gaugeClasses.gaugeClasses.valueText, className),
|
|
46
48
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, (0, _extends2.default)({
|
|
47
49
|
x: cx,
|
|
48
50
|
y: cy,
|
|
@@ -12,7 +12,7 @@ const seriesProcessor = ({
|
|
|
12
12
|
}, dataset) => {
|
|
13
13
|
const completeSeries = Object.fromEntries(Object.entries(series).map(([seriesId, seriesData]) => {
|
|
14
14
|
const datasetKeys = seriesData?.datasetKeys;
|
|
15
|
-
const missingKeys = ['x', 'y'
|
|
15
|
+
const missingKeys = ['x', 'y'].filter(key => typeof datasetKeys?.[key] !== 'string');
|
|
16
16
|
if (seriesData?.datasetKeys && missingKeys.length > 0) {
|
|
17
17
|
throw new Error([`MUI X Charts: scatter series with id='${seriesId}' has incomplete datasetKeys.`, `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.`].join('\n'));
|
|
18
18
|
}
|
|
@@ -29,6 +29,7 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
29
29
|
const xAxisConfig = xAxes[xAxisId];
|
|
30
30
|
const yAxisConfig = yAxes[yAxisId];
|
|
31
31
|
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
32
|
+
const reverse = (verticalLayout ? yAxisConfig.reverse : xAxisConfig.reverse) ?? false;
|
|
32
33
|
checkScaleErrors(verticalLayout, seriesId, series[seriesId], xAxisId, xAxes, yAxisId, yAxes);
|
|
33
34
|
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
34
35
|
const xScale = xAxisConfig.scale;
|
|
@@ -50,19 +51,20 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
50
51
|
layout,
|
|
51
52
|
minBarSize
|
|
52
53
|
} = series[seriesId];
|
|
53
|
-
const seriesDataPoints =
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const seriesDataPoints = [];
|
|
55
|
+
for (let dataIndex = 0; dataIndex < baseScaleConfig.data.length; dataIndex += 1) {
|
|
56
|
+
const baseValue = baseScaleConfig.data[dataIndex];
|
|
57
|
+
const seriesValue = currentSeriesData[dataIndex];
|
|
58
|
+
if (seriesValue == null) {
|
|
59
|
+
continue;
|
|
56
60
|
}
|
|
57
61
|
const values = stackedData[dataIndex];
|
|
58
62
|
const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
|
|
59
63
|
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
60
64
|
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
61
65
|
const stackId = series[seriesId].stack;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
startCoordinate
|
|
65
|
-
} = getValueCoordinate(verticalLayout, minValueCoord, maxValueCoord, currentSeriesData[dataIndex], minBarSize);
|
|
66
|
+
const barSize = seriesValue === 0 ? 0 : Math.max(minBarSize, maxValueCoord - minValueCoord);
|
|
67
|
+
const startCoordinate = shouldInvertStartCoordinate(verticalLayout, seriesValue, reverse) ? maxValueCoord - barSize : minValueCoord;
|
|
66
68
|
const result = {
|
|
67
69
|
seriesId,
|
|
68
70
|
dataIndex,
|
|
@@ -78,7 +80,7 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
78
80
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
79
81
|
};
|
|
80
82
|
if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
|
|
81
|
-
|
|
83
|
+
continue;
|
|
82
84
|
}
|
|
83
85
|
if (!masks[result.maskId]) {
|
|
84
86
|
masks[result.maskId] = {
|
|
@@ -99,10 +101,11 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
99
101
|
mask.height = result.layout === 'vertical' ? mask.height + result.height : result.height;
|
|
100
102
|
mask.x = Math.min(mask.x === 0 ? Infinity : mask.x, result.x);
|
|
101
103
|
mask.y = Math.min(mask.y === 0 ? Infinity : mask.y, result.y);
|
|
102
|
-
|
|
103
|
-
mask.
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const value = result.value ?? 0;
|
|
105
|
+
mask.hasNegative = mask.hasNegative || (reverse ? value > 0 : value < 0);
|
|
106
|
+
mask.hasPositive = mask.hasPositive || (reverse ? value < 0 : value > 0);
|
|
107
|
+
seriesDataPoints.push(result);
|
|
108
|
+
}
|
|
106
109
|
return {
|
|
107
110
|
seriesId,
|
|
108
111
|
data: seriesDataPoints
|
|
@@ -142,25 +145,9 @@ function getBandSize({
|
|
|
142
145
|
offset
|
|
143
146
|
};
|
|
144
147
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
const isSizeLessThanMin = maxValueCoord - minValueCoord < minBarSize;
|
|
153
|
-
const barSize = isSizeLessThanMin ? minBarSize : maxValueCoord - minValueCoord;
|
|
154
|
-
const isVerticalAndPositive = isVertical && baseValue >= 0;
|
|
155
|
-
const isHorizontalAndNegative = !isVertical && baseValue < 0;
|
|
156
|
-
if (isSizeLessThanMin && (isVerticalAndPositive || isHorizontalAndNegative)) {
|
|
157
|
-
return {
|
|
158
|
-
barSize,
|
|
159
|
-
startCoordinate: maxValueCoord - barSize
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
barSize,
|
|
164
|
-
startCoordinate: minValueCoord
|
|
165
|
-
};
|
|
148
|
+
function shouldInvertStartCoordinate(verticalLayout, baseValue, reverse) {
|
|
149
|
+
const isVerticalAndPositive = verticalLayout && baseValue > 0;
|
|
150
|
+
const isHorizontalAndNegative = !verticalLayout && baseValue < 0;
|
|
151
|
+
const invertStartCoordinate = isVerticalAndPositive || isHorizontalAndNegative;
|
|
152
|
+
return reverse ? !invertStartCoordinate : invertStartCoordinate;
|
|
166
153
|
}
|
package/esm/Gauge/Gauge.js
CHANGED
|
@@ -18,10 +18,7 @@ const useUtilityClasses = props => {
|
|
|
18
18
|
classes
|
|
19
19
|
} = props;
|
|
20
20
|
const slots = {
|
|
21
|
-
root: ['root']
|
|
22
|
-
valueArc: ['valueArc'],
|
|
23
|
-
referenceArc: ['referenceArc'],
|
|
24
|
-
valueText: ['valueText']
|
|
21
|
+
root: ['root']
|
|
25
22
|
};
|
|
26
23
|
return composeClasses(slots, getGaugeUtilityClass, classes);
|
|
27
24
|
};
|
|
@@ -37,13 +34,9 @@ const Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props, ref) {
|
|
|
37
34
|
return /*#__PURE__*/_jsxs(GaugeContainer, _extends({}, other, {
|
|
38
35
|
className: clsx(classes.root, className),
|
|
39
36
|
ref: ref,
|
|
40
|
-
children: [/*#__PURE__*/_jsx(GaugeReferenceArc, {
|
|
41
|
-
className: classes.referenceArc
|
|
42
|
-
}), /*#__PURE__*/_jsx(GaugeValueArc, {
|
|
43
|
-
className: classes.valueArc,
|
|
37
|
+
children: [/*#__PURE__*/_jsx(GaugeReferenceArc, {}), /*#__PURE__*/_jsx(GaugeValueArc, {
|
|
44
38
|
skipAnimation: skipAnimation
|
|
45
39
|
}), /*#__PURE__*/_jsx(GaugeValueText, {
|
|
46
|
-
className: classes.valueText,
|
|
47
40
|
text: text
|
|
48
41
|
}), children]
|
|
49
42
|
}));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["className"];
|
|
4
6
|
import * as React from 'react';
|
|
5
7
|
import { arc as d3Arc } from '@mui/x-charts-vendor/d3-shape';
|
|
6
8
|
import { styled } from '@mui/material/styles';
|
|
9
|
+
import clsx from 'clsx';
|
|
7
10
|
import { useGaugeState } from "./GaugeProvider.js";
|
|
11
|
+
import { gaugeClasses } from "./gaugeClasses.js";
|
|
8
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
13
|
const StyledPath = styled('path', {
|
|
10
14
|
name: 'MuiGauge',
|
|
@@ -14,7 +18,11 @@ const StyledPath = styled('path', {
|
|
|
14
18
|
}) => ({
|
|
15
19
|
fill: (theme.vars || theme).palette.divider
|
|
16
20
|
}));
|
|
17
|
-
export function GaugeReferenceArc(
|
|
21
|
+
export function GaugeReferenceArc(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
className
|
|
24
|
+
} = _ref,
|
|
25
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
18
26
|
const {
|
|
19
27
|
startAngle,
|
|
20
28
|
endAngle,
|
|
@@ -25,6 +33,7 @@ export function GaugeReferenceArc(props) {
|
|
|
25
33
|
cy
|
|
26
34
|
} = useGaugeState();
|
|
27
35
|
return /*#__PURE__*/_jsx(StyledPath, _extends({
|
|
36
|
+
className: clsx(gaugeClasses.referenceArc, className),
|
|
28
37
|
transform: `translate(${cx}, ${cy})`,
|
|
29
38
|
d: d3Arc().cornerRadius(cornerRadius)({
|
|
30
39
|
startAngle,
|
|
@@ -32,5 +41,5 @@ export function GaugeReferenceArc(props) {
|
|
|
32
41
|
innerRadius,
|
|
33
42
|
outerRadius
|
|
34
43
|
})
|
|
35
|
-
},
|
|
44
|
+
}, other));
|
|
36
45
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare function GaugeValueArc(
|
|
2
|
+
declare function GaugeValueArc({
|
|
3
|
+
className,
|
|
4
|
+
...other
|
|
5
|
+
}: React.ComponentProps<'path'> & {
|
|
3
6
|
skipAnimation?: boolean;
|
|
4
7
|
}): React.JSX.Element | null;
|
|
5
8
|
declare namespace GaugeValueArc {
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["className"],
|
|
6
|
+
_excluded2 = ["cx", "cy", "startAngle", "endAngle", "cornerRadius", "innerRadius", "outerRadius", "skipAnimation"];
|
|
6
7
|
import * as React from 'react';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
import { styled } from '@mui/material/styles';
|
|
10
|
+
import clsx from 'clsx';
|
|
9
11
|
import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
|
|
10
12
|
import { useAnimateGaugeValueArc } from "../hooks/animation/useAnimateGaugeValueArc.js";
|
|
11
13
|
import { useGaugeState } from "./GaugeProvider.js";
|
|
14
|
+
import { gaugeClasses } from "./gaugeClasses.js";
|
|
12
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
16
|
const StyledPath = styled('path', {
|
|
14
17
|
name: 'MuiGauge',
|
|
15
|
-
slot: '
|
|
18
|
+
slot: 'ValueArc'
|
|
16
19
|
})(({
|
|
17
20
|
theme
|
|
18
21
|
}) => ({
|
|
19
22
|
fill: (theme.vars || theme).palette.primary.main
|
|
20
23
|
}));
|
|
21
|
-
function GaugeValueArc(
|
|
24
|
+
function GaugeValueArc(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
className
|
|
27
|
+
} = _ref,
|
|
28
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
29
|
const {
|
|
23
30
|
value,
|
|
24
31
|
valueMin,
|
|
@@ -35,7 +42,8 @@ function GaugeValueArc(props) {
|
|
|
35
42
|
return null;
|
|
36
43
|
}
|
|
37
44
|
const valueAngle = startAngle + (value - valueMin) / (valueMax - valueMin) * (endAngle - startAngle);
|
|
38
|
-
return /*#__PURE__*/_jsx(AnimatedGaugeValueArc, _extends({},
|
|
45
|
+
return /*#__PURE__*/_jsx(AnimatedGaugeValueArc, _extends({}, other, {
|
|
46
|
+
className: clsx(gaugeClasses.valueArc, className),
|
|
39
47
|
cx: cx,
|
|
40
48
|
cy: cy,
|
|
41
49
|
startAngle: startAngle,
|
|
@@ -53,7 +61,7 @@ process.env.NODE_ENV !== "production" ? GaugeValueArc.propTypes = {
|
|
|
53
61
|
skipAnimation: PropTypes.bool
|
|
54
62
|
} : void 0;
|
|
55
63
|
export { GaugeValueArc };
|
|
56
|
-
function AnimatedGaugeValueArc(
|
|
64
|
+
function AnimatedGaugeValueArc(_ref2) {
|
|
57
65
|
let {
|
|
58
66
|
cx,
|
|
59
67
|
cy,
|
|
@@ -63,8 +71,8 @@ function AnimatedGaugeValueArc(_ref) {
|
|
|
63
71
|
innerRadius,
|
|
64
72
|
outerRadius,
|
|
65
73
|
skipAnimation: inSkipAnimation
|
|
66
|
-
} =
|
|
67
|
-
other = _objectWithoutPropertiesLoose(
|
|
74
|
+
} = _ref2,
|
|
75
|
+
other = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
68
76
|
const skipAnimation = useSkipAnimation(inSkipAnimation);
|
|
69
77
|
const animatedProps = useAnimateGaugeValueArc({
|
|
70
78
|
startAngle,
|
|
@@ -5,8 +5,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["text", "className"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import clsx from 'clsx';
|
|
8
9
|
import { useGaugeState } from "./GaugeProvider.js";
|
|
9
10
|
import { ChartsText } from "../ChartsText/index.js";
|
|
11
|
+
import { gaugeClasses } from "./gaugeClasses.js";
|
|
10
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
13
|
function defaultFormatter({
|
|
12
14
|
value
|
|
@@ -35,7 +37,7 @@ function GaugeValueText(props) {
|
|
|
35
37
|
return null;
|
|
36
38
|
}
|
|
37
39
|
return /*#__PURE__*/_jsx("g", {
|
|
38
|
-
className: className,
|
|
40
|
+
className: clsx(gaugeClasses.valueText, className),
|
|
39
41
|
children: /*#__PURE__*/_jsx(ChartsText, _extends({
|
|
40
42
|
x: cx,
|
|
41
43
|
y: cy,
|