@mui/x-charts 6.0.0-alpha.12 → 6.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +3 -3
- package/BarChart/BarChart.js +3 -2
- package/BarChart/BarElement.js +2 -4
- package/BarChart/formatter.js +1 -2
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +144 -0
- package/ChartContainer/index.js +2 -3
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsLegend/ChartsLegend.js +4 -8
- package/ChartsLegend/chartsLegendClasses.js +1 -2
- package/ChartsSurface.js +2 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +16 -6
- package/ChartsTooltip/ChartsTooltip.d.ts +23 -0
- package/ChartsTooltip/ChartsTooltip.js +47 -13
- package/ChartsTooltip/ChartsTooltipTable.js +6 -11
- package/ChartsTooltip/tooltipClasses.js +1 -2
- package/LineChart/AreaElement.js +2 -4
- package/LineChart/LineChart.d.ts +3 -3
- package/LineChart/LineChart.js +7 -3
- package/LineChart/LineElement.js +2 -4
- package/LineChart/LineHighlightElement.js +1 -2
- package/LineChart/MarkElement.js +1 -2
- package/LineChart/formatter.js +1 -2
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +1 -0
- package/PieChart/PieArc.js +6 -4
- package/PieChart/PieArcLabel.js +1 -2
- package/PieChart/PieChart.d.ts +5 -4
- package/PieChart/PieChart.js +7 -2
- package/PieChart/PiePlot.d.ts +8 -0
- package/PieChart/PiePlot.js +21 -5
- package/PieChart/formatter.js +1 -2
- package/PieChart/legend.js +1 -2
- package/ResponsiveChartContainer/index.js +2 -3
- package/ScatterChart/ScatterChart.d.ts +3 -3
- package/ScatterChart/ScatterChart.js +3 -2
- package/ScatterChart/formatter.js +1 -2
- package/ScatterChart/legend.js +1 -2
- package/SparkLineChart/SparkLineChart.d.ts +3 -3
- package/SparkLineChart/SparkLineChart.js +7 -3
- package/colorPalettes/colorPalettes.js +6 -12
- package/constants.js +4 -7
- package/context/CartesianContextProvider.js +1 -2
- package/context/DrawingProvider.js +2 -4
- package/context/HighlightProvider.js +1 -2
- package/context/InteractionProvider.js +1 -2
- package/context/SeriesContextProvider.js +1 -2
- package/esm/BarChart/BarChart.js +2 -0
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/esm/ChartsTooltip/ChartsTooltip.js +47 -12
- package/esm/LineChart/LineChart.js +6 -1
- package/esm/PieChart/PieArc.js +5 -2
- package/esm/PieChart/PieChart.js +7 -2
- package/esm/PieChart/PiePlot.js +17 -2
- package/esm/ScatterChart/ScatterChart.js +2 -0
- package/esm/SparkLineChart/SparkLineChart.js +6 -1
- package/hooks/useChartDimensions.js +1 -2
- package/hooks/useTicks.js +1 -2
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.js +6 -11
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/stackSeries.js +2 -4
- package/legacy/BarChart/BarChart.js +2 -0
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/legacy/ChartsTooltip/ChartsTooltip.js +50 -12
- package/legacy/LineChart/LineChart.js +6 -1
- package/legacy/PieChart/PieArc.js +4 -1
- package/legacy/PieChart/PieChart.js +7 -2
- package/legacy/PieChart/PiePlot.js +17 -2
- package/legacy/ScatterChart/ScatterChart.js +2 -0
- package/legacy/SparkLineChart/SparkLineChart.js +6 -1
- package/legacy/index.js +1 -1
- package/modern/BarChart/BarChart.js +2 -0
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/modern/ChartsTooltip/ChartsTooltip.js +46 -12
- package/modern/LineChart/LineChart.js +6 -1
- package/modern/PieChart/PieArc.js +5 -2
- package/modern/PieChart/PieChart.js +7 -2
- package/modern/PieChart/PiePlot.js +17 -2
- package/modern/ScatterChart/ScatterChart.js +2 -0
- package/modern/SparkLineChart/SparkLineChart.js +6 -1
- package/modern/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
4
6
|
import { Popper } from '@mui/base/Popper';
|
|
5
7
|
import { NoSsr } from '@mui/base/NoSsr';
|
|
8
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
9
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
7
10
|
import { generateVirtualElement, useMouseTracker, getTootipHasData } from './utils';
|
|
8
11
|
import { ChartsItemTooltipContent } from './ChartsItemTooltipContent';
|
|
@@ -19,11 +22,27 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
19
22
|
};
|
|
20
23
|
return composeClasses(slots, getTooltipUtilityClass, classes);
|
|
21
24
|
};
|
|
25
|
+
var ChartsTooltipRoot = styled(Popper, {
|
|
26
|
+
name: 'MuiChartsTooltip',
|
|
27
|
+
slot: 'Root',
|
|
28
|
+
overridesResolver: function overridesResolver(_, styles) {
|
|
29
|
+
return styles.root;
|
|
30
|
+
}
|
|
31
|
+
})(function (_ref) {
|
|
32
|
+
var theme = _ref.theme;
|
|
33
|
+
return {
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
zIndex: theme.zIndex.modal
|
|
36
|
+
};
|
|
37
|
+
});
|
|
22
38
|
function ChartsTooltip(props) {
|
|
39
|
+
var _slots$popper, _slots$itemContent, _slots$axisContent;
|
|
23
40
|
var _props$trigger = props.trigger,
|
|
24
41
|
trigger = _props$trigger === void 0 ? 'axis' : _props$trigger,
|
|
25
42
|
itemContent = props.itemContent,
|
|
26
|
-
axisContent = props.axisContent
|
|
43
|
+
axisContent = props.axisContent,
|
|
44
|
+
slots = props.slots,
|
|
45
|
+
slotProps = props.slotProps;
|
|
27
46
|
var mousePosition = useMouseTracker();
|
|
28
47
|
var _React$useContext = React.useContext(InteractionContext),
|
|
29
48
|
item = _React$useContext.item,
|
|
@@ -34,33 +53,40 @@ function ChartsTooltip(props) {
|
|
|
34
53
|
var classes = useUtilityClasses({
|
|
35
54
|
classes: props.classes
|
|
36
55
|
});
|
|
56
|
+
var PopperComponent = (_slots$popper = slots == null ? void 0 : slots.popper) != null ? _slots$popper : ChartsTooltipRoot;
|
|
57
|
+
var popperProps = useSlotProps({
|
|
58
|
+
elementType: PopperComponent,
|
|
59
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.popper,
|
|
60
|
+
additionalProps: {
|
|
61
|
+
open: popperOpen,
|
|
62
|
+
placement: 'right-start',
|
|
63
|
+
anchorEl: generateVirtualElement(mousePosition)
|
|
64
|
+
},
|
|
65
|
+
ownerState: {}
|
|
66
|
+
});
|
|
37
67
|
if (trigger === 'none') {
|
|
38
68
|
return null;
|
|
39
69
|
}
|
|
40
70
|
return /*#__PURE__*/_jsx(NoSsr, {
|
|
41
|
-
children: popperOpen && /*#__PURE__*/_jsx(
|
|
42
|
-
open: popperOpen,
|
|
43
|
-
placement: "right-start",
|
|
44
|
-
anchorEl: generateVirtualElement(mousePosition),
|
|
45
|
-
style: {
|
|
46
|
-
pointerEvents: 'none'
|
|
47
|
-
},
|
|
71
|
+
children: popperOpen && /*#__PURE__*/_jsx(PopperComponent, _extends({}, popperProps, {
|
|
48
72
|
children: trigger === 'item' ? /*#__PURE__*/_jsx(ChartsItemTooltipContent, {
|
|
49
73
|
itemData: displayedData,
|
|
50
|
-
content: itemContent,
|
|
74
|
+
content: (_slots$itemContent = slots == null ? void 0 : slots.itemContent) != null ? _slots$itemContent : itemContent,
|
|
75
|
+
contentProps: slotProps == null ? void 0 : slotProps.itemContent,
|
|
51
76
|
sx: {
|
|
52
77
|
mx: 2
|
|
53
78
|
},
|
|
54
79
|
classes: classes
|
|
55
80
|
}) : /*#__PURE__*/_jsx(ChartsAxisTooltipContent, {
|
|
56
81
|
axisData: displayedData,
|
|
57
|
-
content: axisContent,
|
|
82
|
+
content: (_slots$axisContent = slots == null ? void 0 : slots.axisContent) != null ? _slots$axisContent : axisContent,
|
|
83
|
+
contentProps: slotProps == null ? void 0 : slotProps.axisContent,
|
|
58
84
|
sx: {
|
|
59
85
|
mx: 2
|
|
60
86
|
},
|
|
61
87
|
classes: classes
|
|
62
88
|
})
|
|
63
|
-
})
|
|
89
|
+
}))
|
|
64
90
|
});
|
|
65
91
|
}
|
|
66
92
|
process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
@@ -70,6 +96,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
70
96
|
// ----------------------------------------------------------------------
|
|
71
97
|
/**
|
|
72
98
|
* Component to override the tooltip content when triger is set to 'axis'.
|
|
99
|
+
* @deprecated Use slots.axisContent instead
|
|
73
100
|
*/
|
|
74
101
|
axisContent: PropTypes.elementType,
|
|
75
102
|
/**
|
|
@@ -78,8 +105,19 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
78
105
|
classes: PropTypes.object,
|
|
79
106
|
/**
|
|
80
107
|
* Component to override the tooltip content when triger is set to 'item'.
|
|
108
|
+
* @deprecated Use slots.itemContent instead
|
|
81
109
|
*/
|
|
82
110
|
itemContent: PropTypes.elementType,
|
|
111
|
+
/**
|
|
112
|
+
* The props used for each component slot.
|
|
113
|
+
* @default {}
|
|
114
|
+
*/
|
|
115
|
+
slotProps: PropTypes.object,
|
|
116
|
+
/**
|
|
117
|
+
* Overridable component slots.
|
|
118
|
+
* @default {}
|
|
119
|
+
*/
|
|
120
|
+
slots: PropTypes.object,
|
|
83
121
|
/**
|
|
84
122
|
* Select the kind of tooltip to display
|
|
85
123
|
* - 'item': Shows data about the item below the mouse.
|
|
@@ -95,7 +95,10 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
95
95
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
96
96
|
slots: slots,
|
|
97
97
|
slotProps: slotProps
|
|
98
|
-
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
98
|
+
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
99
|
+
slots: slots,
|
|
100
|
+
slotProps: slotProps
|
|
101
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
99
102
|
id: clipPathId
|
|
100
103
|
}), children]
|
|
101
104
|
});
|
|
@@ -254,6 +257,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
254
257
|
axisContent: PropTypes.elementType,
|
|
255
258
|
classes: PropTypes.object,
|
|
256
259
|
itemContent: PropTypes.elementType,
|
|
260
|
+
slotProps: PropTypes.object,
|
|
261
|
+
slots: PropTypes.object,
|
|
257
262
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
258
263
|
}),
|
|
259
264
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded"];
|
|
3
|
+
var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { arc as d3Arc } from 'd3-shape';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -59,6 +59,7 @@ export default function PieArc(props) {
|
|
|
59
59
|
faded = _props$faded === void 0 ? {
|
|
60
60
|
additionalRadius: -5
|
|
61
61
|
} : _props$faded,
|
|
62
|
+
onClick = props.onClick,
|
|
62
63
|
other = _objectWithoutProperties(props, _excluded);
|
|
63
64
|
var getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
64
65
|
var _React$useContext = React.useContext(InteractionContext),
|
|
@@ -93,6 +94,8 @@ export default function PieArc(props) {
|
|
|
93
94
|
innerRadius: innerRadius,
|
|
94
95
|
outerRadius: outerRadius
|
|
95
96
|
})),
|
|
97
|
+
onClick: onClick,
|
|
98
|
+
cursor: onClick ? 'pointer' : 'unset',
|
|
96
99
|
ownerState: ownerState,
|
|
97
100
|
className: classes.root
|
|
98
101
|
}, getInteractionItemProps({
|
|
@@ -53,7 +53,8 @@ function PieChart(props) {
|
|
|
53
53
|
bottomAxis = _props$bottomAxis === void 0 ? null : _props$bottomAxis,
|
|
54
54
|
children = props.children,
|
|
55
55
|
slots = props.slots,
|
|
56
|
-
slotProps = props.slotProps
|
|
56
|
+
slotProps = props.slotProps,
|
|
57
|
+
onClick = props.onClick;
|
|
57
58
|
var margin = _extends({}, defaultMargin, marginProps);
|
|
58
59
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
59
60
|
series: series.map(function (s) {
|
|
@@ -86,7 +87,8 @@ function PieChart(props) {
|
|
|
86
87
|
slotProps: slotProps
|
|
87
88
|
}), /*#__PURE__*/_jsx(PiePlot, {
|
|
88
89
|
slots: slots,
|
|
89
|
-
slotProps: slotProps
|
|
90
|
+
slotProps: slotProps,
|
|
91
|
+
onClick: onClick
|
|
90
92
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
91
93
|
slots: slots,
|
|
92
94
|
slotProps: slotProps
|
|
@@ -182,6 +184,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
182
184
|
right: PropTypes.number,
|
|
183
185
|
top: PropTypes.number
|
|
184
186
|
}),
|
|
187
|
+
onClick: PropTypes.func,
|
|
185
188
|
/**
|
|
186
189
|
* Indicate which axis to display the right of the charts.
|
|
187
190
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -256,6 +259,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
256
259
|
axisContent: PropTypes.elementType,
|
|
257
260
|
classes: PropTypes.object,
|
|
258
261
|
itemContent: PropTypes.elementType,
|
|
262
|
+
slotProps: PropTypes.object,
|
|
263
|
+
slots: PropTypes.object,
|
|
259
264
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
260
265
|
}),
|
|
261
266
|
/**
|
|
@@ -26,7 +26,8 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
26
26
|
function PiePlot(props) {
|
|
27
27
|
var _slots$pieArc, _slots$pieArcLabel;
|
|
28
28
|
var slots = props.slots,
|
|
29
|
-
slotProps = props.slotProps
|
|
29
|
+
slotProps = props.slotProps,
|
|
30
|
+
onClick = props.onClick;
|
|
30
31
|
var seriesData = React.useContext(SeriesContext).pie;
|
|
31
32
|
var _React$useContext = React.useContext(DrawingContext),
|
|
32
33
|
left = _React$useContext.left,
|
|
@@ -73,7 +74,14 @@ function PiePlot(props) {
|
|
|
73
74
|
dataIndex: index,
|
|
74
75
|
highlightScope: series[seriesId].highlightScope,
|
|
75
76
|
highlighted: highlighted,
|
|
76
|
-
faded: faded
|
|
77
|
+
faded: faded,
|
|
78
|
+
onClick: onClick && function (event) {
|
|
79
|
+
onClick(event, {
|
|
80
|
+
type: 'pie',
|
|
81
|
+
seriesId: seriesId,
|
|
82
|
+
dataIndex: index
|
|
83
|
+
}, item);
|
|
84
|
+
}
|
|
77
85
|
}, slotProps == null ? void 0 : slotProps.pieArc));
|
|
78
86
|
}), data.map(function (item, index) {
|
|
79
87
|
return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
|
|
@@ -98,6 +106,13 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
|
98
106
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
99
107
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
100
108
|
// ----------------------------------------------------------------------
|
|
109
|
+
/**
|
|
110
|
+
* Callback fired when a pie item is clicked.
|
|
111
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
112
|
+
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
113
|
+
* @param {DefaultizedPieValueType} item The pie item.
|
|
114
|
+
*/
|
|
115
|
+
onClick: PropTypes.func,
|
|
101
116
|
/**
|
|
102
117
|
* The props used for each component slot.
|
|
103
118
|
* @default {}
|
|
@@ -210,6 +210,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
210
210
|
axisContent: PropTypes.elementType,
|
|
211
211
|
classes: PropTypes.object,
|
|
212
212
|
itemContent: PropTypes.elementType,
|
|
213
|
+
slotProps: PropTypes.object,
|
|
214
|
+
slots: PropTypes.object,
|
|
213
215
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
214
216
|
}),
|
|
215
217
|
/**
|
|
@@ -90,7 +90,10 @@ var SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props
|
|
|
90
90
|
slots: slots,
|
|
91
91
|
slotProps: slotProps
|
|
92
92
|
})]
|
|
93
|
-
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
93
|
+
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
94
|
+
slotProps: slotProps,
|
|
95
|
+
slots: slots
|
|
96
|
+
})), children]
|
|
94
97
|
});
|
|
95
98
|
});
|
|
96
99
|
process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
@@ -165,6 +168,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
165
168
|
axisContent: PropTypes.elementType,
|
|
166
169
|
classes: PropTypes.object,
|
|
167
170
|
itemContent: PropTypes.elementType,
|
|
171
|
+
slotProps: PropTypes.object,
|
|
172
|
+
slots: PropTypes.object,
|
|
168
173
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
169
174
|
}),
|
|
170
175
|
/**
|
package/legacy/index.js
CHANGED
|
@@ -241,6 +241,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
241
241
|
axisContent: PropTypes.elementType,
|
|
242
242
|
classes: PropTypes.object,
|
|
243
243
|
itemContent: PropTypes.elementType,
|
|
244
|
+
slotProps: PropTypes.object,
|
|
245
|
+
slots: PropTypes.object,
|
|
244
246
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
245
247
|
}),
|
|
246
248
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import Typography from '@mui/material/Typography';
|
|
4
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
3
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
4
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
5
7
|
import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
@@ -66,6 +68,7 @@ export function DefaultChartsAxisContent(props) {
|
|
|
66
68
|
export function ChartsAxisTooltipContent(props) {
|
|
67
69
|
const {
|
|
68
70
|
content,
|
|
71
|
+
contentProps,
|
|
69
72
|
axisData,
|
|
70
73
|
sx,
|
|
71
74
|
classes
|
|
@@ -98,13 +101,19 @@ export function ChartsAxisTooltipContent(props) {
|
|
|
98
101
|
return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
99
102
|
}, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
|
|
100
103
|
const Content = content ?? DefaultChartsAxisContent;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const chartTooltipContentProps = useSlotProps({
|
|
105
|
+
elementType: Content,
|
|
106
|
+
externalSlotProps: contentProps,
|
|
107
|
+
additionalProps: {
|
|
108
|
+
axisData,
|
|
109
|
+
series: relevantSeries,
|
|
110
|
+
axis: relevantAxis,
|
|
111
|
+
dataIndex,
|
|
112
|
+
axisValue,
|
|
113
|
+
sx,
|
|
114
|
+
classes
|
|
115
|
+
},
|
|
116
|
+
ownerState: {}
|
|
109
117
|
});
|
|
118
|
+
return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
|
|
110
119
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
3
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
2
4
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
3
5
|
import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
4
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -57,14 +59,21 @@ export function ChartsItemTooltipContent(props) {
|
|
|
57
59
|
content,
|
|
58
60
|
itemData,
|
|
59
61
|
sx,
|
|
60
|
-
classes
|
|
62
|
+
classes,
|
|
63
|
+
contentProps
|
|
61
64
|
} = props;
|
|
62
65
|
const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
|
|
63
66
|
const Content = content ?? DefaultChartsItemContent;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const chartTooltipContentProps = useSlotProps({
|
|
68
|
+
elementType: Content,
|
|
69
|
+
externalSlotProps: contentProps,
|
|
70
|
+
additionalProps: {
|
|
71
|
+
itemData,
|
|
72
|
+
series,
|
|
73
|
+
sx,
|
|
74
|
+
classes
|
|
75
|
+
},
|
|
76
|
+
ownerState: {}
|
|
69
77
|
});
|
|
78
|
+
return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
|
|
70
79
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
4
6
|
import { Popper } from '@mui/base/Popper';
|
|
5
7
|
import { NoSsr } from '@mui/base/NoSsr';
|
|
8
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
9
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
7
10
|
import { generateVirtualElement, useMouseTracker, getTootipHasData } from './utils';
|
|
8
11
|
import { ChartsItemTooltipContent } from './ChartsItemTooltipContent';
|
|
@@ -21,11 +24,23 @@ const useUtilityClasses = ownerState => {
|
|
|
21
24
|
};
|
|
22
25
|
return composeClasses(slots, getTooltipUtilityClass, classes);
|
|
23
26
|
};
|
|
27
|
+
const ChartsTooltipRoot = styled(Popper, {
|
|
28
|
+
name: 'MuiChartsTooltip',
|
|
29
|
+
slot: 'Root',
|
|
30
|
+
overridesResolver: (_, styles) => styles.root
|
|
31
|
+
})(({
|
|
32
|
+
theme
|
|
33
|
+
}) => ({
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
zIndex: theme.zIndex.modal
|
|
36
|
+
}));
|
|
24
37
|
function ChartsTooltip(props) {
|
|
25
38
|
const {
|
|
26
39
|
trigger = 'axis',
|
|
27
40
|
itemContent,
|
|
28
|
-
axisContent
|
|
41
|
+
axisContent,
|
|
42
|
+
slots,
|
|
43
|
+
slotProps
|
|
29
44
|
} = props;
|
|
30
45
|
const mousePosition = useMouseTracker();
|
|
31
46
|
const {
|
|
@@ -38,33 +53,40 @@ function ChartsTooltip(props) {
|
|
|
38
53
|
const classes = useUtilityClasses({
|
|
39
54
|
classes: props.classes
|
|
40
55
|
});
|
|
56
|
+
const PopperComponent = slots?.popper ?? ChartsTooltipRoot;
|
|
57
|
+
const popperProps = useSlotProps({
|
|
58
|
+
elementType: PopperComponent,
|
|
59
|
+
externalSlotProps: slotProps?.popper,
|
|
60
|
+
additionalProps: {
|
|
61
|
+
open: popperOpen,
|
|
62
|
+
placement: 'right-start',
|
|
63
|
+
anchorEl: generateVirtualElement(mousePosition)
|
|
64
|
+
},
|
|
65
|
+
ownerState: {}
|
|
66
|
+
});
|
|
41
67
|
if (trigger === 'none') {
|
|
42
68
|
return null;
|
|
43
69
|
}
|
|
44
70
|
return /*#__PURE__*/_jsx(NoSsr, {
|
|
45
|
-
children: popperOpen && /*#__PURE__*/_jsx(
|
|
46
|
-
open: popperOpen,
|
|
47
|
-
placement: "right-start",
|
|
48
|
-
anchorEl: generateVirtualElement(mousePosition),
|
|
49
|
-
style: {
|
|
50
|
-
pointerEvents: 'none'
|
|
51
|
-
},
|
|
71
|
+
children: popperOpen && /*#__PURE__*/_jsx(PopperComponent, _extends({}, popperProps, {
|
|
52
72
|
children: trigger === 'item' ? /*#__PURE__*/_jsx(ChartsItemTooltipContent, {
|
|
53
73
|
itemData: displayedData,
|
|
54
|
-
content: itemContent,
|
|
74
|
+
content: slots?.itemContent ?? itemContent,
|
|
75
|
+
contentProps: slotProps?.itemContent,
|
|
55
76
|
sx: {
|
|
56
77
|
mx: 2
|
|
57
78
|
},
|
|
58
79
|
classes: classes
|
|
59
80
|
}) : /*#__PURE__*/_jsx(ChartsAxisTooltipContent, {
|
|
60
81
|
axisData: displayedData,
|
|
61
|
-
content: axisContent,
|
|
82
|
+
content: slots?.axisContent ?? axisContent,
|
|
83
|
+
contentProps: slotProps?.axisContent,
|
|
62
84
|
sx: {
|
|
63
85
|
mx: 2
|
|
64
86
|
},
|
|
65
87
|
classes: classes
|
|
66
88
|
})
|
|
67
|
-
})
|
|
89
|
+
}))
|
|
68
90
|
});
|
|
69
91
|
}
|
|
70
92
|
process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
@@ -74,6 +96,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
74
96
|
// ----------------------------------------------------------------------
|
|
75
97
|
/**
|
|
76
98
|
* Component to override the tooltip content when triger is set to 'axis'.
|
|
99
|
+
* @deprecated Use slots.axisContent instead
|
|
77
100
|
*/
|
|
78
101
|
axisContent: PropTypes.elementType,
|
|
79
102
|
/**
|
|
@@ -82,8 +105,19 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
82
105
|
classes: PropTypes.object,
|
|
83
106
|
/**
|
|
84
107
|
* Component to override the tooltip content when triger is set to 'item'.
|
|
108
|
+
* @deprecated Use slots.itemContent instead
|
|
85
109
|
*/
|
|
86
110
|
itemContent: PropTypes.elementType,
|
|
111
|
+
/**
|
|
112
|
+
* The props used for each component slot.
|
|
113
|
+
* @default {}
|
|
114
|
+
*/
|
|
115
|
+
slotProps: PropTypes.object,
|
|
116
|
+
/**
|
|
117
|
+
* Overridable component slots.
|
|
118
|
+
* @default {}
|
|
119
|
+
*/
|
|
120
|
+
slots: PropTypes.object,
|
|
87
121
|
/**
|
|
88
122
|
* Select the kind of tooltip to display
|
|
89
123
|
* - 'item': Shows data about the item below the mouse.
|
|
@@ -88,7 +88,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
88
88
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
89
89
|
slots: slots,
|
|
90
90
|
slotProps: slotProps
|
|
91
|
-
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
91
|
+
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
92
|
+
slots: slots,
|
|
93
|
+
slotProps: slotProps
|
|
94
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
92
95
|
id: clipPathId
|
|
93
96
|
}), children]
|
|
94
97
|
});
|
|
@@ -247,6 +250,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
247
250
|
axisContent: PropTypes.elementType,
|
|
248
251
|
classes: PropTypes.object,
|
|
249
252
|
itemContent: PropTypes.elementType,
|
|
253
|
+
slotProps: PropTypes.object,
|
|
254
|
+
slots: PropTypes.object,
|
|
250
255
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
251
256
|
}),
|
|
252
257
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded"];
|
|
3
|
+
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { arc as d3Arc } from 'd3-shape';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -54,7 +54,8 @@ export default function PieArc(props) {
|
|
|
54
54
|
highlighted,
|
|
55
55
|
faded = {
|
|
56
56
|
additionalRadius: -5
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
|
+
onClick
|
|
58
59
|
} = props,
|
|
59
60
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
60
61
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -91,6 +92,8 @@ export default function PieArc(props) {
|
|
|
91
92
|
innerRadius,
|
|
92
93
|
outerRadius
|
|
93
94
|
})),
|
|
95
|
+
onClick: onClick,
|
|
96
|
+
cursor: onClick ? 'pointer' : 'unset',
|
|
94
97
|
ownerState: ownerState,
|
|
95
98
|
className: classes.root
|
|
96
99
|
}, getInteractionItemProps({
|
|
@@ -46,7 +46,8 @@ function PieChart(props) {
|
|
|
46
46
|
bottomAxis = null,
|
|
47
47
|
children,
|
|
48
48
|
slots,
|
|
49
|
-
slotProps
|
|
49
|
+
slotProps,
|
|
50
|
+
onClick
|
|
50
51
|
} = props;
|
|
51
52
|
const margin = _extends({}, defaultMargin, marginProps);
|
|
52
53
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
@@ -74,7 +75,8 @@ function PieChart(props) {
|
|
|
74
75
|
slotProps: slotProps
|
|
75
76
|
}), /*#__PURE__*/_jsx(PiePlot, {
|
|
76
77
|
slots: slots,
|
|
77
|
-
slotProps: slotProps
|
|
78
|
+
slotProps: slotProps,
|
|
79
|
+
onClick: onClick
|
|
78
80
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
79
81
|
slots: slots,
|
|
80
82
|
slotProps: slotProps
|
|
@@ -170,6 +172,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
170
172
|
right: PropTypes.number,
|
|
171
173
|
top: PropTypes.number
|
|
172
174
|
}),
|
|
175
|
+
onClick: PropTypes.func,
|
|
173
176
|
/**
|
|
174
177
|
* Indicate which axis to display the right of the charts.
|
|
175
178
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -244,6 +247,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
244
247
|
axisContent: PropTypes.elementType,
|
|
245
248
|
classes: PropTypes.object,
|
|
246
249
|
itemContent: PropTypes.elementType,
|
|
250
|
+
slotProps: PropTypes.object,
|
|
251
|
+
slots: PropTypes.object,
|
|
247
252
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
248
253
|
}),
|
|
249
254
|
/**
|
|
@@ -25,7 +25,8 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
25
25
|
function PiePlot(props) {
|
|
26
26
|
const {
|
|
27
27
|
slots,
|
|
28
|
-
slotProps
|
|
28
|
+
slotProps,
|
|
29
|
+
onClick
|
|
29
30
|
} = props;
|
|
30
31
|
const seriesData = React.useContext(SeriesContext).pie;
|
|
31
32
|
const {
|
|
@@ -76,7 +77,14 @@ function PiePlot(props) {
|
|
|
76
77
|
dataIndex: index,
|
|
77
78
|
highlightScope: series[seriesId].highlightScope,
|
|
78
79
|
highlighted: highlighted,
|
|
79
|
-
faded: faded
|
|
80
|
+
faded: faded,
|
|
81
|
+
onClick: onClick && (event => {
|
|
82
|
+
onClick(event, {
|
|
83
|
+
type: 'pie',
|
|
84
|
+
seriesId,
|
|
85
|
+
dataIndex: index
|
|
86
|
+
}, item);
|
|
87
|
+
})
|
|
80
88
|
}, slotProps?.pieArc));
|
|
81
89
|
}), data.map((item, index) => {
|
|
82
90
|
return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
|
|
@@ -101,6 +109,13 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
|
101
109
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
102
110
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
103
111
|
// ----------------------------------------------------------------------
|
|
112
|
+
/**
|
|
113
|
+
* Callback fired when a pie item is clicked.
|
|
114
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
115
|
+
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
116
|
+
* @param {DefaultizedPieValueType} item The pie item.
|
|
117
|
+
*/
|
|
118
|
+
onClick: PropTypes.func,
|
|
104
119
|
/**
|
|
105
120
|
* The props used for each component slot.
|
|
106
121
|
* @default {}
|
|
@@ -210,6 +210,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
210
210
|
axisContent: PropTypes.elementType,
|
|
211
211
|
classes: PropTypes.object,
|
|
212
212
|
itemContent: PropTypes.elementType,
|
|
213
|
+
slotProps: PropTypes.object,
|
|
214
|
+
slots: PropTypes.object,
|
|
213
215
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
214
216
|
}),
|
|
215
217
|
/**
|
|
@@ -84,7 +84,10 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
84
84
|
slots: slots,
|
|
85
85
|
slotProps: slotProps
|
|
86
86
|
})]
|
|
87
|
-
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
87
|
+
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
88
|
+
slotProps: slotProps,
|
|
89
|
+
slots: slots
|
|
90
|
+
})), children]
|
|
88
91
|
});
|
|
89
92
|
});
|
|
90
93
|
process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
@@ -159,6 +162,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
159
162
|
axisContent: PropTypes.elementType,
|
|
160
163
|
classes: PropTypes.object,
|
|
161
164
|
itemContent: PropTypes.elementType,
|
|
165
|
+
slotProps: PropTypes.object,
|
|
166
|
+
slots: PropTypes.object,
|
|
162
167
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
163
168
|
}),
|
|
164
169
|
/**
|
package/modern/index.js
CHANGED