@mui/x-charts 7.7.0 → 7.8.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 (167) hide show
  1. package/BarChart/BarChart.js +21 -104
  2. package/BarChart/BarElement.d.ts +225 -228
  3. package/BarChart/BarLabel/BarLabel.d.ts +225 -228
  4. package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
  5. package/BarChart/BarLabel/BarLabelPlot.js +1 -24
  6. package/BarChart/BarLabel/getBarLabel.d.ts +1 -1
  7. package/BarChart/BarPlot.js +2 -2
  8. package/BarChart/checkScaleErrors.d.ts +5 -9
  9. package/BarChart/types.d.ts +2 -2
  10. package/BarChart/useBarChartProps.d.ts +34 -0
  11. package/BarChart/useBarChartProps.js +143 -0
  12. package/CHANGELOG.md +181 -0
  13. package/ChartContainer/ChartContainer.d.ts +2 -2
  14. package/ChartContainer/ChartContainer.js +6 -10
  15. package/ChartContainer/useChartContainerHooks.d.ts +11 -0
  16. package/ChartContainer/useChartContainerHooks.js +34 -0
  17. package/ChartContainer/usePluginsMerge.d.ts +1 -2
  18. package/ChartsAxis/ChartsAxis.js +2 -2
  19. package/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  20. package/ChartsGrid/ChartsGrid.js +2 -2
  21. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  22. package/ChartsReferenceLine/common.d.ts +0 -1
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  24. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  25. package/ChartsTooltip/ChartsTooltipTable.d.ts +0 -1
  26. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -4
  27. package/ChartsXAxis/ChartsXAxis.js +2 -2
  28. package/ChartsYAxis/ChartsYAxis.js +5 -3
  29. package/Gauge/GaugeProvider.d.ts +1 -1
  30. package/LineChart/AnimatedArea.d.ts +225 -228
  31. package/LineChart/AnimatedLine.d.ts +225 -228
  32. package/LineChart/AreaPlot.js +2 -2
  33. package/LineChart/LineChart.js +24 -106
  34. package/LineChart/LineHighlightPlot.js +2 -2
  35. package/LineChart/LinePlot.js +2 -2
  36. package/LineChart/MarkPlot.js +2 -2
  37. package/LineChart/useLineChartProps.d.ts +40 -0
  38. package/LineChart/useLineChartProps.js +152 -0
  39. package/PieChart/PieArc.d.ts +0 -1
  40. package/PieChart/PieArcLabel.d.ts +0 -1
  41. package/PieChart/dataTransform/transition.d.ts +0 -1
  42. package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -2
  43. package/ScatterChart/ScatterChart.js +20 -75
  44. package/ScatterChart/ScatterPlot.js +2 -2
  45. package/ScatterChart/useScatterChartProps.d.ts +31 -0
  46. package/ScatterChart/useScatterChartProps.js +116 -0
  47. package/context/CartesianProvider/CartesianContext.d.ts +25 -0
  48. package/context/CartesianProvider/CartesianContext.js +21 -0
  49. package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
  50. package/context/CartesianProvider/CartesianProvider.js +44 -0
  51. package/context/CartesianProvider/computeValue.d.ts +19 -0
  52. package/context/CartesianProvider/computeValue.js +104 -0
  53. package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
  54. package/context/CartesianProvider/getAxisExtremum.js +28 -0
  55. package/context/CartesianProvider/index.d.ts +9 -0
  56. package/context/CartesianProvider/index.js +51 -0
  57. package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
  58. package/context/CartesianProvider/normalizeAxis.js +23 -0
  59. package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
  60. package/context/CartesianProvider/useCartesianContext.js +17 -0
  61. package/context/ColorProvider.d.ts +2 -2
  62. package/esm/BarChart/BarChart.js +21 -104
  63. package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
  64. package/esm/BarChart/BarPlot.js +2 -2
  65. package/esm/BarChart/useBarChartProps.js +135 -0
  66. package/esm/ChartContainer/ChartContainer.js +5 -9
  67. package/esm/ChartContainer/useChartContainerHooks.js +24 -0
  68. package/esm/ChartsAxis/ChartsAxis.js +2 -2
  69. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  70. package/esm/ChartsGrid/ChartsGrid.js +2 -2
  71. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  72. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  73. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  74. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  75. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  76. package/esm/ChartsYAxis/ChartsYAxis.js +5 -3
  77. package/esm/LineChart/AreaPlot.js +2 -2
  78. package/esm/LineChart/LineChart.js +24 -106
  79. package/esm/LineChart/LineHighlightPlot.js +2 -2
  80. package/esm/LineChart/LinePlot.js +2 -2
  81. package/esm/LineChart/MarkPlot.js +2 -2
  82. package/esm/LineChart/useLineChartProps.js +144 -0
  83. package/esm/ScatterChart/ScatterChart.js +20 -75
  84. package/esm/ScatterChart/ScatterPlot.js +2 -2
  85. package/esm/ScatterChart/useScatterChartProps.js +108 -0
  86. package/esm/context/CartesianProvider/CartesianContext.js +13 -0
  87. package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
  88. package/esm/context/CartesianProvider/computeValue.js +97 -0
  89. package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
  90. package/esm/context/CartesianProvider/index.js +10 -0
  91. package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
  92. package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
  93. package/esm/hooks/useAxisEvents.js +7 -10
  94. package/esm/hooks/useColorScale.js +3 -3
  95. package/esm/hooks/useScale.js +4 -5
  96. package/esm/hooks/useTicks.js +2 -1
  97. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  98. package/esm/internals/getSVGPoint.js +11 -0
  99. package/esm/internals/index.js +8 -2
  100. package/esm/internals/utils.js +0 -12
  101. package/hooks/useAxisEvents.js +8 -11
  102. package/hooks/useChartDimensions.d.ts +1 -1
  103. package/hooks/useColor.d.ts +1 -1
  104. package/hooks/useColorScale.js +3 -3
  105. package/hooks/useDrawingArea.d.ts +2 -8
  106. package/hooks/useScale.js +4 -7
  107. package/hooks/useTicks.js +2 -1
  108. package/index.js +1 -1
  109. package/internals/components/AxisSharedComponents.d.ts +0 -1
  110. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
  111. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  112. package/internals/defaultizeColor.d.ts +68 -68
  113. package/internals/getSVGPoint.d.ts +6 -0
  114. package/internals/getSVGPoint.js +17 -0
  115. package/internals/getWordsByLines.d.ts +0 -1
  116. package/internals/index.d.ts +9 -1
  117. package/internals/index.js +69 -5
  118. package/internals/useAnimatedPath.d.ts +0 -1
  119. package/internals/utils.d.ts +0 -6
  120. package/internals/utils.js +0 -13
  121. package/models/axis.d.ts +1 -2
  122. package/models/plugin.d.ts +4 -1
  123. package/modern/BarChart/BarChart.js +21 -104
  124. package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
  125. package/modern/BarChart/BarPlot.js +2 -2
  126. package/modern/BarChart/useBarChartProps.js +135 -0
  127. package/modern/ChartContainer/ChartContainer.js +5 -9
  128. package/modern/ChartContainer/useChartContainerHooks.js +24 -0
  129. package/modern/ChartsAxis/ChartsAxis.js +2 -2
  130. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  131. package/modern/ChartsGrid/ChartsGrid.js +2 -2
  132. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  133. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  134. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  135. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  136. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  137. package/modern/ChartsYAxis/ChartsYAxis.js +5 -3
  138. package/modern/LineChart/AreaPlot.js +2 -2
  139. package/modern/LineChart/LineChart.js +24 -106
  140. package/modern/LineChart/LineHighlightPlot.js +2 -2
  141. package/modern/LineChart/LinePlot.js +2 -2
  142. package/modern/LineChart/MarkPlot.js +2 -2
  143. package/modern/LineChart/useLineChartProps.js +144 -0
  144. package/modern/ScatterChart/ScatterChart.js +20 -75
  145. package/modern/ScatterChart/ScatterPlot.js +2 -2
  146. package/modern/ScatterChart/useScatterChartProps.js +108 -0
  147. package/modern/context/CartesianProvider/CartesianContext.js +13 -0
  148. package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
  149. package/modern/context/CartesianProvider/computeValue.js +97 -0
  150. package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
  151. package/modern/context/CartesianProvider/index.js +10 -0
  152. package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
  153. package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
  154. package/modern/hooks/useAxisEvents.js +7 -10
  155. package/modern/hooks/useColorScale.js +3 -3
  156. package/modern/hooks/useScale.js +4 -5
  157. package/modern/hooks/useTicks.js +2 -1
  158. package/modern/index.js +1 -1
  159. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  160. package/modern/internals/getSVGPoint.js +11 -0
  161. package/modern/internals/index.js +8 -2
  162. package/modern/internals/utils.js +0 -12
  163. package/package.json +3 -3
  164. package/context/CartesianContextProvider.d.ts +0 -61
  165. package/context/CartesianContextProvider.js +0 -220
  166. package/esm/context/CartesianContextProvider.js +0 -211
  167. package/modern/context/CartesianContextProvider.js +0 -211
