@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
package/LineChart/LinePlot.js
CHANGED
|
@@ -17,8 +17,18 @@ var _useScale = require("../hooks/useScale");
|
|
|
17
17
|
var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
const _excluded = ["slots", "slotProps"];
|
|
20
|
-
function _getRequireWildcardCache(
|
|
21
|
-
function _interopRequireWildcard(
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
/**
|
|
23
|
+
* Demos:
|
|
24
|
+
*
|
|
25
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
26
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
27
|
+
*
|
|
28
|
+
* API:
|
|
29
|
+
*
|
|
30
|
+
* - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
|
|
31
|
+
*/
|
|
22
32
|
function LinePlot(props) {
|
|
23
33
|
const {
|
|
24
34
|
slots,
|
|
@@ -50,25 +60,28 @@ function LinePlot(props) {
|
|
|
50
60
|
const {
|
|
51
61
|
xAxisKey = defaultXAxisId,
|
|
52
62
|
yAxisKey = defaultYAxisId,
|
|
53
|
-
stackedData
|
|
63
|
+
stackedData,
|
|
64
|
+
data,
|
|
65
|
+
connectNulls
|
|
54
66
|
} = series[seriesId];
|
|
55
67
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
56
68
|
const yScale = yAxis[yAxisKey].scale;
|
|
57
69
|
const xData = xAxis[xAxisKey].data;
|
|
58
|
-
if (xData === undefined) {
|
|
59
|
-
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
60
|
-
}
|
|
61
|
-
const linePath = (0, _d3Shape.line)().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
|
|
62
70
|
if (process.env.NODE_ENV !== 'production') {
|
|
63
|
-
if (xData
|
|
64
|
-
throw new Error(`
|
|
71
|
+
if (xData === undefined) {
|
|
72
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
73
|
+
}
|
|
74
|
+
if (xData.length < stackedData.length) {
|
|
75
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
65
76
|
}
|
|
66
77
|
}
|
|
78
|
+
const linePath = (0, _d3Shape.line)().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
67
79
|
const curve = (0, _getCurve.default)(series[seriesId].curve);
|
|
68
|
-
const
|
|
80
|
+
const formattedData = xData?.map((x, index) => ({
|
|
69
81
|
x,
|
|
70
|
-
y: stackedData[index]
|
|
71
|
-
}));
|
|
82
|
+
y: stackedData[index]
|
|
83
|
+
})) ?? [];
|
|
84
|
+
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
72
85
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineElement.LineElement, {
|
|
73
86
|
id: seriesId,
|
|
74
87
|
d: linePath.curve(curve)(d3Data) || undefined,
|
|
@@ -31,6 +31,16 @@ export type MarkElementProps = Omit<MarkElementOwnerState, 'isFaded' | 'isHighli
|
|
|
31
31
|
dataIndex: number;
|
|
32
32
|
highlightScope?: Partial<HighlightScope>;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Demos:
|
|
36
|
+
*
|
|
37
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
38
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
39
|
+
*
|
|
40
|
+
* API:
|
|
41
|
+
*
|
|
42
|
+
* - [MarkElement API](https://mui.com/x/api/charts/mark-element/)
|
|
43
|
+
*/
|
|
34
44
|
declare function MarkElement(props: MarkElementProps): React.JSX.Element;
|
|
35
45
|
declare namespace MarkElement {
|
|
36
46
|
var propTypes: any;
|
package/LineChart/MarkElement.js
CHANGED
|
@@ -21,13 +21,12 @@ var _InteractionProvider = require("../context/InteractionProvider");
|
|
|
21
21
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "highlightScope"];
|
|
24
|
-
function _getRequireWildcardCache(
|
|
25
|
-
function _interopRequireWildcard(
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
26
|
function getMarkElementUtilityClass(slot) {
|
|
27
27
|
return (0, _generateUtilityClass.default)('MuiMarkElement', slot);
|
|
28
28
|
}
|
|
29
|
-
const markElementClasses = (0, _generateUtilityClasses.default)('MuiMarkElement', ['root', 'highlighted', 'faded']);
|
|
30
|
-
exports.markElementClasses = markElementClasses;
|
|
29
|
+
const markElementClasses = exports.markElementClasses = (0, _generateUtilityClasses.default)('MuiMarkElement', ['root', 'highlighted', 'faded']);
|
|
31
30
|
const useUtilityClasses = ownerState => {
|
|
32
31
|
const {
|
|
33
32
|
classes,
|
|
@@ -50,7 +49,7 @@ const MarkElementPath = (0, _styles.styled)('path', {
|
|
|
50
49
|
}) => ({
|
|
51
50
|
transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
|
|
52
51
|
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
53
|
-
fill: theme.palette.background.paper,
|
|
52
|
+
fill: (theme.vars || theme).palette.background.paper,
|
|
54
53
|
stroke: ownerState.color,
|
|
55
54
|
strokeWidth: 2
|
|
56
55
|
}));
|
|
@@ -71,6 +70,16 @@ MarkElementPath.propTypes = {
|
|
|
71
70
|
}).isRequired,
|
|
72
71
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
|
|
73
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Demos:
|
|
75
|
+
*
|
|
76
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
77
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
78
|
+
*
|
|
79
|
+
* API:
|
|
80
|
+
*
|
|
81
|
+
* - [MarkElement API](https://mui.com/x/api/charts/mark-element/)
|
|
82
|
+
*/
|
|
74
83
|
function MarkElement(props) {
|
|
75
84
|
const {
|
|
76
85
|
x,
|
package/LineChart/MarkPlot.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement> {
|
|
|
18
18
|
*/
|
|
19
19
|
slotProps?: MarkPlotSlotComponentProps;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Demos:
|
|
23
|
+
*
|
|
24
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
25
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
26
|
+
*
|
|
27
|
+
* API:
|
|
28
|
+
*
|
|
29
|
+
* - [MarkPlot API](https://mui.com/x/api/charts/mark-plot/)
|
|
30
|
+
*/
|
|
21
31
|
declare function MarkPlot(props: MarkPlotProps): React.JSX.Element | null;
|
|
22
32
|
declare namespace MarkPlot {
|
|
23
33
|
var propTypes: any;
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -15,8 +15,18 @@ var _MarkElement = require("./MarkElement");
|
|
|
15
15
|
var _useScale = require("../hooks/useScale");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
const _excluded = ["slots", "slotProps"];
|
|
18
|
-
function _getRequireWildcardCache(
|
|
19
|
-
function _interopRequireWildcard(
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
+
/**
|
|
21
|
+
* Demos:
|
|
22
|
+
*
|
|
23
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
24
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
25
|
+
*
|
|
26
|
+
* API:
|
|
27
|
+
*
|
|
28
|
+
* - [MarkPlot API](https://mui.com/x/api/charts/mark-plot/)
|
|
29
|
+
*/
|
|
20
30
|
function MarkPlot(props) {
|
|
21
31
|
const {
|
|
22
32
|
slots,
|
|
@@ -50,6 +60,7 @@ function MarkPlot(props) {
|
|
|
50
60
|
xAxisKey = defaultXAxisId,
|
|
51
61
|
yAxisKey = defaultYAxisId,
|
|
52
62
|
stackedData,
|
|
63
|
+
data,
|
|
53
64
|
showMark = true
|
|
54
65
|
} = series[seriesId];
|
|
55
66
|
if (showMark === false) {
|
|
@@ -76,36 +87,57 @@ function MarkPlot(props) {
|
|
|
76
87
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
77
88
|
}
|
|
78
89
|
return xData?.map((x, index) => {
|
|
79
|
-
const
|
|
90
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
80
91
|
return {
|
|
81
92
|
x: xScale(x),
|
|
82
|
-
y: yScale(
|
|
93
|
+
y: value === null ? null : yScale(value),
|
|
83
94
|
position: x,
|
|
84
|
-
value
|
|
95
|
+
value,
|
|
85
96
|
index
|
|
86
97
|
};
|
|
87
|
-
}).filter(
|
|
98
|
+
}).filter(({
|
|
88
99
|
x,
|
|
89
100
|
y,
|
|
90
101
|
index,
|
|
91
102
|
position,
|
|
92
103
|
value
|
|
93
104
|
}) => {
|
|
94
|
-
|
|
105
|
+
if (value === null || y === null) {
|
|
106
|
+
// Remove missing data point
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (!isInRange({
|
|
110
|
+
x,
|
|
111
|
+
y
|
|
112
|
+
})) {
|
|
113
|
+
// Remove out of range
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (showMark === true) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return showMark({
|
|
95
120
|
x,
|
|
96
121
|
y,
|
|
97
122
|
index,
|
|
98
123
|
position,
|
|
99
124
|
value
|
|
100
|
-
})
|
|
125
|
+
});
|
|
126
|
+
}).map(({
|
|
127
|
+
x,
|
|
128
|
+
y,
|
|
129
|
+
index
|
|
130
|
+
}) => {
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Mark, (0, _extends2.default)({
|
|
101
132
|
id: seriesId,
|
|
102
133
|
dataIndex: index,
|
|
103
134
|
shape: "circle",
|
|
104
135
|
color: series[seriesId].color,
|
|
105
136
|
x: x,
|
|
106
|
-
y: y
|
|
137
|
+
y: y // Don't knwo why TS don't get from the filter that y can't be null
|
|
138
|
+
,
|
|
107
139
|
highlightScope: series[seriesId].highlightScope
|
|
108
|
-
}, slotProps?.mark), `${seriesId}-${index}`)
|
|
140
|
+
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
109
141
|
});
|
|
110
142
|
});
|
|
111
143
|
})
|
package/LineChart/formatter.js
CHANGED
|
@@ -31,7 +31,7 @@ const formatter = (params, dataset) => {
|
|
|
31
31
|
d3Dataset[index][id] = value;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
} else if (dataset === undefined) {
|
|
34
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
35
35
|
throw new Error([`MUI: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -47,7 +47,8 @@ const formatter = (params, dataset) => {
|
|
|
47
47
|
// Use dataKey if needed and available
|
|
48
48
|
const dataKey = series[id].dataKey;
|
|
49
49
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
50
|
-
})).
|
|
50
|
+
})).value((d, key) => d[key] ?? 0) // defaultize null value to 0
|
|
51
|
+
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
51
52
|
ids.forEach((id, index) => {
|
|
52
53
|
const dataKey = series[id].dataKey;
|
|
53
54
|
completedSeries[id] = (0, _extends2.default)({}, series[id], {
|
|
@@ -59,8 +60,7 @@ const formatter = (params, dataset) => {
|
|
|
59
60
|
return {
|
|
60
61
|
seriesOrder,
|
|
61
62
|
stackingGroups,
|
|
62
|
-
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v
|
|
63
|
+
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v?.toLocaleString())
|
|
63
64
|
};
|
|
64
65
|
};
|
|
65
|
-
var _default = formatter;
|
|
66
|
-
exports.default = _default;
|
|
66
|
+
var _default = exports.default = formatter;
|
package/LineChart/legend.js
CHANGED
package/PieChart/PieArc.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SpringValue } from '@react-spring/web';
|
|
3
3
|
import { HighlightScope } from '../context/HighlightProvider';
|
|
4
|
-
import { PieSeriesType } from '../models/seriesType/pie';
|
|
5
4
|
export interface PieArcClasses {
|
|
6
5
|
/** Styles applied to the root element. */
|
|
7
6
|
root: string;
|
|
@@ -21,16 +20,15 @@ interface PieArcOwnerState {
|
|
|
21
20
|
}
|
|
22
21
|
export declare function getPieArcUtilityClass(slot: string): string;
|
|
23
22
|
export declare const pieArcClasses: PieArcClasses;
|
|
24
|
-
export type PieArcProps =
|
|
23
|
+
export type PieArcProps = PieArcOwnerState & React.ComponentPropsWithoutRef<'path'> & {
|
|
24
|
+
startAngle: SpringValue<number>;
|
|
25
|
+
endAngle: SpringValue<number>;
|
|
26
|
+
innerRadius: SpringValue<number>;
|
|
27
|
+
outerRadius: SpringValue<number>;
|
|
28
|
+
cornerRadius: SpringValue<number>;
|
|
29
|
+
paddingAngle: SpringValue<number>;
|
|
25
30
|
highlightScope?: Partial<HighlightScope>;
|
|
26
|
-
|
|
27
|
-
outerRadius: number;
|
|
28
|
-
cornerRadius: PieSeriesType['cornerRadius'];
|
|
29
|
-
highlighted: PieSeriesType['highlighted'];
|
|
30
|
-
faded: PieSeriesType['faded'];
|
|
31
|
+
onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var propTypes: any;
|
|
35
|
-
}
|
|
36
|
-
export default PieArc;
|
|
33
|
+
export default function PieArc(props: PieArcProps): React.JSX.Element;
|
|
34
|
+
export {};
|
package/PieChart/PieArc.js
CHANGED
|
@@ -11,22 +11,20 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _d3Shape = require("d3-shape");
|
|
14
|
-
var
|
|
14
|
+
var _web = require("@react-spring/web");
|
|
15
15
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
16
16
|
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
17
17
|
var _styles = require("@mui/material/styles");
|
|
18
18
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
19
|
-
var _InteractionProvider = require("../context/InteractionProvider");
|
|
20
19
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
21
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "
|
|
23
|
-
function _getRequireWildcardCache(
|
|
24
|
-
function _interopRequireWildcard(
|
|
21
|
+
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "onClick", "isFaded", "isHighlighted", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
24
|
function getPieArcUtilityClass(slot) {
|
|
26
25
|
return (0, _generateUtilityClass.default)('MuiPieArc', slot);
|
|
27
26
|
}
|
|
28
|
-
const pieArcClasses = (0, _generateUtilityClasses.default)('MuiPieArc', ['root', 'highlighted', 'faded']);
|
|
29
|
-
exports.pieArcClasses = pieArcClasses;
|
|
27
|
+
const pieArcClasses = exports.pieArcClasses = (0, _generateUtilityClasses.default)('MuiPieArc', ['root', 'highlighted', 'faded']);
|
|
30
28
|
const useUtilityClasses = ownerState => {
|
|
31
29
|
const {
|
|
32
30
|
classes,
|
|
@@ -39,19 +37,16 @@ const useUtilityClasses = ownerState => {
|
|
|
39
37
|
};
|
|
40
38
|
return (0, _composeClasses.default)(slots, getPieArcUtilityClass, classes);
|
|
41
39
|
};
|
|
42
|
-
const PieArcRoot = (0, _styles.styled)(
|
|
40
|
+
const PieArcRoot = (0, _styles.styled)(_web.animated.path, {
|
|
43
41
|
name: 'MuiPieArc',
|
|
44
42
|
slot: 'Root',
|
|
45
43
|
overridesResolver: (_, styles) => styles.arc
|
|
46
44
|
})(({
|
|
47
|
-
ownerState,
|
|
48
45
|
theme
|
|
49
46
|
}) => ({
|
|
50
|
-
stroke: theme.palette.background.paper,
|
|
47
|
+
stroke: (theme.vars || theme).palette.background.paper,
|
|
51
48
|
strokeWidth: 1,
|
|
52
|
-
strokeLinejoin: 'round'
|
|
53
|
-
fill: ownerState.color,
|
|
54
|
-
opacity: ownerState.isFaded ? 0.3 : 1
|
|
49
|
+
strokeLinejoin: 'round'
|
|
55
50
|
}));
|
|
56
51
|
function PieArc(props) {
|
|
57
52
|
const {
|
|
@@ -60,29 +55,17 @@ function PieArc(props) {
|
|
|
60
55
|
classes: innerClasses,
|
|
61
56
|
color,
|
|
62
57
|
highlightScope,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
onClick,
|
|
59
|
+
isFaded,
|
|
60
|
+
isHighlighted,
|
|
61
|
+
startAngle,
|
|
62
|
+
endAngle,
|
|
63
|
+
paddingAngle,
|
|
64
|
+
innerRadius,
|
|
65
|
+
outerRadius,
|
|
66
|
+
cornerRadius
|
|
70
67
|
} = props,
|
|
71
68
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
72
|
-
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
|
|
73
|
-
const {
|
|
74
|
-
item
|
|
75
|
-
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
76
|
-
const isHighlighted = (0, _useInteractionItemProps.getIsHighlighted)(item, {
|
|
77
|
-
type: 'pie',
|
|
78
|
-
seriesId: id,
|
|
79
|
-
dataIndex
|
|
80
|
-
}, highlightScope);
|
|
81
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
|
|
82
|
-
type: 'pie',
|
|
83
|
-
seriesId: id,
|
|
84
|
-
dataIndex
|
|
85
|
-
}, highlightScope);
|
|
86
69
|
const ownerState = {
|
|
87
70
|
id,
|
|
88
71
|
dataIndex,
|
|
@@ -92,37 +75,22 @@ function PieArc(props) {
|
|
|
92
75
|
isHighlighted
|
|
93
76
|
};
|
|
94
77
|
const classes = useUtilityClasses(ownerState);
|
|
95
|
-
const
|
|
96
|
-
additionalRadius: 0
|
|
97
|
-
}, isFaded && faded || isHighlighted && highlighted || {});
|
|
98
|
-
const innerRadius = Math.max(0, attibuesOverride.innerRadius ?? baseInnerRadius);
|
|
99
|
-
const outerRadius = Math.max(0, attibuesOverride.outerRadius ?? baseOuterRadius + attibuesOverride.additionalRadius);
|
|
100
|
-
const cornerRadius = attibuesOverride.cornerRadius ?? baseCornerRadius;
|
|
78
|
+
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
|
|
101
79
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PieArcRoot, (0, _extends2.default)({
|
|
102
|
-
d: (0,
|
|
103
|
-
|
|
104
|
-
|
|
80
|
+
d: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], (sA, eA, pA, iR, oR, cR) => (0, _d3Shape.arc)().cornerRadius(cR)({
|
|
81
|
+
padAngle: pA,
|
|
82
|
+
startAngle: sA,
|
|
83
|
+
endAngle: eA,
|
|
84
|
+
innerRadius: iR,
|
|
85
|
+
outerRadius: oR
|
|
105
86
|
})),
|
|
87
|
+
onClick: onClick,
|
|
88
|
+
cursor: onClick ? 'pointer' : 'unset',
|
|
106
89
|
ownerState: ownerState,
|
|
107
90
|
className: classes.root
|
|
108
|
-
}, getInteractionItemProps({
|
|
91
|
+
}, other, getInteractionItemProps({
|
|
109
92
|
type: 'pie',
|
|
110
93
|
seriesId: id,
|
|
111
94
|
dataIndex
|
|
112
95
|
})));
|
|
113
|
-
}
|
|
114
|
-
process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
|
|
115
|
-
// ----------------------------- Warning --------------------------------
|
|
116
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
117
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
118
|
-
// ----------------------------------------------------------------------
|
|
119
|
-
classes: _propTypes.default.object,
|
|
120
|
-
cornerRadius: _propTypes.default.number,
|
|
121
|
-
dataIndex: _propTypes.default.number.isRequired,
|
|
122
|
-
highlightScope: _propTypes.default.shape({
|
|
123
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
124
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
125
|
-
}),
|
|
126
|
-
innerRadius: _propTypes.default.number,
|
|
127
|
-
outerRadius: _propTypes.default.number.isRequired
|
|
128
|
-
} : void 0;
|
|
96
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { HighlightScope } from '../context/HighlightProvider';
|
|
4
|
-
import { PieSeriesType } from '../models/seriesType/pie';
|
|
2
|
+
import { SpringValue } from '@react-spring/web';
|
|
5
3
|
export interface PieArcLabelClasses {
|
|
6
4
|
/** Styles applied to the root element. */
|
|
7
5
|
root: string;
|
|
@@ -13,7 +11,6 @@ export interface PieArcLabelClasses {
|
|
|
13
11
|
export type PieArcLabelClassKey = keyof PieArcLabelClasses;
|
|
14
12
|
interface PieArcLabelOwnerState {
|
|
15
13
|
id: string;
|
|
16
|
-
dataIndex: number;
|
|
17
14
|
color: string;
|
|
18
15
|
isFaded: boolean;
|
|
19
16
|
isHighlighted: boolean;
|
|
@@ -21,11 +18,13 @@ interface PieArcLabelOwnerState {
|
|
|
21
18
|
}
|
|
22
19
|
export declare function getPieArcLabelUtilityClass(slot: string): string;
|
|
23
20
|
export declare const pieArcLabelClasses: PieArcLabelClasses;
|
|
24
|
-
export type PieArcLabelProps =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
export type PieArcLabelProps = PieArcLabelOwnerState & React.ComponentPropsWithoutRef<'text'> & {
|
|
22
|
+
startAngle: SpringValue<number>;
|
|
23
|
+
endAngle: SpringValue<number>;
|
|
24
|
+
innerRadius: SpringValue<number>;
|
|
25
|
+
outerRadius: SpringValue<number>;
|
|
26
|
+
cornerRadius: SpringValue<number>;
|
|
27
|
+
paddingAngle: SpringValue<number>;
|
|
29
28
|
} & {
|
|
30
29
|
formattedArcLabel?: string | null;
|
|
31
30
|
};
|
package/PieChart/PieArcLabel.js
CHANGED
|
@@ -10,23 +10,21 @@ exports.pieArcLabelClasses = void 0;
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _web = require("@react-spring/web");
|
|
13
14
|
var _d3Shape = require("d3-shape");
|
|
14
15
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
16
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
16
17
|
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
17
18
|
var _styles = require("@mui/material/styles");
|
|
18
19
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
19
|
-
var _InteractionProvider = require("../context/InteractionProvider");
|
|
20
|
-
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
21
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["id", "
|
|
23
|
-
function _getRequireWildcardCache(
|
|
24
|
-
function _interopRequireWildcard(
|
|
21
|
+
const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
24
|
function getPieArcLabelUtilityClass(slot) {
|
|
26
25
|
return (0, _generateUtilityClass.default)('MuiPieArcLabel', slot);
|
|
27
26
|
}
|
|
28
|
-
const pieArcLabelClasses = (0, _generateUtilityClasses.default)('MuiPieArcLabel', ['root', 'highlighted', 'faded']);
|
|
29
|
-
exports.pieArcLabelClasses = pieArcLabelClasses;
|
|
27
|
+
const pieArcLabelClasses = exports.pieArcLabelClasses = (0, _generateUtilityClasses.default)('MuiPieArcLabel', ['root', 'highlighted', 'faded']);
|
|
30
28
|
const useUtilityClasses = ownerState => {
|
|
31
29
|
const {
|
|
32
30
|
classes,
|
|
@@ -39,61 +37,71 @@ const useUtilityClasses = ownerState => {
|
|
|
39
37
|
};
|
|
40
38
|
return (0, _composeClasses.default)(slots, getPieArcLabelUtilityClass, classes);
|
|
41
39
|
};
|
|
42
|
-
const PieArcLabelRoot = (0, _styles.styled)(
|
|
40
|
+
const PieArcLabelRoot = (0, _styles.styled)(_web.animated.text, {
|
|
43
41
|
name: 'MuiPieArcLabel',
|
|
44
42
|
slot: 'Root',
|
|
45
43
|
overridesResolver: (_, styles) => styles.root
|
|
46
44
|
})(({
|
|
47
45
|
theme
|
|
48
46
|
}) => ({
|
|
49
|
-
fill: theme.palette.text.primary,
|
|
50
|
-
textAnchor: 'middle'
|
|
47
|
+
fill: (theme.vars || theme).palette.text.primary,
|
|
48
|
+
textAnchor: 'middle',
|
|
49
|
+
dominantBaseline: 'middle'
|
|
51
50
|
}));
|
|
51
|
+
/**
|
|
52
|
+
* Helper to compute label position.
|
|
53
|
+
* It's not an inline function because we need it in inerpolation.
|
|
54
|
+
*/
|
|
55
|
+
const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, innerRadius, outerRadius, cornerRadius) => {
|
|
56
|
+
if (!formattedArcLabel) {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
const [x, y] = (0, _d3Shape.arc)().cornerRadius(cornerRadius).centroid({
|
|
60
|
+
padAngle,
|
|
61
|
+
startAngle,
|
|
62
|
+
endAngle,
|
|
63
|
+
innerRadius,
|
|
64
|
+
outerRadius
|
|
65
|
+
});
|
|
66
|
+
if (variable === 'x') {
|
|
67
|
+
return x;
|
|
68
|
+
}
|
|
69
|
+
return y;
|
|
70
|
+
};
|
|
52
71
|
function PieArcLabel(props) {
|
|
53
72
|
const {
|
|
54
73
|
id,
|
|
55
|
-
dataIndex,
|
|
56
74
|
classes: innerClasses,
|
|
57
75
|
color,
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
startAngle,
|
|
77
|
+
endAngle,
|
|
78
|
+
paddingAngle,
|
|
79
|
+
innerRadius,
|
|
60
80
|
outerRadius,
|
|
61
|
-
cornerRadius
|
|
62
|
-
formattedArcLabel
|
|
81
|
+
cornerRadius,
|
|
82
|
+
formattedArcLabel,
|
|
83
|
+
isHighlighted,
|
|
84
|
+
isFaded,
|
|
85
|
+
style
|
|
63
86
|
} = props,
|
|
64
87
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
65
|
-
const {
|
|
66
|
-
item
|
|
67
|
-
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
68
|
-
const isHighlighted = (0, _useInteractionItemProps.getIsHighlighted)(item, {
|
|
69
|
-
type: 'pie',
|
|
70
|
-
seriesId: id,
|
|
71
|
-
dataIndex
|
|
72
|
-
}, highlightScope);
|
|
73
|
-
const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
|
|
74
|
-
type: 'pie',
|
|
75
|
-
seriesId: id,
|
|
76
|
-
dataIndex
|
|
77
|
-
}, highlightScope);
|
|
78
88
|
const ownerState = {
|
|
79
89
|
id,
|
|
80
|
-
dataIndex,
|
|
81
90
|
classes: innerClasses,
|
|
82
91
|
color,
|
|
83
92
|
isFaded,
|
|
84
93
|
isHighlighted
|
|
85
94
|
};
|
|
86
95
|
const classes = useUtilityClasses(ownerState);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
y: arcLabelPosition[1],
|
|
96
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PieArcLabelRoot, (0, _extends2.default)({
|
|
97
|
+
className: classes.root
|
|
98
|
+
}, other, {
|
|
99
|
+
style: (0, _extends2.default)({
|
|
100
|
+
x: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
|
|
101
|
+
y: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
|
|
102
|
+
}, style),
|
|
95
103
|
children: formattedArcLabel
|
|
96
|
-
});
|
|
104
|
+
}));
|
|
97
105
|
}
|
|
98
106
|
process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
99
107
|
// ----------------------------- Warning --------------------------------
|