@mui/x-charts 8.5.3 → 8.7.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 (228) 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 +59 -183
  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/BarChart/useBarPlotData.d.ts +8 -0
  11. package/BarChart/useBarPlotData.js +146 -0
  12. package/CHANGELOG.md +210 -0
  13. package/ChartContainer/ChartContainer.d.ts +1 -21
  14. package/ChartContainer/ChartContainer.js +0 -8
  15. package/ChartContainer/index.d.ts +8 -1
  16. package/ChartsLegend/ChartsLegend.js +1 -0
  17. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  18. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
  19. package/ChartsReferenceLine/ChartsXReferenceLine.js +48 -1
  20. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
  21. package/ChartsReferenceLine/ChartsYReferenceLine.js +48 -1
  22. package/ChartsReferenceLine/index.d.ts +3 -1
  23. package/ChartsSurface/ChartsSurface.js +2 -1
  24. package/ChartsTooltip/ChartsTooltipContainer.js +6 -3
  25. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  26. package/ChartsTooltip/utils.js +18 -29
  27. package/ChartsXAxis/ChartsXAxis.js +4 -108
  28. package/ChartsXAxis/getVisibleLabels.d.ts +14 -0
  29. package/ChartsXAxis/getVisibleLabels.js +71 -0
  30. package/ChartsXAxis/shortenLabels.d.ts +4 -0
  31. package/ChartsXAxis/shortenLabels.js +48 -0
  32. package/ChartsYAxis/ChartsYAxis.js +2 -39
  33. package/ChartsYAxis/shortenLabels.d.ts +4 -0
  34. package/ChartsYAxis/shortenLabels.js +46 -0
  35. package/LineChart/AnimatedArea.js +4 -1
  36. package/LineChart/AnimatedLine.js +4 -1
  37. package/LineChart/AreaPlot.js +5 -115
  38. package/LineChart/CircleMarkElement.js +4 -1
  39. package/LineChart/LinePlot.js +5 -99
  40. package/LineChart/MarkElement.js +4 -1
  41. package/LineChart/MarkPlot.js +1 -0
  42. package/LineChart/useAreaPlotData.d.ts +12 -0
  43. package/LineChart/useAreaPlotData.js +125 -0
  44. package/LineChart/useLinePlotData.d.ts +11 -0
  45. package/LineChart/useLinePlotData.js +108 -0
  46. package/PieChart/PieArc.js +3 -1
  47. package/PieChart/PiePlot.js +6 -0
  48. package/PieChart/index.d.ts +3 -1
  49. package/PieChart/index.js +18 -1
  50. package/PieChart/pieClasses.d.ts +12 -0
  51. package/PieChart/pieClasses.js +24 -0
  52. package/ScatterChart/Scatter.js +22 -48
  53. package/ScatterChart/useScatterPlotData.d.ts +8 -0
  54. package/ScatterChart/useScatterPlotData.js +33 -0
  55. package/Toolbar/ToolbarButton.js +2 -0
  56. package/context/ChartApi.d.ts +22 -0
  57. package/context/ChartApi.js +5 -0
  58. package/context/ChartProvider/ChartContext.js +1 -0
  59. package/context/index.d.ts +2 -1
  60. package/context/useChartApiContext.d.ts +1 -1
  61. package/esm/BarChart/AnimatedBarElement.js +3 -1
  62. package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
  63. package/esm/BarChart/BarLabel/BarLabelPlot.js +33 -25
  64. package/esm/BarChart/BarPlot.js +60 -185
  65. package/esm/BarChart/barClasses.d.ts +12 -0
  66. package/esm/BarChart/barClasses.js +15 -0
  67. package/esm/BarChart/index.d.ts +3 -1
  68. package/esm/BarChart/index.js +2 -1
  69. package/esm/BarChart/types.d.ts +5 -1
  70. package/esm/BarChart/useBarPlotData.d.ts +8 -0
  71. package/esm/BarChart/useBarPlotData.js +139 -0
  72. package/esm/ChartContainer/ChartContainer.d.ts +1 -21
  73. package/esm/ChartContainer/ChartContainer.js +0 -8
  74. package/esm/ChartContainer/index.d.ts +8 -1
  75. package/esm/ChartContainer/index.js +6 -1
  76. package/esm/ChartsLegend/ChartsLegend.js +1 -0
  77. package/esm/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  78. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
  79. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +47 -0
  80. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
  81. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +47 -0
  82. package/esm/ChartsReferenceLine/index.d.ts +3 -1
  83. package/esm/ChartsReferenceLine/index.js +2 -1
  84. package/esm/ChartsSurface/ChartsSurface.js +2 -1
  85. package/esm/ChartsTooltip/ChartsTooltipContainer.js +6 -3
  86. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  87. package/esm/ChartsTooltip/utils.js +18 -29
  88. package/esm/ChartsXAxis/ChartsXAxis.js +2 -106
  89. package/esm/ChartsXAxis/getVisibleLabels.d.ts +14 -0
  90. package/esm/ChartsXAxis/getVisibleLabels.js +67 -0
  91. package/esm/ChartsXAxis/shortenLabels.d.ts +4 -0
  92. package/esm/ChartsXAxis/shortenLabels.js +42 -0
  93. package/esm/ChartsYAxis/ChartsYAxis.js +1 -38
  94. package/esm/ChartsYAxis/shortenLabels.d.ts +4 -0
  95. package/esm/ChartsYAxis/shortenLabels.js +41 -0
  96. package/esm/LineChart/AnimatedArea.js +4 -1
  97. package/esm/LineChart/AnimatedLine.js +4 -1
  98. package/esm/LineChart/AreaPlot.js +5 -115
  99. package/esm/LineChart/CircleMarkElement.js +4 -1
  100. package/esm/LineChart/LinePlot.js +5 -99
  101. package/esm/LineChart/MarkElement.js +4 -1
  102. package/esm/LineChart/MarkPlot.js +1 -0
  103. package/esm/LineChart/useAreaPlotData.d.ts +12 -0
  104. package/esm/LineChart/useAreaPlotData.js +118 -0
  105. package/esm/LineChart/useLinePlotData.d.ts +11 -0
  106. package/esm/LineChart/useLinePlotData.js +101 -0
  107. package/esm/PieChart/PieArc.js +3 -1
  108. package/esm/PieChart/PiePlot.js +6 -0
  109. package/esm/PieChart/index.d.ts +3 -1
  110. package/esm/PieChart/index.js +2 -1
  111. package/esm/PieChart/pieClasses.d.ts +12 -0
  112. package/esm/PieChart/pieClasses.js +15 -0
  113. package/esm/ScatterChart/Scatter.js +23 -49
  114. package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
  115. package/esm/ScatterChart/useScatterPlotData.js +26 -0
  116. package/esm/Toolbar/ToolbarButton.js +2 -0
  117. package/esm/context/ChartApi.d.ts +22 -0
  118. package/esm/context/ChartApi.js +1 -0
  119. package/esm/context/ChartProvider/ChartContext.js +2 -0
  120. package/esm/context/index.d.ts +2 -1
  121. package/esm/context/useChartApiContext.d.ts +1 -1
  122. package/esm/hooks/useInteractionItemProps.d.ts +14 -9
  123. package/esm/hooks/useInteractionItemProps.js +28 -28
  124. package/esm/index.d.ts +2 -1
  125. package/esm/index.js +2 -2
  126. package/esm/internals/components/NotRendered.d.ts +9 -0
  127. package/esm/internals/components/NotRendered.js +10 -0
  128. package/esm/internals/index.d.ts +6 -0
  129. package/esm/internals/index.js +6 -0
  130. package/esm/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
  131. package/esm/internals/plugins/corePlugins/corePlugins.js +2 -1
  132. package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
  133. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -1
  134. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
  135. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +2 -2
  136. package/esm/internals/plugins/corePlugins/useChartId/useChartId.js +2 -0
  137. package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  138. package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
  139. package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.js +1 -0
  140. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
  141. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +77 -0
  142. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
  143. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +1 -0
  144. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  145. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
  146. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
  147. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
  148. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
  149. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
  150. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
  151. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +52 -36
  152. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
  153. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
  154. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +47 -30
  155. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
  156. package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  157. package/esm/internals/store/useCharts.d.ts +1 -1
  158. package/esm/locales/elGR.d.ts +19 -0
  159. package/esm/locales/elGR.js +15 -0
  160. package/esm/locales/enUS.d.ts +3 -0
  161. package/esm/locales/enUS.js +8 -2
  162. package/esm/locales/frFR.d.ts +3 -0
  163. package/esm/locales/frFR.js +7 -0
  164. package/esm/locales/index.d.ts +1 -0
  165. package/esm/locales/index.js +1 -0
  166. package/esm/locales/ptBR.d.ts +3 -0
  167. package/esm/locales/ptBR.js +7 -1
  168. package/esm/locales/ptPT.d.ts +3 -0
  169. package/esm/locales/ptPT.js +7 -1
  170. package/esm/locales/utils/chartsLocaleTextApi.d.ts +17 -0
  171. package/esm/locales/utils/getChartsLocalization.d.ts +3 -0
  172. package/esm/locales/utils/imageMimeTypes.d.ts +2 -0
  173. package/esm/locales/utils/imageMimeTypes.js +5 -0
  174. package/esm/models/slots/chartsBaseSlotProps.d.ts +4 -0
  175. package/hooks/useInteractionItemProps.d.ts +14 -9
  176. package/hooks/useInteractionItemProps.js +29 -28
  177. package/index.d.ts +2 -1
  178. package/index.js +37 -11
  179. package/internals/components/NotRendered.d.ts +9 -0
  180. package/internals/components/NotRendered.js +16 -0
  181. package/internals/index.d.ts +6 -0
  182. package/internals/index.js +56 -0
  183. package/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
  184. package/internals/plugins/corePlugins/corePlugins.js +2 -1
  185. package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
  186. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -1
  187. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
  188. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +2 -2
  189. package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -0
  190. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  191. package/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
  192. package/internals/plugins/corePlugins/useChartInteractionListener/index.js +12 -0
  193. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
  194. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +84 -0
  195. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
  196. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +5 -0
  197. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  198. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
  199. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
  200. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
  201. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
  202. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
  203. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
  204. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +52 -36
  205. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
  206. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
  207. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +46 -30
  208. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
  209. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  210. package/internals/store/useCharts.d.ts +1 -1
  211. package/locales/elGR.d.ts +19 -0
  212. package/locales/elGR.js +21 -0
  213. package/locales/enUS.d.ts +3 -0
  214. package/locales/enUS.js +8 -2
  215. package/locales/frFR.d.ts +3 -0
  216. package/locales/frFR.js +7 -0
  217. package/locales/index.d.ts +1 -0
  218. package/locales/index.js +11 -0
  219. package/locales/ptBR.d.ts +3 -0
  220. package/locales/ptBR.js +7 -1
  221. package/locales/ptPT.d.ts +3 -0
  222. package/locales/ptPT.js +7 -1
  223. package/locales/utils/chartsLocaleTextApi.d.ts +17 -0
  224. package/locales/utils/getChartsLocalization.d.ts +3 -0
  225. package/locales/utils/imageMimeTypes.d.ts +2 -0
  226. package/locales/utils/imageMimeTypes.js +11 -0
  227. package/models/slots/chartsBaseSlotProps.d.ts +4 -0
  228. package/package.json +3 -2