@@ -10,7 +10,4 @@ type BarLabelPlotProps = {
10
10
  * @ignore - internal component.
11
11
  */
12
12
  declare function BarLabelPlot(props: BarLabelPlotProps): React.JSX.Element;
13
- declare namespace BarLabelPlot {
14
- var propTypes: any;
15
- }
16
13
  export { BarLabelPlot };
@@ -8,7 +8,6 @@ exports.BarLabelPlot = BarLabelPlot;
8
8
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
- var _propTypes = _interopRequireDefault(require("prop-types"));
12
11
  var _web = require("@react-spring/web");
13
12
  var _BarLabelItem = require("./BarLabelItem");
14
13
  var _jsxRuntime = require("react/jsx-runtime");
@@ -81,26 +80,4 @@ function BarLabelPlot(props) {
81
80
  style: style
82
81
  })))
83
82
  });
84
- }
85
- process.env.NODE_ENV !== "production" ? BarLabelPlot.propTypes = {
86
- // ----------------------------- Warning --------------------------------
87
- // | These PropTypes are generated from the TypeScript type definitions |
88
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
89
- // ----------------------------------------------------------------------
90
- barLabel: _propTypes.default.oneOfType([_propTypes.default.oneOf(['value']), _propTypes.default.func]),
91
- bars: _propTypes.default.arrayOf(_propTypes.default.shape({
92
- color: _propTypes.default.string.isRequired,
93
- dataIndex: _propTypes.default.number.isRequired,
94
- height: _propTypes.default.number.isRequired,
95
- layout: _propTypes.default.oneOf(['horizontal', 'vertical']),
96
- maskId: _propTypes.default.string.isRequired,
97
- seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
98
- value: _propTypes.default.number,
99
- width: _propTypes.default.number.isRequired,
100
- x: _propTypes.default.number.isRequired,
101
- xOrigin: _propTypes.default.number.isRequired,
102
- y: _propTypes.default.number.isRequired,
103
- yOrigin: _propTypes.default.number.isRequired
104
- })).isRequired,
105
- skipAnimation: _propTypes.default.bool
106
- } : void 0;
83
+ }
@@ -1,7 +1,7 @@
1
1
  import { SeriesId } from '../../models/seriesType/common';
