@mui/x-charts 7.5.1 → 7.6.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.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 +87 -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/LineChart/LineChart.js
CHANGED
|
@@ -66,7 +66,9 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
|
|
|
66
66
|
slots,
|
|
67
67
|
slotProps,
|
|
68
68
|
skipAnimation,
|
|
69
|
-
loading
|
|
69
|
+
loading,
|
|
70
|
+
highlightedItem,
|
|
71
|
+
onHighlightChange
|
|
70
72
|
} = props;
|
|
71
73
|
const id = (0, _useId.default)();
|
|
72
74
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -91,6 +93,8 @@ const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function Lin
|
|
|
91
93
|
dataset: dataset,
|
|
92
94
|
sx: sx,
|
|
93
95
|
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
96
|
+
highlightedItem: highlightedItem,
|
|
97
|
+
onHighlightChange: onHighlightChange,
|
|
94
98
|
children: [onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, {
|
|
95
99
|
onAxisClick: onAxisClick
|
|
96
100
|
}), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
|
|
@@ -192,6 +196,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
192
196
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
193
197
|
*/
|
|
194
198
|
height: _propTypes.default.number,
|
|
199
|
+
/**
|
|
200
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
201
|
+
*/
|
|
202
|
+
highlightedItem: _propTypes.default.shape({
|
|
203
|
+
dataIndex: _propTypes.default.number,
|
|
204
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
205
|
+
}),
|
|
195
206
|
/**
|
|
196
207
|
* Indicate which axis to display the left of the charts.
|
|
197
208
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -240,6 +251,12 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
240
251
|
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
241
252
|
*/
|
|
242
253
|
onAxisClick: _propTypes.default.func,
|
|
254
|
+
/**
|
|
255
|
+
* The callback fired when the highlighted item changes.
|
|
256
|
+
*
|
|
257
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
258
|
+
*/
|
|
259
|
+
onHighlightChange: _propTypes.default.func,
|
|
243
260
|
/**
|
|
244
261
|
* Callback fired when a line element is clicked.
|
|
245
262
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { HighlightScope } from '../context/HighlightProvider';
|
|
3
2
|
import { AnimatedLineProps } from './AnimatedLine';
|
|
4
3
|
import { SeriesId } from '../models/seriesType/common';
|
|
5
4
|
export interface LineElementClasses {
|
|
@@ -33,7 +32,6 @@ export interface LineElementSlotProps {
|
|
|
33
32
|
}
|
|
34
33
|
export interface LineElementProps extends Omit<LineElementOwnerState, 'isFaded' | 'isHighlighted'>, Pick<AnimatedLineProps, '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/LineElement.js
CHANGED
|
@@ -15,11 +15,11 @@ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"
|
|
|
15
15
|
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
|
-
var _InteractionProvider = require("../context/InteractionProvider");
|
|
19
18
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
20
19
|
var _AnimatedLine = require("./AnimatedLine");
|
|
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 getLineElementUtilityClass(slot) {
|
|
@@ -54,24 +54,18 @@ function LineElement(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" ? LineElement.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.
|
package/LineChart/LinePlot.js
CHANGED
|
@@ -103,7 +103,6 @@ function LinePlot(props) {
|
|
|
103
103
|
d,
|
|
104
104
|
seriesId,
|
|
105
105
|
color,
|
|
106
|
-
highlightScope,
|
|
107
106
|
gradientUsed
|
|
108
107
|
}) => {
|
|
109
108
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineElement.LineElement, {
|
|
@@ -111,7 +110,6 @@ function LinePlot(props) {
|
|
|
111
110
|
d: d,
|
|
112
111
|
color: color,
|
|
113
112
|
gradientId: gradientUsed && getGradientId(...gradientUsed),
|
|
114
|
-
highlightScope: highlightScope,
|
|
115
113
|
skipAnimation: skipAnimation,
|
|
116
114
|
slots: slots,
|
|
117
115
|
slotProps: slotProps,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { HighlightScope } from '../context/HighlightProvider';
|
|
3
2
|
import { SeriesId } from '../models/seriesType/common';
|
|
4
3
|
export interface MarkElementClasses {
|
|
5
4
|
/** Styles applied to the root element. */
|
|
@@ -33,7 +32,6 @@ export type MarkElementProps = Omit<MarkElementOwnerState, 'isFaded' | 'isHighli
|
|
|
33
32
|
* The index to the element in the series' data array.
|
|
34
33
|
*/
|
|
35
34
|
dataIndex: number;
|
|
36
|
-
highlightScope?: Partial<HighlightScope>;
|
|
37
35
|
};
|
|
38
36
|
/**
|
|
39
37
|
* Demos:
|
package/LineChart/MarkElement.js
CHANGED
|
@@ -20,8 +20,9 @@ var _web = require("@react-spring/web");
|
|
|
20
20
|
var _utils = require("../internals/utils");
|
|
21
21
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
22
22
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
23
|
+
var _context = require("../context");
|
|
23
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
|
-
const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "
|
|
25
|
+
const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "onClick", "skipAnimation"];
|
|
25
26
|
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
27
|
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
28
|
function getMarkElementUtilityClass(slot) {
|
|
@@ -71,24 +72,20 @@ function MarkElement(props) {
|
|
|
71
72
|
color,
|
|
72
73
|
shape,
|
|
73
74
|
dataIndex,
|
|
74
|
-
highlightScope,
|
|
75
75
|
onClick,
|
|
76
76
|
skipAnimation
|
|
77
77
|
} = props,
|
|
78
78
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
79
|
-
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(
|
|
79
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)();
|
|
80
|
+
const {
|
|
81
|
+
isFaded,
|
|
82
|
+
isHighlighted
|
|
83
|
+
} = (0, _context.useItemHighlighted)({
|
|
84
|
+
seriesId: id
|
|
85
|
+
});
|
|
80
86
|
const {
|
|
81
|
-
item,
|
|
82
87
|
axis
|
|
83
88
|
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
84
|
-
const isHighlighted = axis.x?.index === dataIndex || (0, _useInteractionItemProps.getIsHighlighted)(item, {
|
|
85
|
-
type: 'line',
|
|
86
|
-
seriesId: id
|
|
87
|
-
}, highlightScope);
|
|
88
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
|
|
89
|
-
type: 'line',
|
|
90
|
-
seriesId: id
|
|
91
|
-
}, highlightScope);
|
|
92
89
|
const position = (0, _web.useSpring)({
|
|
93
90
|
x,
|
|
94
91
|
y,
|
|
@@ -97,7 +94,7 @@ function MarkElement(props) {
|
|
|
97
94
|
const ownerState = {
|
|
98
95
|
id,
|
|
99
96
|
classes: innerClasses,
|
|
100
|
-
isHighlighted,
|
|
97
|
+
isHighlighted: axis.x?.index === dataIndex || isHighlighted,
|
|
101
98
|
isFaded,
|
|
102
99
|
color
|
|
103
100
|
};
|
|
@@ -128,10 +125,6 @@ process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
|
|
|
128
125
|
* The index to the element in the series' data array.
|
|
129
126
|
*/
|
|
130
127
|
dataIndex: _propTypes.default.number.isRequired,
|
|
131
|
-
highlightScope: _propTypes.default.shape({
|
|
132
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
133
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
134
|
-
}),
|
|
135
128
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
136
129
|
/**
|
|
137
130
|
* The shape of the marker.
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -148,7 +148,6 @@ function MarkPlot(props) {
|
|
|
148
148
|
x: x,
|
|
149
149
|
y: y // Don't know why TS doesn't get from the filter that y can't be null
|
|
150
150
|
,
|
|
151
|
-
highlightScope: series[seriesId].highlightScope,
|
|
152
151
|
skipAnimation: skipAnimation,
|
|
153
152
|
onClick: onItemClick && (event => onItemClick(event, {
|
|
154
153
|
type: 'line',
|
package/PieChart/PieArc.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="@react-spring/core" />
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { SpringValue } from '@react-spring/web';
|
|
4
|
-
import { HighlightScope } from '../context/HighlightProvider';
|
|
5
4
|
import { PieItemId } from '../models';
|
|
5
|
+
import { HighlightScope } from '../context';
|
|
6
6
|
export interface PieArcClasses {
|
|
7
7
|
/** Styles applied to the root element. */
|
|
8
8
|
root: string;
|
|
@@ -25,6 +25,9 @@ export declare const pieArcClasses: PieArcClasses;
|
|
|
25
25
|
export type PieArcProps = Omit<React.SVGProps<SVGPathElement>, 'ref' | 'id'> & PieArcOwnerState & {
|
|
26
26
|
cornerRadius: SpringValue<number>;
|
|
27
27
|
endAngle: SpringValue<number>;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use the `isFaded` or `isHighlighted` props instead.
|
|
30
|
+
*/
|
|
28
31
|
highlightScope?: Partial<HighlightScope>;
|
|
29
32
|
innerRadius: SpringValue<number>;
|
|
30
33
|
onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
|
package/PieChart/PieArc.js
CHANGED
|
@@ -19,7 +19,7 @@ var _styles = require("@mui/material/styles");
|
|
|
19
19
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
20
20
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "
|
|
22
|
+
const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle", "highlightScope"];
|
|
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 getPieArcUtilityClass(slot) {
|
|
@@ -56,7 +56,6 @@ function PieArc(props) {
|
|
|
56
56
|
cornerRadius,
|
|
57
57
|
dataIndex,
|
|
58
58
|
endAngle,
|
|
59
|
-
highlightScope,
|
|
60
59
|
id,
|
|
61
60
|
innerRadius,
|
|
62
61
|
isFaded,
|
|
@@ -76,7 +75,7 @@ function PieArc(props) {
|
|
|
76
75
|
isHighlighted
|
|
77
76
|
};
|
|
78
77
|
const classes = useUtilityClasses(ownerState);
|
|
79
|
-
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(
|
|
78
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)();
|
|
80
79
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PieArcRoot, (0, _extends2.default)({
|
|
81
80
|
d: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], (sA, eA, pA, iR, oR, cR) => (0, _d3Shape.arc)().cornerRadius(cR)({
|
|
82
81
|
padAngle: pA,
|
|
@@ -102,8 +101,13 @@ process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
|
|
|
102
101
|
// ----------------------------------------------------------------------
|
|
103
102
|
classes: _propTypes.default.object,
|
|
104
103
|
dataIndex: _propTypes.default.number.isRequired,
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Use the `isFaded` or `isHighlighted` props instead.
|
|
106
|
+
*/
|
|
105
107
|
highlightScope: _propTypes.default.shape({
|
|
108
|
+
fade: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
106
109
|
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
110
|
+
highlight: _propTypes.default.oneOf(['item', 'none', 'series']),
|
|
107
111
|
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
108
112
|
}),
|
|
109
113
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
@@ -7,7 +7,7 @@ export interface PieArcLabelPlotSlots {
|
|
|
7
7
|
export interface PieArcLabelPlotSlotProps {
|
|
8
8
|
pieArcLabel?: Partial<PieArcLabelProps>;
|
|
9
9
|
}
|
|
10
|
-
export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle' | 'id'
|
|
10
|
+
export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle' | 'id'>, ComputedPieRadius {
|
|
11
11
|
/**
|
|
12
12
|
* Override the arc attributes when it is faded.
|
|
13
13
|
* @default { additionalRadius: -5 }
|
|
@@ -15,7 +15,7 @@ var _useTransformData = require("./dataTransform/useTransformData");
|
|
|
15
15
|
var _PieArcLabel = require("./PieArcLabel");
|
|
16
16
|
var _getLabel = require("../internals/getLabel");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "
|
|
18
|
+
const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
|
|
19
19
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
|
|
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; }
|
|
@@ -52,7 +52,6 @@ function PieArcLabelPlot(props) {
|
|
|
52
52
|
additionalRadius: -5
|
|
53
53
|
},
|
|
54
54
|
highlighted,
|
|
55
|
-
highlightScope,
|
|
56
55
|
id,
|
|
57
56
|
innerRadius,
|
|
58
57
|
outerRadius,
|
|
@@ -69,7 +68,6 @@ function PieArcLabelPlot(props) {
|
|
|
69
68
|
cornerRadius,
|
|
70
69
|
paddingAngle,
|
|
71
70
|
id,
|
|
72
|
-
highlightScope,
|
|
73
71
|
highlighted,
|
|
74
72
|
faded,
|
|
75
73
|
data
|
|
@@ -171,10 +169,6 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
171
169
|
outerRadius: _propTypes.default.number,
|
|
172
170
|
paddingAngle: _propTypes.default.number
|
|
173
171
|
}),
|
|
174
|
-
highlightScope: _propTypes.default.shape({
|
|
175
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
176
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
177
|
-
}),
|
|
178
172
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
179
173
|
/**
|
|
180
174
|
* The radius between circle center and the beginning of the arc.
|
package/PieChart/PieArcPlot.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface PieArcPlotSlots {
|
|
|
7
7
|
export interface PieArcPlotSlotProps {
|
|
8
8
|
pieArc?: Partial<PieArcProps>;
|
|
9
9
|
}
|
|
10
|
-
export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'id'
|
|
10
|
+
export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'id'>, ComputedPieRadius {
|
|
11
11
|
/**
|
|
12
12
|
* Override the arc attributes when it is faded.
|
|
13
13
|
* @default { additionalRadius: -5 }
|
package/PieChart/PieArcPlot.js
CHANGED
|
@@ -13,8 +13,9 @@ var _web = require("@react-spring/web");
|
|
|
13
13
|
var _PieArc = require("./PieArc");
|
|
14
14
|
var _transition = require("./dataTransform/transition");
|
|
15
15
|
var _useTransformData = require("./dataTransform/useTransformData");
|
|
16
|
+
var _context = require("../context");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "
|
|
18
|
+
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
|
|
18
19
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
|
|
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; }
|
|
@@ -27,7 +28,6 @@ function PieArcPlot(props) {
|
|
|
27
28
|
cornerRadius = 0,
|
|
28
29
|
paddingAngle = 0,
|
|
29
30
|
id,
|
|
30
|
-
highlightScope,
|
|
31
31
|
highlighted,
|
|
32
32
|
faded = {
|
|
33
33
|
additionalRadius: -5
|
|
@@ -43,7 +43,6 @@ function PieArcPlot(props) {
|
|
|
43
43
|
cornerRadius,
|
|
44
44
|
paddingAngle,
|
|
45
45
|
id,
|
|
46
|
-
highlightScope,
|
|
47
46
|
highlighted,
|
|
48
47
|
faded,
|
|
49
48
|
data
|
|
@@ -51,6 +50,9 @@ function PieArcPlot(props) {
|
|
|
51
50
|
const transition = (0, _web.useTransition)(transformedData, (0, _extends2.default)({}, _transition.defaultTransitionConfig, {
|
|
52
51
|
immediate: skipAnimation
|
|
53
52
|
}));
|
|
53
|
+
const {
|
|
54
|
+
highlightScope
|
|
55
|
+
} = (0, _context.useHighlighted)();
|
|
54
56
|
if (data.length === 0) {
|
|
55
57
|
return null;
|
|
56
58
|
}
|
|
@@ -142,10 +144,6 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
142
144
|
outerRadius: _propTypes.default.number,
|
|
143
145
|
paddingAngle: _propTypes.default.number
|
|
144
146
|
}),
|
|
145
|
-
highlightScope: _propTypes.default.shape({
|
|
146
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
147
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
148
|
-
}),
|
|
149
147
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
150
148
|
/**
|
|
151
149
|
* The radius between circle center and the beginning of the arc.
|
package/PieChart/PieChart.js
CHANGED
|
@@ -70,7 +70,9 @@ function PieChart(props) {
|
|
|
70
70
|
slots,
|
|
71
71
|
slotProps,
|
|
72
72
|
onItemClick,
|
|
73
|
-
loading
|
|
73
|
+
loading,
|
|
74
|
+
highlightedItem,
|
|
75
|
+
onHighlightChange
|
|
74
76
|
} = props;
|
|
75
77
|
const isRTL = (0, _useIsRTL.useIsRTL)();
|
|
76
78
|
const margin = (0, _extends2.default)({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
|
|
@@ -97,6 +99,8 @@ function PieChart(props) {
|
|
|
97
99
|
colors: colors,
|
|
98
100
|
sx: sx,
|
|
99
101
|
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
102
|
+
highlightedItem: highlightedItem,
|
|
103
|
+
onHighlightChange: onHighlightChange,
|
|
100
104
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
|
|
101
105
|
topAxis: topAxis,
|
|
102
106
|
leftAxis: leftAxis,
|
|
@@ -164,6 +168,13 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
164
168
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
165
169
|
*/
|
|
166
170
|
height: _propTypes.default.number,
|
|
171
|
+
/**
|
|
172
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
173
|
+
*/
|
|
174
|
+
highlightedItem: _propTypes.default.shape({
|
|
175
|
+
dataIndex: _propTypes.default.number,
|
|
176
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
177
|
+
}),
|
|
167
178
|
/**
|
|
168
179
|
* Indicate which axis to display the left of the charts.
|
|
169
180
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -203,6 +214,12 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
203
214
|
right: _propTypes.default.number,
|
|
204
215
|
top: _propTypes.default.number
|
|
205
216
|
}),
|
|
217
|
+
/**
|
|
218
|
+
* The callback fired when the highlighted item changes.
|
|
219
|
+
*
|
|
220
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
221
|
+
*/
|
|
222
|
+
onHighlightChange: _propTypes.default.func,
|
|
206
223
|
/**
|
|
207
224
|
* Callback fired when a pie arc is clicked.
|
|
208
225
|
*/
|
package/PieChart/PiePlot.js
CHANGED
|
@@ -58,8 +58,7 @@ function PiePlot(props) {
|
|
|
58
58
|
cx: cxParam,
|
|
59
59
|
cy: cyParam,
|
|
60
60
|
highlighted,
|
|
61
|
-
faded
|
|
62
|
-
highlightScope
|
|
61
|
+
faded
|
|
63
62
|
} = series[seriesId];
|
|
64
63
|
const {
|
|
65
64
|
cx,
|
|
@@ -84,7 +83,6 @@ function PiePlot(props) {
|
|
|
84
83
|
id: seriesId,
|
|
85
84
|
data: data,
|
|
86
85
|
skipAnimation: skipAnimation,
|
|
87
|
-
highlightScope: highlightScope,
|
|
88
86
|
highlighted: highlighted,
|
|
89
87
|
faded: faded,
|
|
90
88
|
onItemClick: onItemClick,
|
|
@@ -103,8 +101,7 @@ function PiePlot(props) {
|
|
|
103
101
|
arcLabelMinAngle,
|
|
104
102
|
data,
|
|
105
103
|
cx: cxParam,
|
|
106
|
-
cy: cyParam
|
|
107
|
-
highlightScope
|
|
104
|
+
cy: cyParam
|
|
108
105
|
} = series[seriesId];
|
|
109
106
|
const {
|
|
110
107
|
cx,
|
|
@@ -133,7 +130,6 @@ function PiePlot(props) {
|
|
|
133
130
|
skipAnimation: skipAnimation,
|
|
134
131
|
arcLabel: arcLabel,
|
|
135
132
|
arcLabelMinAngle: arcLabelMinAngle,
|
|
136
|
-
highlightScope: highlightScope,
|
|
137
133
|
slots: slots,
|
|
138
134
|
slotProps: slotProps
|
|
139
135
|
})
|
|
@@ -12,4 +12,4 @@ export interface ValueWithHighlight extends DefaultizedPieValueType, AnimatedObj
|
|
|
12
12
|
isFaded: boolean;
|
|
13
13
|
isHighlighted: boolean;
|
|
14
14
|
}
|
|
15
|
-
export declare function useTransformData(series: Pick<DefaultizedPieSeriesType, 'cornerRadius' | 'paddingAngle' | 'id' | '
|
|
15
|
+
export declare function useTransformData(series: Pick<DefaultizedPieSeriesType, 'cornerRadius' | 'paddingAngle' | 'id' | 'highlighted' | 'faded' | 'data'> & ComputedPieRadius): ValueWithHighlight[];
|
|
@@ -7,14 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useTransformData = useTransformData;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
11
|
-
var _useInteractionItemProps = require("../../hooks/useInteractionItemProps");
|
|
10
|
+
var _context = require("../../context");
|
|
12
11
|
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); }
|
|
13
12
|
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; }
|
|
14
13
|
function useTransformData(series) {
|
|
15
14
|
const {
|
|
16
15
|
id: seriesId,
|
|
17
|
-
highlightScope,
|
|
18
16
|
data,
|
|
19
17
|
faded,
|
|
20
18
|
highlighted,
|
|
@@ -25,29 +23,16 @@ function useTransformData(series) {
|
|
|
25
23
|
cornerRadius: baseCornerRadius = 0
|
|
26
24
|
} = series;
|
|
27
25
|
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
seriesId,
|
|
34
|
-
dataIndex
|
|
35
|
-
}, highlightScope);
|
|
36
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(highlightedItem, {
|
|
37
|
-
type: 'pie',
|
|
26
|
+
isFaded: isItemFaded,
|
|
27
|
+
isHighlighted: isItemHighlighted
|
|
28
|
+
} = (0, _context.useHighlighted)();
|
|
29
|
+
const dataWithHighlight = React.useMemo(() => data.map((item, itemIndex) => {
|
|
30
|
+
const currentItem = {
|
|
38
31
|
seriesId,
|
|
39
|
-
dataIndex
|
|
40
|
-
}, highlightScope);
|
|
41
|
-
return {
|
|
42
|
-
isHighlighted,
|
|
43
|
-
isFaded
|
|
32
|
+
dataIndex: itemIndex
|
|
44
33
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
isHighlighted,
|
|
49
|
-
isFaded
|
|
50
|
-
} = getHighlightStatus(itemIndex);
|
|
34
|
+
const isHighlighted = isItemHighlighted(currentItem);
|
|
35
|
+
const isFaded = !isHighlighted && isItemFaded(currentItem);
|
|
51
36
|
const attributesOverride = (0, _extends2.default)({
|
|
52
37
|
additionalRadius: 0
|
|
53
38
|
}, isFaded && faded || isHighlighted && highlighted || {});
|
|
@@ -65,6 +50,6 @@ function useTransformData(series) {
|
|
|
65
50
|
cornerRadius,
|
|
66
51
|
arcLabelRadius
|
|
67
52
|
});
|
|
68
|
-
}), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded,
|
|
53
|
+
}), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, highlighted, isItemFaded, isItemHighlighted, seriesId]);
|
|
69
54
|
return dataWithHighlight;
|
|
70
55
|
}
|
|
@@ -83,6 +83,13 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
83
83
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
84
84
|
*/
|
|
85
85
|
height: _propTypes.default.number,
|
|
86
|
+
/**
|
|
87
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
88
|
+
*/
|
|
89
|
+
highlightedItem: _propTypes.default.shape({
|
|
90
|
+
dataIndex: _propTypes.default.number,
|
|
91
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
92
|
+
}),
|
|
86
93
|
/**
|
|
87
94
|
* The margin between the SVG and the drawing area.
|
|
88
95
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -95,6 +102,12 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
95
102
|
right: _propTypes.default.number,
|
|
96
103
|
top: _propTypes.default.number
|
|
97
104
|
}),
|
|
105
|
+
/**
|
|
106
|
+
* The callback fired when the highlighted item changes.
|
|
107
|
+
*
|
|
108
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
109
|
+
*/
|
|
110
|
+
onHighlightChange: _propTypes.default.func,
|
|
98
111
|
/**
|
|
99
112
|
* The array of series to display.
|
|
100
113
|
* Each type of series has its own specificity.
|
package/ScatterChart/Scatter.js
CHANGED
|
@@ -11,6 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
var _useScale = require("../hooks/useScale");
|
|
12
12
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
13
13
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
14
|
+
var _context = require("../context");
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
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); }
|
|
16
17
|
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; }
|
|
@@ -34,16 +35,15 @@ function Scatter(props) {
|
|
|
34
35
|
markerSize,
|
|
35
36
|
onItemClick
|
|
36
37
|
} = props;
|
|
37
|
-
const highlightScope = React.useMemo(() => (0, _extends2.default)({
|
|
38
|
-
highlighted: 'item',
|
|
39
|
-
faded: 'global'
|
|
40
|
-
}, series.highlightScope), [series.highlightScope]);
|
|
41
38
|
const {
|
|
42
|
-
item,
|
|
43
39
|
useVoronoiInteraction
|
|
44
40
|
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
45
41
|
const skipInteractionHandlers = useVoronoiInteraction || series.disableHover;
|
|
46
|
-
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(
|
|
42
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(skipInteractionHandlers);
|
|
43
|
+
const {
|
|
44
|
+
isFaded,
|
|
45
|
+
isHighlighted
|
|
46
|
+
} = (0, _context.useHighlighted)();
|
|
47
47
|
const cleanData = React.useMemo(() => {
|
|
48
48
|
const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
49
49
|
const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
|
|
@@ -65,12 +65,16 @@ function Scatter(props) {
|
|
|
65
65
|
dataIndex: i
|
|
66
66
|
};
|
|
67
67
|
if (isInRange) {
|
|
68
|
-
const
|
|
68
|
+
const currentItem = {
|
|
69
|
+
seriesId: pointCtx.seriesId,
|
|
70
|
+
dataIndex: pointCtx.dataIndex
|
|
71
|
+
};
|
|
72
|
+
const isItemHighlighted = isHighlighted(currentItem);
|
|
69
73
|
temp.push({
|
|
70
74
|
x,
|
|
71
75
|
y,
|
|
72
|
-
isHighlighted,
|
|
73
|
-
isFaded: !
|
|
76
|
+
isHighlighted: isItemHighlighted,
|
|
77
|
+
isFaded: !isItemHighlighted && isFaded(currentItem),
|
|
74
78
|
interactionProps: getInteractionItemProps(pointCtx),
|
|
75
79
|
id: scatterPoint.id,
|
|
76
80
|
dataIndex: i,
|
|
@@ -79,7 +83,7 @@ function Scatter(props) {
|
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
return temp;
|
|
82
|
-
}, [xScale, yScale, series.data, series.id,
|
|
86
|
+
}, [xScale, yScale, series.data, series.id, getInteractionItemProps, color, colorGetter, isFaded, isHighlighted]);
|
|
83
87
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
84
88
|
children: cleanData.map(dataPoint => /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({
|
|
85
89
|
cx: 0,
|