@mui/x-charts 8.5.3 → 8.6.0

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.
Files changed (104) hide show
  1. package/BarChart/AnimatedBarElement.js +3 -1
  2. package/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
  3. package/BarChart/BarLabel/BarLabelPlot.js +33 -25
  4. package/BarChart/BarPlot.js +55 -40
  5. package/BarChart/barClasses.d.ts +12 -0
  6. package/BarChart/barClasses.js +25 -0
  7. package/BarChart/index.d.ts +3 -1
  8. package/BarChart/index.js +23 -1
  9. package/BarChart/types.d.ts +5 -1
  10. package/CHANGELOG.md +107 -0
  11. package/ChartsLegend/ChartsLegend.js +1 -0
  12. package/ChartsXAxis/ChartsXAxis.js +4 -108
  13. package/ChartsXAxis/getVisibleLabels.d.ts +14 -0
  14. package/ChartsXAxis/getVisibleLabels.js +71 -0
  15. package/ChartsXAxis/shortenLabels.d.ts +4 -0
  16. package/ChartsXAxis/shortenLabels.js +48 -0
  17. package/ChartsYAxis/ChartsYAxis.js +2 -39
  18. package/ChartsYAxis/shortenLabels.d.ts +4 -0
  19. package/ChartsYAxis/shortenLabels.js +46 -0
  20. package/LineChart/AnimatedArea.js +4 -1
  21. package/LineChart/AnimatedLine.js +4 -1
  22. package/LineChart/CircleMarkElement.js +4 -1
  23. package/LineChart/MarkElement.js +4 -1
  24. package/LineChart/MarkPlot.js +1 -0
  25. package/PieChart/PieArc.js +3 -1
  26. package/PieChart/PiePlot.js +6 -0
  27. package/PieChart/index.d.ts +3 -1
  28. package/PieChart/index.js +18 -1
  29. package/PieChart/pieClasses.d.ts +12 -0
  30. package/PieChart/pieClasses.js +24 -0
  31. package/Toolbar/ToolbarButton.js +2 -0
  32. package/esm/BarChart/AnimatedBarElement.js +3 -1
  33. package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
  34. package/esm/BarChart/BarLabel/BarLabelPlot.js +33 -25
  35. package/esm/BarChart/BarPlot.js +55 -40
  36. package/esm/BarChart/barClasses.d.ts +12 -0
  37. package/esm/BarChart/barClasses.js +15 -0
  38. package/esm/BarChart/index.d.ts +3 -1
  39. package/esm/BarChart/index.js +2 -1
  40. package/esm/BarChart/types.d.ts +5 -1
  41. package/esm/ChartsLegend/ChartsLegend.js +1 -0
  42. package/esm/ChartsXAxis/ChartsXAxis.js +2 -106
  43. package/esm/ChartsXAxis/getVisibleLabels.d.ts +14 -0
  44. package/esm/ChartsXAxis/getVisibleLabels.js +67 -0
  45. package/esm/ChartsXAxis/shortenLabels.d.ts +4 -0
  46. package/esm/ChartsXAxis/shortenLabels.js +42 -0
  47. package/esm/ChartsYAxis/ChartsYAxis.js +1 -38
  48. package/esm/ChartsYAxis/shortenLabels.d.ts +4 -0
  49. package/esm/ChartsYAxis/shortenLabels.js +41 -0
  50. package/esm/LineChart/AnimatedArea.js +4 -1
  51. package/esm/LineChart/AnimatedLine.js +4 -1
  52. package/esm/LineChart/CircleMarkElement.js +4 -1
  53. package/esm/LineChart/MarkElement.js +4 -1
  54. package/esm/LineChart/MarkPlot.js +1 -0
  55. package/esm/PieChart/PieArc.js +3 -1
  56. package/esm/PieChart/PiePlot.js +6 -0
  57. package/esm/PieChart/index.d.ts +3 -1
  58. package/esm/PieChart/index.js +2 -1
  59. package/esm/PieChart/pieClasses.d.ts +12 -0
  60. package/esm/PieChart/pieClasses.js +15 -0
  61. package/esm/Toolbar/ToolbarButton.js +2 -0
  62. package/esm/index.js +1 -1
  63. package/esm/internals/components/NotRendered.d.ts +9 -0
  64. package/esm/internals/components/NotRendered.js +10 -0
  65. package/esm/internals/index.d.ts +1 -0
  66. package/esm/internals/index.js +1 -0
  67. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +30 -2
  68. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +8 -2
  69. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +20 -4
  70. package/esm/locales/enUS.d.ts +3 -0
  71. package/esm/locales/enUS.js +8 -2
  72. package/esm/locales/frFR.d.ts +3 -0
  73. package/esm/locales/frFR.js +7 -0
  74. package/esm/locales/ptBR.d.ts +3 -0
  75. package/esm/locales/ptBR.js +7 -1
  76. package/esm/locales/ptPT.d.ts +3 -0
  77. package/esm/locales/ptPT.js +7 -1
  78. package/esm/locales/utils/chartsLocaleTextApi.d.ts +17 -0
  79. package/esm/locales/utils/getChartsLocalization.d.ts +3 -0
  80. package/esm/locales/utils/imageMimeTypes.d.ts +2 -0
  81. package/esm/locales/utils/imageMimeTypes.js +5 -0
  82. package/esm/models/slots/chartsBaseSlotProps.d.ts +4 -0
  83. package/index.js +1 -1
  84. package/internals/components/NotRendered.d.ts +9 -0
  85. package/internals/components/NotRendered.js +16 -0
  86. package/internals/index.d.ts +1 -0
  87. package/internals/index.js +12 -0
  88. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +30 -2
  89. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +8 -2
  90. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +20 -4
  91. package/locales/enUS.d.ts +3 -0
  92. package/locales/enUS.js +8 -2
  93. package/locales/frFR.d.ts +3 -0
  94. package/locales/frFR.js +7 -0
  95. package/locales/ptBR.d.ts +3 -0
  96. package/locales/ptBR.js +7 -1
  97. package/locales/ptPT.d.ts +3 -0
  98. package/locales/ptPT.js +7 -1
  99. package/locales/utils/chartsLocaleTextApi.d.ts +17 -0
  100. package/locales/utils/getChartsLocalization.d.ts +3 -0
  101. package/locales/utils/imageMimeTypes.d.ts +2 -0
  102. package/locales/utils/imageMimeTypes.js +11 -0
  103. package/models/slots/chartsBaseSlotProps.d.ts +4 -0
  104. package/package.json +2 -2
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getVisibleLabels = getVisibleLabels;
8
+ var _geometry = require("../internals/geometry");
9
+ var _getWordsByLines = require("../internals/getWordsByLines");
10
+ /* Returns a set of indices of the tick labels that should be visible. */
11
+ function getVisibleLabels(xTicks, {
12
+ tickLabelStyle: style,
13
+ tickLabelInterval,
14
+ tickLabelMinGap,
15
+ reverse,
16
+ isMounted,
17
+ isXInside
18
+ }) {
19
+ const getTickLabelSize = tick => {
20
+ if (!isMounted || tick.formattedValue === undefined) {
21
+ return {
22
+ width: 0,
23
+ height: 0
24
+ };
25
+ }
26
+ const tickSizes = (0, _getWordsByLines.getWordsByLines)({
27
+ style,
28
+ needsComputation: true,
29
+ text: tick.formattedValue
30
+ });
31
+ return {
32
+ width: Math.max(...tickSizes.map(size => size.width)),
33
+ height: Math.max(tickSizes.length * tickSizes[0].height)
34
+ };
35
+ };
36
+ if (typeof tickLabelInterval === 'function') {
37
+ return new Set(xTicks.filter((item, index) => tickLabelInterval(item.value, index)));
38
+ }
39
+
40
+ // Filter label to avoid overlap
41
+ let previousTextLimit = 0;
42
+ const direction = reverse ? -1 : 1;
43
+ return new Set(xTicks.filter((item, labelIndex) => {
44
+ const {
45
+ offset,
46
+ labelOffset
47
+ } = item;
48
+ const textPosition = offset + labelOffset;
49
+ if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
50
+ return false;
51
+ }
52
+ if (!isXInside(textPosition)) {
53
+ return false;
54
+ }
55
+
56
+ /* Measuring text width is expensive, so we need to delay it as much as possible to improve performance. */
57
+ const {
58
+ width,
59
+ height
60
+ } = getTickLabelSize(item);
61
+ const distance = (0, _geometry.getMinXTranslation)(width, height, style?.angle);
62
+ const currentTextLimit = textPosition - direction * distance / 2;
63
+ if (labelIndex > 0 && direction * currentTextLimit < direction * (previousTextLimit + tickLabelMinGap)) {
64
+ // Except for the first label, we skip all label that overlap with the last accepted.
65
+ // Notice that the early return prevents `previousTextLimit` from being updated.
66
+ return false;
67
+ }
68
+ previousTextLimit = textPosition + direction * distance / 2;
69
+ return true;
70
+ }));
71
+ }
@@ -0,0 +1,4 @@
1
+ import { TickItemType } from "../hooks/useTicks.js";
2
+ import { ChartsXAxisProps } from "../models/axis.js";
3
+ import { ChartDrawingArea } from "../hooks/useDrawingArea.js";
4
+ export declare function shortenLabels(visibleLabels: Set<TickItemType>, drawingArea: Pick<ChartDrawingArea, 'left' | 'width' | 'right'>, maxHeight: number, isRtl: boolean, tickLabelStyle: ChartsXAxisProps['tickLabelStyle']): Map<TickItemType, string>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shortenLabels = shortenLabels;
7
+ var _clampAngle = require("../internals/clampAngle");
8
+ var _ellipsize = require("../internals/ellipsize");
9
+ var _domUtils = require("../internals/domUtils");
10
+ function shortenLabels(visibleLabels, drawingArea, maxHeight, isRtl, tickLabelStyle) {
11
+ const shortenedLabels = new Map();
12
+ const angle = (0, _clampAngle.clampAngle)(tickLabelStyle?.angle ?? 0);
13
+
14
+ // Multiplying the space available to the left of the text position by leftBoundFactor returns the max width of the text.
15
+ // Same for rightBoundFactor
16
+ let leftBoundFactor = 1;
17
+ let rightBoundFactor = 1;
18
+ if (tickLabelStyle?.textAnchor === 'start') {
19
+ leftBoundFactor = Infinity;
20
+ rightBoundFactor = 1;
21
+ } else if (tickLabelStyle?.textAnchor === 'end') {
22
+ leftBoundFactor = 1;
23
+ rightBoundFactor = Infinity;
24
+ } else {
25
+ leftBoundFactor = 2;
26
+ rightBoundFactor = 2;
27
+ }
28
+ if (angle > 90 && angle < 270) {
29
+ [leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
30
+ }
31
+ if (isRtl) {
32
+ [leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
33
+ }
34
+ for (const item of visibleLabels) {
35
+ if (item.formattedValue) {
36
+ // That maximum width of the tick depends on its proximity to the axis bounds.
37
+ const width = Math.min((item.offset + item.labelOffset) * leftBoundFactor, (drawingArea.left + drawingArea.width + drawingArea.right - item.offset - item.labelOffset) * rightBoundFactor);
38
+ const doesTextFit = text => (0, _ellipsize.doesTextFitInRect)(text, {
39
+ width,
40
+ height: maxHeight,
41
+ angle,
42
+ measureText: string => (0, _domUtils.getStringSize)(string, tickLabelStyle)
43
+ });
44
+ shortenedLabels.set(item, (0, _ellipsize.ellipsize)(item.formattedValue.toString(), doesTextFit));
45
+ }
46
+ }
47
+ return shortenedLabels;
48
+ }
@@ -17,7 +17,6 @@ var _styles = require("@mui/material/styles");
17
17
  var _RtlProvider = require("@mui/system/RtlProvider");
18
18
  var _useIsHydrated = require("../hooks/useIsHydrated");
19
19
  var _defaultTextPlacement = require("../ChartsText/defaultTextPlacement");
20
- var _ellipsize = require("../internals/ellipsize");
21
20
  var _domUtils = require("../internals/domUtils");
22
21
  var _useTicks = require("../hooks/useTicks");
23
22
  var _useDrawingArea = require("../hooks/useDrawingArea");
@@ -28,8 +27,8 @@ var _isInfinity = require("../internals/isInfinity");
28
27
  var _isBandScale = require("../internals/isBandScale");
29
28
  var _ChartProvider = require("../context/ChartProvider");
30
29
  var _hooks = require("../hooks");
31
- var _clampAngle = require("../internals/clampAngle");
32
30
  var _invertTextAnchor = require("../internals/invertTextAnchor");
31
+ var _shortenLabels = require("./shortenLabels");
33
32
  var _jsxRuntime = require("react/jsx-runtime");
34
33
  const _excluded = ["scale", "tickNumber"];
35
34
  const useUtilityClasses = ownerState => {
@@ -53,42 +52,6 @@ const useUtilityClasses = ownerState => {
53
52
  const TICK_LABEL_GAP = 2;
54
53
  /* Gap between the axis label and tick labels. */
55
54
  const AXIS_LABEL_TICK_LABEL_GAP = 2;
56
- function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelStyle) {
57
- const shortenedLabels = new Map();
58
- const angle = (0, _clampAngle.clampAngle)(tickLabelStyle?.angle ?? 0);
59
- let topBoundFactor = 1;
60
- let bottomBoundFactor = 1;
61
- if (tickLabelStyle?.textAnchor === 'start') {
62
- topBoundFactor = Infinity;
63
- bottomBoundFactor = 1;
64
- } else if (tickLabelStyle?.textAnchor === 'end') {
65
- topBoundFactor = 1;
66
- bottomBoundFactor = Infinity;
67
- } else {
68
- topBoundFactor = 2;
69
- bottomBoundFactor = 2;
70
- }
71
- if (angle > 180) {
72
- [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
73
- }
74
- if (isRtl) {
75
- [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
76
- }
77
- for (const item of visibleLabels) {
78
- if (item.formattedValue) {
79
- // That maximum height of the tick depends on its proximity to the axis bounds.
80
- const height = Math.min((item.offset + item.labelOffset) * topBoundFactor, (drawingArea.top + drawingArea.height + drawingArea.bottom - item.offset - item.labelOffset) * bottomBoundFactor);
81
- const doesTextFit = text => (0, _ellipsize.doesTextFitInRect)(text, {
82
- width: maxWidth,
83
- height,
84
- angle,
85
- measureText: string => (0, _domUtils.getStringSize)(string, tickLabelStyle)
86
- });
87
- shortenedLabels.set(item, (0, _ellipsize.ellipsize)(item.formattedValue.toString(), doesTextFit));
88
- }
89
- }
90
- return shortenedLabels;
91
- }
92
55
  const YAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
93
56
  name: 'MuiChartsYAxis',
94
57
  slot: 'Root'
@@ -226,7 +189,7 @@ function ChartsYAxis(inProps) {
226
189
  };
227
190
  /* If there's an axis title, the tick labels have less space to render */
228
191
  const tickLabelsMaxWidth = Math.max(0, axisWidth - (label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height + AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - TICK_LABEL_GAP);
229
- const tickLabels = isHydrated ? shortenLabels(yTicks, drawingArea, tickLabelsMaxWidth, isRtl, axisTickLabelProps.style) : new Map(Array.from(yTicks).map(item => [item, item.formattedValue]));
192
+ const tickLabels = isHydrated ? (0, _shortenLabels.shortenLabels)(yTicks, drawingArea, tickLabelsMaxWidth, isRtl, axisTickLabelProps.style) : new Map(Array.from(yTicks).map(item => [item, item.formattedValue]));
230
193
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(YAxisRoot, {
231
194
  transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
232
195
  className: classes.root,
@@ -0,0 +1,4 @@
1
+ import { ChartDrawingArea } from "../hooks/index.js";
2
+ import { TickItemType } from "../hooks/useTicks.js";
3
+ import { ChartsYAxisProps } from "../models/index.js";
4
+ export declare function shortenLabels(visibleLabels: TickItemType[], drawingArea: Pick<ChartDrawingArea, 'top' | 'height' | 'bottom'>, maxWidth: number, isRtl: boolean, tickLabelStyle: ChartsYAxisProps['tickLabelStyle']): Map<TickItemType, string>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.shortenLabels = shortenLabels;
8
+ var _clampAngle = require("../internals/clampAngle");
9
+ var _ellipsize = require("../internals/ellipsize");
10
+ var _domUtils = require("../internals/domUtils");
11
+ function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelStyle) {
12
+ const shortenedLabels = new Map();
13
+ const angle = (0, _clampAngle.clampAngle)(tickLabelStyle?.angle ?? 0);
14
+ let topBoundFactor = 1;
15
+ let bottomBoundFactor = 1;
16
+ if (tickLabelStyle?.textAnchor === 'start') {
17
+ topBoundFactor = Infinity;
18
+ bottomBoundFactor = 1;
19
+ } else if (tickLabelStyle?.textAnchor === 'end') {
20
+ topBoundFactor = 1;
21
+ bottomBoundFactor = Infinity;
22
+ } else {
23
+ topBoundFactor = 2;
24
+ bottomBoundFactor = 2;
25
+ }
26
+ if (angle > 180) {
27
+ [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
28
+ }
29
+ if (isRtl) {
30
+ [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
31
+ }
32
+ for (const item of visibleLabels) {
33
+ if (item.formattedValue) {
34
+ // That maximum height of the tick depends on its proximity to the axis bounds.
35
+ const height = Math.min((item.offset + item.labelOffset) * topBoundFactor, (drawingArea.top + drawingArea.height + drawingArea.bottom - item.offset - item.labelOffset) * bottomBoundFactor);
36
+ const doesTextFit = text => (0, _ellipsize.doesTextFitInRect)(text, {
37
+ width: maxWidth,
38
+ height,
39
+ angle,
40
+ measureText: string => (0, _domUtils.getStringSize)(string, tickLabelStyle)
41
+ });
42
+ shortenedLabels.set(item, (0, _ellipsize.ellipsize)(item.formattedValue.toString(), doesTextFit));
43
+ }
44
+ }
45
+ return shortenedLabels;
46
+ }
@@ -41,7 +41,10 @@ function AnimatedArea(props) {
41
41
  // eslint-disable-next-line no-nested-ternary
42
42
  ownerState.isHighlighted ? 'brightness(140%)' : ownerState.gradientId ? undefined : 'brightness(120%)',
43
43
  opacity: ownerState.isFaded ? 0.3 : 1,
44
- stroke: "none"
44
+ stroke: "none",
45
+ "data-series": ownerState.id,
46
+ "data-highlighted": ownerState.isHighlighted || undefined,
47
+ "data-faded": ownerState.isFaded || undefined
45
48
  }, other, animatedProps))
46
49
  });
47
50
  }
@@ -43,7 +43,10 @@ const AnimatedLine = exports.AnimatedLine = /*#__PURE__*/React.forwardRef(functi
43
43
  strokeLinejoin: "round",
44
44
  fill: "none",
45
45
  filter: ownerState.isHighlighted ? 'brightness(120%)' : undefined,
46
- opacity: ownerState.isFaded ? 0.3 : 1
46
+ opacity: ownerState.isFaded ? 0.3 : 1,
47
+ "data-series": ownerState.id,
48
+ "data-highlighted": ownerState.isHighlighted || undefined,
49
+ "data-faded": ownerState.isFaded || undefined
47
50
  }, other, animateProps))
48
51
  });