2
2
  import { BarLabelFunction } from './BarLabel.types';
3
3
  export declare const getBarLabel: (options: {
4
- barLabel: 'value' | BarLabelFunction;
4
+ barLabel: "value" | BarLabelFunction;
5
5
  value: number | null;
6
6
  dataIndex: number;
7
7
  seriesId: SeriesId;
@@ -10,7 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _web = require("@react-spring/web");
13
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
13
+ var _CartesianProvider = require("../context/CartesianProvider");
14
14
  var _BarElement = require("./BarElement");
15
15
  var _getColor = _interopRequireDefault(require("./getColor"));
16
16
  var _hooks = require("../hooks");
@@ -55,7 +55,7 @@ const useAggregatedData = () => {
55
55
  stackingGroups: [],
56
56
  seriesOrder: []
57
57
  };
58
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
58
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
59
59
  const chartId = (0, _hooks.useChartId)();
60
60
  const {
61
61
  series,
@@ -1,11 +1,7 @@
1
- import { AxisDefaultized } from '../models/axis';
1
+ import { AxisDefaultized, AxisId } from '../models/axis';
2
2
  import { SeriesId } from '../models/seriesType/common';
3
- export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey: string, xAxis: {
4
- DEFAULT_X_AXIS_KEY: AxisDefaultized;
5
- } & {
6
- [axisKey: string]: AxisDefaultized;
7
- }, yAxisKey: string, yAxis: {
8
- DEFAULT_X_AXIS_KEY: AxisDefaultized;
9
- } & {
10
- [axisKey: string]: AxisDefaultized;
3
+ export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey: AxisId, xAxis: {
4
+ [axisKey: AxisId]: AxisDefaultized;
5
+ }, yAxisKey: AxisId, yAxis: {
6
+ [axisKey: AxisId]: AxisDefaultized;
11
7
  }): void;
@@ -5,8 +5,8 @@ export type AnimationData = {
5
5
  y: number;
6
6
  width: number;
7
7
  height: number;
8
- yOrigin: number;
9
- xOrigin: number;
8
+ yOrigin?: number;
9
+ xOrigin?: number;
10
10
  layout: BarSeriesType['layout'];
11
11
  };
12
12
  export interface CompletedBarData extends AnimationData {
@@ -0,0 +1,34 @@
1
+ import type { BarChartProps } from './BarChart';
2
+ import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
3
+ import { BarPlotProps } from './BarPlot';
4
+ import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
5
+ import { ChartsGridProps } from '../ChartsGrid';
6
+ import { ChartsClipPathProps } from '../ChartsClipPath';
7
+ import { ChartsOverlayProps } from '../ChartsOverlay';
8
+ import { ChartsAxisProps } from '../ChartsAxis';
9
+ import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
10
+ import { ChartsLegendProps } from '../ChartsLegend';
11
+ import { ChartsTooltipProps } from '../ChartsTooltip';
12
+ /**
13
+ * A helper function that extracts BarChartProps from the input props
14
+ * and returns an object with props for the children components of BarChart.
15
+ *
16
+ * @param props The input props for BarChart
17
+ * @returns An object with props for the children components of BarChart
18
+ */
19
+ export declare const useBarChartProps: (props: BarChartProps) => {
20
+ chartContainerProps: ResponsiveChartContainerProps;
21
+ barPlotProps: BarPlotProps;
22
+ axisClickHandlerProps: ChartsOnAxisClickHandlerProps;
23
+ gridProps: ChartsGridProps;
24
+ clipPathProps: ChartsClipPathProps;
25
+ clipPathGroupProps: {
26
+ clipPath: string;
27
+ };
28
+ overlayProps: ChartsOverlayProps;
29
+ chartsAxisProps: ChartsAxisProps;
30
+ axisHighlightProps: ChartsAxisHighlightProps;
31
+ legendProps: ChartsLegendProps;
32
+ tooltipProps: ChartsTooltipProps;
33
+ children: import("react").ReactNode;
34
+ };
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useBarChartProps = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
10
+ var _constants = require("../constants");
11
+ /**
12
+ * A helper function that extracts BarChartProps from the input props
13
+ * and returns an object with props for the children components of BarChart.
14
+ *
15
+ * @param props The input props for BarChart
16
+ * @returns An object with props for the children components of BarChart
17
+ */
18
+ const useBarChartProps = props => {
19
+ const {
20
+ xAxis,
21
+ yAxis,
22
+ series,
23
+ width,
24
+ height,
25
+ margin,
26
+ colors,
27
+ dataset,
28
+ sx,
29
+ tooltip,
30
+ onAxisClick,
31
+ axisHighlight,
32
+ legend,
33
+ grid,
34
+ topAxis,
35
+ leftAxis,
36
+ rightAxis,
37
+ bottomAxis,
38
+ children,
39
+ slots,
40
+ slotProps,
41
+ skipAnimation,
42
+ loading,
43
+ layout,
44
+ onItemClick,
45
+ highlightedItem,
46
+ onHighlightChange,
47
+ borderRadius,
48
+ barLabel
49
+ } = props;
50
+ const id = (0, _useId.default)();
51
+ const clipPathId = `${id}-clip-path`;
52
+ const hasHorizontalSeries = layout === 'horizontal' || layout === undefined && series.some(item => item.layout === 'horizontal');
53
+ const defaultAxisConfig = {
54
+ scaleType: 'band',
55
+ data: Array.from({
56
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
57
+ }, (_, index) => index)
58
+ };
59
+ const chartContainerProps = {
60
+ series: series.map(s => (0, _extends2.default)({
61
+ type: 'bar'
62
+ }, s, {
63
+ layout: hasHorizontalSeries ? 'horizontal' : 'vertical'
64
+ })),
65
+ width,
66
+ height,
67
+ margin,
68
+ colors,
69
+ dataset,
70
+ xAxis: xAxis ?? (hasHorizontalSeries ? undefined : [(0, _extends2.default)({
71
+ id: _constants.DEFAULT_X_AXIS_KEY
72
+ }, defaultAxisConfig)]),
73
+ yAxis: yAxis ?? (hasHorizontalSeries ? [(0, _extends2.default)({
74
+ id: _constants.DEFAULT_Y_AXIS_KEY
75
+ }, defaultAxisConfig)] : undefined),
76
+ sx,
77
+ highlightedItem,
78
+ onHighlightChange,
79
+ disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
80
+ };
81
+ const barPlotProps = {
82
+ onItemClick,
83
+ slots,
84
+ slotProps,
85
+ skipAnimation,
86
+ borderRadius,
87
+ barLabel
88
+ };
89
+ const axisClickHandlerProps = {
90
+ onAxisClick
91
+ };
92
+ const gridProps = {
93
+ vertical: grid?.vertical,
94
+ horizontal: grid?.horizontal
95
+ };
96
+ const clipPathGroupProps = {
97
+ clipPath: `url(#${clipPathId})`
98
+ };
99
+ const clipPathProps = {
100
+ id: clipPathId
101
+ };
102
+ const overlayProps = {
103
+ slots,
104
+ slotProps,
105
+ loading
106
+ };
107
+ const chartsAxisProps = {
108
+ topAxis,
109
+ leftAxis,
110
+ rightAxis,
111
+ bottomAxis,
112
+ slots,
113
+ slotProps
114
+ };
115
+ const axisHighlightProps = (0, _extends2.default)({}, hasHorizontalSeries ? {
116
+ y: 'band'
117
+ } : {
118
+ x: 'band'
119
+ }, axisHighlight);
120
+ const legendProps = (0, _extends2.default)({}, legend, {
121
+ slots,
122
+ slotProps
123
+ });
124
+ const tooltipProps = (0, _extends2.default)({}, tooltip, {
125
+ slots,
126
+ slotProps
127
+ });
128
+ return {
129
+ chartContainerProps,
130
+ barPlotProps,
131
+ axisClickHandlerProps,
132
+ gridProps,
133
+ clipPathProps,
134
+ clipPathGroupProps,
135
+ overlayProps,
136
+ chartsAxisProps,
137
+ axisHighlightProps,
138
+ legendProps,
139
+ tooltipProps,
140
+ children
141
+ };
142
+ };
143
+ exports.useBarChartProps = useBarChartProps;
package/CHANGELOG.md CHANGED
@@ -3,6 +3,187 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.8.0
7
+
8
+ _Jun 28, 2024_
9
+
10
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🛰 Introduce server-side data source for improved server integration in the Data Grid.
13
+
14
+ Supports server-side pagination, sorting and filtering on plain and tree data, and automatic caching.
15
+
16
+ To enable, provide a `getRows` function to the `unstable_dataSource` prop on the Data Grid component.
17
+
18
+ ```tsx
19
+ const dataSource = {
20
+ getRows: async (params: GridServerGetRowsParams) => {
21
+ const data = await fetch(
22
+ `https://api.example.com/data?${new URLSearchParams({
23
+ page: params.page,
24
+ pageSize: params.pageSize,
25
+ sortModel: JSON.stringify(params.sortModel),
26
+ filterModel: JSON.stringify(params.filterModel),
27
+ }).toString()}`,
28
+ );
29
+ return {
30
+ rows: data.rows,
31
+ totalRows: data.totalRows,
32
+ };
33
+ },
34
+ }
35
+ <DataGridPro
36
+ unstable_dataSource={dataSource}
37
+ {...otherProps}
38
+ />
39
+ ```
40
+
41
+ See [server-side data documentation](https://mui.com/x/react-data-grid/server-side-data/) for more details.
42
+
43
+ - 📈 Support Date data on the BarChart component
44
+ - ↕️ Support custom column sort icons on the Data Grid
45
+ - 🖱️ Support modifying the expansion trigger on the Tree View components
46
+
47
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
48
+
49
+ ### Data Grid
50
+
51
+ #### `@mui/x-data-grid@7.8.0`
52
+
53
+ - [DataGrid] Add `columnHeaderSortIcon` slot (#13563) @arminmeh
54
+ - [DataGrid] Fix dimensions lag issue after autosize (#13587) @MBilalShafi
55
+ - [DataGrid] Fix print export failure when `hideFooter` option is set (#13034) @tarunrajput
56
+
57
+ #### `@mui/x-data-grid-pro@7.8.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
58
+
59
+ Same changes as in `@mui/x-data-grid@7.8.0`, plus:
60
+
61
+ - [DataGridPro] Fix multi-sorting indicator being cut off (#13625) @KenanYusuf
62
+ - [DataGridPro] Server-side tree data support (#12317) @MBilalShafi
63
+
64
+ #### `@mui/x-data-grid-premium@7.8.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
65
+
66
+ Same changes as in `@mui/x-data-grid-pro@7.8.0`.
67
+
68
+ ### Date and Time Pickers
69
+
70
+ #### `@mui/x-date-pickers@7.8.0`
71
+
72
+ - [fields] Fix section clearing behavior on Android (#13652) @LukasTy
73
+
74
+ #### `@mui/x-date-pickers-pro@7.8.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
75
+
76
+ Same changes as in `@mui/x-date-pickers@7.8.0`.
77
+
78
+ ### Charts
79
+
80
+ #### `@mui/x-charts@7.8.0`
81
+
82
+ - [charts] Fix line chart props not passing correct event handlers (#13609) @JCQuintas
83
+ - [charts] Support BarChart with `Date` data (#13471) @alexfauquette
84
+ - [charts] Support RTL for y-axis (#13614) @alexfauquette
85
+ - [charts] Use default values instead of non-null assertion to prevent error being thrown (#13637) @JCQuintas
86
+
87
+ ### Tree View
88
+
89
+ #### `@mui/x-tree-view@7.8.0`
90
+
91
+ - [TreeView] Add `expansionTrigger` prop (#13533) @noraleonte
92
+ - [TreeView] Support experimental features from plugin's dependencies (#13632) @flaviendelangle
93
+
94
+ ### Docs
95
+
96
+ - [docs] Add callout for `Luxon` `throwOnInvalid` support (#13621) @LukasTy
97
+ - [docs] Add "Overlays" section to the Data Grid documentation (#13624) @KenanYusuf
98
+
99
+ ### Core
100
+
101
+ - [core] Add eslint rule to restrict import from `../internals` root (#13633) @JCQuintas
102
+ - [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
103
+ - [license] Allow usage of charts and tree view pro package for old premium licenses (#13619) @flaviendelangle
104
+
105
+ ## 7.7.1
106
+
107
+ _Jun 21, 2024_
108
+
109
+ We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
110
+
111
+ - 🌍 Improve Portuguese (pt-PT) locale on the Data Grid
112
+ - 🌍 Improve Danish (da-DK) locale on the Date and Time Pickers
113
+ - 🐞 Bugfixes
114
+ - 📚 Documentation improvements
115
+
116
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
117
+
118
+ ### Data Grid
119
+
120
+ #### `@mui/x-data-grid@7.7.1`
121
+
122
+ - [DataGrid][docs] Clarify enabling pagination (#13350) @oliviertassinari
123
+ - [DataGrid] Fix CSV export escaping for non-string values (#13560) @joeycumines-scw
124
+ - [l10n] Improve Portuguese (pt-PT) locale (#13348) @joaosreis
125
+
126
+ #### `@mui/x-data-grid-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
127
+
128
+ Same changes as in `@mui/x-data-grid@7.7.1`, plus:
129
+
130
+ - [DataGrid] Warn about `getTreeDataPath` reference (#13519) @cherniavskii
131
+
132
+ #### `@mui/x-data-grid-premium@7.7.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
133
+
134
+ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
135
+
136
+ ### Date and Time Pickers
137
+
138
+ #### `@mui/x-date-pickers@7.7.1`
139
+
140
+ - [fields] Prevent digit editing on the `Space` key down (#13510) @flaviendelangle
141
+ - [l10n] Improve Danish (da-DK) locale (#13375) @jacrowland1
142
+ - [pickers] Add context to `onAccept` callback (#13511) @flaviendelangle
143
+ - [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
144
+ - [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
145
+ - [pickers] Fix controlled `view` behavior (#13552) @LukasTy
146
+ - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
147
+
148
+ #### `@mui/x-date-pickers-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
149
+
150
+ Same changes as in `@mui/x-date-pickers@7.7.1`, plus:
151
+
152
+ - [DateRangePicker] Add accessible name to calendar grid (#13538) @LukasTy
153
+
154
+ ### Charts
155
+
156
+ #### `@mui/x-charts@7.7.1`
157
+
158
+ - [charts] Divide `CartesianProvider` to use logic in Pro package (#13531) @JCQuintas
159
+ - [charts] Do not publish the pro package (#13539) @alexfauquette
160
+ - [charts] Export `Pro` versions of regular charts (#13547) @JCQuintas
161
+ - [charts] Prepare `ChartContainerPro` for future Zoom changes (#13532) @JCQuintas
162
+ - [charts] Remove unnecessary proptypes from internal component (#13518) @JCQuintas
163
+
164
+ ### Tree View
165
+
166
+ #### `@mui/x-tree-view@7.7.1`
167
+
168
+ - [TreeView] Improve typing to support optional dependencies in plugins and in the item (#13523) @flaviendelangle
169
+ - [TreeView] Move `useTreeViewId` to the core plugins (#13566) @flaviendelangle
170
+ - [TreeView] Remove unused state from `useTreeViewId` (#13579) @flaviendelangle
171
+ - [TreeView] Support `itemId` with escaping characters when using `SimpleTreeView` (#13487) @oukunan
172
+
173
+ ### Docs
174
+
175
+ - [docs] Add section about the new uncovered product watermark (#13568) @michelengelen
176
+ - [docs] Document the `PickerValidDate` type override (#13476) @flaviendelangle
177
+ - [docs] Fix typo (#13507) @anshtiwatne
178
+ - [docs] Remove "-" in heat-map and tree-map urls (#13569) @alexfauquette
179
+ - [docs] Use dedicated tab for weather dataset (#13513) @alexfauquette
180
+ - [x-license] license update proposal (#13459) @michelengelen
181
+
182
+ ### Core
183
+
184
+ - [core] Fix failing CI test (#13574) @alexfauquette
185
+ - [infra] Remove explicit `@testing-library/react` dependency (#13478) @LukasTy
186
+
6
187
  ## 7.7.0
7
188
 
8
189
  _Jun 13, 2024_
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { DrawingProviderProps } from '../context/DrawingProvider';
3
3
  import { SeriesContextProviderProps } from '../context/SeriesContextProvider';
4
4
  import { ChartsSurfaceProps } from '../ChartsSurface';
5
- import { CartesianContextProviderProps } from '../context/CartesianContextProvider';
5
+ import { CartesianContextProviderProps } from '../context/CartesianProvider';
6
6
  import { HighlightedProviderProps, ZAxisContextProviderProps } from '../context';
7
7
  import { ChartsPluginType } from '../models/plugin';
8
8
  import { ChartSeriesType } from '../models/seriesType/config';
@@ -20,6 +20,6 @@ declare const ChartContainer: React.ForwardRefExoticComponent<Omit<ChartsSurface
20
20
  * An array of plugins defining how to preprocess data.
21
21
  * If not provided, the container supports line, bar, scatter and pie charts.
22
22
  */
23
- plugins?: ChartsPluginType<keyof import("../models/seriesType/config").ChartsSeriesConfig>[] | undefined;
23
+ plugins?: ChartsPluginType<ChartSeriesType>[];
24
24
  } & React.RefAttributes<unknown>>;
25
25
  export { ChartContainer };
@@ -7,17 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ChartContainer = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
11
10
  var _DrawingProvider = require("../context/DrawingProvider");
12
11
  var _SeriesContextProvider = require("../context/SeriesContextProvider");
13
12
  var _InteractionProvider = require("../context/InteractionProvider");
14
13
  var _ColorProvider = require("../context/ColorProvider");
15
- var _useReducedMotion = require("../hooks/useReducedMotion");
16
14
  var _ChartsSurface = require("../ChartsSurface");
17
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
15
+ var _CartesianProvider = require("../context/CartesianProvider");
18
16
  var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
19
17
  var _context = require("../context");
20
- var _usePluginsMerge = require("./usePluginsMerge");
18
+ var _useChartContainerHooks = require("./useChartContainerHooks");
21
19
  var _jsxRuntime = require("react/jsx-runtime");
22
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -41,16 +39,14 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
41
39
  plugins,
42
40
  children
43
41
  } = props;
44
- const svgRef = React.useRef(null);
45
- const handleRef = (0, _useForkRef.default)(ref, svgRef);
46
42
  const {
43
+ svgRef,
44
+ handleRef,
47
45
  xExtremumGetters,
48
46
  yExtremumGetters,
49
47
  seriesFormatters,
50
48
  colorProcessors
51
- } = (0, _usePluginsMerge.usePluginsMerge)(plugins);
52
- (0, _useReducedMotion.useReducedMotion)(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
53
-
49
+ } = (0, _useChartContainerHooks.useChartContainerHooks)(ref, plugins);
54
50
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DrawingProvider.DrawingProvider, {
55
51
  width: width,
56
52
  height: height,
@@ -63,7 +59,7 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
63
59
  colors: colors,
64
60
  dataset: dataset,
65
61
  seriesFormatters: seriesFormatters,
66
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartesianContextProvider.CartesianContextProvider, {
62
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartesianProvider.CartesianContextProvider, {
67
63
  xAxis: xAxis,
68
64
  yAxis: yAxis,
69
65
  dataset: dataset,
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { ChartsPluginType } from '../models';
3
+ import { ChartSeriesType } from '../models/seriesType/config';
4
+ export declare const useChartContainerHooks: (ref: React.ForwardedRef<unknown> | null, plugins?: ChartsPluginType<ChartSeriesType>[]) => {
5
+ svgRef: React.RefObject<SVGSVGElement>;
6
+ handleRef: ((instance: unknown) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null;
7
+ xExtremumGetters: import("../models").ExtremumGettersConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
8
+ yExtremumGetters: import("../models").ExtremumGettersConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
9
+ seriesFormatters: import("../internals").SeriesFormatterConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
10
+ colorProcessors: import("../models").ColorProcessorsConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
11
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useChartContainerHooks = void 0;
8
+ var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _usePluginsMerge = require("./usePluginsMerge");
11
+ var _useReducedMotion = require("../hooks/useReducedMotion");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const useChartContainerHooks = (ref, plugins) => {
15
+ const svgRef = React.useRef(null);
16
+ const handleRef = (0, _useForkRef.default)(ref, svgRef);
17
+ const {
18
+ xExtremumGetters,
19
+ yExtremumGetters,
20
+ seriesFormatters,
21
+ colorProcessors
22
+ } = (0, _usePluginsMerge.usePluginsMerge)(plugins);
23
+ (0, _useReducedMotion.useReducedMotion)(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
24
+
25
+ return {
26
+ svgRef,
27
+ handleRef,
28
+ xExtremumGetters,
29
+ yExtremumGetters,
30
+ seriesFormatters,
31
+ colorProcessors
32
+ };
33
+ };
34
+ exports.useChartContainerHooks = useChartContainerHooks;
@@ -1,6 +1,5 @@
1
- import { ChartsPluginType, ColorProcessorsConfig } from '../models';
1
+ import { ChartsPluginType, ColorProcessorsConfig, ExtremumGettersConfig } from '../models';
2
2
  import { ChartSeriesType } from '../models/seriesType/config';
3
- import { ExtremumGettersConfig } from '../context/CartesianContextProvider';
4
3
  import { SeriesFormatterConfig } from '../context/SeriesContextProvider';
5
4
  export declare function usePluginsMerge<T extends ChartSeriesType>(plugins?: ChartsPluginType<T>[]): {
6
5
  seriesFormatters: SeriesFormatterConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
@@ -8,7 +8,7 @@ exports.ChartsAxis = ChartsAxis;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
11
+ var _CartesianProvider = require("../context/CartesianProvider");
12
12
  var _ChartsXAxis = require("../ChartsXAxis");
13
13
  var _ChartsYAxis = require("../ChartsYAxis");
14
14
  var _jsxRuntime = require("react/jsx-runtime");
@@ -56,7 +56,7 @@ function ChartsAxis(props) {
56
56
  xAxisIds,
57
57
  yAxis,
58
58
  yAxisIds
59
- } = React.useContext(_CartesianContextProvider.CartesianContext);
59
+ } = (0, _CartesianProvider.useCartesianContext)();
60
60
 
61
61
  // TODO: use for plotting line without ticks or any thing
62
62
  // const drawingArea = React.useContext(DrawingContext);
@@ -15,7 +15,7 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
15
15
  var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
16
16
  var _styles = require("@mui/material/styles");
17
17
  var _InteractionProvider = require("../context/InteractionProvider");
18
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
18
+ var _CartesianProvider = require("../context/CartesianProvider");
19
19
  var _useScale = require("../hooks/useScale");
20
20
  var _isBandScale = require("../internals/isBandScale");
21
21
  var _jsxRuntime = require("react/jsx-runtime");
@@ -66,7 +66,7 @@ function ChartsAxisHighlight(props) {
66
66
  xAxis,
67
67
  yAxisIds,
68
68
  yAxis
69
- } = React.useContext(_CartesianContextProvider.CartesianContext);
69
+ } = (0, _CartesianProvider.useCartesianContext)();
70
70
  const classes = useUtilityClasses();
71
71
  const USED_X_AXIS_ID = xAxisIds[0];
72
72
  const USED_Y_AXIS_ID = yAxisIds[0];
@@ -77,15 +77,30 @@ function ChartsAxisHighlight(props) {
77
77
  } = React.useContext(_InteractionProvider.InteractionContext);
78
78
  const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
79
79
  const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
80
+ const axisX = axis.x;
81
+ const axisY = axis.y;
82
+ const isBandScaleX = xAxisHighlight === 'band' && axisX !== null && (0, _isBandScale.isBandScale)(xScale);
83
+ const isBandScaleY = yAxisHighlight === 'band' && axisY !== null && (0, _isBandScale.isBandScale)(yScale);
84
+ if (process.env.NODE_ENV !== 'production') {
85
+ const isXError = isBandScaleX && xScale(axisX.value) === undefined;
86
+ const isYError = isBandScaleY && yScale(axisY.value) === undefined;
87
+ if (isXError || isYError) {
88
+ console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
89
+ }
90
+ }
80
91
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
81
- children: [xAxisHighlight === 'band' && axis.x !== null && (0, _isBandScale.isBandScale)(xScale) && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsAxisHighlightPath, {
82
- d: `M ${xScale(axis.x.value) - (xScale.step() - xScale.bandwidth()) / 2} ${yScale.range()[0]} l ${xScale.step()} 0 l 0 ${yScale.range()[1] - yScale.range()[0]} l ${-xScale.step()} 0 Z`,
92
+ children: [isBandScaleX && xScale(axisX.value) !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsAxisHighlightPath
93
+ // @ts-expect-error, xScale value is checked in the statement above
94
+ , {
95
+ d: `M ${xScale(axisX.value) - (xScale.step() - xScale.bandwidth()) / 2} ${yScale.range()[0]} l ${xScale.step()} 0 l 0 ${yScale.range()[1] - yScale.range()[0]} l ${-xScale.step()} 0 Z`,
83
96
  className: classes.root,
84
97
  ownerState: {
85
98
  axisHighlight: 'band'
86
99
  }
87
- }), yAxisHighlight === 'band' && axis.y !== null && (0, _isBandScale.isBandScale)(yScale) && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsAxisHighlightPath, {
88
- d: `M ${xScale.range()[0]} ${yScale(axis.y.value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${xScale.range()[1] - xScale.range()[0]} 0 l 0 ${-yScale.step()} Z`,
100
+ }), isBandScaleY && yScale(axisY.value) === undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsAxisHighlightPath, {
101
+ d: `M ${xScale.range()[0]} ${
102
+ // @ts-expect-error, yScale value is checked in the statement above
103
+ yScale(axisY.value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${xScale.range()[1] - xScale.range()[0]} 0 l 0 ${-yScale.step()} Z`,
89
104
  className: classes.root,
90
105
  ownerState: {
91
106
  axisHighlight: 'band'