@mui/x-charts 8.5.2 → 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 (188) 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 +203 -11
  11. package/ChartsLegend/ChartsLegend.d.ts +1 -0
  12. package/ChartsLegend/ChartsLegend.js +2 -0
  13. package/ChartsLegend/ContinuousColorLegend.d.ts +1 -0
  14. package/ChartsLegend/PiecewiseColorLegend.d.ts +1 -0
  15. package/ChartsLegend/chartsLegendClasses.d.ts +3 -1
  16. package/ChartsLegend/chartsLegendClasses.js +2 -1
  17. package/ChartsSurface/ChartsSurface.d.ts +1 -1
  18. package/ChartsXAxis/ChartsXAxis.js +4 -108
  19. package/ChartsXAxis/getVisibleLabels.d.ts +14 -0
  20. package/ChartsXAxis/getVisibleLabels.js +71 -0
  21. package/ChartsXAxis/shortenLabels.d.ts +4 -0
  22. package/ChartsXAxis/shortenLabels.js +48 -0
  23. package/ChartsYAxis/ChartsYAxis.js +2 -39
  24. package/ChartsYAxis/shortenLabels.d.ts +4 -0
  25. package/ChartsYAxis/shortenLabels.js +46 -0
  26. package/LineChart/AnimatedArea.js +4 -1
  27. package/LineChart/AnimatedLine.js +4 -1
  28. package/LineChart/CircleMarkElement.js +4 -1
  29. package/LineChart/MarkElement.js +4 -1
  30. package/LineChart/MarkPlot.js +1 -0
  31. package/PieChart/PieArc.js +3 -1
  32. package/PieChart/PiePlot.js +6 -0
  33. package/PieChart/index.d.ts +3 -1
  34. package/PieChart/index.js +18 -1
  35. package/PieChart/pieClasses.d.ts +12 -0
  36. package/PieChart/pieClasses.js +24 -0
  37. package/ScatterChart/Scatter.d.ts +2 -0
  38. package/ScatterChart/Scatter.js +9 -1
  39. package/ScatterChart/index.d.ts +3 -1
  40. package/ScatterChart/index.js +16 -1
  41. package/ScatterChart/scatterClasses.d.ts +8 -0
  42. package/ScatterChart/scatterClasses.js +22 -0
  43. package/Toolbar/ToolbarButton.js +2 -0
  44. package/esm/BarChart/AnimatedBarElement.js +3 -1
  45. package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
  46. package/esm/BarChart/BarLabel/BarLabelPlot.js +33 -25
  47. package/esm/BarChart/BarPlot.js +55 -40
  48. package/esm/BarChart/barClasses.d.ts +12 -0
  49. package/esm/BarChart/barClasses.js +15 -0
  50. package/esm/BarChart/index.d.ts +3 -1
  51. package/esm/BarChart/index.js +2 -1
  52. package/esm/BarChart/types.d.ts +5 -1
  53. package/esm/ChartsLegend/ChartsLegend.d.ts +1 -0
  54. package/esm/ChartsLegend/ChartsLegend.js +2 -0
  55. package/esm/ChartsLegend/ContinuousColorLegend.d.ts +1 -0
  56. package/esm/ChartsLegend/PiecewiseColorLegend.d.ts +1 -0
  57. package/esm/ChartsLegend/chartsLegendClasses.d.ts +3 -1
  58. package/esm/ChartsLegend/chartsLegendClasses.js +2 -1
  59. package/esm/ChartsSurface/ChartsSurface.d.ts +1 -1
  60. package/esm/ChartsXAxis/ChartsXAxis.js +2 -106
  61. package/esm/ChartsXAxis/getVisibleLabels.d.ts +14 -0
  62. package/esm/ChartsXAxis/getVisibleLabels.js +67 -0
  63. package/esm/ChartsXAxis/shortenLabels.d.ts +4 -0
  64. package/esm/ChartsXAxis/shortenLabels.js +42 -0
  65. package/esm/ChartsYAxis/ChartsYAxis.js +1 -38
  66. package/esm/ChartsYAxis/shortenLabels.d.ts +4 -0
  67. package/esm/ChartsYAxis/shortenLabels.js +41 -0
  68. package/esm/LineChart/AnimatedArea.js +4 -1
  69. package/esm/LineChart/AnimatedLine.js +4 -1
  70. package/esm/LineChart/CircleMarkElement.js +4 -1
  71. package/esm/LineChart/MarkElement.js +4 -1
  72. package/esm/LineChart/MarkPlot.js +1 -0
  73. package/esm/PieChart/PieArc.js +3 -1
  74. package/esm/PieChart/PiePlot.js +6 -0
  75. package/esm/PieChart/index.d.ts +3 -1
  76. package/esm/PieChart/index.js +2 -1
  77. package/esm/PieChart/pieClasses.d.ts +12 -0
  78. package/esm/PieChart/pieClasses.js +15 -0
  79. package/esm/ScatterChart/Scatter.d.ts +2 -0
  80. package/esm/ScatterChart/Scatter.js +9 -1
  81. package/esm/ScatterChart/index.d.ts +3 -1
  82. package/esm/ScatterChart/index.js +2 -1
  83. package/esm/ScatterChart/scatterClasses.d.ts +8 -0
  84. package/esm/ScatterChart/scatterClasses.js +13 -0
  85. package/esm/Toolbar/ToolbarButton.js +2 -0
  86. package/esm/hooks/useItemHighlighted.js +2 -2
  87. package/esm/index.js +1 -1
  88. package/esm/internals/components/NotRendered.d.ts +9 -0
  89. package/esm/internals/components/NotRendered.js +10 -0
  90. package/esm/internals/createSeriesSelectorOfType.js +2 -2
  91. package/esm/internals/index.d.ts +1 -0
  92. package/esm/internals/index.js +1 -0
  93. package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +3 -29
  94. package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +1 -1
  95. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +30 -2
  96. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +14 -724
  97. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +10 -10
  98. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +8 -2
  99. package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +3 -29
  100. package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +1 -1
  101. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +6 -54
  102. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +2 -2
  103. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +12 -208
  104. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +7 -66
  105. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +2 -3
  106. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +21 -6222
  107. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +4 -6
  108. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +50 -5
  109. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +18 -622
  110. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -3
  111. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +18 -230
  112. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +6 -6
  113. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +20 -4
  114. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +17 -2012
  115. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +2 -2
  116. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +39 -4
  117. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +3 -27
  118. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +1 -1
  119. package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +5 -40
  120. package/esm/internals/plugins/utils/selectors.d.ts +18 -6
  121. package/esm/internals/plugins/utils/selectors.js +3 -3
  122. package/esm/internals/store/useSelector.d.ts +2 -2
  123. package/esm/internals/store/useSelector.js +2 -2
  124. package/esm/locales/enUS.d.ts +3 -0
  125. package/esm/locales/enUS.js +8 -2
  126. package/esm/locales/frFR.d.ts +3 -0
  127. package/esm/locales/frFR.js +7 -0
  128. package/esm/locales/ptBR.d.ts +3 -0
  129. package/esm/locales/ptBR.js +7 -1
  130. package/esm/locales/ptPT.d.ts +3 -0
  131. package/esm/locales/ptPT.js +7 -1
  132. package/esm/locales/utils/chartsLocaleTextApi.d.ts +17 -0
  133. package/esm/locales/utils/getChartsLocalization.d.ts +3 -0
  134. package/esm/locales/utils/imageMimeTypes.d.ts +2 -0
  135. package/esm/locales/utils/imageMimeTypes.js +5 -0
  136. package/esm/models/slots/chartsBaseSlotProps.d.ts +4 -0
  137. package/hooks/useItemHighlighted.js +2 -2
  138. package/index.js +1 -1
  139. package/internals/components/NotRendered.d.ts +9 -0
  140. package/internals/components/NotRendered.js +16 -0
  141. package/internals/createSeriesSelectorOfType.js +2 -2
  142. package/internals/index.d.ts +1 -0
  143. package/internals/index.js +12 -0
  144. package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +3 -29
  145. package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +1 -1
  146. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +30 -2
  147. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +14 -724
  148. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +11 -10
  149. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +8 -2
  150. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +3 -29
  151. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +1 -1
  152. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +6 -54
  153. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +2 -2
  154. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +12 -208
  155. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +7 -66
  156. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +4 -3
  157. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +21 -6222
  158. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +4 -6
  159. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +50 -5
  160. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +18 -622
  161. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -3
  162. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +18 -230
  163. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +6 -6
  164. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +20 -4
  165. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +17 -2012
  166. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +2 -2
  167. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +39 -4
  168. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +3 -27
  169. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +1 -1
  170. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +5 -40
  171. package/internals/plugins/utils/selectors.d.ts +18 -6
  172. package/internals/plugins/utils/selectors.js +3 -3
  173. package/internals/store/useSelector.d.ts +2 -2
  174. package/internals/store/useSelector.js +2 -2
  175. package/locales/enUS.d.ts +3 -0
  176. package/locales/enUS.js +8 -2
  177. package/locales/frFR.d.ts +3 -0
  178. package/locales/frFR.js +7 -0
  179. package/locales/ptBR.d.ts +3 -0
  180. package/locales/ptBR.js +7 -1
  181. package/locales/ptPT.d.ts +3 -0
  182. package/locales/ptPT.js +7 -1
  183. package/locales/utils/chartsLocaleTextApi.d.ts +17 -0
  184. package/locales/utils/getChartsLocalization.d.ts +3 -0
  185. package/locales/utils/imageMimeTypes.d.ts +2 -0
  186. package/locales/utils/imageMimeTypes.js +11 -0
  187. package/models/slots/chartsBaseSlotProps.d.ts +4 -0
  188. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import { SxProps, Theme } from '@mui/material/styles';