49
52
  });
@@ -76,7 +76,10 @@ function CircleMarkElement(props) {
76
76
  className: classes.root,
77
77
  onClick: onClick,
78
78
  cursor: onClick ? 'pointer' : 'unset'
79
- }, interactionProps));
79
+ }, interactionProps, {
80
+ "data-highlighted": isHighlighted || undefined,
81
+ "data-faded": isFaded || undefined
82
+ }));
80
83
  }
81
84
  process.env.NODE_ENV !== "production" ? CircleMarkElement.propTypes = {
82
85
  // ----------------------------- Warning --------------------------------
@@ -84,7 +84,10 @@ function MarkElement(props) {
84
84
  d: (0, _d3Shape.symbol)(_d3Shape.symbolsFill[(0, _getSymbol.getSymbol)(shape)])(),
85
85
  onClick: onClick,
86
86
  cursor: onClick ? 'pointer' : 'unset'
87
- }, interactionProps));
87
+ }, interactionProps, {
88
+ "data-highlighted": isHighlighted || undefined,
89
+ "data-faded": isFaded || undefined
90
+ }));
88
91
  }
89
92
  process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
90
93
  // ----------------------------- Warning --------------------------------
@@ -109,6 +109,7 @@ function MarkPlot(props) {
109
109
  });
