@mui/x-charts 8.0.0 → 8.1.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 (148) hide show
  1. package/BarChart/BarChart.js +4 -0
  2. package/BarChart/BarPlot.js +1 -2
  3. package/CHANGELOG.md +106 -0
  4. package/ChartContainer/ChartContainer.d.ts +1 -0
  5. package/ChartContainer/ChartContainer.js +4 -0
  6. package/ChartContainer/useChartContainerProps.js +4 -2
  7. package/ChartDataProvider/ChartDataProvider.d.ts +2 -1
  8. package/ChartDataProvider/ChartDataProvider.js +10 -1
  9. package/ChartDataProvider/useChartDataProviderProps.d.ts +3 -1
  10. package/ChartDataProvider/useChartDataProviderProps.js +3 -1
  11. package/ChartsAxisHighlight/ChartsAxisHighlightPath.js +1 -2
  12. package/ChartsGrid/styledComponents.js +1 -2
  13. package/ChartsLabel/ChartsLabelGradient.js +1 -2
  14. package/ChartsLabel/ChartsLabelMark.js +1 -2
  15. package/ChartsLegend/ChartsLegend.js +1 -2
  16. package/ChartsLegend/ContinuousColorLegend.js +1 -2
  17. package/ChartsLegend/PiecewiseColorLegend.js +1 -2
  18. package/ChartsLocalizationProvider/ChartsLocalizationProvider.d.ts +27 -0
  19. package/ChartsLocalizationProvider/ChartsLocalizationProvider.js +73 -0
  20. package/ChartsLocalizationProvider/index.d.ts +2 -0
  21. package/ChartsLocalizationProvider/index.js +12 -0
  22. package/ChartsOverlay/ChartsLoadingOverlay.js +5 -1
  23. package/ChartsOverlay/ChartsNoDataOverlay.js +5 -1
  24. package/ChartsOverlay/ChartsOverlay.d.ts +2 -0
  25. package/ChartsTooltip/ChartsTooltipContainer.js +11 -10
  26. package/ChartsTooltip/ChartsTooltipTable.js +3 -5
  27. package/ChartsTooltip/utils.d.ts +1 -1
  28. package/ChartsTooltip/utils.js +0 -1
  29. package/ChartsXAxis/ChartsXAxis.js +1 -2
  30. package/ChartsYAxis/ChartsYAxis.js +1 -2
  31. package/Gauge/GaugeReferenceArc.js +1 -2
  32. package/Gauge/GaugeValueArc.js +1 -2
  33. package/LineChart/AreaPlot.js +1 -2
  34. package/LineChart/LineChart.js +4 -0
  35. package/LineChart/LinePlot.js +1 -2
  36. package/LineChart/MarkElement.js +1 -2
  37. package/PieChart/PieArc.js +1 -1
  38. package/PieChart/PieArcLabel.js +1 -2
  39. package/PieChart/PieChart.js +4 -0
  40. package/RadarChart/RadarChart.js +4 -0
  41. package/RadarChart/RadarDataProvider/RadarDataProvider.js +4 -0
  42. package/ScatterChart/ScatterChart.js +4 -0
  43. package/SparkLineChart/SparkLineChart.js +4 -0
  44. package/context/ChartProvider/ChartProvider.types.d.ts +4 -0
  45. package/esm/BarChart/BarChart.js +4 -0
  46. package/esm/BarChart/BarPlot.js +1 -2
  47. package/esm/ChartContainer/ChartContainer.d.ts +1 -0
  48. package/esm/ChartContainer/ChartContainer.js +4 -0
  49. package/esm/ChartContainer/useChartContainerProps.js +4 -2
  50. package/esm/ChartDataProvider/ChartDataProvider.d.ts +2 -1
  51. package/esm/ChartDataProvider/ChartDataProvider.js +10 -1
  52. package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +3 -1
  53. package/esm/ChartDataProvider/useChartDataProviderProps.js +3 -1
  54. package/esm/ChartsAxisHighlight/ChartsAxisHighlightPath.js +1 -2
  55. package/esm/ChartsGrid/styledComponents.js +1 -2
  56. package/esm/ChartsLabel/ChartsLabelGradient.js +1 -2
  57. package/esm/ChartsLabel/ChartsLabelMark.js +1 -2
  58. package/esm/ChartsLegend/ChartsLegend.js +1 -2
  59. package/esm/ChartsLegend/ContinuousColorLegend.js +1 -2
  60. package/esm/ChartsLegend/PiecewiseColorLegend.js +1 -2
  61. package/esm/ChartsLocalizationProvider/ChartsLocalizationProvider.d.ts +27 -0
  62. package/esm/ChartsLocalizationProvider/ChartsLocalizationProvider.js +66 -0
  63. package/esm/ChartsLocalizationProvider/index.d.ts +2 -0
  64. package/esm/ChartsLocalizationProvider/index.js +1 -0
  65. package/esm/ChartsOverlay/ChartsLoadingOverlay.js +5 -1
  66. package/esm/ChartsOverlay/ChartsNoDataOverlay.js +5 -1
  67. package/esm/ChartsOverlay/ChartsOverlay.d.ts +2 -0
  68. package/esm/ChartsTooltip/ChartsTooltipContainer.js +11 -10
  69. package/esm/ChartsTooltip/ChartsTooltipTable.js +3 -5
  70. package/esm/ChartsTooltip/utils.d.ts +1 -1
  71. package/esm/ChartsTooltip/utils.js +0 -1
  72. package/esm/ChartsXAxis/ChartsXAxis.js +1 -2
  73. package/esm/ChartsYAxis/ChartsYAxis.js +1 -2
  74. package/esm/Gauge/GaugeReferenceArc.js +1 -2
  75. package/esm/Gauge/GaugeValueArc.js +1 -2
  76. package/esm/LineChart/AreaPlot.js +1 -2
  77. package/esm/LineChart/LineChart.js +4 -0
  78. package/esm/LineChart/LinePlot.js +1 -2
  79. package/esm/LineChart/MarkElement.js +1 -2
  80. package/esm/PieChart/PieArc.js +1 -1
  81. package/esm/PieChart/PieArcLabel.js +1 -2
  82. package/esm/PieChart/PieChart.js +4 -0
  83. package/esm/RadarChart/RadarChart.js +4 -0
  84. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.js +4 -0
  85. package/esm/ScatterChart/ScatterChart.js +4 -0
  86. package/esm/SparkLineChart/SparkLineChart.js +4 -0
  87. package/esm/context/ChartProvider/ChartProvider.types.d.ts +4 -0
  88. package/esm/hooks/index.d.ts +3 -1
  89. package/esm/hooks/index.js +3 -1
  90. package/esm/hooks/useChartRootRef.d.ts +6 -0
  91. package/esm/hooks/useChartRootRef.js +12 -0
  92. package/esm/hooks/useChartsLocalization.d.ts +1 -0
  93. package/esm/hooks/useChartsLocalization.js +9 -0
  94. package/esm/index.d.ts +1 -0
  95. package/esm/index.js +2 -1
  96. package/esm/internals/components/AxisSharedComponents.js +1 -2
  97. package/esm/internals/components/ChartsWrapper/ChartsWrapper.js +4 -2
  98. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +0 -1
  99. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +3 -3
  100. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +15 -0
  101. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3 -3
  102. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +8 -0
  103. package/esm/internals/plugins/models/plugin.d.ts +4 -0
  104. package/esm/internals/store/useCharts.d.ts +1 -0
  105. package/esm/internals/store/useCharts.js +4 -1
  106. package/esm/locales/enUS.d.ts +15 -0
  107. package/esm/locales/enUS.js +11 -0
  108. package/esm/locales/frFR.d.ts +14 -0
  109. package/esm/locales/frFR.js +7 -0
  110. package/esm/locales/index.d.ts +3 -0
  111. package/esm/locales/index.js +3 -0
  112. package/esm/locales/utils/chartsLocaleTextApi.d.ts +11 -0
  113. package/esm/locales/utils/chartsLocaleTextApi.js +1 -0
  114. package/esm/locales/utils/getChartsLocalization.d.ts +18 -0
  115. package/esm/locales/utils/getChartsLocalization.js +17 -0
  116. package/esm/themeAugmentation/components.d.ts +3 -0
  117. package/esm/themeAugmentation/props.d.ts +2 -0
  118. package/hooks/index.d.ts +3 -1
  119. package/hooks/index.js +24 -0
  120. package/hooks/useChartRootRef.d.ts +6 -0
  121. package/hooks/useChartRootRef.js +16 -0
  122. package/hooks/useChartsLocalization.d.ts +1 -0
  123. package/hooks/useChartsLocalization.js +17 -0
  124. package/index.d.ts +1 -0
  125. package/index.js +12 -1
  126. package/internals/components/AxisSharedComponents.js +1 -2
  127. package/internals/components/ChartsWrapper/ChartsWrapper.js +4 -2
  128. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +0 -1
  129. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +3 -3
  130. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +15 -0
  131. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3 -3
  132. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +8 -0
  133. package/internals/plugins/models/plugin.d.ts +4 -0
  134. package/internals/store/useCharts.d.ts +1 -0
  135. package/internals/store/useCharts.js +4 -1
  136. package/locales/enUS.d.ts +15 -0
  137. package/locales/enUS.js +16 -0
  138. package/locales/frFR.d.ts +14 -0
  139. package/locales/frFR.js +13 -0
  140. package/locales/index.d.ts +3 -0
  141. package/locales/index.js +27 -0
  142. package/locales/utils/chartsLocaleTextApi.d.ts +11 -0
  143. package/locales/utils/chartsLocaleTextApi.js +5 -0
  144. package/locales/utils/getChartsLocalization.d.ts +18 -0
  145. package/locales/utils/getChartsLocalization.js +25 -0
  146. package/package.json +1 -2
  147. package/themeAugmentation/components.d.ts +3 -0
  148. package/themeAugmentation/props.d.ts +2 -0