2
2
  import * as React from 'react';
3
- export interface ChartsSurfaceProps {
3
+ export interface ChartsSurfaceProps extends Omit<React.SVGProps<SVGSVGElement>, 'id' | 'children' | 'className' | 'height' | 'width' | 'cx' | 'cy' | 'viewBox' | 'color' | 'ref'> {
4
4
  className?: string;
5
5
  title?: string;
6
6
  desc?: string;
@@ -15,24 +15,22 @@ var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
15
15
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
16
16
  var _styles = require("@mui/material/styles");
17
17
  var _RtlProvider = require("@mui/system/RtlProvider");
18
- var _clampAngle = require("../internals/clampAngle");
19
18
  var _useIsHydrated = require("../hooks/useIsHydrated");
20
- var _ellipsize = require("../internals/ellipsize");
21
19
  var _domUtils = require("../internals/domUtils");
22
20
  var _useTicks = require("../hooks/useTicks");
23
21
  var _axisClasses = require("../ChartsAxis/axisClasses");
24
22
  var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
25
23
  var _ChartsText = require("../ChartsText");
26
- var _geometry = require("../internals/geometry");
27
24
  var _useMounted = require("../hooks/useMounted");
28
25
  var _useDrawingArea = require("../hooks/useDrawingArea");
29
- var _getWordsByLines = require("../internals/getWordsByLines");
30
26
  var _isInfinity = require("../internals/isInfinity");
31
27
  var _isBandScale = require("../internals/isBandScale");
32
28
  var _useChartContext = require("../context/ChartProvider/useChartContext");
33
29
  var _useAxis = require("../hooks/useAxis");
34
30
  var _defaultTextPlacement = require("../ChartsText/defaultTextPlacement");
35
31
  var _invertTextAnchor = require("../internals/invertTextAnchor");
32
+ var _shortenLabels = require("./shortenLabels");
33
+ var _getVisibleLabels = require("./getVisibleLabels");
36
34
  var _jsxRuntime = require("react/jsx-runtime");
37
35
  const _excluded = ["scale", "tickNumber", "reverse"];
38
36
  const useUtilityClasses = ownerState => {
@@ -56,108 +54,6 @@ const useUtilityClasses = ownerState => {
56
54
  const TICK_LABEL_GAP = 3;
57
55
  /* Gap between the axis label and tick labels. */
58
56
  const AXIS_LABEL_TICK_LABEL_GAP = 4;
59
-
60
- /* Returns a set of indices of the tick labels that should be visible. */
61
- function getVisibleLabels(xTicks, {
62
- tickLabelStyle: style,
63
- tickLabelInterval,
64
- tickLabelMinGap,
65
- reverse,
66
- isMounted,
67
- isXInside
68
- }) {
69
- const getTickLabelSize = tick => {
70
- if (!isMounted || tick.formattedValue === undefined) {
71
- return {
72
- width: 0,
73
- height: 0
74
- };
75
- }
76
- const tickSizes = (0, _getWordsByLines.getWordsByLines)({
77
- style,
78
- needsComputation: true,
79
- text: tick.formattedValue
80
- });
81
- return {
82
- width: Math.max(...tickSizes.map(size => size.width)),
83
- height: Math.max(tickSizes.length * tickSizes[0].height)
84
- };
85
- };
86
- if (typeof tickLabelInterval === 'function') {
87
- return new Set(xTicks.filter((item, index) => tickLabelInterval(item.value, index)));
88
- }
89
-
90
- // Filter label to avoid overlap
91
- let previousTextLimit = 0;
92
- const direction = reverse ? -1 : 1;
93
- return new Set(xTicks.filter((item, labelIndex) => {
94
- const {
95
- offset,
96
- labelOffset
97
- } = item;
98
- const textPosition = offset + labelOffset;
99
- if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
100
- return false;
101
- }
102
- if (!isXInside(textPosition)) {
103
- return false;
104
- }
105
-
106
- /* Measuring text width is expensive, so we need to delay it as much as possible to improve performance. */
107
- const {
108
- width,
109
- height
110
- } = getTickLabelSize(item);
111
- const distance = (0, _geometry.getMinXTranslation)(width, height, style?.angle);
112
- const currentTextLimit = textPosition - direction * distance / 2;
113
- if (labelIndex > 0 && direction * currentTextLimit < direction * (previousTextLimit + tickLabelMinGap)) {
114
- // Except for the first label, we skip all label that overlap with the last accepted.
115
- // Notice that the early return prevents `previousTextLimit` from being updated.
116
- return false;
117
- }
118
- previousTextLimit = textPosition + direction * distance / 2;
119
- return true;
120
- }));
121
- }
122
- function shortenLabels(visibleLabels, drawingArea, maxHeight, isRtl, tickLabelStyle) {
123
- const shortenedLabels = new Map();
124
- const angle = (0, _clampAngle.clampAngle)(tickLabelStyle?.angle ?? 0);
125
-
126
- // Multiplying the space available to the left of the text position by leftBoundFactor returns the max width of the text.
127
- // Same for rightBoundFactor
128
- let leftBoundFactor = 1;
129
- let rightBoundFactor = 1;
130
- if (tickLabelStyle?.textAnchor === 'start') {
131
- leftBoundFactor = Infinity;
132
- rightBoundFactor = 1;
133
- } else if (tickLabelStyle?.textAnchor === 'end') {
134
- leftBoundFactor = 1;
135
- rightBoundFactor = Infinity;
136
- } else {
137
- leftBoundFactor = 2;
138
- rightBoundFactor = 2;
139
- }
140
- if (angle > 90 && angle < 270) {
141
- [leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
142
- }
143
- if (isRtl) {
144
- [leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
145
- }
146
- for (const item of visibleLabels) {
147
- if (item.formattedValue) {
148
- // That maximum width of the tick depends on its proximity to the axis bounds.
149
- const width = Math.min((item.offset + item.labelOffset) * leftBoundFactor, (drawingArea.left + drawingArea.width + drawingArea.right - item.offset - item.labelOffset) * rightBoundFactor);
150
- const doesTextFit = text => (0, _ellipsize.doesTextFitInRect)(text, {
151
- width,
152
- height: maxHeight,
153
- angle,
154
- measureText: string => (0, _domUtils.getStringSize)(string, tickLabelStyle)
155
- });
156
- shortenedLabels.set(item, (0, _ellipsize.ellipsize)(item.formattedValue.toString(), doesTextFit));
157
- }
158
- }
159
- return shortenedLabels;
160
- }
161
57
  const XAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
162
58
  name: 'MuiChartsXAxis',
163
59
  slot: 'Root'
@@ -261,7 +157,7 @@ function ChartsXAxis(inProps) {
261
157
  tickLabelPlacement,
262
158
  direction: 'x'
263
159
  });
264
- const visibleLabels = getVisibleLabels(xTicks, {
160
+ const visibleLabels = (0, _getVisibleLabels.getVisibleLabels)(xTicks, {
265
161
  tickLabelStyle: axisTickLabelProps.style,
266
162
  tickLabelInterval,
267
163
  tickLabelMinGap,
@@ -299,7 +195,7 @@ function ChartsXAxis(inProps) {
299
195
 
300
196
  /* If there's an axis title, the tick labels have less space to render */
301
197
  const tickLabelsMaxHeight = Math.max(0, axisHeight - (label ? labelHeight + AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - TICK_LABEL_GAP);
302
- const tickLabels = isHydrated ? shortenLabels(visibleLabels, drawingArea, tickLabelsMaxHeight, isRtl, axisTickLabelProps.style) : new Map(Array.from(visibleLabels).map(item => [item, item.formattedValue]));
198
+ const tickLabels = isHydrated ? (0, _shortenLabels.shortenLabels)(visibleLabels, drawingArea, tickLabelsMaxHeight, isRtl, axisTickLabelProps.style) : new Map(Array.from(visibleLabels).map(item => [item, item.formattedValue]));
303
199
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(XAxisRoot, {
304
200
  transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
305
201
  className: classes.root,
@@ -0,0 +1,14 @@
1
+ import { TickItemType } from "../hooks/useTicks.js";
2
+ import { ChartsXAxisProps, ComputedXAxis } from "../models/axis.js";
3
+ export declare function getVisibleLabels(xTicks: TickItemType[], {
4
+ tickLabelStyle: style,
5
+ tickLabelInterval,
6
+ tickLabelMinGap,
7
+ reverse,
8
+ isMounted,
9
+ isXInside
10
+ }: Pick<ChartsXAxisProps, 'tickLabelInterval' | 'tickLabelStyle'> & Pick<ComputedXAxis, 'reverse'> & {
11
+ isMounted: boolean;
12
+ tickLabelMinGap: NonNullable<ChartsXAxisProps['tickLabelMinGap']>;
13
+ isXInside: (x: number) => boolean;
14
+ }): Set<TickItemType>;
@@ -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;