110
110
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
111
111
  clipPath: `url(#${clipId})`,
112
+ "data-series": seriesId,
112
113
  children: xData?.map((x, index) => {
113
114
  const value = data[index] == null ? null : stackedData[index][1];
114
115
  return {
@@ -103,7 +103,9 @@ const PieArc = exports.PieArc = /*#__PURE__*/React.forwardRef(function PieArc(pr
103
103
  opacity: ownerState.isFaded ? 0.3 : 1,
104
104
  filter: ownerState.isHighlighted ? 'brightness(120%)' : 'none',
105
105
  strokeWidth: 1,
106
- strokeLinejoin: "round"
106
+ strokeLinejoin: "round",
107
+ "data-highlighted": ownerState.isHighlighted || undefined,
108
+ "data-faded": ownerState.isFaded || undefined
107
109
  }, other, interactionProps, animatedProps));
108
110
  });
109
111
  if (process.env.NODE_ENV !== "production") PieArc.displayName = "PieArc";
@@ -16,6 +16,7 @@ var _getPieCoordinates = require("./getPieCoordinates");
16
16
  var _usePieSeries = require("../hooks/usePieSeries");
17
17
  var _useSkipAnimation = require("../hooks/useSkipAnimation");
18
18
  var _hooks = require("../hooks");