@@ -83,8 +83,7 @@ function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelSty
83
83
  }
84
84
  const YAxisRoot = styled(AxisRoot, {
85
85
  name: 'MuiChartsYAxis',
86
- slot: 'Root',
87
- overridesResolver: (props, styles) => styles.root
86
+ slot: 'Root'
88
87
  })({});
89
88
  const defaultProps = {
90
89
  disableLine: false,
@@ -8,8 +8,7 @@ import { useGaugeState } from "./GaugeProvider.js";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  const StyledPath = styled('path', {
10
10
  name: 'MuiGauge',
11
- slot: 'ReferenceArc',
12
- overridesResolver: (props, styles) => styles.referenceArc
11
+ slot: 'ReferenceArc'
13
12
  })(({
14
13
  theme
15
14
  }) => ({
@@ -12,8 +12,7 @@ import { useGaugeState } from "./GaugeProvider.js";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const StyledPath = styled('path', {
14
14
  name: 'MuiGauge',
15
- slot: 'ReferenceArc',
16
- overridesResolver: (props, styles) => styles.referenceArc
15
+ slot: 'ReferenceArc'
17
16
  })(({
18
17
  theme
19
18
  }) => ({
@@ -20,8 +20,7 @@ import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugin
20
20
  import { jsx as _jsx } from "react/jsx-runtime";
21
21
  const AreaPlotRoot = styled('g', {
22
22
  name: 'MuiAreaPlot',
23
- slot: 'Root',
24
- overridesResolver: (_, styles) => styles.root
23
+ slot: 'Root'
25
24
  })({
26
25
  [`& .${areaElementClasses.root}`]: {
27
26
  transition: 'opacity 0.2s ease-in, fill 0.2s ease-in'
@@ -142,6 +142,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
142
142
  * @default false
143
143
  */
144
144
  loading: PropTypes.bool,
145
+ /**
146
+ * Localized text for chart components.
147
+ */
148
+ localeText: PropTypes.object,
145
149
  /**
146
150
  * The margin between the SVG and the drawing area.
147
151
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -21,8 +21,7 @@ import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugin
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  const LinePlotRoot = styled('g', {
23
23
  name: 'MuiAreaPlot',
24
- slot: 'Root',
25
- overridesResolver: (_, styles) => styles.root
24
+ slot: 'Root'
26
25
  })({
27
26
  [`& .${lineElementClasses.root}`]: {
28
27
  transition: 'opacity 0.2s ease-in, fill 0.2s ease-in'
@@ -18,8 +18,7 @@ import { useStore } from "../internals/store/useStore.js";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  const MarkElementPath = styled('path', {
20
20
  name: 'MuiMarkElement',
21
- slot: 'Root',
22
- overridesResolver: (_, styles) => styles.root
21
+ slot: 'Root'
23
22
  })(({
24
23
  ownerState,
25
24
  theme
@@ -33,7 +33,7 @@ const useUtilityClasses = ownerState => {
33
33
  const PieArcRoot = styled('path', {
34
34
  name: 'MuiPieArc',
35
35
  slot: 'Root',
36
- overridesResolver: (_, styles) => styles.arc
36
+ overridesResolver: (_, styles) => styles.arc // FIXME: Inconsistent naming with slot
37
37
  })(({
38
38
  theme
39
39
  }) => ({
@@ -31,8 +31,7 @@ const useUtilityClasses = ownerState => {
31
31
  };
32
32
  const PieArcLabelRoot = styled('text', {
33
33
  name: 'MuiPieArcLabel',
34
- slot: 'Root',
35
- overridesResolver: (_, styles) => styles.root
34
+ slot: 'Root'
36
35
  })(({
37
36
  theme
38
37
  }) => ({
@@ -148,6 +148,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
148
148
  * @default false
149
149
  */
150
150
  loading: PropTypes.bool,
151
+ /**
152
+ * Localized text for chart components.
153
+ */
154
+ localeText: PropTypes.object,
151
155
  /**
152
156
  * The margin between the SVG and the drawing area.
153
157
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -99,6 +99,10 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes = {
99
99
  * @default false
100
100
  */
101
101
  loading: PropTypes.bool,
102
+ /**
103
+ * Localized text for chart components.
104
+ */
105
+ localeText: PropTypes.object,
102
106
  /**
103
107
  * The margin between the SVG and the drawing area.
104
108
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -134,6 +134,10 @@ process.env.NODE_ENV !== "production" ? RadarDataProvider.propTypes = {
134
134
  * If you don't provide this prop. It falls back to a randomly generated id.
135
135
  */
136
136
  id: PropTypes.string,
137
+ /**
138
+ * Localized text for chart components.
139
+ */
140
+ localeText: PropTypes.object,
137
141
  /**
138
142
  * The margin between the SVG and the drawing area.
139
143
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -134,6 +134,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
134
134
  * @default false
135
135
  */
136
136
  loading: PropTypes.bool,
137
+ /**
138
+ * Localized text for chart components.
139
+ */
140
+ localeText: PropTypes.object,
137
141
  /**
138
142
  * The margin between the SVG and the drawing area.
139
143
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -177,6 +177,10 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
177
177
  * If you don't provide this prop. It falls back to a randomly generated id.
178
178
  */
179
179
  id: PropTypes.string,
180
+ /**
181
+ * Localized text for chart components.
182
+ */
183
+ localeText: PropTypes.object,
180
184
  /**
181
185
  * The margin between the SVG and the drawing area.
182
186
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -22,6 +22,10 @@ export type ChartContextValue<TSignatures extends readonly ChartAnyPluginSignatu
22
22
  * The ref to the <svg />.
23
23
  */
24
24
  svgRef: React.RefObject<SVGSVGElement | null>;
25
+ /**
26
+ * The ref to the chart root element.
27
+ */
28
+ chartRootRef: React.RefObject<HTMLDivElement | null>;
25
29
  };
26
30
  export type ChartPluginParams<TSignatures extends readonly ChartAnyPluginSignature[]> = UseChartBaseProps<TSignatures> & MergeSignaturesProperty<[...ChartCorePluginSignatures, ...TSignatures], 'params'>;
27
31
  export interface ChartProviderProps<TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = []> {
@@ -14,4 +14,6 @@ export * from "./useItemHighlighted.js";
14
14
  export * from "./useItemHighlightedGetter.js";
15
15
  export * from "./useLegend.js";
16
16
  export { useChartGradientId, useChartGradientIdObjectBound } from "./useChartGradientId.js";
17
- export * from "./animation/index.js";
17
+ export * from "./animation/index.js";
18
+ export * from "./useChartRootRef.js";
19
+ export * from "./useChartsLocalization.js";
@@ -14,4 +14,6 @@ export * from "./useItemHighlighted.js";
14
14
  export * from "./useItemHighlightedGetter.js";
15
15
  export * from "./useLegend.js";
16
16
  export { useChartGradientId, useChartGradientIdObjectBound } from "./useChartGradientId.js";
17
- export * from "./animation/index.js";
17
+ export * from "./animation/index.js";
18
+ export * from "./useChartRootRef.js";
19
+ export * from "./useChartsLocalization.js";
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Get the ref for the root chart element.
4
+ * @returns The root chart element ref.
5
+ */
6
+ export declare function useChartRootRef(): React.RefObject<HTMLDivElement | null>;
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+
3
+ import { useChartContext } from "../context/ChartProvider/index.js";
4
+
5
+ /**
6
+ * Get the ref for the root chart element.
7
+ * @returns The root chart element ref.
8
+ */
9
+ export function useChartRootRef() {
10
+ const context = useChartContext();
11
+ return context.chartRootRef;
12
+ }
@@ -0,0 +1 @@
1
+ export declare const useChartsLocalization: () => import("../ChartsLocalizationProvider/ChartsLocalizationProvider").ChartsLocalizationContextValue;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { ChartsLocalizationContext } from "../ChartsLocalizationProvider/ChartsLocalizationProvider.js";
3
+ export const useChartsLocalization = () => {
4
+ const localization = React.useContext(ChartsLocalizationContext);
5
+ if (localization === null) {
6
+ throw new Error(['MUI X: Can not find the charts localization context.', 'It looks like you forgot to wrap your component in ChartsLocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-charts` package'].join('\n'));
7
+ }
8
+ return localization;
9
+ };
package/esm/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from "./ChartsText/index.js";
13
13
  export * from "./ChartsTooltip/index.js";
14
14
  export * from "./ChartsLabel/index.js";
15
15
  export * from "./ChartsLegend/index.js";
16
+ export * from "./ChartsLocalizationProvider/index.js";
16
17
  export * from "./ChartsAxisHighlight/index.js";
17
18
  export * from "./BarChart/index.js";
18
19
  export * from "./LineChart/index.js";
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.0.0
2
+ * @mui/x-charts v8.1.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -20,6 +20,7 @@ export * from "./ChartsText/index.js";
20
20
  export * from "./ChartsTooltip/index.js";
21
21
  export * from "./ChartsLabel/index.js";
22
22
  export * from "./ChartsLegend/index.js";
23
+ export * from "./ChartsLocalizationProvider/index.js";
23
24
  export * from "./ChartsAxisHighlight/index.js";
24
25
  export * from "./BarChart/index.js";
25
26
  export * from "./LineChart/index.js";
@@ -3,8 +3,7 @@ import { styled } from '@mui/material/styles';
3
3
  import { axisClasses } from "../../ChartsAxis/axisClasses.js";
4
4
  export const AxisRoot = styled('g', {
5
5
  name: 'MuiChartsAxis',
6
- slot: 'Root',
7
- overridesResolver: (props, styles) => styles.root
6
+ slot: 'Root'
8
7
  })(({
9
8
  theme
10
9
  }) => ({
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { styled } from '@mui/material/styles';
3
+ import { useChartRootRef } from "../../../hooks/useChartRootRef.js";
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
4
5
  const getDirection = (direction, position) => {
5
6
  if (direction === 'vertical') {
@@ -34,8 +35,7 @@ const getAlign = (direction, position) => {
34
35
  };
35
36
  const Root = styled('div', {
36
37
  name: 'MuiChartsWrapper',
37
- slot: 'Root',
38
- overridesResolver: (props, styles) => styles.root
38
+ slot: 'Root'
39
39
  })(({
40
40
  ownerState
41
41
  }) => ({
@@ -57,7 +57,9 @@ function ChartsWrapper(props) {
57
57
  children,
58
58
  sx
59
59
  } = props;
60
+ const chartRootRef = useChartRootRef();
60
61
  return /*#__PURE__*/_jsx(Root, {
62
+ ref: chartRootRef,
61
63
  ownerState: props,
62
64
  sx: sx,
63
65
  children: children
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- /* eslint-disable react-compiler/react-compiler */
4
3
  import _extends from "@babel/runtime/helpers/esm/extends";
5
4
  import * as React from 'react';
6
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';