@mui/x-charts 6.0.0-alpha.13 → 6.0.0-alpha.15
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 +6 -3
- package/BarChart/BarChart.js +7 -10
- package/BarChart/BarElement.js +2 -4
- package/BarChart/formatter.js +1 -2
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +165 -1
- package/ChartContainer/index.js +2 -3
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsLegend/ChartsLegend.d.ts +43 -24
- package/ChartsLegend/ChartsLegend.js +186 -148
- package/ChartsLegend/chartsLegendClasses.js +1 -2
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.js +5 -14
- 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/ChartsXAxis/ChartsXAxis.js +48 -25
- package/ChartsYAxis/ChartsYAxis.js +47 -26
- package/LineChart/AreaElement.js +2 -4
- package/LineChart/LineChart.d.ts +6 -3
- package/LineChart/LineChart.js +11 -11
- 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 +8 -4
- package/PieChart/PieChart.js +11 -10
- 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 +6 -3
- package/ScatterChart/ScatterChart.js +7 -10
- 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 +5 -8
- package/context/CartesianContextProvider.js +11 -12
- package/context/DrawingProvider.d.ts +2 -0
- package/context/DrawingProvider.js +4 -4
- package/context/HighlightProvider.js +1 -2
- package/context/InteractionProvider.js +1 -2
- package/context/SeriesContextProvider.js +1 -2
- package/esm/BarChart/BarChart.js +6 -8
- package/esm/ChartsLegend/ChartsLegend.js +184 -142
- package/esm/ChartsSurface.js +3 -11
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/esm/ChartsTooltip/ChartsTooltip.js +47 -12
- package/esm/ChartsXAxis/ChartsXAxis.js +47 -24
- package/esm/ChartsYAxis/ChartsYAxis.js +46 -25
- package/esm/LineChart/LineChart.js +10 -9
- package/esm/PieChart/PieArc.js +5 -2
- package/esm/PieChart/PieChart.js +11 -10
- package/esm/PieChart/PiePlot.js +17 -2
- package/esm/ScatterChart/ScatterChart.js +6 -8
- package/esm/SparkLineChart/SparkLineChart.js +6 -1
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +11 -11
- package/esm/context/DrawingProvider.js +2 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useTicks.js +5 -5
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +71 -0
- package/esm/internals/domUtils.js +113 -0
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +3 -2
- package/hooks/useTicks.d.ts +2 -3
- package/hooks/useTicks.js +7 -8
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +18 -78
- package/internals/components/ChartsText.d.ts +32 -0
- package/internals/components/ChartsText.js +81 -0
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/domUtils.d.ts +14 -0
- package/internals/domUtils.js +122 -0
- package/internals/stackSeries.js +2 -4
- package/legacy/BarChart/BarChart.js +6 -8
- package/legacy/ChartsLegend/ChartsLegend.js +196 -140
- package/legacy/ChartsSurface.js +2 -11
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/legacy/ChartsTooltip/ChartsTooltip.js +50 -12
- package/legacy/ChartsXAxis/ChartsXAxis.js +47 -24
- package/legacy/ChartsYAxis/ChartsYAxis.js +46 -25
- package/legacy/LineChart/LineChart.js +10 -9
- package/legacy/PieChart/PieArc.js +4 -1
- package/legacy/PieChart/PieChart.js +11 -10
- package/legacy/PieChart/PiePlot.js +17 -2
- package/legacy/ScatterChart/ScatterChart.js +6 -8
- package/legacy/SparkLineChart/SparkLineChart.js +6 -1
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +11 -11
- package/legacy/context/DrawingProvider.js +2 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useTicks.js +5 -5
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +9 -63
- package/legacy/internals/components/ChartsText.js +77 -0
- package/legacy/internals/domUtils.js +121 -0
- package/models/axis.d.ts +6 -5
- package/models/layout.d.ts +7 -6
- package/modern/BarChart/BarChart.js +6 -8
- package/modern/ChartsLegend/ChartsLegend.js +184 -142
- package/modern/ChartsSurface.js +3 -11
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/modern/ChartsTooltip/ChartsTooltip.js +46 -12
- package/modern/ChartsXAxis/ChartsXAxis.js +47 -24
- package/modern/ChartsYAxis/ChartsYAxis.js +46 -25
- package/modern/LineChart/LineChart.js +10 -9
- package/modern/PieChart/PieArc.js +5 -2
- package/modern/PieChart/PieChart.js +11 -10
- package/modern/PieChart/PiePlot.js +17 -2
- package/modern/ScatterChart/ScatterChart.js +6 -8
- package/modern/SparkLineChart/SparkLineChart.js +6 -1
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +11 -11
- package/modern/context/DrawingProvider.js +2 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useTicks.js +5 -5
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +71 -0
- package/modern/internals/domUtils.js +113 -0
- package/package.json +3 -3
|
@@ -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";
|
|
@@ -53,13 +55,20 @@ export function ChartsItemTooltipContent(props) {
|
|
|
53
55
|
var content = props.content,
|
|
54
56
|
itemData = props.itemData,
|
|
55
57
|
sx = props.sx,
|
|
56
|
-
classes = props.classes
|
|
58
|
+
classes = props.classes,
|
|
59
|
+
contentProps = props.contentProps;
|
|
57
60
|
var series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
|
|
58
61
|
var Content = content != null ? content : DefaultChartsItemContent;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
var chartTooltipContentProps = useSlotProps({
|
|
63
|
+
elementType: Content,
|
|
64
|
+
externalSlotProps: contentProps,
|
|
65
|
+
additionalProps: {
|
|
66
|
+
itemData: itemData,
|
|
67
|
+
series: series,
|
|
68
|
+
sx: sx,
|
|
69
|
+
classes: classes
|
|
70
|
+
},
|
|
71
|
+
ownerState: {}
|
|
64
72
|
});
|
|
73
|
+
return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
|
|
65
74
|
}
|
|
@@ -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.
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["scale", "
|
|
3
|
+
var _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
11
|
import useTicks from '../hooks/useTicks';
|
|
11
12
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
12
|
-
import {
|
|
13
|
+
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
14
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
13
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
17
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
@@ -42,7 +44,7 @@ function ChartsXAxis(inProps) {
|
|
|
42
44
|
var _React$useContext = React.useContext(CartesianContext),
|
|
43
45
|
_React$useContext$xAx = _React$useContext.xAxis[props.axisId],
|
|
44
46
|
xScale = _React$useContext$xAx.scale,
|
|
45
|
-
|
|
47
|
+
tickNumber = _React$useContext$xAx.tickNumber,
|
|
46
48
|
settings = _objectWithoutProperties(_React$useContext$xAx, _excluded);
|
|
47
49
|
var defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
48
50
|
var position = defaultizedProps.position,
|
|
@@ -67,7 +69,7 @@ function ChartsXAxis(inProps) {
|
|
|
67
69
|
var tickSize = disableTicks ? 4 : tickSizeProp;
|
|
68
70
|
var xTicks = useTicks({
|
|
69
71
|
scale: xScale,
|
|
70
|
-
|
|
72
|
+
tickNumber: tickNumber,
|
|
71
73
|
valueFormatter: valueFormatter
|
|
72
74
|
});
|
|
73
75
|
var positionSigne = position === 'bottom' ? 1 : -1;
|
|
@@ -75,10 +77,38 @@ function ChartsXAxis(inProps) {
|
|
|
75
77
|
x: left + width / 2,
|
|
76
78
|
y: positionSigne * (tickFontSize + tickSize + 10)
|
|
77
79
|
};
|
|
78
|
-
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine :
|
|
79
|
-
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick :
|
|
80
|
-
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel :
|
|
81
|
-
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel :
|
|
80
|
+
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
81
|
+
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
82
|
+
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
83
|
+
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
84
|
+
var axisTickLabelProps = useSlotProps({
|
|
85
|
+
elementType: TickLabel,
|
|
86
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
87
|
+
additionalProps: {
|
|
88
|
+
textAnchor: 'middle',
|
|
89
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
90
|
+
style: {
|
|
91
|
+
fontSize: tickFontSize
|
|
92
|
+
},
|
|
93
|
+
className: classes.tickLabel
|
|
94
|
+
},
|
|
95
|
+
className: classes.tickLabel,
|
|
96
|
+
ownerState: {}
|
|
97
|
+
});
|
|
98
|
+
var axisLabelProps = useSlotProps({
|
|
99
|
+
elementType: Label,
|
|
100
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
101
|
+
additionalProps: {
|
|
102
|
+
textAnchor: 'middle',
|
|
103
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
104
|
+
style: {
|
|
105
|
+
fontSize: labelFontSize,
|
|
106
|
+
transformOrigin: "".concat(labelRefPoint.x, "px ").concat(labelRefPoint.y, "px")
|
|
107
|
+
},
|
|
108
|
+
className: classes.label
|
|
109
|
+
},
|
|
110
|
+
ownerState: {}
|
|
111
|
+
});
|
|
82
112
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
83
113
|
transform: "translate(0, ".concat(position === 'bottom' ? top + height : top, ")"),
|
|
84
114
|
className: classes.root,
|
|
@@ -101,24 +131,17 @@ function ChartsXAxis(inProps) {
|
|
|
101
131
|
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
102
132
|
x: xTickLabel,
|
|
103
133
|
y: yTickLabel,
|
|
104
|
-
"transform-origin": "".concat(xTickLabel, "px ").concat(yTickLabel, "px")
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
className: classes.tickLabel
|
|
109
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
110
|
-
children: formattedValue
|
|
134
|
+
"transform-origin": "".concat(xTickLabel, "px ").concat(yTickLabel, "px")
|
|
135
|
+
}, axisTickLabelProps, {
|
|
136
|
+
text: formattedValue.toString()
|
|
111
137
|
}))]
|
|
112
138
|
}, index);
|
|
113
|
-
}), label && /*#__PURE__*/_jsx(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
120
|
-
children: label
|
|
121
|
-
}))]
|
|
139
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
140
|
+
className: classes.label,
|
|
141
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
142
|
+
text: label
|
|
143
|
+
}))
|
|
144
|
+
})]
|
|
122
145
|
});
|
|
123
146
|
}
|
|
124
147
|
process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["scale", "
|
|
3
|
+
var _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
11
|
import useTicks from '../hooks/useTicks';
|
|
11
|
-
import {
|
|
12
|
+
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
13
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
12
14
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
13
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -42,7 +44,7 @@ function ChartsYAxis(inProps) {
|
|
|
42
44
|
var _React$useContext = React.useContext(CartesianContext),
|
|
43
45
|
_React$useContext$yAx = _React$useContext.yAxis[props.axisId],
|
|
44
46
|
yScale = _React$useContext$yAx.scale,
|
|
45
|
-
|
|
47
|
+
tickNumber = _React$useContext$yAx.tickNumber,
|
|
46
48
|
settings = _objectWithoutProperties(_React$useContext$yAx, _excluded);
|
|
47
49
|
var defaultizedProps = _extends({}, defaultProps, settings, props);
|
|
48
50
|
var position = defaultizedProps.position,
|
|
@@ -67,7 +69,7 @@ function ChartsYAxis(inProps) {
|
|
|
67
69
|
var tickSize = disableTicks ? 4 : tickSizeProp;
|
|
68
70
|
var yTicks = useTicks({
|
|
69
71
|
scale: yScale,
|
|
70
|
-
|
|
72
|
+
tickNumber: tickNumber,
|
|
71
73
|
valueFormatter: valueFormatter
|
|
72
74
|
});
|
|
73
75
|
var positionSigne = position === 'right' ? 1 : -1;
|
|
@@ -75,10 +77,38 @@ function ChartsYAxis(inProps) {
|
|
|
75
77
|
x: positionSigne * (tickFontSize + tickSize + 10),
|
|
76
78
|
y: top + height / 2
|
|
77
79
|
};
|
|
78
|
-
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine :
|
|
79
|
-
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick :
|
|
80
|
-
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel :
|
|
81
|
-
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel :
|
|
80
|
+
var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
81
|
+
var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
82
|
+
var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
83
|
+
var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
84
|
+
var axisTickLabelProps = useSlotProps({
|
|
85
|
+
elementType: TickLabel,
|
|
86
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
87
|
+
additionalProps: {
|
|
88
|
+
textAnchor: position === 'right' ? 'start' : 'end',
|
|
89
|
+
dominantBaseline: 'central',
|
|
90
|
+
style: {
|
|
91
|
+
fontSize: tickFontSize
|
|
92
|
+
},
|
|
93
|
+
className: classes.tickLabel
|
|
94
|
+
},
|
|
95
|
+
ownerState: {}
|
|
96
|
+
});
|
|
97
|
+
var axisLabelProps = useSlotProps({
|
|
98
|
+
elementType: Label,
|
|
99
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
100
|
+
additionalProps: {
|
|
101
|
+
textAnchor: 'middle',
|
|
102
|
+
dominantBaseline: 'auto',
|
|
103
|
+
style: {
|
|
104
|
+
fontSize: labelFontSize,
|
|
105
|
+
transform: "rotate(".concat(positionSigne * 90, "deg)"),
|
|
106
|
+
transformOrigin: "".concat(labelRefPoint.x, "px ").concat(labelRefPoint.y, "px")
|
|
107
|
+
},
|
|
108
|
+
className: classes.label
|
|
109
|
+
},
|
|
110
|
+
ownerState: {}
|
|
111
|
+
});
|
|
82
112
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
83
113
|
transform: "translate(".concat(position === 'right' ? left + width : left, ", 0)"),
|
|
84
114
|
className: classes.root,
|
|
@@ -102,24 +132,15 @@ function ChartsYAxis(inProps) {
|
|
|
102
132
|
x: xTickLabel,
|
|
103
133
|
y: yTickLabel,
|
|
104
134
|
"transform-origin": "".concat(xTickLabel, "px ").concat(yTickLabel, "px"),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
className: classes.tickLabel
|
|
109
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
110
|
-
children: formattedValue.toLocaleString()
|
|
111
|
-
}))]
|
|
135
|
+
text: formattedValue.toString()
|
|
136
|
+
}, axisTickLabelProps))]
|
|
112
137
|
}, index);
|
|
113
|
-
}), label && /*#__PURE__*/_jsx(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
className: classes.label
|
|
120
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
121
|
-
children: label
|
|
122
|
-
}))]
|
|
138
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
139
|
+
className: classes.label,
|
|
140
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
141
|
+
text: label
|
|
142
|
+
}))
|
|
143
|
+
})]
|
|
123
144
|
});
|
|
124
145
|
}
|
|
125
146
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
@@ -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
|
});
|
|
@@ -169,23 +172,19 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
169
172
|
tickNumber: PropTypes.number,
|
|
170
173
|
tickSize: PropTypes.number
|
|
171
174
|
}), PropTypes.string]),
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
177
|
+
*/
|
|
172
178
|
legend: PropTypes.shape({
|
|
173
179
|
classes: PropTypes.object,
|
|
174
180
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
175
181
|
hidden: PropTypes.bool,
|
|
176
|
-
itemWidth: PropTypes.number,
|
|
177
|
-
markSize: PropTypes.number,
|
|
178
|
-
offset: PropTypes.shape({
|
|
179
|
-
x: PropTypes.number,
|
|
180
|
-
y: PropTypes.number
|
|
181
|
-
}),
|
|
182
182
|
position: PropTypes.shape({
|
|
183
183
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
184
184
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
185
185
|
}),
|
|
186
186
|
slotProps: PropTypes.object,
|
|
187
|
-
slots: PropTypes.object
|
|
188
|
-
spacing: PropTypes.number
|
|
187
|
+
slots: PropTypes.object
|
|
189
188
|
}),
|
|
190
189
|
margin: PropTypes.shape({
|
|
191
190
|
bottom: PropTypes.number,
|
|
@@ -254,6 +253,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
254
253
|
axisContent: PropTypes.elementType,
|
|
255
254
|
classes: PropTypes.object,
|
|
256
255
|
itemContent: PropTypes.elementType,
|
|
256
|
+
slotProps: PropTypes.object,
|
|
257
|
+
slots: PropTypes.object,
|
|
257
258
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
258
259
|
}),
|
|
259
260
|
/**
|
|
@@ -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
|
|
@@ -158,23 +160,19 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
158
160
|
tickNumber: PropTypes.number,
|
|
159
161
|
tickSize: PropTypes.number
|
|
160
162
|
}), PropTypes.string]),
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
165
|
+
*/
|
|
161
166
|
legend: PropTypes.shape({
|
|
162
167
|
classes: PropTypes.object,
|
|
163
168
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
164
169
|
hidden: PropTypes.bool,
|
|
165
|
-
itemWidth: PropTypes.number,
|
|
166
|
-
markSize: PropTypes.number,
|
|
167
|
-
offset: PropTypes.shape({
|
|
168
|
-
x: PropTypes.number,
|
|
169
|
-
y: PropTypes.number
|
|
170
|
-
}),
|
|
171
170
|
position: PropTypes.shape({
|
|
172
171
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
173
172
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
174
173
|
}),
|
|
175
174
|
slotProps: PropTypes.object,
|
|
176
|
-
slots: PropTypes.object
|
|
177
|
-
spacing: PropTypes.number
|
|
175
|
+
slots: PropTypes.object
|
|
178
176
|
}),
|
|
179
177
|
margin: PropTypes.shape({
|
|
180
178
|
bottom: PropTypes.number,
|
|
@@ -182,6 +180,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
182
180
|
right: PropTypes.number,
|
|
183
181
|
top: PropTypes.number
|
|
184
182
|
}),
|
|
183
|
+
onClick: PropTypes.func,
|
|
185
184
|
/**
|
|
186
185
|
* Indicate which axis to display the right of the charts.
|
|
187
186
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -256,6 +255,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
256
255
|
axisContent: PropTypes.elementType,
|
|
257
256
|
classes: PropTypes.object,
|
|
258
257
|
itemContent: PropTypes.elementType,
|
|
258
|
+
slotProps: PropTypes.object,
|
|
259
|
+
slots: PropTypes.object,
|
|
259
260
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
260
261
|
}),
|
|
261
262
|
/**
|
|
@@ -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 {}
|
|
@@ -128,23 +128,19 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
128
128
|
tickNumber: PropTypes.number,
|
|
129
129
|
tickSize: PropTypes.number
|
|
130
130
|
}), PropTypes.string]),
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
133
|
+
*/
|
|
131
134
|
legend: PropTypes.shape({
|
|
132
135
|
classes: PropTypes.object,
|
|
133
136
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
134
137
|
hidden: PropTypes.bool,
|
|
135
|
-
itemWidth: PropTypes.number,
|
|
136
|
-
markSize: PropTypes.number,
|
|
137
|
-
offset: PropTypes.shape({
|
|
138
|
-
x: PropTypes.number,
|
|
139
|
-
y: PropTypes.number
|
|
140
|
-
}),
|
|
141
138
|
position: PropTypes.shape({
|
|
142
139
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
143
140
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
144
141
|
}),
|
|
145
142
|
slotProps: PropTypes.object,
|
|
146
|
-
slots: PropTypes.object
|
|
147
|
-
spacing: PropTypes.number
|
|
143
|
+
slots: PropTypes.object
|
|
148
144
|
}),
|
|
149
145
|
margin: PropTypes.shape({
|
|
150
146
|
bottom: PropTypes.number,
|
|
@@ -210,6 +206,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
210
206
|
axisContent: PropTypes.elementType,
|
|
211
207
|
classes: PropTypes.object,
|
|
212
208
|
itemContent: PropTypes.elementType,
|
|
209
|
+
slotProps: PropTypes.object,
|
|
210
|
+
slots: PropTypes.object,
|
|
213
211
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
214
212
|
}),
|
|
215
213
|
/**
|
|
@@ -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
|
/**
|