19
+ var _pieClasses = require("./pieClasses");
19
20
  var _jsxRuntime = require("react/jsx-runtime");
20
21
  /**
21
22
  * Demos:
@@ -42,6 +43,7 @@ function PiePlot(props) {
42
43
  height
43
44
  } = (0, _hooks.useDrawingArea)();
44
45
  const skipAnimation = (0, _useSkipAnimation.useSkipAnimation)(inSkipAnimation);
46
+ const classes = (0, _pieClasses.useUtilityClasses)();
45
47
  if (seriesData === undefined) {
46
48
  return null;
47
49
  }
@@ -76,7 +78,9 @@ function PiePlot(props) {
76
78
  const outerRadius = (0, _getPercentageValue.getPercentageValue)(outerRadiusParam ?? availableRadius, availableRadius);
77
79
  const innerRadius = (0, _getPercentageValue.getPercentageValue)(innerRadiusParam ?? 0, availableRadius);
78
80
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
81
+ className: classes.series,
79
82
  transform: `translate(${left + cx}, ${top + cy})`,
83
+ "data-series": seriesId,
80
84
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PieArcPlot.PieArcPlot, {
81
85
  innerRadius: innerRadius,
82
86
  outerRadius: outerRadius,
@@ -120,7 +124,9 @@ function PiePlot(props) {
120
124
  const innerRadius = (0, _getPercentageValue.getPercentageValue)(innerRadiusParam ?? 0, availableRadius);
121
125
  const arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : (0, _getPercentageValue.getPercentageValue)(arcLabelRadiusParam, availableRadius);
122
126
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
127
+ className: classes.seriesLabels,
123
128
  transform: `translate(${left + cx}, ${top + cy})`,
129
+ "data-series": seriesId,
124
130
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PieArcLabelPlot.PieArcLabelPlot, {
125
131
  innerRadius: innerRadius,
126
132
  outerRadius: outerRadius ?? availableRadius,
@@ -4,4 +4,6 @@ export * from "./PieArcPlot.js";
4
4
  export * from "./PieArcLabelPlot.js";
5
5
  export * from "./PieArc.js";
6
6
  export * from "./PieArcLabel.js";
7
- export * from "./getPieCoordinates.js";
7
+ export * from "./getPieCoordinates.js";
8
+ export { pieClasses } from "./pieClasses.js";
9
+ export type { PieClasses, PieClassKey } from "./pieClasses.js";
package/PieChart/index.js CHANGED
@@ -3,9 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ pieClasses: true
8
+ };
9
+ Object.defineProperty(exports, "pieClasses", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _pieClasses.pieClasses;
13
+ }
14
+ });
6
15
  var _PieChart = require("./PieChart");
7
16
  Object.keys(_PieChart).forEach(function (key) {
8
17
  if (key === "default" || key === "__esModule") return;
18
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
9
19
  if (key in exports && exports[key] === _PieChart[key]) return;
10
20
  Object.defineProperty(exports, key, {
11
21
  enumerable: true,
@@ -17,6 +27,7 @@ Object.keys(_PieChart).forEach(function (key) {
17
27
  var _PiePlot = require("./PiePlot");
18
28
  Object.keys(_PiePlot).forEach(function (key) {
19
29
  if (key === "default" || key === "__esModule") return;
30
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
31
  if (key in exports && exports[key] === _PiePlot[key]) return;
21
32
  Object.defineProperty(exports, key, {
22
33
  enumerable: true,
@@ -28,6 +39,7 @@ Object.keys(_PiePlot).forEach(function (key) {
28
39
  var _PieArcPlot = require("./PieArcPlot");
29
40
  Object.keys(_PieArcPlot).forEach(function (key) {
30
41
  if (key === "default" || key === "__esModule") return;
42
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
31
43
  if (key in exports && exports[key] === _PieArcPlot[key]) return;
32
44
  Object.defineProperty(exports, key, {
33
45
  enumerable: true,
@@ -39,6 +51,7 @@ Object.keys(_PieArcPlot).forEach(function (key) {
39
51
  var _PieArcLabelPlot = require("./PieArcLabelPlot");
40
52
  Object.keys(_PieArcLabelPlot).forEach(function (key) {
41
53
  if (key === "default" || key === "__esModule") return;
54
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
42
55
  if (key in exports && exports[key] === _PieArcLabelPlot[key]) return;
43
56
  Object.defineProperty(exports, key, {
44
57
  enumerable: true,
@@ -50,6 +63,7 @@ Object.keys(_PieArcLabelPlot).forEach(function (key) {
50
63
  var _PieArc = require("./PieArc");
51
64
  Object.keys(_PieArc).forEach(function (key) {
52
65
  if (key === "default" || key === "__esModule") return;
66
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
53
67
  if (key in exports && exports[key] === _PieArc[key]) return;
54
68
  Object.defineProperty(exports, key, {
55
69
  enumerable: true,
@@ -61,6 +75,7 @@ Object.keys(_PieArc).forEach(function (key) {
61
75
  var _PieArcLabel = require("./PieArcLabel");
62
76
  Object.keys(_PieArcLabel).forEach(function (key) {
63
77
  if (key === "default" || key === "__esModule") return;
78
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
79
  if (key in exports && exports[key] === _PieArcLabel[key]) return;
65
80
  Object.defineProperty(exports, key, {
66
81
  enumerable: true,
@@ -72,6 +87,7 @@ Object.keys(_PieArcLabel).forEach(function (key) {
72
87
  var _getPieCoordinates = require("./getPieCoordinates");
73
88
  Object.keys(_getPieCoordinates).forEach(function (key) {
74
89
  if (key === "default" || key === "__esModule") return;
90
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
75
91
  if (key in exports && exports[key] === _getPieCoordinates[key]) return;
76
92
  Object.defineProperty(exports, key, {
77
93
  enumerable: true,
@@ -79,4 +95,5 @@ Object.keys(_getPieCoordinates).forEach(function (key) {
79
95
  return _getPieCoordinates[key];
80
96
  }
81
97
  });
82
- });
98
+ });
99
+ var _pieClasses = require("./pieClasses");
@@ -0,0 +1,12 @@
1
+ export interface PieClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ /** Styles applied to the `g` element that contains all pie arcs of a series. */
5
+ series: string;
6
+ /** Styles applied to the `g` element that contains all pie arc labels of a series. */
7
+ seriesLabels: string;
8
+ }
9
+ export type PieClassKey = keyof PieClasses;
10
+ export declare function getPieUtilityClass(slot: string): string;
11
+ export declare const pieClasses: PieClasses;
12
+ export declare const useUtilityClasses: (classes?: Partial<PieClasses>) => Record<"root" | "series" | "seriesLabels", string>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getPieUtilityClass = getPieUtilityClass;
8
+ exports.useUtilityClasses = exports.pieClasses = void 0;
9
+ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
10
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
11
+ var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
12
+ function getPieUtilityClass(slot) {
13
+ return (0, _generateUtilityClass.default)('MuiPieChart', slot);
14
+ }
15
+ const pieClasses = exports.pieClasses = (0, _generateUtilityClasses.default)('MuiPieChart', ['root', 'series', 'seriesLabels']);
16
+ const useUtilityClasses = classes => {
17
+ const slots = {
18
+ root: ['root'],
19
+ series: ['series'],
20
+ seriesLabels: ['seriesLabels']
21
+ };
22
+ return (0, _composeClasses.default)(slots, getPieUtilityClass, classes);
23
+ };
24
+ exports.useUtilityClasses = useUtilityClasses;
@@ -51,10 +51,12 @@ process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
51
51
  // ----------------------------------------------------------------------
