@mui/x-charts 7.0.0-alpha.2 → 7.0.0-alpha.4
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/BarElement.d.ts +5 -1
- package/BarChart/BarElement.js +24 -1
- package/BarChart/index.d.ts +2 -1
- package/BarChart/index.js +15 -4
- package/CHANGELOG.md +364 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
- package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
- package/ChartsTooltip/index.d.ts +4 -0
- package/ChartsTooltip/index.js +44 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +14 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +174 -0
- package/ChartsVoronoiHandler/index.d.ts +1 -0
- package/ChartsVoronoiHandler/index.js +16 -0
- package/ChartsVoronoiHandler/package.json +6 -0
- package/ChartsYAxis/ChartsYAxis.js +6 -4
- package/LineChart/extremums.js +25 -8
- package/LineChart/index.d.ts +1 -1
- package/LineChart/index.js +11 -11
- package/PieChart/PieArc.d.ts +5 -2
- package/PieChart/PieArc.js +17 -2
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +5 -10
- package/PieChart/PieArcLabelPlot.d.ts +5 -1
- package/PieChart/PieArcLabelPlot.js +91 -3
- package/PieChart/PieArcPlot.d.ts +5 -1
- package/PieChart/PieArcPlot.js +90 -3
- package/PieChart/index.d.ts +3 -1
- package/PieChart/index.js +26 -4
- package/README.md +0 -1
- package/ScatterChart/Scatter.js +15 -6
- package/ScatterChart/ScatterChart.d.ts +7 -1
- package/ScatterChart/ScatterChart.js +18 -1
- package/ScatterChart/index.d.ts +1 -1
- package/ScatterChart/index.js +8 -8
- package/SparkLineChart/SparkLineChart.js +1 -0
- package/context/InteractionProvider.d.ts +10 -0
- package/context/InteractionProvider.js +21 -1
- package/esm/BarChart/BarElement.js +26 -2
- package/esm/BarChart/index.js +2 -1
- package/esm/ChartsLegend/index.js +2 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
- package/esm/ChartsTooltip/index.js +5 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +168 -0
- package/esm/ChartsVoronoiHandler/index.js +1 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +6 -4
- package/esm/LineChart/extremums.js +25 -8
- package/esm/LineChart/index.js +1 -1
- package/esm/PieChart/PieArc.js +18 -2
- package/esm/PieChart/PieArcLabel.js +7 -11
- package/esm/PieChart/PieArcLabelPlot.js +92 -3
- package/esm/PieChart/PieArcPlot.js +91 -3
- package/esm/PieChart/index.js +3 -1
- package/esm/ScatterChart/Scatter.js +15 -6
- package/esm/ScatterChart/ScatterChart.js +18 -1
- package/esm/ScatterChart/index.js +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +1 -0
- package/esm/context/InteractionProvider.js +21 -1
- package/esm/hooks/useAxisEvents.js +20 -27
- package/esm/hooks/useInteractionItemProps.js +4 -1
- package/esm/index.js +1 -0
- package/esm/internals/defaultizeValueFormatter.js +4 -3
- package/esm/internals/utils.js +11 -0
- package/hooks/useAxisEvents.js +20 -27
- package/hooks/useInteractionItemProps.d.ts +2 -2
- package/hooks/useInteractionItemProps.js +4 -1
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +1 -0
- package/internals/defaultizeValueFormatter.d.ts +3 -1
- package/internals/defaultizeValueFormatter.js +3 -3
- package/internals/utils.d.ts +6 -0
- package/internals/utils.js +12 -0
- package/legacy/BarChart/BarElement.js +26 -2
- package/legacy/BarChart/index.js +2 -1
- package/legacy/ChartsLegend/index.js +2 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
- package/legacy/ChartsTooltip/index.js +5 -1
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +162 -0
- package/legacy/ChartsVoronoiHandler/index.js +1 -0
- package/legacy/ChartsYAxis/ChartsYAxis.js +6 -4
- package/legacy/LineChart/extremums.js +29 -14
- package/legacy/LineChart/index.js +1 -1
- package/legacy/PieChart/PieArc.js +18 -2
- package/legacy/PieChart/PieArcLabel.js +7 -11
- package/legacy/PieChart/PieArcLabelPlot.js +92 -3
- package/legacy/PieChart/PieArcPlot.js +91 -3
- package/legacy/PieChart/index.js +3 -1
- package/legacy/ScatterChart/Scatter.js +18 -7
- package/legacy/ScatterChart/ScatterChart.js +18 -1
- package/legacy/ScatterChart/index.js +1 -1
- package/legacy/SparkLineChart/SparkLineChart.js +1 -0
- package/legacy/context/InteractionProvider.js +21 -1
- package/legacy/hooks/useAxisEvents.js +20 -27
- package/legacy/hooks/useInteractionItemProps.js +6 -1
- package/legacy/index.js +2 -1
- package/legacy/internals/defaultizeValueFormatter.js +4 -3
- package/legacy/internals/utils.js +11 -0
- package/models/seriesType/config.d.ts +5 -1
- package/models/seriesType/scatter.d.ts +6 -1
- package/modern/BarChart/BarElement.js +26 -2
- package/modern/BarChart/index.js +2 -1
- package/modern/ChartsLegend/index.js +2 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
- package/modern/ChartsTooltip/index.js +5 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +166 -0
- package/modern/ChartsVoronoiHandler/index.js +1 -0
- package/modern/ChartsYAxis/ChartsYAxis.js +6 -4
- package/modern/LineChart/extremums.js +25 -8
- package/modern/LineChart/index.js +1 -1
- package/modern/PieChart/PieArc.js +18 -2
- package/modern/PieChart/PieArcLabel.js +7 -11
- package/modern/PieChart/PieArcLabelPlot.js +92 -3
- package/modern/PieChart/PieArcPlot.js +91 -3
- package/modern/PieChart/index.js +3 -1
- package/modern/ScatterChart/Scatter.js +15 -6
- package/modern/ScatterChart/ScatterChart.js +18 -1
- package/modern/ScatterChart/index.js +1 -1
- package/modern/SparkLineChart/SparkLineChart.js +1 -0
- package/modern/context/InteractionProvider.js +21 -1
- package/modern/hooks/useAxisEvents.js +20 -27
- package/modern/hooks/useInteractionItemProps.js +4 -1
- package/modern/index.js +2 -1
- package/modern/internals/defaultizeValueFormatter.js +3 -3
- package/modern/internals/utils.js +11 -0
- package/package.json +6 -4
package/PieChart/PieArcPlot.js
CHANGED
|
@@ -8,8 +8,9 @@ exports.PieArcPlot = PieArcPlot;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
12
|
var _web = require("@react-spring/web");
|
|
12
|
-
var _PieArc =
|
|
13
|
+
var _PieArc = require("./PieArc");
|
|
13
14
|
var _transition = require("./dataTransform/transition");
|
|
14
15
|
var _useTransformData = require("./dataTransform/useTransformData");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -53,7 +54,7 @@ function PieArcPlot(props) {
|
|
|
53
54
|
if (data.length === 0) {
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
56
|
-
const Arc = slots?.pieArc ?? _PieArc.
|
|
57
|
+
const Arc = slots?.pieArc ?? _PieArc.PieArc;
|
|
57
58
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
|
|
58
59
|
children: transition((_ref, item, _, index) => {
|
|
59
60
|
let {
|
|
@@ -89,4 +90,90 @@ function PieArcPlot(props) {
|
|
|
89
90
|
}, slotProps?.pieArc));
|
|
90
91
|
})
|
|
91
92
|
}));
|
|
92
|
-
}
|
|
93
|
+
}
|
|
94
|
+
process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
95
|
+
// ----------------------------- Warning --------------------------------
|
|
96
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
97
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
98
|
+
// ----------------------------------------------------------------------
|
|
99
|
+
/**
|
|
100
|
+
* The radius applied to arc corners (similar to border radius).
|
|
101
|
+
* @default 0
|
|
102
|
+
*/
|
|
103
|
+
cornerRadius: _propTypes.default.number,
|
|
104
|
+
data: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
105
|
+
color: _propTypes.default.string.isRequired,
|
|
106
|
+
endAngle: _propTypes.default.number.isRequired,
|
|
107
|
+
formattedValue: _propTypes.default.string.isRequired,
|
|
108
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
109
|
+
index: _propTypes.default.number.isRequired,
|
|
110
|
+
label: _propTypes.default.string,
|
|
111
|
+
padAngle: _propTypes.default.number.isRequired,
|
|
112
|
+
startAngle: _propTypes.default.number.isRequired,
|
|
113
|
+
value: _propTypes.default.number.isRequired
|
|
114
|
+
})).isRequired,
|
|
115
|
+
/**
|
|
116
|
+
* Override the arc attibutes when it is faded.
|
|
117
|
+
*/
|
|
118
|
+
faded: _propTypes.default.shape({
|
|
119
|
+
additionalRadius: _propTypes.default.number,
|
|
120
|
+
color: _propTypes.default.string,
|
|
121
|
+
cornerRadius: _propTypes.default.number,
|
|
122
|
+
innerRadius: _propTypes.default.number,
|
|
123
|
+
outerRadius: _propTypes.default.number,
|
|
124
|
+
paddingAngle: _propTypes.default.number
|
|
125
|
+
}),
|
|
126
|
+
/**
|
|
127
|
+
* Override the arc attibutes when it is highlighted.
|
|
128
|
+
*/
|
|
129
|
+
highlighted: _propTypes.default.shape({
|
|
130
|
+
additionalRadius: _propTypes.default.number,
|
|
131
|
+
color: _propTypes.default.string,
|
|
132
|
+
cornerRadius: _propTypes.default.number,
|
|
133
|
+
innerRadius: _propTypes.default.number,
|
|
134
|
+
outerRadius: _propTypes.default.number,
|
|
135
|
+
paddingAngle: _propTypes.default.number
|
|
136
|
+
}),
|
|
137
|
+
highlightScope: _propTypes.default.shape({
|
|
138
|
+
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
139
|
+
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
140
|
+
}),
|
|
141
|
+
id: _propTypes.default.string.isRequired,
|
|
142
|
+
/**
|
|
143
|
+
* The radius between circle center and the begining of the arc.
|
|
144
|
+
* @default 0
|
|
145
|
+
*/
|
|
146
|
+
innerRadius: _propTypes.default.number,
|
|
147
|
+
/**
|
|
148
|
+
* Callback fired when a pie item is clicked.
|
|
149
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
150
|
+
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
151
|
+
* @param {DefaultizedPieValueType} item The pie item.
|
|
152
|
+
*/
|
|
153
|
+
onClick: _propTypes.default.func,
|
|
154
|
+
/**
|
|
155
|
+
* The radius between circle center and the end of the arc.
|
|
156
|
+
* @default R_max The maximal radius that fit into the drawing area.
|
|
157
|
+
*/
|
|
158
|
+
outerRadius: _propTypes.default.number.isRequired,
|
|
159
|
+
/**
|
|
160
|
+
* The padding angle (deg) between two arcs.
|
|
161
|
+
* @default 0
|
|
162
|
+
*/
|
|
163
|
+
paddingAngle: _propTypes.default.number,
|
|
164
|
+
/**
|
|
165
|
+
* If `true`, animations are skiped.
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
168
|
+
skipAnimation: _propTypes.default.bool,
|
|
169
|
+
/**
|
|
170
|
+
* The props used for each component slot.
|
|
171
|
+
* @default {}
|
|
172
|
+
*/
|
|
173
|
+
slotProps: _propTypes.default.object,
|
|
174
|
+
/**
|
|
175
|
+
* Overridable component slots.
|
|
176
|
+
* @default {}
|
|
177
|
+
*/
|
|
178
|
+
slots: _propTypes.default.object
|
|
179
|
+
} : void 0;
|
package/PieChart/index.d.ts
CHANGED
package/PieChart/index.js
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _PieChart = require("./PieChart");
|
|
7
|
+
Object.keys(_PieChart).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _PieChart[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _PieChart[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
6
17
|
var _PiePlot = require("./PiePlot");
|
|
7
18
|
Object.keys(_PiePlot).forEach(function (key) {
|
|
8
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -14,14 +25,25 @@ Object.keys(_PiePlot).forEach(function (key) {
|
|
|
14
25
|
}
|
|
15
26
|
});
|
|
16
27
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
28
|
+
var _PieArcPlot = require("./PieArcPlot");
|
|
29
|
+
Object.keys(_PieArcPlot).forEach(function (key) {
|
|
19
30
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
31
|
+
if (key in exports && exports[key] === _PieArcPlot[key]) return;
|
|
21
32
|
Object.defineProperty(exports, key, {
|
|
22
33
|
enumerable: true,
|
|
23
34
|
get: function () {
|
|
24
|
-
return
|
|
35
|
+
return _PieArcPlot[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _PieArcLabelPlot = require("./PieArcLabelPlot");
|
|
40
|
+
Object.keys(_PieArcLabelPlot).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _PieArcLabelPlot[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _PieArcLabelPlot[key];
|
|
25
47
|
}
|
|
26
48
|
});
|
|
27
49
|
});
|
package/README.md
CHANGED
package/ScatterChart/Scatter.js
CHANGED
|
@@ -32,10 +32,16 @@ function Scatter(props) {
|
|
|
32
32
|
color,
|
|
33
33
|
markerSize
|
|
34
34
|
} = props;
|
|
35
|
+
const highlightScope = React.useMemo(() => (0, _extends2.default)({
|
|
36
|
+
highlighted: 'item',
|
|
37
|
+
faded: 'global'
|
|
38
|
+
}, series.highlightScope), [series.highlightScope]);
|
|
35
39
|
const {
|
|
36
|
-
item
|
|
40
|
+
item,
|
|
41
|
+
useVoronoiInteraction
|
|
37
42
|
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
38
|
-
const
|
|
43
|
+
const skipInteractionHandlers = useVoronoiInteraction || series.disableHover;
|
|
44
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope, skipInteractionHandlers);
|
|
39
45
|
const cleanData = React.useMemo(() => {
|
|
40
46
|
const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
41
47
|
const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
|
|
@@ -57,22 +63,24 @@ function Scatter(props) {
|
|
|
57
63
|
dataIndex: i
|
|
58
64
|
};
|
|
59
65
|
if (isInRange) {
|
|
66
|
+
const isHighlighted = (0, _useInteractionItemProps.getIsHighlighted)(item, pointCtx, highlightScope);
|
|
60
67
|
temp.push({
|
|
61
68
|
x,
|
|
62
69
|
y,
|
|
63
|
-
|
|
70
|
+
isHighlighted,
|
|
71
|
+
isFaded: !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, pointCtx, highlightScope),
|
|
64
72
|
interactionProps: getInteractionItemProps(pointCtx),
|
|
65
73
|
id: scatterPoint.id
|
|
66
74
|
});
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
return temp;
|
|
70
|
-
}, [
|
|
78
|
+
}, [xScale, yScale, series.data, series.id, item, highlightScope, getInteractionItemProps]);
|
|
71
79
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
72
80
|
children: cleanData.map(dataPoint => /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({
|
|
73
81
|
cx: 0,
|
|
74
82
|
cy: 0,
|
|
75
|
-
r: markerSize,
|
|
83
|
+
r: (dataPoint.isHighlighted ? 1.2 : 1) * markerSize,
|
|
76
84
|
transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
|
|
77
85
|
fill: color,
|
|
78
86
|
opacity: dataPoint.isFaded && 0.3 || 1
|
|
@@ -87,12 +95,13 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
|
|
|
87
95
|
color: _propTypes.default.string.isRequired,
|
|
88
96
|
markerSize: _propTypes.default.number.isRequired,
|
|
89
97
|
series: _propTypes.default.shape({
|
|
90
|
-
color: _propTypes.default.string,
|
|
98
|
+
color: _propTypes.default.string.isRequired,
|
|
91
99
|
data: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
92
100
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
93
101
|
x: _propTypes.default.number.isRequired,
|
|
94
102
|
y: _propTypes.default.number.isRequired
|
|
95
103
|
})).isRequired,
|
|
104
|
+
disableHover: _propTypes.default.bool,
|
|
96
105
|
highlightScope: _propTypes.default.shape({
|
|
97
106
|
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
98
107
|
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
@@ -8,14 +8,20 @@ import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '
|
|
|
8
8
|
import { ChartsLegendProps, ChartsLegendSlotProps, ChartsLegendSlots } from '../ChartsLegend';
|
|
9
9
|
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
10
10
|
import { ChartsAxisSlots, ChartsAxisSlotProps } from '../models/axis';
|
|
11
|
+
import { ChartsVoronoiHandlerProps } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
11
12
|
export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsTooltipSlots {
|
|
12
13
|
}
|
|
13
14
|
export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps {
|
|
14
15
|
}
|
|
15
|
-
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'
|
|
16
|
+
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, ChartsVoronoiHandlerProps {
|
|
16
17
|
series: MakeOptional<ScatterSeriesType, 'type'>[];
|
|
17
18
|
tooltip?: ChartsTooltipProps;
|
|
18
19
|
axisHighlight?: ChartsAxisHighlightProps;
|
|
20
|
+
/**
|
|
21
|
+
* If true, the interaction will not use the Voronoi cell and fall back to hover events.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
disableVoronoi?: boolean;
|
|
19
25
|
/**
|
|
20
26
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
21
27
|
*/
|
|
@@ -14,6 +14,7 @@ var _ChartsAxis = require("../ChartsAxis");
|
|
|
14
14
|
var _ChartsTooltip = require("../ChartsTooltip");
|
|
15
15
|
var _ChartsLegend = require("../ChartsLegend");
|
|
16
16
|
var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
|
|
17
|
+
var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler");
|
|
17
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
19
|
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); }
|
|
19
20
|
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 && Object.prototype.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,6 +35,8 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
34
35
|
series,
|
|
35
36
|
tooltip,
|
|
36
37
|
axisHighlight,
|
|
38
|
+
voronoiMaxRadius,
|
|
39
|
+
disableVoronoi,
|
|
37
40
|
legend,
|
|
38
41
|
width,
|
|
39
42
|
height,
|
|
@@ -60,7 +63,9 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
60
63
|
xAxis: xAxis,
|
|
61
64
|
yAxis: yAxis,
|
|
62
65
|
sx: sx,
|
|
63
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
66
|
+
children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, {
|
|
67
|
+
voronoiMaxRadius: voronoiMaxRadius
|
|
68
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
|
|
64
69
|
topAxis: topAxis,
|
|
65
70
|
leftAxis: leftAxis,
|
|
66
71
|
rightAxis: rightAxis,
|
|
@@ -134,6 +139,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
134
139
|
* @default false
|
|
135
140
|
*/
|
|
136
141
|
disableAxisListener: _propTypes.default.bool,
|
|
142
|
+
/**
|
|
143
|
+
* If true, the interaction will not use the Voronoi cell and fall back to hover events.
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
disableVoronoi: _propTypes.default.bool,
|
|
137
147
|
/**
|
|
138
148
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
139
149
|
* @default undefined
|
|
@@ -226,6 +236,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
226
236
|
x: _propTypes.default.number.isRequired,
|
|
227
237
|
y: _propTypes.default.number.isRequired
|
|
228
238
|
})).isRequired,
|
|
239
|
+
disableHover: _propTypes.default.bool,
|
|
229
240
|
highlightScope: _propTypes.default.shape({
|
|
230
241
|
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
231
242
|
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
@@ -291,6 +302,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
291
302
|
x: _propTypes.default.number,
|
|
292
303
|
y: _propTypes.default.number
|
|
293
304
|
}),
|
|
305
|
+
/**
|
|
306
|
+
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
307
|
+
* If `undefined`, the radius is assumed to be infinite.
|
|
308
|
+
* @default undefined
|
|
309
|
+
*/
|
|
310
|
+
voronoiMaxRadius: _propTypes.default.number,
|
|
294
311
|
/**
|
|
295
312
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
296
313
|
* @default undefined
|
package/ScatterChart/index.d.ts
CHANGED
package/ScatterChart/index.js
CHANGED
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _ScatterChart = require("./ScatterChart");
|
|
7
|
+
Object.keys(_ScatterChart).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _ScatterChart[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _ScatterChart[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
17
|
+
var _ScatterPlot = require("./ScatterPlot");
|
|
18
|
+
Object.keys(_ScatterPlot).forEach(function (key) {
|
|
19
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
20
|
+
if (key in exports && exports[key] === _ScatterPlot[key]) return;
|
|
21
21
|
Object.defineProperty(exports, key, {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
get: function () {
|
|
24
|
-
return
|
|
24
|
+
return _ScatterPlot[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
@@ -86,6 +86,7 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
86
86
|
sx: sx,
|
|
87
87
|
disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
88
88
|
children: [plotType === 'bar' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarChart.BarPlot, {
|
|
89
|
+
skipAnimation: true,
|
|
89
90
|
slots: slots,
|
|
90
91
|
slotProps: slotProps,
|
|
91
92
|
sx: {
|
|
@@ -20,6 +20,11 @@ type InteractionActions<T extends ChartSeriesType = ChartSeriesType> = {
|
|
|
20
20
|
} | {
|
|
21
21
|
type: 'leaveItem';
|
|
22
22
|
data: ItemInteractionData<T>;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'exitChart';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'updateVoronoiUsage';
|
|
27
|
+
useVoronoiInteraction: boolean;
|
|
23
28
|
} | {
|
|
24
29
|
type: 'updateAxis';
|
|
25
30
|
data: AxisInteractionData;
|
|
@@ -33,6 +38,11 @@ type InteractionState = {
|
|
|
33
38
|
* The x- and y-axes currently interacting.
|
|
34
39
|
*/
|
|
35
40
|
axis: AxisInteractionData;
|
|
41
|
+
/**
|
|
42
|
+
* Set to `true` when `VoronoiHandler` is active.
|
|
43
|
+
* Used to prevent collision with mouseEnter events.
|
|
44
|
+
*/
|
|
45
|
+
useVoronoiInteraction: boolean;
|
|
36
46
|
dispatch: React.Dispatch<InteractionActions>;
|
|
37
47
|
};
|
|
38
48
|
export declare const InteractionContext: React.Context<InteractionState>;
|
|
@@ -17,6 +17,7 @@ const InteractionContext = exports.InteractionContext = /*#__PURE__*/React.creat
|
|
|
17
17
|
x: null,
|
|
18
18
|
y: null
|
|
19
19
|
},
|
|
20
|
+
useVoronoiInteraction: false,
|
|
20
21
|
dispatch: () => null
|
|
21
22
|
});
|
|
22
23
|
const dataReducer = (prevState, action) => {
|
|
@@ -25,6 +26,21 @@ const dataReducer = (prevState, action) => {
|
|
|
25
26
|
return (0, _extends2.default)({}, prevState, {
|
|
26
27
|
item: action.data
|
|
27
28
|
});
|
|
29
|
+
case 'exitChart':
|
|
30
|
+
if (prevState.item === null && prevState.axis.x === null && prevState.axis.y === null) {
|
|
31
|
+
return prevState;
|
|
32
|
+
}
|
|
33
|
+
return (0, _extends2.default)({}, prevState, {
|
|
34
|
+
axis: {
|
|
35
|
+
x: null,
|
|
36
|
+
y: null
|
|
37
|
+
},
|
|
38
|
+
item: null
|
|
39
|
+
});
|
|
40
|
+
case 'updateVoronoiUsage':
|
|
41
|
+
return (0, _extends2.default)({}, prevState, {
|
|
42
|
+
useVoronoiInteraction: action.useVoronoiInteraction
|
|
43
|
+
});
|
|
28
44
|
case 'leaveItem':
|
|
29
45
|
if (prevState.item === null || Object.keys(action.data).some(key => action.data[key] !== prevState.item[key])) {
|
|
30
46
|
// The item is already something else
|
|
@@ -34,6 +50,9 @@ const dataReducer = (prevState, action) => {
|
|
|
34
50
|
item: null
|
|
35
51
|
});
|
|
36
52
|
case 'updateAxis':
|
|
53
|
+
if (action.data.x === prevState.axis.x && action.data.y === prevState.axis.y) {
|
|
54
|
+
return prevState;
|
|
55
|
+
}
|
|
37
56
|
return (0, _extends2.default)({}, prevState, {
|
|
38
57
|
axis: action.data
|
|
39
58
|
});
|
|
@@ -49,7 +68,8 @@ function InteractionProvider({
|
|
|
49
68
|
axis: {
|
|
50
69
|
x: null,
|
|
51
70
|
y: null
|
|
52
|
-
}
|
|
71
|
+
},
|
|
72
|
+
useVoronoiInteraction: false
|
|
53
73
|
});
|
|
54
74
|
const value = React.useMemo(() => (0, _extends2.default)({}, data, {
|
|
55
75
|
dispatch
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
7
|
import { useSlotProps } from '@mui/base/utils';
|
|
7
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
@@ -39,7 +40,7 @@ export const BarElementPath = styled(animated.rect, {
|
|
|
39
40
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
40
41
|
opacity: ownerState.isFaded && 0.3 || 1
|
|
41
42
|
}));
|
|
42
|
-
|
|
43
|
+
function BarElement(props) {
|
|
43
44
|
var _slots$bar;
|
|
44
45
|
const {
|
|
45
46
|
id,
|
|
@@ -90,4 +91,27 @@ export function BarElement(props) {
|
|
|
90
91
|
ownerState
|
|
91
92
|
});
|
|
92
93
|
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
93
|
-
}
|
|
94
|
+
}
|
|
95
|
+
process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
|
|
96
|
+
// ----------------------------- Warning --------------------------------
|
|
97
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
98
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
99
|
+
// ----------------------------------------------------------------------
|
|
100
|
+
classes: PropTypes.object,
|
|
101
|
+
dataIndex: PropTypes.number.isRequired,
|
|
102
|
+
highlightScope: PropTypes.shape({
|
|
103
|
+
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
104
|
+
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
105
|
+
}),
|
|
106
|
+
/**
|
|
107
|
+
* The props used for each component slot.
|
|
108
|
+
* @default {}
|
|
109
|
+
*/
|
|
110
|
+
slotProps: PropTypes.object,
|
|
111
|
+
/**
|
|
112
|
+
* Overridable component slots.
|
|
113
|
+
* @default {}
|
|
114
|
+
*/
|
|
115
|
+
slots: PropTypes.object
|
|
116
|
+
} : void 0;
|
|
117
|
+
export { BarElement };
|
package/esm/BarChart/index.js
CHANGED