@@ -1,23 +1,16 @@
1
1
  'use client';
2
2
 
3
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
5
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { styled } from '@mui/material/styles';
9
- import { warnOnce } from '@mui/x-internals/warning';
10
- import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
11
9
  import { LineElement, lineElementClasses } from "./LineElement.js";
12
- import { getValueToPositionMapper } from "../hooks/useScale.js";
13
- import { getCurveFactory } from "../internals/getCurve.js";
14
- import { isBandScale } from "../internals/isBandScale.js";
15
- import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
16
- import { useLineSeriesContext } from "../hooks/useLineSeries.js";
17
10
  import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
18
- import { useChartGradientIdBuilder } from "../hooks/useChartGradientId.js";
19
11
  import { useXAxes, useYAxes } from "../hooks/index.js";
20
12
  import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js";
13
+ import { useLinePlotData } from "./useLinePlotData.js";
21
14
  import { jsx as _jsx } from "react/jsx-runtime";
22
15
  const LinePlotRoot = styled('g', {
23
16
  name: 'MuiAreaPlot',
@@ -28,100 +21,13 @@ const LinePlotRoot = styled('g', {
28
21
  }
29
22
  });
30
23
  const useAggregatedData = () => {
31
- const seriesData = useLineSeriesContext();
32
24
  const {
33
- xAxis,
34
- xAxisIds
25
+ xAxis: xAxes
35
26
  } = useXAxes();
36
27
  const {
37
- yAxis,
38
- yAxisIds
28
+ yAxis: yAxes
39
29
  } = useYAxes();
40
- const getGradientId = useChartGradientIdBuilder();
41
-
42
- // This memo prevents odd line chart behavior when hydrating.
43
- const allData = React.useMemo(() => {
44
- if (seriesData === undefined) {
45
- return [];
46
- }
47
- const {
48
- series,
49
- stackingGroups
50
- } = seriesData;
51
- const defaultXAxisId = xAxisIds[0];
52
- const defaultYAxisId = yAxisIds[0];
53
- return stackingGroups.flatMap(({
54
- ids: groupIds
55
- }) => {
56
- return groupIds.flatMap(seriesId => {
57
- const {
58
- xAxisId = defaultXAxisId,
59
- yAxisId = defaultYAxisId,
60
- stackedData,
61
- data,
62
- connectNulls,
63
- curve,
64
- strictStepCurve
65
- } = series[seriesId];
66
- const xScale = xAxis[xAxisId].scale;
67
- const xPosition = getValueToPositionMapper(xScale);
68
- const yScale = yAxis[yAxisId].scale;
69
- const xData = xAxis[xAxisId].data;
70
- const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
71
- if (process.env.NODE_ENV !== 'production') {
72
- if (xData === undefined) {
73
- throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
74
- }
75
- if (xData.length < stackedData.length) {
76
- warnOnce(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`, 'error');
77
- }
78
- }
79
- const shouldExpand = curve?.includes('step') && !strictStepCurve && isBandScale(xScale);
80
- const formattedData = xData?.flatMap((x, index) => {
81
- const nullData = data[index] == null;
82
- if (shouldExpand) {
83
- const rep = [{
84
- x,
85
- y: stackedData[index],
86
- nullData,
87
- isExtension: false
88
- }];
89
- if (!nullData && (index === 0 || data[index - 1] == null)) {
90
- rep.unshift({
91
- x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
92
- y: stackedData[index],
93
- nullData,
94
- isExtension: true
95
- });
96
- }
97
- if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
98
- rep.push({
99
- x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
100
- y: stackedData[index],
101
- nullData,
102
- isExtension: true
103
- });
104
- }
105
- return rep;
106
- }
107
- return {
108
- x,
109
- y: stackedData[index],
110
- nullData
111
- };
112
- }) ?? [];
113
- const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
114
- const linePath = d3Line().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => yScale(d.y[1]));
115
- const d = linePath.curve(getCurveFactory(curve))(d3Data) || '';
116
- return _extends({}, series[seriesId], {
117
- gradientId,
118
- d,
119
- seriesId
120
- });
121
- });
122
- });
123
- }, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
124
- return allData;
30
+ return useLinePlotData(xAxes, yAxes);
125
31
  };
126
32
 
127
33
  /**
@@ -77,7 +77,10 @@ function MarkElement(props) {
77
77
  d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
78
78
  onClick: onClick,
79
79
  cursor: onClick ? 'pointer' : 'unset'
80
- }, interactionProps));
80
+ }, interactionProps, {
81
+ "data-highlighted": isHighlighted || undefined,
82
+ "data-faded": isFaded || undefined
83
+ }));
81
84
  }
82
85
  process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
83
86
  // ----------------------------- Warning --------------------------------
@@ -102,6 +102,7 @@ function MarkPlot(props) {
102
102
  });
103
103
  return /*#__PURE__*/_jsx("g", {
104
104
  clipPath: `url(#${clipId})`,
105
+ "data-series": seriesId,
105
106
  children: xData?.map((x, index) => {
106
107
  const value = data[index] == null ? null : stackedData[index][1];
107
108
  return {
@@ -0,0 +1,12 @@
1
+ import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
2
+ import { ChartsXAxisProps, ChartsYAxisProps } from "../models/index.js";
3
+ import { SeriesId } from "../models/seriesType/common.js";
4
+ interface AreaPlotDataPoint {
5
+ d: string;
6
+ seriesId: SeriesId;
7
+ color: string;
8
+ area?: boolean;
9
+ gradientId?: string;
10
+ }
11
+ export declare function useAreaPlotData(xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): AreaPlotDataPoint[];
12
+ export {};
@@ -0,0 +1,118 @@
1
+ import * as React from 'react';
2
+ import { area as d3Area } from '@mui/x-charts-vendor/d3-shape';
3
+ import { useChartGradientIdBuilder } from "../hooks/useChartGradientId.js";
4
+ import { isBandScale } from "../internals/isBandScale.js";
5
+ import { getCurveFactory } from "../internals/getCurve.js";
6
+ import { getValueToPositionMapper, useLineSeriesContext, useXAxes, useYAxes } from "../hooks/index.js";
7
+ import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
8
+ export function useAreaPlotData(xAxes, yAxes) {
9
+ const seriesData = useLineSeriesContext();
10
+ const defaultXAxisId = useXAxes().xAxisIds[0];
11
+ const defaultYAxisId = useYAxes().yAxisIds[0];
12
+ const getGradientId = useChartGradientIdBuilder();
13
+
14
+ // This memo prevents odd line chart behavior when hydrating.
15
+ const allData = React.useMemo(() => {
16
+ if (seriesData === undefined) {
17
+ return [];
18
+ }
19
+ const {
20
+ series,
21
+ stackingGroups
22
+ } = seriesData;
23
+ const areaPlotData = [];
24
+ for (const stackingGroup of stackingGroups) {
25
+ const groupIds = stackingGroup.ids;
26
+ for (let i = groupIds.length - 1; i >= 0; i -= 1) {
27
+ const seriesId = groupIds[i];
28
+ const {
29
+ xAxisId = defaultXAxisId,
30
+ yAxisId = defaultYAxisId,
31
+ stackedData,
32
+ data,
33
+ connectNulls,
34
+ baseline,
35
+ curve,
36
+ strictStepCurve
37
+ } = series[seriesId];
38
+ if (!(xAxisId in xAxes) || !(yAxisId in yAxes)) {
39
+ continue;
40
+ }
41
+ const xScale = xAxes[xAxisId].scale;
42
+ const xPosition = getValueToPositionMapper(xScale);
43
+ const yScale = yAxes[yAxisId].scale;
44
+ const xData = xAxes[xAxisId].data;
45
+ const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
46
+ if (process.env.NODE_ENV !== 'production') {
47
+ if (xData === undefined) {
48
+ throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
49
+ }
50
+ if (xData.length < stackedData.length) {
51
+ throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
52
+ }
53
+ }
54
+ const shouldExpand = curve?.includes('step') && !strictStepCurve && isBandScale(xScale);
55
+ const formattedData = xData?.flatMap((x, index) => {
56
+ const nullData = data[index] == null;
57
+ if (shouldExpand) {
58
+ const rep = [{
59
+ x,
60
+ y: stackedData[index],
61
+ nullData,
62
+ isExtension: false
63
+ }];
64
+ if (!nullData && (index === 0 || data[index - 1] == null)) {
65
+ rep.unshift({
66
+ x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
67
+ y: stackedData[index],
68
+ nullData,
69
+ isExtension: true
70
+ });
71
+ }
72
+ if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
73
+ rep.push({
74
+ x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
75
+ y: stackedData[index],
76
+ nullData,
77
+ isExtension: true
78
+ });
79
+ }
80
+ return rep;
81
+ }
82
+ return {
83
+ x,
84
+ y: stackedData[index],
85
+ nullData
86
+ };
87
+ }) ?? [];
88
+ const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
89
+ const areaPath = d3Area().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
90
+ if (typeof baseline === 'number') {
91
+ return yScale(baseline);
92
+ }
93
+ if (baseline === 'max') {
94
+ return yScale.range()[1];
95
+ }
96
+ if (baseline === 'min') {
97
+ return yScale.range()[0];
98
+ }
99
+ const value = d.y && yScale(d.y[0]);
100
+ if (Number.isNaN(value)) {
101
+ return yScale.range()[0];
102
+ }
103
+ return value;
104
+ }).y1(d => d.y && yScale(d.y[1]));
105
+ const d = areaPath.curve(getCurveFactory(curve))(d3Data) || '';
106
+ areaPlotData.push({
107
+ area: series[seriesId].area,
108
+ color: series[seriesId].color,
109
+ gradientId,
110
+ d,
111
+ seriesId
112
+ });
113
+ }
114
+ }
115
+ return areaPlotData;
116
+ }, [seriesData, defaultXAxisId, defaultYAxisId, xAxes, yAxes, getGradientId]);
117
+ return allData;
118
+ }
@@ -0,0 +1,11 @@
1
+ import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
2
+ import { ChartsXAxisProps, ChartsYAxisProps } from "../models/index.js";
3
+ import { SeriesId } from "../models/seriesType/common.js";
4
+ interface LinePlotDataPoint {
5
+ d: string;
6
+ seriesId: SeriesId;
7
+ color: string;
8
+ gradientId?: string;
9
+ }
10
+ export declare function useLinePlotData(xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): LinePlotDataPoint[];
11
+ export {};
@@ -0,0 +1,101 @@
1
+ import * as React from 'react';
2
+ import { warnOnce } from '@mui/x-internals/warning';
3
+ import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
4
+ import { useChartGradientIdBuilder } from "../hooks/useChartGradientId.js";
5
+ import { isBandScale } from "../internals/isBandScale.js";
6
+ import { getCurveFactory } from "../internals/getCurve.js";
7
+ import { getValueToPositionMapper, useLineSeriesContext, useXAxes, useYAxes } from "../hooks/index.js";
8
+ import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
9
+ export function useLinePlotData(xAxes, yAxes) {
10
+ const seriesData = useLineSeriesContext();
11
+ const defaultXAxisId = useXAxes().xAxisIds[0];
12
+ const defaultYAxisId = useYAxes().yAxisIds[0];
13
+ const getGradientId = useChartGradientIdBuilder();
14
+
15
+ // This memo prevents odd line chart behavior when hydrating.
16
+ const allData = React.useMemo(() => {
17
+ if (seriesData === undefined) {
18
+ return [];
19
+ }
20
+ const {
21
+ series,
22
+ stackingGroups
23
+ } = seriesData;
24
+ const linePlotData = [];
25
+ for (const stackingGroup of stackingGroups) {
26
+ const groupIds = stackingGroup.ids;
27
+ for (const seriesId of groupIds) {
28
+ const {
29
+ xAxisId = defaultXAxisId,
30
+ yAxisId = defaultYAxisId,
31
+ stackedData,
32
+ data,
33
+ connectNulls,
34
+ curve,
35
+ strictStepCurve
36
+ } = series[seriesId];
37
+ if (!(xAxisId in xAxes) || !(yAxisId in yAxes)) {
38
+ continue;
39
+ }
40
+ const xScale = xAxes[xAxisId].scale;
41
+ const xPosition = getValueToPositionMapper(xScale);
42
+ const yScale = yAxes[yAxisId].scale;
43
+ const xData = xAxes[xAxisId].data;
44
+ const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
45
+ if (process.env.NODE_ENV !== 'production') {
46
+ if (xData === undefined) {
47
+ throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
48
+ }
49
+ if (xData.length < stackedData.length) {
50
+ warnOnce(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`, 'error');
51
+ }
52
+ }
53
+ const shouldExpand = curve?.includes('step') && !strictStepCurve && isBandScale(xScale);
54
+ const formattedData = xData?.flatMap((x, index) => {
55
+ const nullData = data[index] == null;
56
+ if (shouldExpand) {
57
+ const rep = [{
58
+ x,
59
+ y: stackedData[index],
60
+ nullData,
61
+ isExtension: false
62
+ }];
63
+ if (!nullData && (index === 0 || data[index - 1] == null)) {
64
+ rep.unshift({
65
+ x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
66
+ y: stackedData[index],
67
+ nullData,
68
+ isExtension: true
69
+ });
70
+ }
71
+ if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
72
+ rep.push({
73
+ x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
74
+ y: stackedData[index],
75
+ nullData,
76
+ isExtension: true
77
+ });
78
+ }
79
+ return rep;
80
+ }
81
+ return {
82
+ x,
83
+ y: stackedData[index],
84
+ nullData
85
+ };
86
+ }) ?? [];
87
+ const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
88
+ const linePath = d3Line().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => yScale(d.y[1]));
89
+ const d = linePath.curve(getCurveFactory(curve))(d3Data) || '';
90
+ linePlotData.push({
91
+ color: series[seriesId].color,
92
+ gradientId,
93
+ d,
94
+ seriesId
95
+ });
96
+ }
97
+ }
98
+ return linePlotData;
99
+ }, [seriesData, defaultXAxisId, defaultYAxisId, xAxes, yAxes, getGradientId]);
100
+ return allData;
101
+ }
@@ -94,7 +94,9 @@ const PieArc = /*#__PURE__*/React.forwardRef(function PieArc(props, ref) {
94
94
  opacity: ownerState.isFaded ? 0.3 : 1,
95
95
  filter: ownerState.isHighlighted ? 'brightness(120%)' : 'none',
96
96
  strokeWidth: 1,
97
- strokeLinejoin: "round"
97
+ strokeLinejoin: "round",
98
+ "data-highlighted": ownerState.isHighlighted || undefined,
99
+ "data-faded": ownerState.isFaded || undefined
98
100
  }, other, interactionProps, animatedProps));
99
101
  });
100
102
  if (process.env.NODE_ENV !== "production") PieArc.displayName = "PieArc";
@@ -9,6 +9,7 @@ import { getPieCoordinates } from "./getPieCoordinates.js";
9
9
  import { usePieSeriesContext } from "../hooks/usePieSeries.js";
10
10
  import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
11
11
  import { useDrawingArea } from "../hooks/index.js";
12
+ import { useUtilityClasses } from "./pieClasses.js";
12
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  /**
14
15
  * Demos:
@@ -35,6 +36,7 @@ function PiePlot(props) {
35
36
  height
36
37
  } = useDrawingArea();
37
38
  const skipAnimation = useSkipAnimation(inSkipAnimation);
39
+ const classes = useUtilityClasses();
38
40
  if (seriesData === undefined) {
39
41
  return null;
40
42
  }
@@ -69,7 +71,9 @@ function PiePlot(props) {
69
71
  const outerRadius = getPercentageValue(outerRadiusParam ?? availableRadius, availableRadius);
70
72
  const innerRadius = getPercentageValue(innerRadiusParam ?? 0, availableRadius);
71
73
  return /*#__PURE__*/_jsx("g", {
74
+ className: classes.series,
72
75
  transform: `translate(${left + cx}, ${top + cy})`,
76
+ "data-series": seriesId,
73
77
  children: /*#__PURE__*/_jsx(PieArcPlot, {
74
78
  innerRadius: innerRadius,
75
79
  outerRadius: outerRadius,
@@ -113,7 +117,9 @@ function PiePlot(props) {
113
117
  const innerRadius = getPercentageValue(innerRadiusParam ?? 0, availableRadius);
114
118
  const arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : getPercentageValue(arcLabelRadiusParam, availableRadius);
115
119
  return /*#__PURE__*/_jsx("g", {
120
+ className: classes.seriesLabels,
116
121
  transform: `translate(${left + cx}, ${top + cy})`,
122
+ "data-series": seriesId,
117
123
  children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
118
124
  innerRadius: innerRadius,
119
125
  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";
@@ -4,4 +4,5 @@ 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";
@@ -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,15 @@
1
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
2
+ import composeClasses from '@mui/utils/composeClasses';
3
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
4
+ export function getPieUtilityClass(slot) {
5
+ return generateUtilityClass('MuiPieChart', slot);
6
+ }
7
+ export const pieClasses = generateUtilityClasses('MuiPieChart', ['root', 'series', 'seriesLabels']);
8
+ export const useUtilityClasses = classes => {
9
+ const slots = {
10
+ root: ['root'],
11
+ series: ['series'],
12
+ seriesLabels: ['seriesLabels']
13
+ };
14
+ return composeClasses(slots, getPieUtilityClass, classes);
15
+ };
@@ -6,15 +6,15 @@ const _excluded = ["ownerState"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import useSlotProps from '@mui/utils/useSlotProps';
9
- import { getValueToPositionMapper } from "../hooks/useScale.js";
10
- import { useInteractionAllItemProps } from "../hooks/useInteractionItemProps.js";
9
+ import { getInteractionItemProps } from "../hooks/useInteractionItemProps.js";
11
10
  import { useStore } from "../internals/store/useStore.js";
12
11
  import { useSelector } from "../internals/store/useSelector.js";
13
12
  import { useItemHighlightedGetter } from "../hooks/useItemHighlightedGetter.js";
14
13
  import { selectorChartsVoronoiIsVoronoiEnabled } from "../internals/plugins/featurePlugins/useChartVoronoi/index.js";
15
- import { useChartContext } from "../context/ChartProvider/index.js";
16
14
  import { ScatterMarker } from "./ScatterMarker.js";
17
15
  import { useUtilityClasses } from "./scatterClasses.js";
16
+ import { useScatterPlotData } from "./useScatterPlotData.js";
17
+ import { useChartContext } from "../context/ChartProvider/index.js";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  /**
20
20
  * Demos:
@@ -48,37 +48,7 @@ function Scatter(props) {
48
48
  isFaded,
49
49
  isHighlighted
50
50
  } = useItemHighlightedGetter();
51
- const cleanData = React.useMemo(() => {
52
- const getXPosition = getValueToPositionMapper(xScale);
53
- const getYPosition = getValueToPositionMapper(yScale);
54
- const temp = [];
55
- for (let i = 0; i < series.data.length; i += 1) {
56
- const scatterPoint = series.data[i];
57
- const x = getXPosition(scatterPoint.x);
58
- const y = getYPosition(scatterPoint.y);
59
- const isInRange = instance.isPointInside(x, y);
60
- if (isInRange) {
61
- const currentItem = {
62
- seriesId: series.id,
63
- dataIndex: i
64
- };
65
- const isItemHighlighted = isHighlighted(currentItem);
66
- temp.push({
67
- x,
68
- y,
69
- isHighlighted: isItemHighlighted,
70
- isFaded: !isItemHighlighted && isFaded(currentItem),
71
- id: scatterPoint.id,
72
- seriesId: series.id,
73
- type: 'scatter',
74
- dataIndex: i,
75
- color: colorGetter ? colorGetter(i) : color
76
- });
77
- }
78
- }
79
- return temp;
80
- }, [xScale, yScale, series.data, series.id, isHighlighted, isFaded, colorGetter, color, instance]);
81
- const interactionItemProps = useInteractionAllItemProps(cleanData, skipInteractionHandlers);
51
+ const scatterPlotData = useScatterPlotData(series, xScale, yScale, instance.isPointInside);
82
52
  const Marker = slots?.marker ?? ScatterMarker;
83
53
  const _useSlotProps = useSlotProps({
84
54
  elementType: Marker,
@@ -94,21 +64,25 @@ function Scatter(props) {
94
64
  return /*#__PURE__*/_jsx("g", {
95
65
  "data-series": series.id,
96
66
  className: classes.root,
97
- children: cleanData.map((dataPoint, i) => /*#__PURE__*/_jsx(Marker, _extends({
98
- dataIndex: dataPoint.dataIndex,
99
- color: dataPoint.color,
100
- isHighlighted: dataPoint.isHighlighted,
101
- isFaded: dataPoint.isFaded,
102
- x: dataPoint.x,
103
- y: dataPoint.y,
104
- onClick: onItemClick && (event => onItemClick(event, {
105
- type: 'scatter',
106
- seriesId: series.id,
107
- dataIndex: dataPoint.dataIndex
108
- })),
109
- "data-highlighted": dataPoint.isHighlighted || undefined,
110
- "data-faded": dataPoint.isFaded || undefined
111
- }, interactionItemProps[i], markerProps), dataPoint.id ?? dataPoint.dataIndex))
67
+ children: scatterPlotData.map((dataPoint, i) => {
68
+ const isItemHighlighted = isHighlighted(dataPoint);
69
+ const isItemFaded = !isItemHighlighted && isFaded(dataPoint);
70
+ return /*#__PURE__*/_jsx(Marker, _extends({
71
+ dataIndex: dataPoint.dataIndex,
72
+ color: colorGetter ? colorGetter(i) : color,
73
+ isHighlighted: isItemHighlighted,
74
+ isFaded: isItemFaded,
75
+ x: dataPoint.x,
76
+ y: dataPoint.y,
77
+ onClick: onItemClick && (event => onItemClick(event, {
78
+ type: 'scatter',
79
+ seriesId: series.id,
80
+ dataIndex: dataPoint.dataIndex
81
+ })),
82
+ "data-highlighted": isItemHighlighted || undefined,
83
+ "data-faded": isItemFaded || undefined
84
+ }, skipInteractionHandlers ? undefined : getInteractionItemProps(instance, dataPoint), markerProps), dataPoint.id ?? dataPoint.dataIndex);
85
+ })
112
86
  });
113
87
  }
114
88
  process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
@@ -0,0 +1,8 @@
1
+ import { SeriesId } from "../models/seriesType/common.js";
2
+ import { D3Scale } from "../models/axis.js";
3
+ import { DefaultizedScatterSeriesType, ScatterValueType } from "../models/index.js";
4
+ export declare function useScatterPlotData(series: DefaultizedScatterSeriesType, xScale: D3Scale, yScale: D3Scale, isPointInside: (x: number, y: number) => boolean): (ScatterValueType & {
5
+ dataIndex: number;
6
+ seriesId: SeriesId;
7
+ type: "scatter";
8
+ })[];
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { getValueToPositionMapper } from "../hooks/index.js";
3
+ export function useScatterPlotData(series, xScale, yScale, isPointInside) {
4
+ return React.useMemo(() => {
5
+ const getXPosition = getValueToPositionMapper(xScale);
6
+ const getYPosition = getValueToPositionMapper(yScale);
7
+ const temp = [];
8
+ for (let i = 0; i < series.data.length; i += 1) {
9
+ const scatterPoint = series.data[i];
10
+ const x = getXPosition(scatterPoint.x);
11
+ const y = getYPosition(scatterPoint.y);
12
+ const isInRange = isPointInside(x, y);
13
+ if (isInRange) {
14
+ temp.push({
15
+ x,
16
+ y,
17
+ id: scatterPoint.id,
18
+ seriesId: series.id,
19
+ type: 'scatter',
20
+ dataIndex: i
21
+ });
22
+ }
23
+ }
24
+ return temp;
25
+ }, [xScale, yScale, series.data, series.id, isPointInside]);
26
+ }
@@ -44,10 +44,12 @@ process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
44
44
  // ----------------------------------------------------------------------
45
45
  className: PropTypes.string,
46
46
  disabled: PropTypes.bool,
47
+ id: PropTypes.string,
47
48
  /**
48
49
  * A function to customize the rendering of the component.
49
50
  */
50
51
  render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
52
+ size: PropTypes.oneOf(['large', 'medium', 'small']),
51
53
  style: PropTypes.object,
52
54
  tabIndex: PropTypes.number
53
55
  } : void 0;
@@ -0,0 +1,22 @@
1
+ import type { PieChartPluginSignatures } from "../PieChart/PieChart.plugins.js";
2
+ import type { BarChartPluginsSignatures } from "../BarChart/BarChart.plugins.js";
3
+ import type { ScatterChartPluginsSignatures } from "../ScatterChart/ScatterChart.plugins.js";
4
+ import type { LineChartPluginsSignatures } from "../LineChart/LineChart.plugins.js";
5
+ import type { AllPluginSignatures, DefaultPluginSignatures } from "../internals/plugins/allPlugins.js";
6
+ import type { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
7
+ import type { ChartPublicAPI } from "../internals/plugins/models/index.js";
8
+ export type PluginsPerSeriesType = {
9
+ line: LineChartPluginsSignatures;
10
+ scatter: ScatterChartPluginsSignatures;
11
+ bar: BarChartPluginsSignatures;
12
+ pie: PieChartPluginSignatures;
13
+ composition: DefaultPluginSignatures;
14
+ };
15
+ /**
16
+ * The API of the chart `apiRef` object.
17
+ * The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
18
+ * @example ChartApi<'bar'>
19
+ * If the chart is being created using composition, the `composition` value can be used.
20
+ * @example ChartApi<'composition'>
21
+ */
22
+ export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartPublicAPI<TSignatures>;