52
52
  className: _propTypes.default.string,
53
53
  disabled: _propTypes.default.bool,
54
+ id: _propTypes.default.string,
54
55
  /**
55
56
  * A function to customize the rendering of the component.
56
57
  */
57
58
  render: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
59
+ size: _propTypes.default.oneOf(['large', 'medium', 'small']),
58
60
  style: _propTypes.default.object,
59
61
  tabIndex: _propTypes.default.number
60
62
  } : void 0;
@@ -14,6 +14,8 @@ export function AnimatedBarElement(props) {
14
14
  const animatedProps = useAnimateBar(props);
15
15
  return /*#__PURE__*/_jsx("rect", _extends({}, other, {
16
16
  filter: ownerState.isHighlighted ? 'brightness(120%)' : undefined,
17
- opacity: ownerState.isFaded ? 0.3 : 1
17
+ opacity: ownerState.isFaded ? 0.3 : 1,
18
+ "data-highlighted": ownerState.isHighlighted || undefined,
19
+ "data-faded": ownerState.isFaded || undefined
18
20
  }, animatedProps));
19
21
  }
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
- import type { CompletedBarData } from "../types.js";
2
+ import type { ProcessedBarSeriesData } from "../types.js";
3
3
  import { BarLabelItemProps } from "./BarLabelItem.js";
