@mui/x-charts 7.5.1 → 7.6.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/BarChart.js +18 -1
- package/BarChart/BarElement.d.ts +0 -3
- package/BarChart/BarElement.js +7 -18
- package/BarChart/BarLabel/BarLabelItem.js +5 -16
- package/BarChart/BarLabel/BarLabelPlot.js +0 -4
- package/BarChart/BarPlot.js +4 -30
- package/BarChart/checkScaleErrors.d.ts +11 -0
- package/BarChart/checkScaleErrors.js +33 -0
- package/BarChart/types.d.ts +0 -2
- package/CHANGELOG.md +112 -1
- package/ChartContainer/ChartContainer.d.ts +3 -2
- package/ChartContainer/ChartContainer.js +19 -2
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +13 -1
- package/LineChart/AreaElement.d.ts +0 -2
- package/LineChart/AreaElement.js +7 -17
- package/LineChart/AreaPlot.js +0 -2
- package/LineChart/LineChart.js +18 -1
- package/LineChart/LineElement.d.ts +0 -2
- package/LineChart/LineElement.js +7 -17
- package/LineChart/LinePlot.js +0 -2
- package/LineChart/MarkElement.d.ts +0 -2
- package/LineChart/MarkElement.js +10 -17
- package/LineChart/MarkPlot.js +0 -1
- package/PieChart/PieArc.d.ts +4 -1
- package/PieChart/PieArc.js +7 -3
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -7
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +5 -7
- package/PieChart/PieChart.js +18 -1
- package/PieChart/PiePlot.js +2 -6
- package/PieChart/dataTransform/useTransformData.d.ts +1 -1
- package/PieChart/dataTransform/useTransformData.js +10 -25
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -0
- package/ScatterChart/Scatter.js +14 -10
- package/ScatterChart/ScatterChart.js +18 -1
- package/SparkLineChart/SparkLineChart.js +13 -0
- package/context/HighlightedProvider/HighlightedContext.d.ts +65 -0
- package/context/HighlightedProvider/HighlightedContext.js +36 -0
- package/context/HighlightedProvider/HighlightedProvider.d.ts +20 -0
- package/context/HighlightedProvider/HighlightedProvider.js +97 -0
- package/context/HighlightedProvider/createIsFaded.d.ts +2 -0
- package/context/HighlightedProvider/createIsFaded.js +19 -0
- package/context/HighlightedProvider/createIsHighlighted.d.ts +2 -0
- package/context/HighlightedProvider/createIsHighlighted.js +19 -0
- package/context/HighlightedProvider/index.d.ts +4 -0
- package/context/HighlightedProvider/index.js +49 -0
- package/context/HighlightedProvider/useHighlighted.d.ts +9 -0
- package/context/HighlightedProvider/useHighlighted.js +24 -0
- package/context/HighlightedProvider/useItemHighlighted.d.ts +21 -0
- package/context/HighlightedProvider/useItemHighlighted.js +37 -0
- package/context/index.d.ts +1 -1
- package/context/index.js +15 -0
- package/esm/BarChart/BarChart.js +18 -1
- package/esm/BarChart/BarElement.js +8 -19
- package/esm/BarChart/BarLabel/BarLabelItem.js +5 -16
- package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -4
- package/esm/BarChart/BarPlot.js +4 -30
- package/esm/BarChart/checkScaleErrors.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +19 -2
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +13 -1
- package/esm/LineChart/AreaElement.js +8 -18
- package/esm/LineChart/AreaPlot.js +0 -2
- package/esm/LineChart/LineChart.js +18 -1
- package/esm/LineChart/LineElement.js +8 -18
- package/esm/LineChart/LinePlot.js +0 -2
- package/esm/LineChart/MarkElement.js +11 -18
- package/esm/LineChart/MarkPlot.js +0 -1
- package/esm/PieChart/PieArc.js +7 -3
- package/esm/PieChart/PieArcLabelPlot.js +1 -7
- package/esm/PieChart/PieArcPlot.js +5 -7
- package/esm/PieChart/PieChart.js +18 -1
- package/esm/PieChart/PiePlot.js +2 -6
- package/esm/PieChart/dataTransform/useTransformData.js +10 -25
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -0
- package/esm/ScatterChart/Scatter.js +15 -11
- package/esm/ScatterChart/ScatterChart.js +18 -1
- package/esm/SparkLineChart/SparkLineChart.js +13 -0
- package/esm/context/HighlightedProvider/HighlightedContext.js +29 -0
- package/esm/context/HighlightedProvider/HighlightedProvider.js +89 -0
- package/esm/context/HighlightedProvider/createIsFaded.js +12 -0
- package/esm/context/HighlightedProvider/createIsHighlighted.js +12 -0
- package/esm/context/HighlightedProvider/index.js +4 -0
- package/esm/context/HighlightedProvider/useHighlighted.js +17 -0
- package/esm/context/HighlightedProvider/useItemHighlighted.js +29 -0
- package/esm/context/index.js +1 -0
- package/esm/hooks/useInteractionItemProps.js +9 -41
- package/hooks/useInteractionItemProps.d.ts +1 -4
- package/hooks/useInteractionItemProps.js +11 -45
- package/index.js +1 -1
- package/internals/colorScale.d.ts +1 -1
- package/internals/defaultizeColor.d.ts +13 -13
- package/models/seriesType/common.d.ts +4 -1
- package/modern/BarChart/BarChart.js +18 -1
- package/modern/BarChart/BarElement.js +8 -19
- package/modern/BarChart/BarLabel/BarLabelItem.js +5 -16
- package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -4
- package/modern/BarChart/BarPlot.js +4 -30
- package/modern/BarChart/checkScaleErrors.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +19 -2
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +13 -1
- package/modern/LineChart/AreaElement.js +8 -18
- package/modern/LineChart/AreaPlot.js +0 -2
- package/modern/LineChart/LineChart.js +18 -1
- package/modern/LineChart/LineElement.js +8 -18
- package/modern/LineChart/LinePlot.js +0 -2
- package/modern/LineChart/MarkElement.js +11 -18
- package/modern/LineChart/MarkPlot.js +0 -1
- package/modern/PieChart/PieArc.js +7 -3
- package/modern/PieChart/PieArcLabelPlot.js +1 -7
- package/modern/PieChart/PieArcPlot.js +5 -7
- package/modern/PieChart/PieChart.js +18 -1
- package/modern/PieChart/PiePlot.js +2 -6
- package/modern/PieChart/dataTransform/useTransformData.js +10 -25
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -0
- package/modern/ScatterChart/Scatter.js +15 -11
- package/modern/ScatterChart/ScatterChart.js +18 -1
- package/modern/SparkLineChart/SparkLineChart.js +13 -0
- package/modern/context/HighlightedProvider/HighlightedContext.js +29 -0
- package/modern/context/HighlightedProvider/HighlightedProvider.js +89 -0
- package/modern/context/HighlightedProvider/createIsFaded.js +12 -0
- package/modern/context/HighlightedProvider/createIsHighlighted.js +12 -0
- package/modern/context/HighlightedProvider/index.js +4 -0
- package/modern/context/HighlightedProvider/useHighlighted.js +17 -0
- package/modern/context/HighlightedProvider/useItemHighlighted.js +29 -0
- package/modern/context/index.js +1 -0
- package/modern/hooks/useInteractionItemProps.js +9 -41
- package/modern/index.js +1 -1
- package/package.json +3 -3
- package/context/HighlightProvider.d.ts +0 -45
- package/context/HighlightProvider.js +0 -60
- package/esm/context/HighlightProvider.js +0 -51
- package/modern/context/HighlightProvider.js +0 -51
package/BarChart/BarChart.js
CHANGED
|
@@ -62,7 +62,9 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
62
62
|
slots,
|
|
63
63
|
slotProps,
|
|
64
64
|
loading,
|
|
65
|
-
barLabel
|
|
65
|
+
barLabel,
|
|
66
|
+
highlightedItem,
|
|
67
|
+
onHighlightChange
|
|
66
68
|
} = props;
|
|
67
69
|
const id = (0, _useId.default)();
|
|
68
70
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -98,6 +100,8 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
98
100
|
dataset: dataset,
|
|
99
101
|
sx: sx,
|
|
100
102
|
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
103
|
+
highlightedItem: highlightedItem,
|
|
104
|
+
onHighlightChange: onHighlightChange,
|
|
101
105
|
children: [onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, {
|
|
102
106
|
onAxisClick: onAxisClick
|
|
103
107
|
}), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
|
|
@@ -197,6 +201,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
197
201
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
198
202
|
*/
|
|
199
203
|
height: _propTypes.default.number,
|
|
204
|
+
/**
|
|
205
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
206
|
+
*/
|
|
207
|
+
highlightedItem: _propTypes.default.shape({
|
|
208
|
+
dataIndex: _propTypes.default.number,
|
|
209
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
210
|
+
}),
|
|
200
211
|
/**
|
|
201
212
|
* The direction of the bar elements.
|
|
202
213
|
* @default 'vertical'
|
|
@@ -246,6 +257,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
246
257
|
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
247
258
|
*/
|
|
248
259
|
onAxisClick: _propTypes.default.func,
|
|
260
|
+
/**
|
|
261
|
+
* The callback fired when the highlighted item changes.
|
|
262
|
+
*
|
|
263
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
264
|
+
*/
|
|
265
|
+
onHighlightChange: _propTypes.default.func,
|
|
249
266
|
/**
|
|
250
267
|
* Callback fired when a bar item is clicked.
|
|
251
268
|
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|
package/BarChart/BarElement.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="@react-spring/shared" />
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { AnimatedProps } from '@react-spring/web';
|
|
4
|
-
import { HighlightScope } from '../context/HighlightProvider';
|
|
5
4
|
import { SeriesId } from '../models/seriesType/common';
|
|
6
5
|
export interface BarElementClasses {
|
|
7
6
|
/** Styles applied to the root element. */
|
|
@@ -1359,7 +1358,6 @@ interface BarProps extends Omit<React.SVGProps<SVGRectElement>, 'id' | 'color' |
|
|
|
1359
1358
|
height?: string | number | undefined;
|
|
1360
1359
|
width?: string | number | undefined;
|
|
1361
1360
|
}> {
|
|
1362
|
-
highlightScope?: Partial<HighlightScope>;
|
|
1363
1361
|
ownerState: BarElementOwnerState;
|
|
1364
1362
|
}
|
|
1365
1363
|
export interface BarElementSlots {
|
|
@@ -1373,7 +1371,6 @@ export interface BarElementSlotProps {
|
|
|
1373
1371
|
bar?: Partial<BarProps>;
|
|
1374
1372
|
}
|
|
1375
1373
|
export type BarElementProps = Omit<BarElementOwnerState, 'isFaded' | 'isHighlighted'> & Omit<React.SVGProps<SVGRectElement>, 'ref' | 'id'> & {
|
|
1376
|
-
highlightScope?: Partial<HighlightScope>;
|
|
1377
1374
|
/**
|
|
1378
1375
|
* The props used for each component slot.
|
|
1379
1376
|
* @default {}
|
package/BarChart/BarElement.js
CHANGED
|
@@ -19,9 +19,9 @@ var _d3Color = require("d3-color");
|
|
|
19
19
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
20
20
|
var _web = require("@react-spring/web");
|
|
21
21
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
22
|
-
var
|
|
22
|
+
var _context = require("../context");
|
|
23
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "
|
|
24
|
+
const _excluded = ["id", "dataIndex", "classes", "color", "slots", "slotProps", "style", "onClick"];
|
|
25
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
26
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
27
|
function getBarElementUtilityClass(slot) {
|
|
@@ -56,27 +56,20 @@ function BarElement(props) {
|
|
|
56
56
|
dataIndex,
|
|
57
57
|
classes: innerClasses,
|
|
58
58
|
color,
|
|
59
|
-
highlightScope,
|
|
60
59
|
slots,
|
|
61
60
|
slotProps,
|
|
62
61
|
style,
|
|
63
62
|
onClick
|
|
64
63
|
} = props,
|
|
65
64
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
66
|
-
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(
|
|
65
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)();
|
|
67
66
|
const {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
type: 'bar',
|
|
72
|
-
seriesId: id,
|
|
73
|
-
dataIndex
|
|
74
|
-
}, highlightScope);
|
|
75
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
|
|
76
|
-
type: 'bar',
|
|
67
|
+
isFaded,
|
|
68
|
+
isHighlighted
|
|
69
|
+
} = (0, _context.useItemHighlighted)({
|
|
77
70
|
seriesId: id,
|
|
78
71
|
dataIndex
|
|
79
|
-
}
|
|
72
|
+
});
|
|
80
73
|
const ownerState = {
|
|
81
74
|
id,
|
|
82
75
|
dataIndex,
|
|
@@ -112,10 +105,6 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
|
|
|
112
105
|
// ----------------------------------------------------------------------
|
|
113
106
|
classes: _propTypes.default.object,
|
|
114
107
|
dataIndex: _propTypes.default.number.isRequired,
|
|
115
|
-
highlightScope: _propTypes.default.shape({
|
|
116
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
117
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
118
|
-
}),
|
|
119
108
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
120
109
|
/**
|
|
121
110
|
* The props used for each component slot.
|
|
@@ -10,12 +10,10 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _utils = require("@mui/base/utils");
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
var _InteractionProvider = require("../../context/InteractionProvider");
|
|
14
|
-
var _useInteractionItemProps = require("../../hooks/useInteractionItemProps");
|
|
15
13
|
var _barLabelClasses = require("./barLabelClasses");
|
|
16
|
-
var _HighlightProvider = require("../../context/HighlightProvider");
|
|
17
14
|
var _getBarLabel = require("./getBarLabel");
|
|
18
15
|
var _BarLabel = require("./BarLabel");
|
|
16
|
+
var _context = require("../../context");
|
|
19
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
18
|
const _excluded = ["seriesId", "classes", "color", "style", "dataIndex", "barLabel", "slots", "slotProps", "height", "width", "value"],
|
|
21
19
|
_excluded2 = ["ownerState"];
|
|
@@ -40,21 +38,12 @@ function BarLabelItem(props) {
|
|
|
40
38
|
} = props,
|
|
41
39
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
42
40
|
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
scope
|
|
47
|
-
} = React.useContext(_HighlightProvider.HighlighContext);
|
|
48
|
-
const isHighlighted = (0, _useInteractionItemProps.getIsHighlighted)(item, {
|
|
49
|
-
type: 'bar',
|
|
50
|
-
seriesId,
|
|
51
|
-
dataIndex
|
|
52
|
-
}, scope);
|
|
53
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
|
|
54
|
-
type: 'bar',
|
|
41
|
+
isFaded,
|
|
42
|
+
isHighlighted
|
|
43
|
+
} = (0, _context.useItemHighlighted)({
|
|
55
44
|
seriesId,
|
|
56
45
|
dataIndex
|
|
57
|
-
}
|
|
46
|
+
});
|
|
58
47
|
const ownerState = {
|
|
59
48
|
seriesId,
|
|
60
49
|
classes: innerClasses,
|
|
@@ -92,10 +92,6 @@ process.env.NODE_ENV !== "production" ? BarLabelPlot.propTypes = {
|
|
|
92
92
|
color: _propTypes.default.string.isRequired,
|
|
93
93
|
dataIndex: _propTypes.default.number.isRequired,
|
|
94
94
|
height: _propTypes.default.number.isRequired,
|
|
95
|
-
highlightScope: _propTypes.default.shape({
|
|
96
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
97
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
98
|
-
}),
|
|
99
95
|
layout: _propTypes.default.oneOf(['horizontal', 'vertical']),
|
|
100
96
|
maskId: _propTypes.default.string.isRequired,
|
|
101
97
|
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
package/BarChart/BarPlot.js
CHANGED
|
@@ -13,12 +13,11 @@ var _web = require("@react-spring/web");
|
|
|
13
13
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
14
14
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
15
15
|
var _BarElement = require("./BarElement");
|
|
16
|
-
var _axis = require("../models/axis");
|
|
17
|
-
var _constants = require("../constants");
|
|
18
16
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
19
17
|
var _hooks = require("../hooks");
|
|
20
18
|
var _BarClipPath = require("./BarClipPath");
|
|
21
19
|
var _BarLabelPlot = require("./BarLabel/BarLabelPlot");
|
|
20
|
+
var _checkScaleErrors = require("./checkScaleErrors");
|
|
22
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
22
|
const _excluded = ["skipAnimation", "onItemClick", "borderRadius", "barLabel"];
|
|
24
23
|
/**
|
|
@@ -80,30 +79,8 @@ const useAggregatedData = () => {
|
|
|
80
79
|
const xAxisConfig = xAxis[xAxisKey];
|
|
81
80
|
const yAxisConfig = yAxis[yAxisKey];
|
|
82
81
|
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!(0, _axis.isBandScaleConfig)(xAxisConfig)) {
|
|
86
|
-
throw new Error(`MUI X Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
87
|
-
}
|
|
88
|
-
if (xAxis[xAxisKey].data === undefined) {
|
|
89
|
-
throw new Error(`MUI X Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property.`);
|
|
90
|
-
}
|
|
91
|
-
baseScaleConfig = xAxisConfig;
|
|
92
|
-
if ((0, _axis.isBandScaleConfig)(yAxisConfig) || (0, _axis.isPointScaleConfig)(yAxisConfig)) {
|
|
93
|
-
throw new Error(`MUI X Charts: ${yAxisKey === _constants.DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
if (!(0, _axis.isBandScaleConfig)(yAxisConfig)) {
|
|
97
|
-
throw new Error(`MUI X Charts: ${yAxisKey === _constants.DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
98
|
-
}
|
|
99
|
-
if (yAxis[yAxisKey].data === undefined) {
|
|
100
|
-
throw new Error(`MUI X Charts: ${yAxisKey === _constants.DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should have data property.`);
|
|
101
|
-
}
|
|
102
|
-
baseScaleConfig = yAxisConfig;
|
|
103
|
-
if ((0, _axis.isBandScaleConfig)(xAxisConfig) || (0, _axis.isPointScaleConfig)(xAxisConfig)) {
|
|
104
|
-
throw new Error(`MUI X Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
82
|
+
(0, _checkScaleErrors.checkScaleErrors)(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis);
|
|
83
|
+
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
107
84
|
const xScale = xAxisConfig.scale;
|
|
108
85
|
const yScale = yAxisConfig.scale;
|
|
109
86
|
const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
|
|
@@ -136,7 +113,6 @@ const useAggregatedData = () => {
|
|
|
136
113
|
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
137
114
|
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
138
115
|
color: colorGetter(dataIndex),
|
|
139
|
-
highlightScope: series[seriesId].highlightScope,
|
|
140
116
|
value: series[seriesId].data[dataIndex],
|
|
141
117
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
142
118
|
};
|
|
@@ -259,14 +235,12 @@ function BarPlot(props) {
|
|
|
259
235
|
seriesId,
|
|
260
236
|
dataIndex,
|
|
261
237
|
color,
|
|
262
|
-
highlightScope,
|
|
263
238
|
maskId
|
|
264
239
|
}) => {
|
|
265
240
|
const barElement = /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarElement.BarElement, (0, _extends2.default)({
|
|
266
241
|
id: seriesId,
|
|
267
242
|
dataIndex: dataIndex,
|
|
268
|
-
color: color
|
|
269
|
-
highlightScope: highlightScope
|
|
243
|
+
color: color
|
|
270
244
|
}, other, {
|
|
271
245
|
onClick: onItemClick && (event => {
|
|
272
246
|
onItemClick(event, {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxisDefaultized } from '../models/axis';
|
|
2
|
+
import { SeriesId } from '../models/seriesType/common';
|
|
3
|
+
export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey: string, xAxis: {
|
|
4
|
+
DEFAULT_X_AXIS_KEY: AxisDefaultized;
|
|
5
|
+
} & {
|
|
6
|
+
[axisKey: string]: AxisDefaultized;
|
|
7
|
+
}, yAxisKey: string, yAxis: {
|
|
8
|
+
DEFAULT_X_AXIS_KEY: AxisDefaultized;
|
|
9
|
+
} & {
|
|
10
|
+
[axisKey: string]: AxisDefaultized;
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkScaleErrors = checkScaleErrors;
|
|
7
|
+
var _constants = require("../constants");
|
|
8
|
+
var _axis = require("../models/axis");
|
|
9
|
+
const getAxisMessage = (axisDirection, axisKey) => {
|
|
10
|
+
const axisName = `${axisDirection}-axis`;
|
|
11
|
+
const axisKeyName = `${axisDirection}Axis`;
|
|
12
|
+
const axisDefaultKey = axisDirection === 'x' ? _constants.DEFAULT_X_AXIS_KEY : _constants.DEFAULT_Y_AXIS_KEY;
|
|
13
|
+
return axisKey === axisDefaultKey ? `The first \`${axisKeyName}\`` : `The ${axisName} with id "${axisKey}"`;
|
|
14
|
+
};
|
|
15
|
+
function checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis) {
|
|
16
|
+
const xAxisConfig = xAxis[xAxisKey];
|
|
17
|
+
const yAxisConfig = yAxis[yAxisKey];
|
|
18
|
+
const discreteAxisConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
19
|
+
const continuousAxisConfig = verticalLayout ? yAxisConfig : xAxisConfig;
|
|
20
|
+
const discreteAxisKey = verticalLayout ? xAxisKey : yAxisKey;
|
|
21
|
+
const continuousAxisKey = verticalLayout ? yAxisKey : xAxisKey;
|
|
22
|
+
const discreteAxisDirection = verticalLayout ? 'x' : 'y';
|
|
23
|
+
const continuousAxisDirection = verticalLayout ? 'y' : 'x';
|
|
24
|
+
if (!(0, _axis.isBandScaleConfig)(discreteAxisConfig)) {
|
|
25
|
+
throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
26
|
+
}
|
|
27
|
+
if (discreteAxisConfig.data === undefined) {
|
|
28
|
+
throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should have data property.`);
|
|
29
|
+
}
|
|
30
|
+
if ((0, _axis.isBandScaleConfig)(continuousAxisConfig) || (0, _axis.isPointScaleConfig)(continuousAxisConfig)) {
|
|
31
|
+
throw new Error(`MUI X Charts: ${getAxisMessage(continuousAxisDirection, continuousAxisKey)} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
32
|
+
}
|
|
33
|
+
}
|
package/BarChart/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HighlightScope } from '../context';
|
|
2
1
|
import type { BarSeriesType } from '../models';
|
|
3
2
|
import type { SeriesId } from '../models/seriesType/common';
|
|
4
3
|
export type AnimationData = {
|
|
@@ -15,7 +14,6 @@ export interface CompletedBarData extends AnimationData {
|
|
|
15
14
|
dataIndex: number;
|
|
16
15
|
color: string;
|
|
17
16
|
value: number | null;
|
|
18
|
-
highlightScope?: Partial<HighlightScope>;
|
|
19
17
|
maskId: string;
|
|
20
18
|
}
|
|
21
19
|
export interface MaskData extends AnimationData {
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,117 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.6.1
|
|
7
|
+
|
|
8
|
+
_May 31, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
🐞 Address the `@mui/internal-test-utils` added as a direct dependency to `@mui/x-data-grid` by mistake.
|
|
13
|
+
|
|
14
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
15
|
+
|
|
16
|
+
### Data Grid
|
|
17
|
+
|
|
18
|
+
#### `@mui/x-data-grid@7.6.1`
|
|
19
|
+
|
|
20
|
+
- [DataGrid] Fix column resize not working with special character (#13069) @oukunan
|
|
21
|
+
- [DataGrid] Move `@mui/internal-test-utils` to dev dependency (#13318) @LukasTy
|
|
22
|
+
|
|
23
|
+
#### `@mui/x-data-grid-pro@7.6.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
24
|
+
|
|
25
|
+
Same changes as in `@mui/x-data-grid@7.6.1`.
|
|
26
|
+
|
|
27
|
+
#### `@mui/x-data-grid-premium@7.6.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
28
|
+
|
|
29
|
+
Same changes as in `@mui/x-data-grid-pro@7.6.1`.
|
|
30
|
+
|
|
31
|
+
## 7.6.0
|
|
32
|
+
|
|
33
|
+
_May 30, 2024_
|
|
34
|
+
|
|
35
|
+
We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
36
|
+
|
|
37
|
+
- 🎁 Allow to define and customize the indentation of nested items in the Tree View
|
|
38
|
+
- ✨ Allow charts highlights to be controlled
|
|
39
|
+
- 🌍 Improve Persian (fa-IR) locale on the Data Grid
|
|
40
|
+
- 🐞 Bugfixes
|
|
41
|
+
- 📚 Documentation improvements
|
|
42
|
+
|
|
43
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
44
|
+
|
|
45
|
+
### Data Grid
|
|
46
|
+
|
|
47
|
+
#### `@mui/x-data-grid@7.6.0`
|
|
48
|
+
|
|
49
|
+
- [DataGrid] Avoid re-rendering all cells on column change (#12980) @romgrk
|
|
50
|
+
- [DataGrid] Export `GridColumnHeadersProps` (#13229) @cherniavskii
|
|
51
|
+
- [DataGrid] Fix header filters' issue with custom filters (#13255) @MBilalShafi
|
|
52
|
+
- [DataGrid] Remove dead logic to support Safari < 13 (#13249) @oliviertassinari
|
|
53
|
+
- [l10n] Improve Persian (fa-IR) locale (#12994) @amiryxe
|
|
54
|
+
|
|
55
|
+
#### `@mui/x-data-grid-pro@7.6.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
56
|
+
|
|
57
|
+
Same changes as in `@mui/x-data-grid@7.6.0`.
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-data-grid-premium@7.6.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
60
|
+
|
|
61
|
+
Same changes as in `@mui/x-data-grid-pro@7.6.0`, plus:
|
|
62
|
+
|
|
63
|
+
- [DataGridPremium] Fix excel export causing column with wrong width (#13191) @romgrk
|
|
64
|
+
|
|
65
|
+
### Date and Time Pickers
|
|
66
|
+
|
|
67
|
+
#### `@mui/x-date-pickers@7.6.0`
|
|
68
|
+
|
|
69
|
+
- [pickers] Fix `DateBuilderReturnType` when the date is `undefined` (#13244) @alexey-kozlenkov
|
|
70
|
+
|
|
71
|
+
#### `@mui/x-date-pickers-pro@7.6.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
72
|
+
|
|
73
|
+
Same changes as in `@mui/x-date-pickers@7.6.0`.
|
|
74
|
+
|
|
75
|
+
### Charts
|
|
76
|
+
|
|
77
|
+
#### `@mui/x-charts@7.6.0`
|
|
78
|
+
|
|
79
|
+
- [charts] Allow charts highlights to be controlled (#12828) @JCQuintas
|
|
80
|
+
- [charts] Refactor axis band scaleType check (#13295) @JCQuintas
|
|
81
|
+
- [charts] Refactor checkScaleErrors to improve readability and simplify axis message logic (#13305) @JCQuintas
|
|
82
|
+
|
|
83
|
+
### Tree View
|
|
84
|
+
|
|
85
|
+
#### `@mui/x-tree-view@7.6.0`
|
|
86
|
+
|
|
87
|
+
- [TreeView] Add JSDoc to every instance method (#13219) @flaviendelangle
|
|
88
|
+
- [TreeView] Allow to customize the indentation of nested items (#13225) @flaviendelangle
|
|
89
|
+
- [TreeView] Allow to define indentation at the item level (#13126) @flaviendelangle
|
|
90
|
+
|
|
91
|
+
### Docs
|
|
92
|
+
|
|
93
|
+
- [docs] Add Bulk editing demo for the Community plan (#12800) @cherniavskii
|
|
94
|
+
- [docs] Add conditional label formatting on tooltip page and link to label page (#13235) @JCQuintas
|
|
95
|
+
- [docs] Add information about key combinations on a11y sections (#13234) @arthurbalduini
|
|
96
|
+
- [docs] Cleanup of the Tree View demos (#13237) @flaviendelangle
|
|
97
|
+
- [docs] Document how to customize a subsection of a line chart (#13210) @alexfauquette
|
|
98
|
+
- [docs] Fix Pickers FAQ callout (#13238) @LukasTy
|
|
99
|
+
- [docs] Fix Vale errors @oliviertassinari
|
|
100
|
+
- [docs] Fix a small typo in property comment (#13245) @Janpot
|
|
101
|
+
- [docs] Improve the Data Grid FAQ page (#13258) @MBilalShafi
|
|
102
|
+
- [docs] Removes unused lines in TreeItem2 styling (#13264) @arthurbalduini
|
|
103
|
+
- [docs] Small improvements on accessibility data grid doc (#13233) @arthurbalduini
|
|
104
|
+
- [docs] Update Pickers demo configurations (#13303) @LukasTy
|
|
105
|
+
|
|
106
|
+
### Core
|
|
107
|
+
|
|
108
|
+
- [core] Add comment on why logic to sync column header (#13248) @oliviertassinari
|
|
109
|
+
- [core] Fix `l10n` script execution with arguments (#13297) @LukasTy
|
|
110
|
+
- [core] Prevent "Add reviewers" workflow from triggering since it doesn't work (#13236) @JCQuintas
|
|
111
|
+
- [docs-infra] Fix `@mui/material` version used in sandboxes (#13260) @LukasTy
|
|
112
|
+
- [test] Use `describeTreeView` for keyboard navigation tests on disabled items (#13184) @flaviendelangle
|
|
113
|
+
- [test] Use `describeTreeView` for remaining items tests (#13262) @flaviendelangle
|
|
114
|
+
- [test] Use test-utils from npm (#12880) @michaldudak
|
|
115
|
+
- [typescript] Remove duplicate `DateRangePosition` type in favor of `RangePosition` (#13288) @LukasTy
|
|
116
|
+
|
|
6
117
|
## v7.5.1
|
|
7
118
|
|
|
8
119
|
_May 23, 2024_
|
|
@@ -339,7 +450,7 @@ Same changes as in `@mui/x-date-pickers@7.3.1`.
|
|
|
339
450
|
### Core
|
|
340
451
|
|
|
341
452
|
- [core] Fix `l10n` GH workflow (#12895) @LukasTy
|
|
342
|
-
- [core] Match Base
|
|
453
|
+
- [core] Match Base UI and Toolpad @oliviertassinari
|
|
343
454
|
- [core] Remove redundant `setupFiles` entries in `package.json` (#12899) @LukasTy
|
|
344
455
|
- [core] Use `describeTreeView` for focus tests (#12698) @flaviendelangle
|
|
345
456
|
- [core] Use `describeTreeView` for type-ahead tests (#12811) @flaviendelangle
|
|
@@ -3,10 +3,11 @@ import { DrawingProviderProps } from '../context/DrawingProvider';
|
|
|
3
3
|
import { SeriesContextProviderProps } from '../context/SeriesContextProvider';
|
|
4
4
|
import { ChartsSurfaceProps } from '../ChartsSurface';
|
|
5
5
|
import { CartesianContextProviderProps } from '../context/CartesianContextProvider';
|
|
6
|
-
|
|
6
|
+
import { HighlightedProviderProps } from '../context';
|
|
7
|
+
export type ChartContainerProps = Omit<ChartsSurfaceProps & SeriesContextProviderProps & Omit<DrawingProviderProps, 'svgRef'> & CartesianContextProviderProps & HighlightedProviderProps, 'children'> & {
|
|
7
8
|
children?: React.ReactNode;
|
|
8
9
|
};
|
|
9
|
-
declare const ChartContainer: React.ForwardRefExoticComponent<Omit<ChartsSurfaceProps & SeriesContextProviderProps & Omit<DrawingProviderProps, "svgRef"> & CartesianContextProviderProps, "children"> & {
|
|
10
|
+
declare const ChartContainer: React.ForwardRefExoticComponent<Omit<ChartsSurfaceProps & SeriesContextProviderProps & Omit<DrawingProviderProps, "svgRef"> & CartesianContextProviderProps & HighlightedProviderProps, "children"> & {
|
|
10
11
|
children?: React.ReactNode;
|
|
11
12
|
} & React.RefAttributes<unknown>>;
|
|
12
13
|
export { ChartContainer };
|
|
@@ -14,8 +14,8 @@ var _InteractionProvider = require("../context/InteractionProvider");
|
|
|
14
14
|
var _useReducedMotion = require("../hooks/useReducedMotion");
|
|
15
15
|
var _ChartsSurface = require("../ChartsSurface");
|
|
16
16
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
17
|
-
var _HighlightProvider = require("../context/HighlightProvider");
|
|
18
17
|
var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
|
|
18
|
+
var _context = require("../context");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -33,6 +33,8 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
|
|
|
33
33
|
title,
|
|
34
34
|
desc,
|
|
35
35
|
disableAxisListener,
|
|
36
|
+
highlightedItem,
|
|
37
|
+
onHighlightChange,
|
|
36
38
|
children
|
|
37
39
|
} = props;
|
|
38
40
|
const svgRef = React.useRef(null);
|
|
@@ -53,7 +55,9 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
|
|
|
53
55
|
yAxis: yAxis,
|
|
54
56
|
dataset: dataset,
|
|
55
57
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InteractionProvider.InteractionProvider, {
|
|
56
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
58
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.HighlightedProvider, {
|
|
59
|
+
highlightedItem: highlightedItem,
|
|
60
|
+
onHighlightChange: onHighlightChange,
|
|
57
61
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, {
|
|
58
62
|
width: width,
|
|
59
63
|
height: height,
|
|
@@ -97,6 +101,13 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
97
101
|
* The height of the chart in px.
|
|
98
102
|
*/
|
|
99
103
|
height: _propTypes.default.number.isRequired,
|
|
104
|
+
/**
|
|
105
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
106
|
+
*/
|
|
107
|
+
highlightedItem: _propTypes.default.shape({
|
|
108
|
+
dataIndex: _propTypes.default.number,
|
|
109
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
110
|
+
}),
|
|
100
111
|
/**
|
|
101
112
|
* The margin between the SVG and the drawing area.
|
|
102
113
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -109,6 +120,12 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
109
120
|
right: _propTypes.default.number,
|
|
110
121
|
top: _propTypes.default.number
|
|
111
122
|
}),
|
|
123
|
+
/**
|
|
124
|
+
* The callback fired when the highlighted item changes.
|
|
125
|
+
*
|
|
126
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
127
|
+
*/
|
|
128
|
+
onHighlightChange: _propTypes.default.func,
|
|
112
129
|
/**
|
|
113
130
|
* The array of series to display.
|
|
114
131
|
* Each type of series has its own specificity.
|
|
@@ -15,6 +15,7 @@ var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
|
15
15
|
var _useScale = require("../hooks/useScale");
|
|
16
16
|
var _utils = require("../internals/utils");
|
|
17
17
|
var _hooks = require("../hooks");
|
|
18
|
+
var _context = require("../context");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -45,6 +46,10 @@ function ChartsVoronoiHandler(props) {
|
|
|
45
46
|
} = React.useContext(_SeriesContextProvider.SeriesContext).scatter ?? {};
|
|
46
47
|
const voronoiRef = React.useRef({});
|
|
47
48
|
const delauneyRef = React.useRef(undefined);
|
|
49
|
+
const {
|
|
50
|
+
setHighlighted,
|
|
51
|
+
clearHighlighted
|
|
52
|
+
} = (0, _context.useHighlighted)();
|
|
48
53
|
const defaultXAxisId = xAxisIds[0];
|
|
49
54
|
const defaultYAxisId = yAxisIds[0];
|
|
50
55
|
(0, _useEnhancedEffect.default)(() => {
|
|
@@ -138,6 +143,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
138
143
|
dispatch({
|
|
139
144
|
type: 'exitChart'
|
|
140
145
|
});
|
|
146
|
+
clearHighlighted();
|
|
141
147
|
};
|
|
142
148
|
const handleMouseMove = event => {
|
|
143
149
|
const closestPoint = getClosestPoint(event);
|
|
@@ -145,6 +151,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
145
151
|
dispatch({
|
|
146
152
|
type: 'exitChart'
|
|
147
153
|
});
|
|
154
|
+
clearHighlighted();
|
|
148
155
|
return;
|
|
149
156
|
}
|
|
150
157
|
if (closestPoint === 'outside-voronoi-max-radius' || closestPoint === 'no-point-found') {
|
|
@@ -154,6 +161,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
154
161
|
type: 'scatter'
|
|
155
162
|
}
|
|
156
163
|
});
|
|
164
|
+
clearHighlighted();
|
|
157
165
|
return;
|
|
158
166
|
}
|
|
159
167
|
const {
|
|
@@ -168,6 +176,10 @@ function ChartsVoronoiHandler(props) {
|
|
|
168
176
|
dataIndex
|
|
169
177
|
}
|
|
170
178
|
});
|
|
179
|
+
setHighlighted({
|
|
180
|
+
seriesId,
|
|
181
|
+
dataIndex
|
|
182
|
+
});
|
|
171
183
|
};
|
|
172
184
|
const handleMouseClick = event => {
|
|
173
185
|
if (!onItemClick) {
|
|
@@ -196,7 +208,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
196
208
|
element.removeEventListener('mousemove', handleMouseMove);
|
|
197
209
|
element.removeEventListener('click', handleMouseClick);
|
|
198
210
|
};
|
|
199
|
-
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick]);
|
|
211
|
+
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted]);
|
|
200
212
|
|
|
201
213
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
202
214
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { HighlightScope } from '../context/HighlightProvider';
|
|
3
2
|
import { AnimatedAreaProps } from './AnimatedArea';
|
|
4
3
|
import { SeriesId } from '../models/seriesType/common';
|
|
5
4
|
export interface AreaElementClasses {
|
|
@@ -33,7 +32,6 @@ export interface AreaElementSlotProps {
|
|
|
33
32
|
}
|
|
34
33
|
export interface AreaElementProps extends Omit<AreaElementOwnerState, 'isFaded' | 'isHighlighted'>, Pick<AnimatedAreaProps, 'skipAnimation'>, Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color' | 'id'> {
|
|
35
34
|
d: string;
|
|
36
|
-
highlightScope?: Partial<HighlightScope>;
|
|
37
35
|
/**
|
|
38
36
|
* The props used for each component slot.
|
|
39
37
|
* @default {}
|
package/LineChart/AreaElement.js
CHANGED
|
@@ -16,10 +16,10 @@ var _utils = require("@mui/base/utils");
|
|
|
16
16
|
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
17
17
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
18
18
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
19
|
-
var _InteractionProvider = require("../context/InteractionProvider");
|
|
20
19
|
var _AnimatedArea = require("./AnimatedArea");
|
|
20
|
+
var _context = require("../context");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["id", "classes", "color", "gradientId", "
|
|
22
|
+
const _excluded = ["id", "classes", "color", "gradientId", "slots", "slotProps", "onClick"];
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
25
|
function getAreaElementUtilityClass(slot) {
|
|
@@ -54,24 +54,18 @@ function AreaElement(props) {
|
|
|
54
54
|
classes: innerClasses,
|
|
55
55
|
color,
|
|
56
56
|
gradientId,
|
|
57
|
-
highlightScope,
|
|
58
57
|
slots,
|
|
59
58
|
slotProps,
|
|
60
59
|
onClick
|
|
61
60
|
} = props,
|
|
62
61
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
63
|
-
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(
|
|
62
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)();
|
|
64
63
|
const {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
type: 'line',
|
|
69
|
-
seriesId: id
|
|
70
|
-
}, highlightScope);
|
|
71
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
|
|
72
|
-
type: 'line',
|
|
64
|
+
isFaded,
|
|
65
|
+
isHighlighted
|
|
66
|
+
} = (0, _context.useItemHighlighted)({
|
|
73
67
|
seriesId: id
|
|
74
|
-
}
|
|
68
|
+
});
|
|
75
69
|
const ownerState = {
|
|
76
70
|
id,
|
|
77
71
|
classes: innerClasses,
|
|
@@ -106,10 +100,6 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
|
106
100
|
color: _propTypes.default.string.isRequired,
|
|
107
101
|
d: _propTypes.default.string.isRequired,
|
|
108
102
|
gradientId: _propTypes.default.string,
|
|
109
|
-
highlightScope: _propTypes.default.shape({
|
|
110
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
111
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
112
|
-
}),
|
|
113
103
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
114
104
|
/**
|
|
115
105
|
* If `true`, animations are skipped.
|