@mui/x-charts 6.0.0-alpha.9 → 6.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +26 -5
- package/BarChart/BarChart.js +93 -17
- package/BarChart/BarElement.d.ts +1319 -4
- package/BarChart/BarElement.js +10 -10
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/BarChart/formatter.js +2 -3
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +797 -59
- package/ChartContainer/index.js +7 -5
- package/ChartsAxis/ChartsAxis.d.ts +9 -0
- package/ChartsAxis/ChartsAxis.js +33 -7
- package/ChartsAxis/axisClasses.d.ts +3 -3
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +21 -0
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +61 -22
- package/ChartsClipPath/ChartsClipPath.d.ts +5 -0
- package/ChartsClipPath/ChartsClipPath.js +7 -2
- package/ChartsLegend/ChartsLegend.d.ts +45 -24
- package/ChartsLegend/ChartsLegend.js +193 -151
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/chartsLegendClasses.js +3 -4
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
- package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
- package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
- package/ChartsReferenceLine/common.d.ts +41 -0
- package/ChartsReferenceLine/common.js +27 -0
- package/ChartsReferenceLine/index.d.ts +2 -0
- package/ChartsReferenceLine/index.js +27 -0
- package/ChartsReferenceLine/package.json +6 -0
- package/ChartsSurface.d.ts +12 -1
- package/ChartsSurface.js +9 -18
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +46 -32
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +18 -9
- package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
- package/ChartsTooltip/ChartsTooltip.js +62 -18
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -10
- package/ChartsTooltip/ChartsTooltipTable.js +22 -20
- package/ChartsTooltip/tooltipClasses.js +1 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.d.ts +9 -0
- package/ChartsXAxis/ChartsXAxis.js +170 -45
- package/ChartsYAxis/ChartsYAxis.d.ts +9 -0
- package/ChartsYAxis/ChartsYAxis.js +95 -38
- package/LineChart/AreaElement.d.ts +11 -1
- package/LineChart/AreaElement.js +14 -6
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +27 -8
- package/LineChart/LineChart.d.ts +23 -3
- package/LineChart/LineChart.js +89 -17
- package/LineChart/LineElement.d.ts +11 -1
- package/LineChart/LineElement.js +14 -6
- package/LineChart/LineHighlightElement.d.ts +10 -0
- package/LineChart/LineHighlightElement.js +13 -4
- package/LineChart/LineHighlightPlot.d.ts +10 -0
- package/LineChart/LineHighlightPlot.js +15 -4
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +25 -12
- package/LineChart/MarkElement.d.ts +10 -0
- package/LineChart/MarkElement.js +14 -5
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +42 -10
- package/LineChart/formatter.js +5 -5
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +11 -13
- package/PieChart/PieArc.js +28 -60
- package/PieChart/PieArcLabel.d.ts +8 -9
- package/PieChart/PieArcLabel.js +46 -38
- package/PieChart/PieArcLabelPlot.d.ts +28 -0
- package/PieChart/PieArcLabelPlot.js +99 -0
- package/PieChart/PieArcPlot.d.ts +35 -0
- package/PieChart/PieArcPlot.js +92 -0
- package/PieChart/PieChart.d.ts +19 -5
- package/PieChart/PieChart.js +95 -18
- package/PieChart/PiePlot.d.ts +15 -9
- package/PieChart/PiePlot.js +77 -55
- package/PieChart/dataTransform/transition.d.ts +4 -0
- package/PieChart/dataTransform/transition.js +136 -0
- package/PieChart/dataTransform/useTransformData.d.ts +15 -0
- package/PieChart/dataTransform/useTransformData.js +67 -0
- package/PieChart/formatter.js +1 -2
- package/PieChart/legend.js +1 -2
- package/README.md +8 -14
- package/ResponsiveChartContainer/index.d.ts +13 -3
- package/ResponsiveChartContainer/index.js +7 -8
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +16 -3
- package/ScatterChart/ScatterChart.js +77 -16
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/ScatterChart/formatter.js +1 -2
- package/ScatterChart/legend.js +1 -2
- package/SparkLineChart/SparkLineChart.d.ts +12 -3
- package/SparkLineChart/SparkLineChart.js +50 -7
- package/colorPalettes/colorPalettes.js +6 -12
- package/constants.js +5 -8
- package/context/CartesianContextProvider.d.ts +26 -1
- package/context/CartesianContextProvider.js +42 -16
- package/context/DrawingProvider.d.ts +25 -0
- package/context/DrawingProvider.js +18 -6
- package/context/HighlightProvider.d.ts +17 -0
- package/context/HighlightProvider.js +3 -4
- package/context/InteractionProvider.d.ts +6 -0
- package/context/InteractionProvider.js +3 -4
- package/context/SeriesContextProvider.d.ts +5 -0
- package/context/SeriesContextProvider.js +3 -4
- package/esm/BarChart/BarChart.js +90 -13
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +32 -5
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/esm/ChartsClipPath/ChartsClipPath.js +5 -0
- package/esm/ChartsLegend/ChartsLegend.js +190 -144
- package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
- package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/esm/ChartsReferenceLine/common.js +20 -0
- package/esm/ChartsReferenceLine/index.js +2 -0
- package/esm/ChartsSurface.js +4 -12
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/esm/ChartsTooltip/ChartsTooltip.js +59 -14
- package/esm/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/esm/ChartsXAxis/ChartsXAxis.js +168 -43
- package/esm/ChartsYAxis/ChartsYAxis.js +93 -36
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +26 -6
- package/esm/LineChart/LineChart.js +86 -13
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +10 -0
- package/esm/LineChart/LineHighlightPlot.js +13 -2
- package/esm/LineChart/LinePlot.js +25 -14
- package/esm/LineChart/MarkElement.js +11 -1
- package/esm/LineChart/MarkPlot.js +40 -8
- package/esm/LineChart/formatter.js +7 -3
- package/esm/PieChart/PieArc.js +26 -58
- package/esm/PieChart/PieArcLabel.js +43 -34
- package/esm/PieChart/PieArcLabelPlot.js +92 -0
- package/esm/PieChart/PieArcPlot.js +84 -0
- package/esm/PieChart/PieChart.js +93 -16
- package/esm/PieChart/PiePlot.js +76 -57
- package/esm/PieChart/dataTransform/transition.js +130 -0
- package/esm/PieChart/dataTransform/useTransformData.js +59 -0
- package/esm/ResponsiveChartContainer/index.js +3 -3
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +74 -12
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +47 -3
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +41 -14
- package/esm/context/DrawingProvider.js +14 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +15 -9
- package/esm/index.js +1 -0
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +77 -0
- package/esm/internals/domUtils.js +113 -0
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +5 -4
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +19 -11
- package/hooks/useTicks.js +19 -14
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +18 -78
- package/internals/components/ChartsText.d.ts +35 -0
- package/internals/components/ChartsText.js +87 -0
- package/internals/defaultizeColor.d.ts +7 -2
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/domUtils.d.ts +13 -0
- package/internals/domUtils.js +122 -0
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/internals/isBandScale.d.ts +3 -1
- package/internals/stackSeries.js +2 -4
- package/internals/utils.d.ts +5 -0
- package/legacy/BarChart/BarChart.js +90 -13
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +32 -5
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -20
- package/legacy/ChartsClipPath/ChartsClipPath.js +5 -0
- package/legacy/ChartsLegend/ChartsLegend.js +205 -142
- package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
- package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/legacy/ChartsReferenceLine/common.js +20 -0
- package/legacy/ChartsReferenceLine/index.js +2 -0
- package/legacy/ChartsSurface.js +3 -12
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +22 -10
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/legacy/ChartsTooltip/ChartsTooltip.js +62 -14
- package/legacy/ChartsTooltip/ChartsTooltipTable.js +34 -26
- package/legacy/ChartsXAxis/ChartsXAxis.js +176 -50
- package/legacy/ChartsYAxis/ChartsYAxis.js +97 -41
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +31 -7
- package/legacy/LineChart/LineChart.js +86 -13
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +10 -0
- package/legacy/LineChart/LineHighlightPlot.js +13 -2
- package/legacy/LineChart/LinePlot.js +29 -12
- package/legacy/LineChart/MarkElement.js +11 -1
- package/legacy/LineChart/MarkPlot.js +39 -8
- package/legacy/LineChart/formatter.js +7 -3
- package/legacy/PieChart/PieArc.js +30 -62
- package/legacy/PieChart/PieArcLabel.js +48 -34
- package/legacy/PieChart/PieArcLabelPlot.js +93 -0
- package/legacy/PieChart/PieArcPlot.js +84 -0
- package/legacy/PieChart/PieChart.js +93 -16
- package/legacy/PieChart/PiePlot.js +76 -59
- package/legacy/PieChart/dataTransform/transition.js +142 -0
- package/legacy/PieChart/dataTransform/useTransformData.js +60 -0
- package/legacy/ResponsiveChartContainer/index.js +3 -3
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +74 -12
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +47 -3
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +41 -14
- package/legacy/context/DrawingProvider.js +14 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +16 -9
- package/legacy/index.js +2 -1
- package/legacy/internals/components/AxisSharedComponents.js +11 -65
- package/legacy/internals/components/ChartsText.js +79 -0
- package/legacy/internals/domUtils.js +121 -0
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +58 -20
- package/models/layout.d.ts +13 -6
- package/models/seriesType/common.d.ts +16 -0
- package/models/seriesType/line.d.ts +8 -3
- package/models/seriesType/pie.d.ts +5 -1
- package/modern/BarChart/BarChart.js +90 -13
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +31 -5
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/modern/ChartsClipPath/ChartsClipPath.js +5 -0
- package/modern/ChartsLegend/ChartsLegend.js +190 -144
- package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
- package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/modern/ChartsReferenceLine/common.js +20 -0
- package/modern/ChartsReferenceLine/index.js +2 -0
- package/modern/ChartsSurface.js +4 -12
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/modern/ChartsTooltip/ChartsTooltip.js +58 -14
- package/modern/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/modern/ChartsXAxis/ChartsXAxis.js +167 -42
- package/modern/ChartsYAxis/ChartsYAxis.js +92 -35
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +25 -6
- package/modern/LineChart/LineChart.js +86 -13
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +10 -0
- package/modern/LineChart/LineHighlightPlot.js +13 -2
- package/modern/LineChart/LinePlot.js +23 -10
- package/modern/LineChart/MarkElement.js +11 -1
- package/modern/LineChart/MarkPlot.js +40 -8
- package/modern/LineChart/formatter.js +4 -3
- package/modern/PieChart/PieArc.js +26 -57
- package/modern/PieChart/PieArcLabel.js +43 -34
- package/modern/PieChart/PieArcLabelPlot.js +90 -0
- package/modern/PieChart/PieArcPlot.js +83 -0
- package/modern/PieChart/PieChart.js +93 -16
- package/modern/PieChart/PiePlot.js +76 -55
- package/modern/PieChart/dataTransform/transition.js +130 -0
- package/modern/PieChart/dataTransform/useTransformData.js +58 -0
- package/modern/ResponsiveChartContainer/index.js +3 -3
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +74 -12
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +47 -3
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +40 -13
- package/modern/context/DrawingProvider.js +14 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +15 -9
- package/modern/index.js +2 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +77 -0
- package/modern/internals/domUtils.js +113 -0
- package/modern/internals/geometry.js +36 -0
- package/package.json +9 -6
- package/themeAugmentation/components.d.ts +1 -0
- package/themeAugmentation/overrides.d.ts +2 -0
|
@@ -17,6 +17,17 @@ var defaultMargin = {
|
|
|
17
17
|
left: 5,
|
|
18
18
|
right: 100
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Demos:
|
|
23
|
+
*
|
|
24
|
+
* - [Pie](https://mui.com/x/react-charts/pie/)
|
|
25
|
+
* - [Pie demonstration](https://mui.com/x/react-charts/pie-demo/)
|
|
26
|
+
*
|
|
27
|
+
* API:
|
|
28
|
+
*
|
|
29
|
+
* - [PieChart API](https://mui.com/x/api/charts/pie-chart/)
|
|
30
|
+
*/
|
|
20
31
|
function PieChart(props) {
|
|
21
32
|
var xAxis = props.xAxis,
|
|
22
33
|
yAxis = props.yAxis,
|
|
@@ -35,6 +46,7 @@ function PieChart(props) {
|
|
|
35
46
|
x: 'none',
|
|
36
47
|
y: 'none'
|
|
37
48
|
} : _props$axisHighlight,
|
|
49
|
+
skipAnimation = props.skipAnimation,
|
|
38
50
|
_props$legend = props.legend,
|
|
39
51
|
legend = _props$legend === void 0 ? {
|
|
40
52
|
direction: 'column',
|
|
@@ -53,7 +65,8 @@ function PieChart(props) {
|
|
|
53
65
|
bottomAxis = _props$bottomAxis === void 0 ? null : _props$bottomAxis,
|
|
54
66
|
children = props.children,
|
|
55
67
|
slots = props.slots,
|
|
56
|
-
slotProps = props.slotProps
|
|
68
|
+
slotProps = props.slotProps,
|
|
69
|
+
onClick = props.onClick;
|
|
57
70
|
var margin = _extends({}, defaultMargin, marginProps);
|
|
58
71
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
59
72
|
series: series.map(function (s) {
|
|
@@ -86,7 +99,9 @@ function PieChart(props) {
|
|
|
86
99
|
slotProps: slotProps
|
|
87
100
|
}), /*#__PURE__*/_jsx(PiePlot, {
|
|
88
101
|
slots: slots,
|
|
89
|
-
slotProps: slotProps
|
|
102
|
+
slotProps: slotProps,
|
|
103
|
+
onClick: onClick,
|
|
104
|
+
skipAnimation: skipAnimation
|
|
90
105
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
91
106
|
slots: slots,
|
|
92
107
|
slotProps: slotProps
|
|
@@ -108,18 +123,22 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
108
123
|
* @default xAxisIds[0] The id of the first provided axis
|
|
109
124
|
*/
|
|
110
125
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
111
|
-
axisId: PropTypes.string
|
|
126
|
+
axisId: PropTypes.string,
|
|
112
127
|
classes: PropTypes.object,
|
|
113
128
|
disableLine: PropTypes.bool,
|
|
114
129
|
disableTicks: PropTypes.bool,
|
|
115
130
|
fill: PropTypes.string,
|
|
116
131
|
label: PropTypes.string,
|
|
117
132
|
labelFontSize: PropTypes.number,
|
|
133
|
+
labelStyle: PropTypes.object,
|
|
118
134
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
119
135
|
slotProps: PropTypes.object,
|
|
120
136
|
slots: PropTypes.object,
|
|
121
137
|
stroke: PropTypes.string,
|
|
122
138
|
tickFontSize: PropTypes.number,
|
|
139
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
140
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
141
|
+
tickLabelStyle: PropTypes.object,
|
|
123
142
|
tickMaxStep: PropTypes.number,
|
|
124
143
|
tickMinStep: PropTypes.number,
|
|
125
144
|
tickNumber: PropTypes.number,
|
|
@@ -131,9 +150,21 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
131
150
|
* Color palette used to colorize multiple series.
|
|
132
151
|
*/
|
|
133
152
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
153
|
+
/**
|
|
154
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
155
|
+
*/
|
|
134
156
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
135
157
|
desc: PropTypes.string,
|
|
158
|
+
/**
|
|
159
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
160
|
+
* It might break interactive features, but will improve performance.
|
|
161
|
+
* @default false
|
|
162
|
+
*/
|
|
136
163
|
disableAxisListener: PropTypes.bool,
|
|
164
|
+
/**
|
|
165
|
+
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
166
|
+
* @default undefined
|
|
167
|
+
*/
|
|
137
168
|
height: PropTypes.number,
|
|
138
169
|
/**
|
|
139
170
|
* Indicate which axis to display the left of the charts.
|
|
@@ -141,65 +172,76 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
141
172
|
* @default yAxisIds[0] The id of the first provided axis
|
|
142
173
|
*/
|
|
143
174
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
144
|
-
axisId: PropTypes.string
|
|
175
|
+
axisId: PropTypes.string,
|
|
145
176
|
classes: PropTypes.object,
|
|
146
177
|
disableLine: PropTypes.bool,
|
|
147
178
|
disableTicks: PropTypes.bool,
|
|
148
179
|
fill: PropTypes.string,
|
|
149
180
|
label: PropTypes.string,
|
|
150
181
|
labelFontSize: PropTypes.number,
|
|
182
|
+
labelStyle: PropTypes.object,
|
|
151
183
|
position: PropTypes.oneOf(['left', 'right']),
|
|
152
184
|
slotProps: PropTypes.object,
|
|
153
185
|
slots: PropTypes.object,
|
|
154
186
|
stroke: PropTypes.string,
|
|
155
187
|
tickFontSize: PropTypes.number,
|
|
188
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
189
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
190
|
+
tickLabelStyle: PropTypes.object,
|
|
156
191
|
tickMaxStep: PropTypes.number,
|
|
157
192
|
tickMinStep: PropTypes.number,
|
|
158
193
|
tickNumber: PropTypes.number,
|
|
159
194
|
tickSize: PropTypes.number
|
|
160
195
|
}), PropTypes.string]),
|
|
196
|
+
/**
|
|
197
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
198
|
+
*/
|
|
161
199
|
legend: PropTypes.shape({
|
|
162
200
|
classes: PropTypes.object,
|
|
163
201
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
164
202
|
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
203
|
position: PropTypes.shape({
|
|
172
204
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
173
205
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
174
206
|
}),
|
|
175
207
|
slotProps: PropTypes.object,
|
|
176
|
-
slots: PropTypes.object
|
|
177
|
-
spacing: PropTypes.number
|
|
208
|
+
slots: PropTypes.object
|
|
178
209
|
}),
|
|
210
|
+
/**
|
|
211
|
+
* The margin between the SVG and the drawing area.
|
|
212
|
+
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
213
|
+
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
214
|
+
* @default object Depends on the charts type.
|
|
215
|
+
*/
|
|
179
216
|
margin: PropTypes.shape({
|
|
180
217
|
bottom: PropTypes.number,
|
|
181
218
|
left: PropTypes.number,
|
|
182
219
|
right: PropTypes.number,
|
|
183
220
|
top: PropTypes.number
|
|
184
221
|
}),
|
|
222
|
+
onClick: PropTypes.func,
|
|
185
223
|
/**
|
|
186
224
|
* Indicate which axis to display the right of the charts.
|
|
187
225
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
188
226
|
* @default null
|
|
189
227
|
*/
|
|
190
228
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
191
|
-
axisId: PropTypes.string
|
|
229
|
+
axisId: PropTypes.string,
|
|
192
230
|
classes: PropTypes.object,
|
|
193
231
|
disableLine: PropTypes.bool,
|
|
194
232
|
disableTicks: PropTypes.bool,
|
|
195
233
|
fill: PropTypes.string,
|
|
196
234
|
label: PropTypes.string,
|
|
197
235
|
labelFontSize: PropTypes.number,
|
|
236
|
+
labelStyle: PropTypes.object,
|
|
198
237
|
position: PropTypes.oneOf(['left', 'right']),
|
|
199
238
|
slotProps: PropTypes.object,
|
|
200
239
|
slots: PropTypes.object,
|
|
201
240
|
stroke: PropTypes.string,
|
|
202
241
|
tickFontSize: PropTypes.number,
|
|
242
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
243
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
244
|
+
tickLabelStyle: PropTypes.object,
|
|
203
245
|
tickMaxStep: PropTypes.number,
|
|
204
246
|
tickMinStep: PropTypes.number,
|
|
205
247
|
tickNumber: PropTypes.number,
|
|
@@ -221,15 +263,19 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
221
263
|
endAngle: PropTypes.number,
|
|
222
264
|
faded: PropTypes.shape({
|
|
223
265
|
additionalRadius: PropTypes.number,
|
|
266
|
+
color: PropTypes.string,
|
|
224
267
|
cornerRadius: PropTypes.number,
|
|
225
268
|
innerRadius: PropTypes.number,
|
|
226
|
-
outerRadius: PropTypes.number
|
|
269
|
+
outerRadius: PropTypes.number,
|
|
270
|
+
paddingAngle: PropTypes.number
|
|
227
271
|
}),
|
|
228
272
|
highlighted: PropTypes.shape({
|
|
229
273
|
additionalRadius: PropTypes.number,
|
|
274
|
+
color: PropTypes.string,
|
|
230
275
|
cornerRadius: PropTypes.number,
|
|
231
276
|
innerRadius: PropTypes.number,
|
|
232
|
-
outerRadius: PropTypes.number
|
|
277
|
+
outerRadius: PropTypes.number,
|
|
278
|
+
paddingAngle: PropTypes.number
|
|
233
279
|
}),
|
|
234
280
|
highlightScope: PropTypes.shape({
|
|
235
281
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
@@ -244,6 +290,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
244
290
|
type: PropTypes.oneOf(['pie']),
|
|
245
291
|
valueFormatter: PropTypes.func
|
|
246
292
|
})).isRequired,
|
|
293
|
+
/**
|
|
294
|
+
* If `true`, animations are skiped.
|
|
295
|
+
* @default false
|
|
296
|
+
*/
|
|
297
|
+
skipAnimation: PropTypes.bool,
|
|
247
298
|
/**
|
|
248
299
|
* The props used for each component slot.
|
|
249
300
|
* @default {}
|
|
@@ -256,6 +307,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
256
307
|
axisContent: PropTypes.elementType,
|
|
257
308
|
classes: PropTypes.object,
|
|
258
309
|
itemContent: PropTypes.elementType,
|
|
310
|
+
slotProps: PropTypes.object,
|
|
311
|
+
slots: PropTypes.object,
|
|
259
312
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
260
313
|
}),
|
|
261
314
|
/**
|
|
@@ -264,18 +317,22 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
264
317
|
* @default null
|
|
265
318
|
*/
|
|
266
319
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
267
|
-
axisId: PropTypes.string
|
|
320
|
+
axisId: PropTypes.string,
|
|
268
321
|
classes: PropTypes.object,
|
|
269
322
|
disableLine: PropTypes.bool,
|
|
270
323
|
disableTicks: PropTypes.bool,
|
|
271
324
|
fill: PropTypes.string,
|
|
272
325
|
label: PropTypes.string,
|
|
273
326
|
labelFontSize: PropTypes.number,
|
|
327
|
+
labelStyle: PropTypes.object,
|
|
274
328
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
275
329
|
slotProps: PropTypes.object,
|
|
276
330
|
slots: PropTypes.object,
|
|
277
331
|
stroke: PropTypes.string,
|
|
278
332
|
tickFontSize: PropTypes.number,
|
|
333
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
334
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
335
|
+
tickLabelStyle: PropTypes.object,
|
|
279
336
|
tickMaxStep: PropTypes.number,
|
|
280
337
|
tickMinStep: PropTypes.number,
|
|
281
338
|
tickNumber: PropTypes.number,
|
|
@@ -287,7 +344,15 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
287
344
|
x: PropTypes.number,
|
|
288
345
|
y: PropTypes.number
|
|
289
346
|
}),
|
|
347
|
+
/**
|
|
348
|
+
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
349
|
+
* @default undefined
|
|
350
|
+
*/
|
|
290
351
|
width: PropTypes.number,
|
|
352
|
+
/**
|
|
353
|
+
* The configuration of the x-axes.
|
|
354
|
+
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
355
|
+
*/
|
|
291
356
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
292
357
|
axisId: PropTypes.string,
|
|
293
358
|
classes: PropTypes.object,
|
|
@@ -300,6 +365,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
300
365
|
id: PropTypes.string,
|
|
301
366
|
label: PropTypes.string,
|
|
302
367
|
labelFontSize: PropTypes.number,
|
|
368
|
+
labelStyle: PropTypes.object,
|
|
303
369
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
304
370
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
305
371
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -308,12 +374,19 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
308
374
|
slots: PropTypes.object,
|
|
309
375
|
stroke: PropTypes.string,
|
|
310
376
|
tickFontSize: PropTypes.number,
|
|
377
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
378
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
379
|
+
tickLabelStyle: PropTypes.object,
|
|
311
380
|
tickMaxStep: PropTypes.number,
|
|
312
381
|
tickMinStep: PropTypes.number,
|
|
313
382
|
tickNumber: PropTypes.number,
|
|
314
383
|
tickSize: PropTypes.number,
|
|
315
384
|
valueFormatter: PropTypes.func
|
|
316
385
|
})),
|
|
386
|
+
/**
|
|
387
|
+
* The configuration of the y-axes.
|
|
388
|
+
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
389
|
+
*/
|
|
317
390
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
318
391
|
axisId: PropTypes.string,
|
|
319
392
|
classes: PropTypes.object,
|
|
@@ -326,6 +399,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
326
399
|
id: PropTypes.string,
|
|
327
400
|
label: PropTypes.string,
|
|
328
401
|
labelFontSize: PropTypes.number,
|
|
402
|
+
labelStyle: PropTypes.object,
|
|
329
403
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
330
404
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
331
405
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -334,6 +408,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
334
408
|
slots: PropTypes.object,
|
|
335
409
|
stroke: PropTypes.string,
|
|
336
410
|
tickFontSize: PropTypes.number,
|
|
411
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
412
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
413
|
+
tickLabelStyle: PropTypes.object,
|
|
337
414
|
tickMaxStep: PropTypes.number,
|
|
338
415
|
tickMinStep: PropTypes.number,
|
|
339
416
|
tickNumber: PropTypes.number,
|
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
5
|
-
import PieArc from './PieArc';
|
|
6
|
-
import PieArcLabel from './PieArcLabel';
|
|
7
4
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { PieArcPlot } from './PieArcPlot';
|
|
6
|
+
import { PieArcLabelPlot } from './PieArcLabelPlot';
|
|
10
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (_item$arcLabel = item[arcLabel]) == null ? void 0 : _item$arcLabel.toString();
|
|
23
|
-
}
|
|
24
|
-
return arcLabel(item);
|
|
25
|
-
}
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* Demos:
|
|
11
|
+
*
|
|
12
|
+
* - [Pie](https://mui.com/x/react-charts/pie/)
|
|
13
|
+
* - [Pie demonstration](https://mui.com/x/react-charts/pie-demo/)
|
|
14
|
+
*
|
|
15
|
+
* API:
|
|
16
|
+
*
|
|
17
|
+
* - [PiePlot API](https://mui.com/x/api/charts/pie-plot/)
|
|
18
|
+
*/
|
|
26
19
|
function PiePlot(props) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
slotProps = props.slotProps
|
|
20
|
+
var skipAnimation = props.skipAnimation,
|
|
21
|
+
slots = props.slots,
|
|
22
|
+
slotProps = props.slotProps,
|
|
23
|
+
onClick = props.onClick;
|
|
30
24
|
var seriesData = React.useContext(SeriesContext).pie;
|
|
31
25
|
var _React$useContext = React.useContext(DrawingContext),
|
|
32
26
|
left = _React$useContext.left,
|
|
@@ -43,54 +37,65 @@ function PiePlot(props) {
|
|
|
43
37
|
};
|
|
44
38
|
var series = seriesData.series,
|
|
45
39
|
seriesOrder = seriesData.seriesOrder;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return /*#__PURE__*/_jsx("g", {
|
|
49
|
-
children: seriesOrder.map(function (seriesId) {
|
|
40
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
41
|
+
children: [seriesOrder.map(function (seriesId) {
|
|
50
42
|
var _series$seriesId = series[seriesId],
|
|
51
43
|
innerRadius = _series$seriesId.innerRadius,
|
|
52
44
|
outerRadius = _series$seriesId.outerRadius,
|
|
53
45
|
cornerRadius = _series$seriesId.cornerRadius,
|
|
54
|
-
|
|
55
|
-
_series$seriesId$arcL = _series$seriesId.arcLabelMinAngle,
|
|
56
|
-
arcLabelMinAngle = _series$seriesId$arcL === void 0 ? 0 : _series$seriesId$arcL,
|
|
46
|
+
paddingAngle = _series$seriesId.paddingAngle,
|
|
57
47
|
data = _series$seriesId.data,
|
|
58
48
|
cx = _series$seriesId.cx,
|
|
59
49
|
cy = _series$seriesId.cy,
|
|
60
50
|
highlighted = _series$seriesId.highlighted,
|
|
61
|
-
faded = _series$seriesId.faded
|
|
51
|
+
faded = _series$seriesId.faded,
|
|
52
|
+
highlightScope = _series$seriesId.highlightScope;
|
|
62
53
|
return /*#__PURE__*/_jsx("g", {
|
|
63
54
|
transform: "translate(".concat(cx === undefined ? center.x : left + cx, ", ").concat(cy === undefined ? center.y : top + cy, ")"),
|
|
64
|
-
children: /*#__PURE__*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}), data.map(function (item, index) {
|
|
79
|
-
return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
|
|
80
|
-
key: item.id,
|
|
81
|
-
innerRadius: innerRadius,
|
|
82
|
-
outerRadius: outerRadius != null ? outerRadius : availableRadius,
|
|
83
|
-
cornerRadius: cornerRadius,
|
|
84
|
-
id: seriesId,
|
|
85
|
-
color: item.color,
|
|
86
|
-
dataIndex: index,
|
|
87
|
-
highlightScope: series[seriesId].highlightScope,
|
|
88
|
-
formattedArcLabel: getItemLabel(arcLabel, arcLabelMinAngle, item)
|
|
89
|
-
}, slotProps == null ? void 0 : slotProps.pieArcLabel));
|
|
90
|
-
})]
|
|
55
|
+
children: /*#__PURE__*/_jsx(PieArcPlot, {
|
|
56
|
+
innerRadius: innerRadius,
|
|
57
|
+
outerRadius: outerRadius != null ? outerRadius : availableRadius,
|
|
58
|
+
cornerRadius: cornerRadius,
|
|
59
|
+
paddingAngle: paddingAngle,
|
|
60
|
+
id: seriesId,
|
|
61
|
+
data: data,
|
|
62
|
+
skipAnimation: skipAnimation,
|
|
63
|
+
highlightScope: highlightScope,
|
|
64
|
+
highlighted: highlighted,
|
|
65
|
+
faded: faded,
|
|
66
|
+
onClick: onClick,
|
|
67
|
+
slots: slots,
|
|
68
|
+
slotProps: slotProps
|
|
91
69
|
})
|
|
92
70
|
}, seriesId);
|
|
93
|
-
})
|
|
71
|
+
}), seriesOrder.map(function (seriesId) {
|
|
72
|
+
var _series$seriesId2 = series[seriesId],
|
|
73
|
+
innerRadius = _series$seriesId2.innerRadius,
|
|
74
|
+
outerRadius = _series$seriesId2.outerRadius,
|
|
75
|
+
cornerRadius = _series$seriesId2.cornerRadius,
|
|
76
|
+
paddingAngle = _series$seriesId2.paddingAngle,
|
|
77
|
+
arcLabel = _series$seriesId2.arcLabel,
|
|
78
|
+
arcLabelMinAngle = _series$seriesId2.arcLabelMinAngle,
|
|
79
|
+
data = _series$seriesId2.data,
|
|
80
|
+
cx = _series$seriesId2.cx,
|
|
81
|
+
cy = _series$seriesId2.cy,
|
|
82
|
+
highlightScope = _series$seriesId2.highlightScope;
|
|
83
|
+
return /*#__PURE__*/_jsx("g", {
|
|
84
|
+
transform: "translate(".concat(cx === undefined ? center.x : left + cx, ", ").concat(cy === undefined ? center.y : top + cy, ")"),
|
|
85
|
+
children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
|
|
86
|
+
innerRadius: innerRadius,
|
|
87
|
+
outerRadius: outerRadius != null ? outerRadius : availableRadius,
|
|
88
|
+
cornerRadius: cornerRadius,
|
|
89
|
+
paddingAngle: paddingAngle,
|
|
90
|
+
id: seriesId,
|
|
91
|
+
data: data,
|
|
92
|
+
skipAnimation: skipAnimation,
|
|
93
|
+
arcLabel: arcLabel,
|
|
94
|
+
arcLabelMinAngle: arcLabelMinAngle,
|
|
95
|
+
highlightScope: highlightScope
|
|
96
|
+
})
|
|
97
|
+
}, seriesId);
|
|
98
|
+
})]
|
|
94
99
|
});
|
|
95
100
|
}
|
|
96
101
|
process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
@@ -98,6 +103,18 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
|
98
103
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
99
104
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
100
105
|
// ----------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Callback fired when a pie item is clicked.
|
|
108
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
109
|
+
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
110
|
+
* @param {DefaultizedPieValueType} item The pie item.
|
|
111
|
+
*/
|
|
112
|
+
onClick: PropTypes.func,
|
|
113
|
+
/**
|
|
114
|
+
* If `true`, animations are skiped.
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
skipAnimation: PropTypes.bool,
|
|
101
118
|
/**
|
|
102
119
|
* The props used for each component slot.
|
|
103
120
|
* @default {}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export var defaultTransitionConfig = {
|
|
2
|
+
keys: function keys(item) {
|
|
3
|
+
return item.id;
|
|
4
|
+
},
|
|
5
|
+
from: function from(_ref) {
|
|
6
|
+
var innerRadius = _ref.innerRadius,
|
|
7
|
+
outerRadius = _ref.outerRadius,
|
|
8
|
+
cornerRadius = _ref.cornerRadius,
|
|
9
|
+
startAngle = _ref.startAngle,
|
|
10
|
+
endAngle = _ref.endAngle,
|
|
11
|
+
paddingAngle = _ref.paddingAngle,
|
|
12
|
+
color = _ref.color,
|
|
13
|
+
isFaded = _ref.isFaded;
|
|
14
|
+
return {
|
|
15
|
+
innerRadius: innerRadius,
|
|
16
|
+
outerRadius: (innerRadius + outerRadius) / 2,
|
|
17
|
+
cornerRadius: cornerRadius,
|
|
18
|
+
startAngle: (startAngle + endAngle) / 2,
|
|
19
|
+
endAngle: (startAngle + endAngle) / 2,
|
|
20
|
+
paddingAngle: paddingAngle,
|
|
21
|
+
fill: color,
|
|
22
|
+
opacity: isFaded ? 0.3 : 1
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
leave: function leave(_ref2) {
|
|
26
|
+
var innerRadius = _ref2.innerRadius,
|
|
27
|
+
startAngle = _ref2.startAngle,
|
|
28
|
+
endAngle = _ref2.endAngle;
|
|
29
|
+
return {
|
|
30
|
+
innerRadius: innerRadius,
|
|
31
|
+
outerRadius: innerRadius,
|
|
32
|
+
startAngle: (startAngle + endAngle) / 2,
|
|
33
|
+
endAngle: (startAngle + endAngle) / 2
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
enter: function enter(_ref3) {
|
|
37
|
+
var innerRadius = _ref3.innerRadius,
|
|
38
|
+
outerRadius = _ref3.outerRadius,
|
|
39
|
+
startAngle = _ref3.startAngle,
|
|
40
|
+
endAngle = _ref3.endAngle;
|
|
41
|
+
return {
|
|
42
|
+
innerRadius: innerRadius,
|
|
43
|
+
outerRadius: outerRadius,
|
|
44
|
+
startAngle: startAngle,
|
|
45
|
+
endAngle: endAngle
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
update: function update(_ref4) {
|
|
49
|
+
var innerRadius = _ref4.innerRadius,
|
|
50
|
+
outerRadius = _ref4.outerRadius,
|
|
51
|
+
cornerRadius = _ref4.cornerRadius,
|
|
52
|
+
startAngle = _ref4.startAngle,
|
|
53
|
+
endAngle = _ref4.endAngle,
|
|
54
|
+
paddingAngle = _ref4.paddingAngle,
|
|
55
|
+
color = _ref4.color,
|
|
56
|
+
isFaded = _ref4.isFaded;
|
|
57
|
+
return {
|
|
58
|
+
innerRadius: innerRadius,
|
|
59
|
+
outerRadius: outerRadius,
|
|
60
|
+
cornerRadius: cornerRadius,
|
|
61
|
+
startAngle: startAngle,
|
|
62
|
+
endAngle: endAngle,
|
|
63
|
+
paddingAngle: paddingAngle,
|
|
64
|
+
fill: color,
|
|
65
|
+
opacity: isFaded ? 0.3 : 1
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
config: {
|
|
69
|
+
tension: 120,
|
|
70
|
+
friction: 14,
|
|
71
|
+
clamp: true
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export var defaultLabelTransitionConfig = {
|
|
75
|
+
keys: function keys(item) {
|
|
76
|
+
return item.id;
|
|
77
|
+
},
|
|
78
|
+
from: function from(_ref5) {
|
|
79
|
+
var innerRadius = _ref5.innerRadius,
|
|
80
|
+
outerRadius = _ref5.outerRadius,
|
|
81
|
+
cornerRadius = _ref5.cornerRadius,
|
|
82
|
+
startAngle = _ref5.startAngle,
|
|
83
|
+
endAngle = _ref5.endAngle,
|
|
84
|
+
paddingAngle = _ref5.paddingAngle;
|
|
85
|
+
return {
|
|
86
|
+
innerRadius: innerRadius,
|
|
87
|
+
outerRadius: (innerRadius + outerRadius) / 2,
|
|
88
|
+
cornerRadius: cornerRadius,
|
|
89
|
+
startAngle: (startAngle + endAngle) / 2,
|
|
90
|
+
endAngle: (startAngle + endAngle) / 2,
|
|
91
|
+
paddingAngle: paddingAngle,
|
|
92
|
+
opacity: 0
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
leave: function leave(_ref6) {
|
|
96
|
+
var innerRadius = _ref6.innerRadius,
|
|
97
|
+
startAngle = _ref6.startAngle,
|
|
98
|
+
endAngle = _ref6.endAngle;
|
|
99
|
+
return {
|
|
100
|
+
innerRadius: innerRadius,
|
|
101
|
+
outerRadius: innerRadius,
|
|
102
|
+
startAngle: (startAngle + endAngle) / 2,
|
|
103
|
+
endAngle: (startAngle + endAngle) / 2,
|
|
104
|
+
opacity: 0
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
enter: function enter(_ref7) {
|
|
108
|
+
var innerRadius = _ref7.innerRadius,
|
|
109
|
+
outerRadius = _ref7.outerRadius,
|
|
110
|
+
startAngle = _ref7.startAngle,
|
|
111
|
+
endAngle = _ref7.endAngle;
|
|
112
|
+
return {
|
|
113
|
+
innerRadius: innerRadius,
|
|
114
|
+
outerRadius: outerRadius,
|
|
115
|
+
startAngle: startAngle,
|
|
116
|
+
endAngle: endAngle,
|
|
117
|
+
opacity: 1
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
update: function update(_ref8) {
|
|
121
|
+
var innerRadius = _ref8.innerRadius,
|
|
122
|
+
outerRadius = _ref8.outerRadius,
|
|
123
|
+
cornerRadius = _ref8.cornerRadius,
|
|
124
|
+
startAngle = _ref8.startAngle,
|
|
125
|
+
endAngle = _ref8.endAngle,
|
|
126
|
+
paddingAngle = _ref8.paddingAngle;
|
|
127
|
+
return {
|
|
128
|
+
innerRadius: innerRadius,
|
|
129
|
+
outerRadius: outerRadius,
|
|
130
|
+
cornerRadius: cornerRadius,
|
|
131
|
+
startAngle: startAngle,
|
|
132
|
+
endAngle: endAngle,
|
|
133
|
+
paddingAngle: paddingAngle,
|
|
134
|
+
opacity: 1
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
config: {
|
|
138
|
+
tension: 120,
|
|
139
|
+
friction: 14,
|
|
140
|
+
clamp: true
|
|
141
|
+
}
|
|
142
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { InteractionContext } from '../../context/InteractionProvider';
|
|
4
|
+
import { getIsHighlighted, getIsFaded } from '../../hooks/useInteractionItemProps';
|
|
5
|
+
export function useTransformData(series) {
|
|
6
|
+
var seriesId = series.id,
|
|
7
|
+
highlightScope = series.highlightScope,
|
|
8
|
+
data = series.data,
|
|
9
|
+
faded = series.faded,
|
|
10
|
+
highlighted = series.highlighted,
|
|
11
|
+
_series$paddingAngle = series.paddingAngle,
|
|
12
|
+
basePaddingAngle = _series$paddingAngle === void 0 ? 0 : _series$paddingAngle,
|
|
13
|
+
_series$innerRadius = series.innerRadius,
|
|
14
|
+
baseInnerRadius = _series$innerRadius === void 0 ? 0 : _series$innerRadius,
|
|
15
|
+
baseOuterRadius = series.outerRadius,
|
|
16
|
+
_series$cornerRadius = series.cornerRadius,
|
|
17
|
+
baseCornerRadius = _series$cornerRadius === void 0 ? 0 : _series$cornerRadius;
|
|
18
|
+
var _React$useContext = React.useContext(InteractionContext),
|
|
19
|
+
highlightedItem = _React$useContext.item;
|
|
20
|
+
var getHighlightStatus = React.useCallback(function (dataIndex) {
|
|
21
|
+
var isHighlighted = getIsHighlighted(highlightedItem, {
|
|
22
|
+
type: 'pie',
|
|
23
|
+
seriesId: seriesId,
|
|
24
|
+
dataIndex: dataIndex
|
|
25
|
+
}, highlightScope);
|
|
26
|
+
var isFaded = !isHighlighted && getIsFaded(highlightedItem, {
|
|
27
|
+
type: 'pie',
|
|
28
|
+
seriesId: seriesId,
|
|
29
|
+
dataIndex: dataIndex
|
|
30
|
+
}, highlightScope);
|
|
31
|
+
return {
|
|
32
|
+
isHighlighted: isHighlighted,
|
|
33
|
+
isFaded: isFaded
|
|
34
|
+
};
|
|
35
|
+
}, [highlightScope, highlightedItem, seriesId]);
|
|
36
|
+
var dataWithHighlight = React.useMemo(function () {
|
|
37
|
+
return data.map(function (item, itemIndex) {
|
|
38
|
+
var _attibuesOverride$pad, _attibuesOverride$inn, _attibuesOverride$out, _attibuesOverride$cor;
|
|
39
|
+
var _getHighlightStatus = getHighlightStatus(itemIndex),
|
|
40
|
+
isHighlighted = _getHighlightStatus.isHighlighted,
|
|
41
|
+
isFaded = _getHighlightStatus.isFaded;
|
|
42
|
+
var attibuesOverride = _extends({
|
|
43
|
+
additionalRadius: 0
|
|
44
|
+
}, isFaded && faded || isHighlighted && highlighted || {});
|
|
45
|
+
var paddingAngle = Math.max(0, Math.PI * ((_attibuesOverride$pad = attibuesOverride.paddingAngle) != null ? _attibuesOverride$pad : basePaddingAngle) / 180);
|
|
46
|
+
var innerRadius = Math.max(0, (_attibuesOverride$inn = attibuesOverride.innerRadius) != null ? _attibuesOverride$inn : baseInnerRadius);
|
|
47
|
+
var outerRadius = Math.max(0, (_attibuesOverride$out = attibuesOverride.outerRadius) != null ? _attibuesOverride$out : baseOuterRadius + attibuesOverride.additionalRadius);
|
|
48
|
+
var cornerRadius = (_attibuesOverride$cor = attibuesOverride.cornerRadius) != null ? _attibuesOverride$cor : baseCornerRadius;
|
|
49
|
+
return _extends({}, item, attibuesOverride, {
|
|
50
|
+
isFaded: isFaded,
|
|
51
|
+
isHighlighted: isHighlighted,
|
|
52
|
+
paddingAngle: paddingAngle,
|
|
53
|
+
innerRadius: innerRadius,
|
|
54
|
+
outerRadius: outerRadius,
|
|
55
|
+
cornerRadius: cornerRadius
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}, [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, data, faded, getHighlightStatus, highlighted]);
|
|
59
|
+
return dataWithHighlight;
|
|
60
|
+
}
|