4
4
  type BarLabelPlotProps = {
5
- bars: CompletedBarData[];
5
+ bars: ProcessedBarSeriesData[];
6
6
  skipAnimation?: boolean;
7
7
  barLabel?: BarLabelItemProps['barLabel'];
8
8
  };
@@ -3,6 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["bars", "skipAnimation"];
4
4
  import * as React from 'react';
5
5
  import { BarLabelItem } from "./BarLabelItem.js";
6
+ import { useUtilityClasses } from "../barClasses.js";
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  /**
8
9
  * @ignore - internal component.
@@ -13,33 +14,40 @@ function BarLabelPlot(props) {
13
14
  skipAnimation
14
15
  } = props,
15
16
  other = _objectWithoutPropertiesLoose(props, _excluded);
17
+ const classes = useUtilityClasses();
16
18
  return /*#__PURE__*/_jsx(React.Fragment, {
17
- children: bars.map(({
18
- xOrigin,
19
- yOrigin,
20
- x,
21
- y,
19
+ children: bars.flatMap(({
22
20
  seriesId,
23
- dataIndex,
24
- color,
25
- value,
26
- width,
27
- height,
28
- layout
29
- }) => /*#__PURE__*/_jsx(BarLabelItem, _extends({
30
- seriesId: seriesId,
31
- dataIndex: dataIndex,
32
- value: value,
33
- color: color,
34
- xOrigin: xOrigin,
35
- yOrigin: yOrigin,
36
- x: x,
37
- y: y,
38
- width: width,
39
- height: height,
40
- skipAnimation: skipAnimation ?? false,
41
- layout: layout ?? 'vertical'
42
- }, other), `${seriesId}-${dataIndex}`))
21
+ data
22
+ }) => /*#__PURE__*/_jsx("g", {
23
+ className: classes.seriesLabels,
24
+ "data-series": seriesId,
25
+ children: data.map(({
26
+ xOrigin,
27
+ yOrigin,
28
+ x,
29
+ y,
30
+ dataIndex,
31
+ color,
32
+ value,
33
+ width,
34
+ height,
35
+ layout
36
+ }) => /*#__PURE__*/_jsx(BarLabelItem, _extends({
37
+ seriesId: seriesId,
38
+ dataIndex: dataIndex,
39
+ value: value,
40
+ color: color,
41
+ xOrigin: xOrigin,
42
+ yOrigin: yOrigin,
43
+ x: x,
44
+ y: y,
45
+ width: width,
46
+ height: height,
47
+ skipAnimation: skipAnimation ?? false,
48
+ layout: layout ?? 'vertical'
49
+ }, other), dataIndex))
50
+ }, seriesId))
43
51
  });
44
52
  }
45
53
  export { BarLabelPlot };