@mui/x-charts 7.0.0-beta.0 → 7.0.0-beta.2
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 +2 -1
- package/BarChart/BarChart.js +33 -12
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +7 -3
- package/BarChart/BarPlot.d.ts +11 -6
- package/BarChart/BarPlot.js +28 -15
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +406 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +20 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +83 -0
- package/ChartsOnAxisClickHandler/index.d.ts +1 -0
- package/ChartsOnAxisClickHandler/index.js +16 -0
- package/ChartsOnAxisClickHandler/package.json +6 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsReferenceLine/common.d.ts +2 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -5
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +4 -1
- package/ChartsTooltip/utils.js +15 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/ChartsXAxis/ChartsXAxis.js +13 -9
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- package/LineChart/AnimatedArea.d.ts +1361 -0
- package/LineChart/AnimatedArea.js +111 -0
- package/LineChart/AnimatedLine.d.ts +1361 -0
- package/LineChart/AnimatedLine.js +113 -0
- package/LineChart/AreaElement.d.ts +19 -18
- package/LineChart/AreaElement.js +17 -34
- package/LineChart/AreaPlot.d.ts +12 -7
- package/LineChart/AreaPlot.js +91 -58
- package/LineChart/LineChart.d.ts +13 -4
- package/LineChart/LineChart.js +45 -14
- package/LineChart/LineElement.d.ts +19 -18
- package/LineChart/LineElement.js +16 -36
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +5 -3
- package/LineChart/LinePlot.d.ts +12 -7
- package/LineChart/LinePlot.js +89 -56
- package/LineChart/MarkElement.d.ts +8 -4
- package/LineChart/MarkElement.js +27 -13
- package/LineChart/MarkPlot.d.ts +8 -1
- package/LineChart/MarkPlot.js +80 -51
- package/LineChart/formatter.js +1 -1
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +22 -0
- package/PieChart/PieArc.d.ts +3 -2
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +2 -2
- package/PieChart/PieArcPlot.d.ts +2 -2
- package/PieChart/PieArcPlot.js +7 -7
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +14 -12
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -4
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/ScatterChart/Scatter.d.ts +7 -1
- package/ScatterChart/Scatter.js +17 -3
- package/ScatterChart/ScatterChart.d.ts +8 -2
- package/ScatterChart/ScatterChart.js +21 -10
- package/ScatterChart/ScatterPlot.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +10 -2
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +7 -4
- package/context/CartesianContextProvider.js +8 -6
- package/context/DrawingProvider.d.ts +6 -1
- package/context/DrawingProvider.js +9 -2
- package/context/InteractionProvider.d.ts +3 -3
- package/esm/BarChart/BarChart.js +33 -12
- package/esm/BarChart/BarElement.js +7 -3
- package/esm/BarChart/BarPlot.js +27 -15
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
- package/esm/ChartsOnAxisClickHandler/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -5
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +12 -0
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- package/esm/LineChart/AnimatedArea.js +103 -0
- package/esm/LineChart/AnimatedLine.js +105 -0
- package/esm/LineChart/AreaElement.js +16 -33
- package/esm/LineChart/AreaPlot.js +92 -59
- package/esm/LineChart/LineChart.js +45 -14
- package/esm/LineChart/LineElement.js +16 -35
- package/esm/LineChart/LineHighlightElement.js +5 -3
- package/esm/LineChart/LinePlot.js +90 -57
- package/esm/LineChart/MarkElement.js +27 -13
- package/esm/LineChart/MarkPlot.js +80 -51
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/index.js +2 -0
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +2 -2
- package/esm/PieChart/PieArcPlot.js +7 -7
- package/esm/PieChart/PieChart.js +14 -12
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/esm/ScatterChart/Scatter.js +17 -3
- package/esm/ScatterChart/ScatterChart.js +21 -10
- package/esm/ScatterChart/ScatterPlot.js +10 -2
- package/esm/SparkLineChart/SparkLineChart.js +7 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/hooks/useDrawingArea.js +7 -3
- package/esm/index.js +1 -0
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/useAnimatedPath.js +29 -0
- package/esm/internals/utils.js +7 -0
- package/hooks/useDrawingArea.d.ts +2 -0
- package/hooks/useDrawingArea.js +7 -3
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/geometry.js +1 -1
- package/internals/stackSeries.d.ts +4 -7
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +38 -0
- package/internals/utils.d.ts +4 -0
- package/internals/utils.js +8 -0
- package/legacy/BarChart/BarChart.js +33 -12
- package/legacy/BarChart/BarElement.js +6 -2
- package/legacy/BarChart/BarPlot.js +28 -14
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +6 -7
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -5
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +12 -0
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
- package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
- package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
- package/legacy/LineChart/AnimatedArea.js +102 -0
- package/legacy/LineChart/AnimatedLine.js +104 -0
- package/legacy/LineChart/AreaElement.js +15 -35
- package/legacy/LineChart/AreaPlot.js +102 -66
- package/legacy/LineChart/LineChart.js +45 -14
- package/legacy/LineChart/LineElement.js +15 -37
- package/legacy/LineChart/LineHighlightElement.js +5 -3
- package/legacy/LineChart/LinePlot.js +97 -63
- package/legacy/LineChart/MarkElement.js +30 -12
- package/legacy/LineChart/MarkPlot.js +83 -53
- package/legacy/LineChart/formatter.js +1 -1
- package/legacy/LineChart/index.js +2 -0
- package/legacy/PieChart/PieArc.js +1 -0
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +2 -2
- package/legacy/PieChart/PieArcPlot.js +7 -7
- package/legacy/PieChart/PieChart.js +14 -12
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/legacy/ScatterChart/Scatter.js +19 -3
- package/legacy/ScatterChart/ScatterChart.js +21 -10
- package/legacy/ScatterChart/ScatterPlot.js +10 -2
- package/legacy/SparkLineChart/SparkLineChart.js +8 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- package/legacy/context/DrawingProvider.js +11 -2
- package/legacy/hooks/useDrawingArea.js +7 -3
- package/legacy/index.js +2 -1
- package/legacy/internals/geometry.js +1 -1
- package/legacy/internals/useAnimatedPath.js +32 -0
- package/legacy/internals/utils.js +7 -0
- package/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +33 -12
- package/modern/BarChart/BarElement.js +7 -3
- package/modern/BarChart/BarPlot.js +27 -15
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/modern/ChartsOnAxisClickHandler/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -5
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +12 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- package/modern/LineChart/AnimatedArea.js +103 -0
- package/modern/LineChart/AnimatedLine.js +105 -0
- package/modern/LineChart/AreaElement.js +16 -33
- package/modern/LineChart/AreaPlot.js +91 -58
- package/modern/LineChart/LineChart.js +45 -14
- package/modern/LineChart/LineElement.js +16 -35
- package/modern/LineChart/LineHighlightElement.js +5 -3
- package/modern/LineChart/LinePlot.js +89 -56
- package/modern/LineChart/MarkElement.js +27 -13
- package/modern/LineChart/MarkPlot.js +80 -51
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/index.js +2 -0
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +2 -2
- package/modern/PieChart/PieArcPlot.js +7 -7
- package/modern/PieChart/PieChart.js +14 -12
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/modern/ScatterChart/Scatter.js +17 -3
- package/modern/ScatterChart/ScatterChart.js +21 -10
- package/modern/ScatterChart/ScatterPlot.js +10 -2
- package/modern/SparkLineChart/SparkLineChart.js +7 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/hooks/useDrawingArea.js +7 -3
- package/modern/index.js +2 -1
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/useAnimatedPath.js +29 -0
- package/modern/internals/utils.js +7 -0
- package/package.json +6 -5
|
@@ -59,19 +59,21 @@ function LineHighlightElement(props) {
|
|
|
59
59
|
y: y
|
|
60
60
|
};
|
|
61
61
|
var classes = useUtilityClasses(ownerState);
|
|
62
|
-
return /*#__PURE__*/_jsx(HighlightElement, _extends({
|
|
62
|
+
return /*#__PURE__*/_jsx(HighlightElement, _extends({
|
|
63
|
+
pointerEvents: "none",
|
|
63
64
|
ownerState: ownerState,
|
|
64
65
|
className: classes.root,
|
|
65
66
|
cx: 0,
|
|
66
67
|
cy: 0,
|
|
67
68
|
r: other.r === undefined ? 5 : other.r
|
|
68
|
-
}));
|
|
69
|
+
}, other));
|
|
69
70
|
}
|
|
70
71
|
process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
71
72
|
// ----------------------------- Warning --------------------------------
|
|
72
73
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
73
74
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
74
75
|
// ----------------------------------------------------------------------
|
|
75
|
-
classes: PropTypes.object
|
|
76
|
+
classes: PropTypes.object,
|
|
77
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
|
|
76
78
|
} : void 0;
|
|
77
79
|
export { LineHighlightElement };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
var _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { line as d3Line } from 'd3-shape';
|
|
@@ -11,6 +11,68 @@ import { getValueToPositionMapper } from '../hooks/useScale';
|
|
|
11
11
|
import getCurveFactory from '../internals/getCurve';
|
|
12
12
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
var useAggregatedData = function useAggregatedData() {
|
|
15
|
+
var seriesData = React.useContext(SeriesContext).line;
|
|
16
|
+
var axisData = React.useContext(CartesianContext);
|
|
17
|
+
if (seriesData === undefined) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
var series = seriesData.series,
|
|
21
|
+
stackingGroups = seriesData.stackingGroups;
|
|
22
|
+
var xAxis = axisData.xAxis,
|
|
23
|
+
yAxis = axisData.yAxis,
|
|
24
|
+
xAxisIds = axisData.xAxisIds,
|
|
25
|
+
yAxisIds = axisData.yAxisIds;
|
|
26
|
+
var defaultXAxisId = xAxisIds[0];
|
|
27
|
+
var defaultYAxisId = yAxisIds[0];
|
|
28
|
+
return stackingGroups.flatMap(function (_ref) {
|
|
29
|
+
var groupIds = _ref.ids;
|
|
30
|
+
return groupIds.flatMap(function (seriesId) {
|
|
31
|
+
var _xData$map;
|
|
32
|
+
var _series$seriesId = series[seriesId],
|
|
33
|
+
_series$seriesId$xAxi = _series$seriesId.xAxisKey,
|
|
34
|
+
xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
|
|
35
|
+
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
36
|
+
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
37
|
+
stackedData = _series$seriesId.stackedData,
|
|
38
|
+
data = _series$seriesId.data,
|
|
39
|
+
connectNulls = _series$seriesId.connectNulls;
|
|
40
|
+
var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
41
|
+
var yScale = yAxis[yAxisKey].scale;
|
|
42
|
+
var xData = xAxis[xAxisKey].data;
|
|
43
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
44
|
+
if (xData === undefined) {
|
|
45
|
+
throw new Error("MUI X Charts: ".concat(xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : "The x-axis with id \"".concat(xAxisKey, "\""), " should have data property to be able to display a line plot."));
|
|
46
|
+
}
|
|
47
|
+
if (xData.length < stackedData.length) {
|
|
48
|
+
throw new Error("MUI X Charts: The data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)."));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var linePath = d3Line().x(function (d) {
|
|
52
|
+
return xScale(d.x);
|
|
53
|
+
}).defined(function (_, i) {
|
|
54
|
+
return connectNulls || data[i] != null;
|
|
55
|
+
}).y(function (d) {
|
|
56
|
+
return yScale(d.y[1]);
|
|
57
|
+
});
|
|
58
|
+
var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
59
|
+
return {
|
|
60
|
+
x: x,
|
|
61
|
+
y: stackedData[index]
|
|
62
|
+
};
|
|
63
|
+
})) != null ? _xData$map : [];
|
|
64
|
+
var d3Data = connectNulls ? formattedData.filter(function (_, i) {
|
|
65
|
+
return data[i] != null;
|
|
66
|
+
}) : formattedData;
|
|
67
|
+
var d = linePath.curve(getCurveFactory(series[seriesId].curve))(d3Data) || '';
|
|
68
|
+
return _extends({}, series[seriesId], {
|
|
69
|
+
d: d,
|
|
70
|
+
seriesId: seriesId
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
14
76
|
/**
|
|
15
77
|
* Demos:
|
|
16
78
|
*
|
|
@@ -24,70 +86,31 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
86
|
function LinePlot(props) {
|
|
25
87
|
var slots = props.slots,
|
|
26
88
|
slotProps = props.slotProps,
|
|
89
|
+
skipAnimation = props.skipAnimation,
|
|
90
|
+
onItemClick = props.onItemClick,
|
|
27
91
|
other = _objectWithoutProperties(props, _excluded);
|
|
28
|
-
var
|
|
29
|
-
var axisData = React.useContext(CartesianContext);
|
|
30
|
-
if (seriesData === undefined) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
var series = seriesData.series,
|
|
34
|
-
stackingGroups = seriesData.stackingGroups;
|
|
35
|
-
var xAxis = axisData.xAxis,
|
|
36
|
-
yAxis = axisData.yAxis,
|
|
37
|
-
xAxisIds = axisData.xAxisIds,
|
|
38
|
-
yAxisIds = axisData.yAxisIds;
|
|
39
|
-
var defaultXAxisId = xAxisIds[0];
|
|
40
|
-
var defaultYAxisId = yAxisIds[0];
|
|
92
|
+
var completedData = useAggregatedData();
|
|
41
93
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
42
|
-
children:
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
if (xData.length < stackedData.length) {
|
|
62
|
-
throw new Error("MUI X Charts: The data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)."));
|
|
63
|
-
}
|
|
94
|
+
children: completedData.map(function (_ref2) {
|
|
95
|
+
var d = _ref2.d,
|
|
96
|
+
seriesId = _ref2.seriesId,
|
|
97
|
+
color = _ref2.color,
|
|
98
|
+
highlightScope = _ref2.highlightScope;
|
|
99
|
+
return /*#__PURE__*/_jsx(LineElement, {
|
|
100
|
+
id: seriesId,
|
|
101
|
+
d: d,
|
|
102
|
+
color: color,
|
|
103
|
+
highlightScope: highlightScope,
|
|
104
|
+
skipAnimation: skipAnimation,
|
|
105
|
+
slots: slots,
|
|
106
|
+
slotProps: slotProps,
|
|
107
|
+
onClick: onItemClick && function (event) {
|
|
108
|
+
return onItemClick(event, {
|
|
109
|
+
type: 'line',
|
|
110
|
+
seriesId: seriesId
|
|
111
|
+
});
|
|
64
112
|
}
|
|
65
|
-
|
|
66
|
-
return xScale(d.x);
|
|
67
|
-
}).defined(function (_, i) {
|
|
68
|
-
return connectNulls || data[i] != null;
|
|
69
|
-
}).y(function (d) {
|
|
70
|
-
return yScale(d.y[1]);
|
|
71
|
-
});
|
|
72
|
-
var curve = getCurveFactory(series[seriesId].curve);
|
|
73
|
-
var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
74
|
-
return {
|
|
75
|
-
x: x,
|
|
76
|
-
y: stackedData[index]
|
|
77
|
-
};
|
|
78
|
-
})) != null ? _xData$map : [];
|
|
79
|
-
var d3Data = connectNulls ? formattedData.filter(function (_, i) {
|
|
80
|
-
return data[i] != null;
|
|
81
|
-
}) : formattedData;
|
|
82
|
-
return /*#__PURE__*/_jsx(LineElement, {
|
|
83
|
-
id: seriesId,
|
|
84
|
-
d: linePath.curve(curve)(d3Data) || undefined,
|
|
85
|
-
color: series[seriesId].color,
|
|
86
|
-
highlightScope: series[seriesId].highlightScope,
|
|
87
|
-
slots: slots,
|
|
88
|
-
slotProps: slotProps
|
|
89
|
-
}, seriesId);
|
|
90
|
-
});
|
|
113
|
+
}, seriesId);
|
|
91
114
|
})
|
|
92
115
|
}));
|
|
93
116
|
}
|
|
@@ -96,6 +119,17 @@ process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
|
|
|
96
119
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
97
120
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
98
121
|
// ----------------------------------------------------------------------
|
|
122
|
+
/**
|
|
123
|
+
* Callback fired when a line item is clicked.
|
|
124
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
125
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
|
|
126
|
+
*/
|
|
127
|
+
onItemClick: PropTypes.func,
|
|
128
|
+
/**
|
|
129
|
+
* If `true`, animations are skipped.
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
skipAnimation: PropTypes.bool,
|
|
99
133
|
/**
|
|
100
134
|
* The props used for each component slot.
|
|
101
135
|
* @default {}
|
|
@@ -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 = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "highlightScope"];
|
|
3
|
+
var _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "highlightScope", "onClick", "skipAnimation"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
@@ -8,6 +8,7 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
10
|
import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
|
|
11
|
+
import { animated, to, useSpring } from '@react-spring/web';
|
|
11
12
|
import { getSymbol } from '../internals/utils';
|
|
12
13
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
13
14
|
import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
@@ -26,7 +27,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
26
27
|
};
|
|
27
28
|
return composeClasses(slots, getMarkElementUtilityClass, classes);
|
|
28
29
|
};
|
|
29
|
-
var MarkElementPath = styled(
|
|
30
|
+
var MarkElementPath = styled(animated.path, {
|
|
30
31
|
name: 'MuiMarkElement',
|
|
31
32
|
slot: 'Root',
|
|
32
33
|
overridesResolver: function overridesResolver(_, styles) {
|
|
@@ -36,8 +37,6 @@ var MarkElementPath = styled('path', {
|
|
|
36
37
|
var ownerState = _ref.ownerState,
|
|
37
38
|
theme = _ref.theme;
|
|
38
39
|
return {
|
|
39
|
-
transform: "translate(".concat(ownerState.x, "px, ").concat(ownerState.y, "px)"),
|
|
40
|
-
transformOrigin: "".concat(ownerState.x, "px ").concat(ownerState.y, "px"),
|
|
41
40
|
fill: (theme.vars || theme).palette.background.paper,
|
|
42
41
|
stroke: ownerState.color,
|
|
43
42
|
strokeWidth: 2
|
|
@@ -54,9 +53,7 @@ MarkElementPath.propTypes = {
|
|
|
54
53
|
color: PropTypes.string.isRequired,
|
|
55
54
|
id: PropTypes.string.isRequired,
|
|
56
55
|
isFaded: PropTypes.bool.isRequired,
|
|
57
|
-
isHighlighted: PropTypes.bool.isRequired
|
|
58
|
-
x: PropTypes.number.isRequired,
|
|
59
|
-
y: PropTypes.number.isRequired
|
|
56
|
+
isHighlighted: PropTypes.bool.isRequired
|
|
60
57
|
}).isRequired,
|
|
61
58
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
62
59
|
};
|
|
@@ -80,6 +77,8 @@ function MarkElement(props) {
|
|
|
80
77
|
shape = props.shape,
|
|
81
78
|
dataIndex = props.dataIndex,
|
|
82
79
|
highlightScope = props.highlightScope,
|
|
80
|
+
onClick = props.onClick,
|
|
81
|
+
skipAnimation = props.skipAnimation,
|
|
83
82
|
other = _objectWithoutProperties(props, _excluded);
|
|
84
83
|
var getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
85
84
|
var _React$useContext = React.useContext(InteractionContext),
|
|
@@ -93,20 +92,33 @@ function MarkElement(props) {
|
|
|
93
92
|
type: 'line',
|
|
94
93
|
seriesId: id
|
|
95
94
|
}, highlightScope);
|
|
95
|
+
var position = useSpring({
|
|
96
|
+
x: x,
|
|
97
|
+
y: y,
|
|
98
|
+
immediate: skipAnimation
|
|
99
|
+
});
|
|
96
100
|
var ownerState = {
|
|
97
101
|
id: id,
|
|
98
102
|
classes: innerClasses,
|
|
99
103
|
isHighlighted: isHighlighted,
|
|
100
104
|
isFaded: isFaded,
|
|
101
|
-
color: color
|
|
102
|
-
x: x,
|
|
103
|
-
y: y
|
|
105
|
+
color: color
|
|
104
106
|
};
|
|
105
107
|
var classes = useUtilityClasses(ownerState);
|
|
106
108
|
return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, {
|
|
109
|
+
style: {
|
|
110
|
+
transform: to([position.x, position.y], function (pX, pY) {
|
|
111
|
+
return "translate(".concat(pX, "px, ").concat(pY, "px)");
|
|
112
|
+
}),
|
|
113
|
+
transformOrigin: to([position.x, position.y], function (pX, pY) {
|
|
114
|
+
return "".concat(pX, "px ").concat(pY, "px");
|
|
115
|
+
})
|
|
116
|
+
},
|
|
107
117
|
ownerState: ownerState,
|
|
108
118
|
className: classes.root,
|
|
109
|
-
d: d3Symbol(d3SymbolsFill[getSymbol(shape)])()
|
|
119
|
+
d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
|
|
120
|
+
onClick: onClick,
|
|
121
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
110
122
|
}, getInteractionItemProps({
|
|
111
123
|
type: 'line',
|
|
112
124
|
seriesId: id,
|
|
@@ -127,9 +139,15 @@ process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
|
|
|
127
139
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
128
140
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
129
141
|
}),
|
|
142
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
130
143
|
/**
|
|
131
144
|
* The shape of the marker.
|
|
132
145
|
*/
|
|
133
|
-
shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired
|
|
146
|
+
shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired,
|
|
147
|
+
/**
|
|
148
|
+
* If `true`, animations are skipped.
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
skipAnimation: PropTypes.bool
|
|
134
152
|
} : void 0;
|
|
135
153
|
export { MarkElement };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["slots", "slotProps"];
|
|
4
|
+
var _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
@@ -9,6 +9,8 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
9
9
|
import { MarkElement } from './MarkElement';
|
|
10
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
11
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
12
|
+
import { DrawingContext } from '../context/DrawingProvider';
|
|
13
|
+
import { cleanId } from '../internals/utils';
|
|
12
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
15
|
/**
|
|
14
16
|
* Demos:
|
|
@@ -24,9 +26,13 @@ function MarkPlot(props) {
|
|
|
24
26
|
var _slots$mark;
|
|
25
27
|
var slots = props.slots,
|
|
26
28
|
slotProps = props.slotProps,
|
|
29
|
+
skipAnimation = props.skipAnimation,
|
|
30
|
+
onItemClick = props.onItemClick,
|
|
27
31
|
other = _objectWithoutProperties(props, _excluded);
|
|
28
32
|
var seriesData = React.useContext(SeriesContext).line;
|
|
29
33
|
var axisData = React.useContext(CartesianContext);
|
|
34
|
+
var _React$useContext = React.useContext(DrawingContext),
|
|
35
|
+
chartId = _React$useContext.chartId;
|
|
30
36
|
var Mark = (_slots$mark = slots == null ? void 0 : slots.mark) != null ? _slots$mark : MarkElement;
|
|
31
37
|
if (seriesData === undefined) {
|
|
32
38
|
return null;
|
|
@@ -42,7 +48,7 @@ function MarkPlot(props) {
|
|
|
42
48
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
43
49
|
children: stackingGroups.flatMap(function (_ref) {
|
|
44
50
|
var groupIds = _ref.ids;
|
|
45
|
-
return groupIds.
|
|
51
|
+
return groupIds.map(function (seriesId) {
|
|
46
52
|
var _series$seriesId = series[seriesId],
|
|
47
53
|
_series$seriesId$xAxi = _series$seriesId.xAxisKey,
|
|
48
54
|
xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
|
|
@@ -74,57 +80,70 @@ function MarkPlot(props) {
|
|
|
74
80
|
if (xData === undefined) {
|
|
75
81
|
throw new Error("MUI X Charts: ".concat(xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : "The x-axis with id \"".concat(xAxisKey, "\""), " should have data property to be able to display a line plot."));
|
|
76
82
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
83
|
+
var clipId = cleanId("".concat(chartId, "-").concat(seriesId, "-line-clip")); // We assume that if displaying line mark, the line will also be rendered
|
|
84
|
+
|
|
85
|
+
return /*#__PURE__*/_jsx("g", {
|
|
86
|
+
clipPath: "url(#".concat(clipId, ")"),
|
|
87
|
+
children: xData == null ? void 0 : xData.map(function (x, index) {
|
|
88
|
+
var value = data[index] == null ? null : stackedData[index][1];
|
|
89
|
+
return {
|
|
90
|
+
x: xScale(x),
|
|
91
|
+
y: value === null ? null : yScale(value),
|
|
92
|
+
position: x,
|
|
93
|
+
value: value,
|
|
94
|
+
index: index
|
|
95
|
+
};
|
|
96
|
+
}).filter(function (_ref3) {
|
|
97
|
+
var x = _ref3.x,
|
|
98
|
+
y = _ref3.y,
|
|
99
|
+
index = _ref3.index,
|
|
100
|
+
position = _ref3.position,
|
|
101
|
+
value = _ref3.value;
|
|
102
|
+
if (value === null || y === null) {
|
|
103
|
+
// Remove missing data point
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (!isInRange({
|
|
107
|
+
x: x,
|
|
108
|
+
y: y
|
|
109
|
+
})) {
|
|
110
|
+
// Remove out of range
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (showMark === true) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return showMark({
|
|
117
|
+
x: x,
|
|
118
|
+
y: y,
|
|
119
|
+
index: index,
|
|
120
|
+
position: position,
|
|
121
|
+
value: value
|
|
122
|
+
});
|
|
123
|
+
}).map(function (_ref4) {
|
|
124
|
+
var x = _ref4.x,
|
|
125
|
+
y = _ref4.y,
|
|
126
|
+
index = _ref4.index;
|
|
127
|
+
return /*#__PURE__*/_jsx(Mark, _extends({
|
|
128
|
+
id: seriesId,
|
|
129
|
+
dataIndex: index,
|
|
130
|
+
shape: "circle",
|
|
131
|
+
color: series[seriesId].color,
|
|
132
|
+
x: x,
|
|
133
|
+
y: y // Don't know why TS doesn't get from the filter that y can't be null
|
|
134
|
+
,
|
|
135
|
+
highlightScope: series[seriesId].highlightScope,
|
|
136
|
+
skipAnimation: skipAnimation,
|
|
137
|
+
onClick: onItemClick && function (event) {
|
|
138
|
+
return onItemClick(event, {
|
|
139
|
+
type: 'line',
|
|
140
|
+
seriesId: seriesId,
|
|
141
|
+
dataIndex: index
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}, slotProps == null ? void 0 : slotProps.mark), "".concat(seriesId, "-").concat(index));
|
|
145
|
+
})
|
|
146
|
+
}, seriesId);
|
|
128
147
|
});
|
|
129
148
|
})
|
|
130
149
|
}));
|
|
@@ -134,6 +153,17 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
|
|
|
134
153
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
135
154
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
136
155
|
// ----------------------------------------------------------------------
|
|
156
|
+
/**
|
|
157
|
+
* Callback fired when a line mark item is clicked.
|
|
158
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
159
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line mark item identifier.
|
|
160
|
+
*/
|
|
161
|
+
onItemClick: PropTypes.func,
|
|
162
|
+
/**
|
|
163
|
+
* If `true`, animations are skipped.
|
|
164
|
+
* @default false
|
|
165
|
+
*/
|
|
166
|
+
skipAnimation: PropTypes.bool,
|
|
137
167
|
/**
|
|
138
168
|
* The props used for each component slot.
|
|
139
169
|
* @default {}
|
|
@@ -75,7 +75,7 @@ var formatter = function formatter(params, dataset) {
|
|
|
75
75
|
seriesOrder: seriesOrder,
|
|
76
76
|
stackingGroups: stackingGroups,
|
|
77
77
|
series: defaultizeValueFormatter(completedSeries, function (v) {
|
|
78
|
-
return v
|
|
78
|
+
return v == null ? '' : v.toLocaleString();
|
|
79
79
|
})
|
|
80
80
|
};
|
|
81
81
|
};
|
|
@@ -4,6 +4,8 @@ export * from './AreaPlot';
|
|
|
4
4
|
export * from './MarkPlot';
|
|
5
5
|
export * from './LineHighlightPlot';
|
|
6
6
|
export * from './AreaElement';
|
|
7
|
+
export * from './AnimatedArea';
|
|
7
8
|
export * from './LineElement';
|
|
9
|
+
export * from './AnimatedLine';
|
|
8
10
|
export * from './MarkElement';
|
|
9
11
|
export * from './LineHighlightElement';
|
|
@@ -96,6 +96,7 @@ process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
|
|
|
96
96
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
97
97
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
98
98
|
}),
|
|
99
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
99
100
|
isFaded: PropTypes.bool.isRequired,
|
|
100
101
|
isHighlighted: PropTypes.bool.isRequired
|
|
101
102
|
} : void 0;
|
|
@@ -105,6 +105,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
|
105
105
|
// ----------------------------------------------------------------------
|
|
106
106
|
classes: PropTypes.object,
|
|
107
107
|
formattedArcLabel: PropTypes.string,
|
|
108
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
108
109
|
isFaded: PropTypes.bool.isRequired,
|
|
109
110
|
isHighlighted: PropTypes.bool.isRequired
|
|
110
111
|
} : void 0;
|
|
@@ -159,7 +159,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
159
159
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
160
160
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
161
161
|
}),
|
|
162
|
-
id: PropTypes.string.isRequired,
|
|
162
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
163
163
|
/**
|
|
164
164
|
* The radius between circle center and the begining of the arc.
|
|
165
165
|
* @default 0
|
|
@@ -175,7 +175,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
175
175
|
*/
|
|
176
176
|
paddingAngle: PropTypes.number,
|
|
177
177
|
/**
|
|
178
|
-
* If `true`, animations are
|
|
178
|
+
* If `true`, animations are skipped.
|
|
179
179
|
* @default false
|
|
180
180
|
*/
|
|
181
181
|
skipAnimation: PropTypes.bool,
|
|
@@ -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 = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "
|
|
3
|
+
var _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
|
|
4
4
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -28,7 +28,7 @@ function PieArcPlot(props) {
|
|
|
28
28
|
additionalRadius: -5
|
|
29
29
|
} : _props$faded,
|
|
30
30
|
data = props.data,
|
|
31
|
-
|
|
31
|
+
onItemClick = props.onItemClick,
|
|
32
32
|
skipAnimation = props.skipAnimation,
|
|
33
33
|
other = _objectWithoutProperties(props, _excluded);
|
|
34
34
|
var transformedData = useTransformData({
|
|
@@ -73,8 +73,8 @@ function PieArcPlot(props) {
|
|
|
73
73
|
highlightScope: highlightScope,
|
|
74
74
|
isFaded: item.isFaded,
|
|
75
75
|
isHighlighted: item.isHighlighted,
|
|
76
|
-
onClick:
|
|
77
|
-
|
|
76
|
+
onClick: onItemClick && function (event) {
|
|
77
|
+
onItemClick(event, {
|
|
78
78
|
type: 'pie',
|
|
79
79
|
seriesId: id,
|
|
80
80
|
dataIndex: index
|
|
@@ -139,7 +139,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
139
139
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
140
140
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
141
141
|
}),
|
|
142
|
-
id: PropTypes.string.isRequired,
|
|
142
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
143
143
|
/**
|
|
144
144
|
* The radius between circle center and the begining of the arc.
|
|
145
145
|
* @default 0
|
|
@@ -151,7 +151,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
151
151
|
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
152
152
|
* @param {DefaultizedPieValueType} item The pie item.
|
|
153
153
|
*/
|
|
154
|
-
|
|
154
|
+
onItemClick: PropTypes.func,
|
|
155
155
|
/**
|
|
156
156
|
* The radius between circle center and the end of the arc.
|
|
157
157
|
*/
|
|
@@ -162,7 +162,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
162
162
|
*/
|
|
163
163
|
paddingAngle: PropTypes.number,
|
|
164
164
|
/**
|
|
165
|
-
* If `true`, animations are
|
|
165
|
+
* If `true`, animations are skipped.
|
|
166
166
|
* @default false
|
|
167
167
|
*/
|
|
168
168
|
skipAnimation: PropTypes.bool,
|