@mui/x-charts-pro 8.12.0 → 8.13.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 (50) hide show
  1. package/BarChartPro/BarChartPro.js +24 -1
  2. package/CHANGELOG.md +145 -0
  3. package/ChartContainerPro/useChartContainerProProps.js +3 -1
  4. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  5. package/FunnelChart/funnelAxisPlugin/computeAxisValue.js +1 -4
  6. package/LineChartPro/LineChartPro.js +24 -1
  7. package/ScatterChartPro/ScatterChartPro.js +24 -1
  8. package/esm/BarChartPro/BarChartPro.js +24 -1
  9. package/esm/ChartContainerPro/useChartContainerProProps.js +3 -1
  10. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  11. package/esm/FunnelChart/funnelAxisPlugin/computeAxisValue.js +2 -5
  12. package/esm/LineChartPro/LineChartPro.js +24 -1
  13. package/esm/ScatterChartPro/ScatterChartPro.js +24 -1
  14. package/esm/index.js +1 -1
  15. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +22 -0
  16. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +4 -0
  17. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +92 -0
  18. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.js +1 -0
  19. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +21 -6
  20. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +1 -1
  21. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +18 -9
  22. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.d.ts +8 -0
  23. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +73 -0
  24. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +14 -4
  25. package/esm/internals/plugins/useChartProZoom/initializeZoomData.d.ts +2 -0
  26. package/esm/internals/plugins/useChartProZoom/initializeZoomData.js +26 -0
  27. package/esm/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.d.ts +2 -0
  28. package/esm/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.js +86 -0
  29. package/esm/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -2
  30. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +25 -44
  31. package/esm/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +9 -0
  32. package/index.js +1 -1
  33. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +22 -0
  34. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +10 -0
  35. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +92 -0
  36. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.js +5 -0
  37. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +21 -6
  38. package/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +1 -1
  39. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +18 -9
  40. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.d.ts +8 -0
  41. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +80 -0
  42. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +14 -4
  43. package/internals/plugins/useChartProZoom/initializeZoomData.d.ts +2 -0
  44. package/internals/plugins/useChartProZoom/initializeZoomData.js +31 -0
  45. package/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.d.ts +2 -0
  46. package/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.js +92 -0
  47. package/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -2
  48. package/internals/plugins/useChartProZoom/useChartProZoom.js +26 -45
  49. package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +9 -0
  50. package/package.json +6 -6
@@ -1423,5 +1423,28 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
1423
1423
  axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
1424
1424
  end: _propTypes.default.number.isRequired,
1425
1425
  start: _propTypes.default.number.isRequired
1426
- }))
1426
+ })),
1427
+ /**
1428
+ * Configuration for zoom interactions.
1429
+ */
1430
+ zoomInteractionConfig: _propTypes.default.shape({
1431
+ pan: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(['drag']), _propTypes.default.shape({
1432
+ pointerMode: _propTypes.default.oneOf(['mouse', 'touch']),
1433
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1434
+ type: _propTypes.default.oneOf(['drag']).isRequired
1435
+ })]).isRequired),
1436
+ zoom: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(['pinch', 'tapAndDrag', 'wheel']), _propTypes.default.shape({
1437
+ pointerMode: _propTypes.default.any,
1438
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1439
+ type: _propTypes.default.oneOf(['wheel']).isRequired
1440
+ }), _propTypes.default.shape({
1441
+ pointerMode: _propTypes.default.any,
1442
+ requiredKeys: _propTypes.default.array,
1443
+ type: _propTypes.default.oneOf(['pinch']).isRequired
1444
+ }), _propTypes.default.shape({
1445
+ pointerMode: _propTypes.default.oneOf(['mouse', 'touch']),
1446
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1447
+ type: _propTypes.default.oneOf(['tapAndDrag']).isRequired
1448
+ })]).isRequired)
1449
+ })
1427
1450
  } : void 0;
package/CHANGELOG.md CHANGED
@@ -5,6 +5,151 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.13.0
9
+
10
+ _Oct 1, 2025_
11
+
12
+ We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 📊 The chart zoom now supports the `tapAndDrag` gesture. Zoom in/out by tapping twice and dragging vertically.
15
+ - 🔎 Charts now allow [fine-grained control for zoom interactions](https://mui.com/x/react-charts/zoom-and-pan/#zoom-interactions-configuration).
16
+ ```jsx
17
+ <BarChartPro
18
+ zoomInteractionConfig={{
19
+ // Only zoom when Control key is pressed
20
+ zoom: [{ type: 'wheel', keys: ['Control'] }],
21
+ // Only pan when Shift key is pressed
22
+ pan: [{ type: 'drag', keys: ['Shift'] }],
23
+ }}
24
+ />
25
+ ```
26
+ - ➡️ Data Grid grouping rows now persist their expansion state when the rows are updated.
27
+ - 📜 Updated Data Grid vertical scrollbar to include pinned rows and aggregation sections.
28
+ - 📌 Improved the appearance of [pinned columns](https://mui.com/x/react-data-grid/column-pinning/#pinned-columns-appearance) and [pinned rows](https://mui.com/x/react-data-grid/row-pinning/#pinned-rows-appearance) sections in the Data Grid.
29
+ - 🚀 Tree View now fetches the children of expanded items on mount when using lazy loading.
30
+ - 🐞 Bugfixes
31
+ - 📚 Documentation improvements
32
+
33
+ Special thanks go out to the community members for their valuable contributions:
34
+ @sai6855
35
+
36
+ The following are all team members who have contributed to this release:
37
+ @alexfauquette, @arminmeh, @bernardobelchior, @flaviendelangle, @hasdfa, @Janpot, @JCQuintas, @KenanYusuf, @mapache-salvaje, @MBilalShafi, @mnajdova, @rita-codes, @siriwatknp
38
+
39
+ ### Data Grid
40
+
41
+ #### `@mui/x-data-grid@8.13.0`
42
+
43
+ - [DataGrid] Add scroll shadows and fix scrollbar overlap (#16476) @KenanYusuf
44
+ - [DataGrid] Fix row spanning stale state issue (#19733) @MBilalShafi
45
+ - [DataGrid] Fix toolbar `slotProps` not being applied (#19769) @sai6855
46
+ - [DataGrid] Skip calling `fetchRows()` when strategy is not initialized (#19728) @MBilalShafi
47
+
48
+ #### `@mui/x-data-grid-pro@8.13.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
49
+
50
+ Same changes as in `@mui/x-data-grid@8.13.0`, plus:
51
+
52
+ - [DataGridPro] Retain expansion state on rows update (#19697) @MBilalShafi
53
+
54
+ #### `@mui/x-data-grid-premium@8.13.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
55
+
56
+ Same changes as in `@mui/x-data-grid-pro@8.13.0`, plus:
57
+
58
+ - [DataGridPremium] Add `metadata.referenceId` to AI assistant prompt resolver (#19695) @hasdfa
59
+ - [DataGridPremium] Fix aggregation value retrieval (#19724) @arminmeh
60
+ - [DataGridPremium] Get correct active chart id while rebuilding data (#19720) @arminmeh
61
+
62
+ ### Date and Time Pickers
63
+
64
+ #### `@mui/x-date-pickers@8.12.0`
65
+
66
+ Internal changes.
67
+
68
+ #### `@mui/x-date-pickers-pro@8.12.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
69
+
70
+ Same changes as in `@mui/x-date-pickers@8.12.0`.
71
+
72
+ ### Charts
73
+
74
+ #### `@mui/x-charts@8.13.0`
75
+
76
+ - [charts] Add `tapAndDrag` zoom gesture (#19727) @JCQuintas
77
+ - [charts] Add arc focus indicator that follows the arc form (#19696) @mnajdova
78
+ - [charts] Fix outline color (#19752) @alexfauquette
79
+ - [charts] Improve tooltip doc (#19731) @JCQuintas
80
+ - [charts] Make axis highlight reflect the keyboard interaction (#19631) @alexfauquette
81
+ - [charts] Prevent horizontal scroll on keyboard navigation (#19704) @alexfauquette
82
+ - [charts] Simplify gestures by removing bindings (#19767) @JCQuintas
83
+
84
+ #### `@mui/x-charts-pro@8.13.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
85
+
86
+ Same changes as in `@mui/x-charts@8.13.0`, plus:
87
+
88
+ - [charts-pro] Allow zoom interactions to be configured (#18646) @JCQuintas
89
+ - [charts-pro] Fix zoom preview having wrong domain in some cases (#19723) @bernardobelchior
90
+
91
+ #### `@mui/x-charts-premium@8.13.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
92
+
93
+ Same changes as in `@mui/x-charts-pro@8.13.0`.
94
+
95
+ ### Tree View
96
+
97
+ #### `@mui/x-tree-view@8.13.0`
98
+
99
+ - [tree view] Export the `apiRef` type of each Tree View component (#19543) @flaviendelangle
100
+ - [tree view] Fix indeterminate checkbox state (#19544) @flaviendelangle
101
+ - [tree view] Improve the lazy loading initial expansion (#19284) @flaviendelangle
102
+ - [tree view] Use Base UI utils whenever possible (#19502) @flaviendelangle
103
+
104
+ #### `@mui/x-tree-view-pro@8.13.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
105
+
106
+ Same changes as in `@mui/x-tree-view@8.13.0`.
107
+
108
+ ### Codemod
109
+
110
+ #### `@mui/x-codemod@8.12.0`
111
+
112
+ Internal changes.
113
+
114
+ ### Docs
115
+
116
+ - [docs] Add a recipe to customize editing component with Autocomplete (#19651) @siriwatknp
117
+ - [docs] Refine the electricity scatter tooltip (#19689) @alexfauquette
118
+ - [docs] Revise the Axis doc (#19052) @mapache-salvaje
119
+ - [docs] Remove reference to nonexistent `FocusedMark` API page (#19773) @bernardobelchior
120
+
121
+ ### Core
122
+
123
+ - [code-infra] Change charts codspeed integration to use walltime (#19729) @JCQuintas
124
+ - [code-infra] Port stylelint from core repo (#19633) @Janpot
125
+ - [code-infra] Stabilize fake timers in regression tests (#19719) @Janpot
126
+ - [code-infra] Stabilize size for bundles with `releaseInfo` (#19674) @Janpot
127
+ - [code-infra] Fix `pnpm-lock.yaml` broken lockfile (#19755) @bernardobelchior
128
+
129
+ ## 8.12.1
130
+
131
+ _Sep 25, 2025_
132
+
133
+ Release highlight ✨:
134
+
135
+ - 🐞 Hotfix for Grid-Charts integration issue with aggregated values
136
+
137
+ ### Data Grid
138
+
139
+ #### `@mui/x-data-grid@8.12.1`
140
+
141
+ Internal changes.
142
+
143
+ #### `@mui/x-data-grid-pro@8.12.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
144
+
145
+ Same changes as in `@mui/x-data-grid@8.12.1`.
146
+
147
+ #### `@mui/x-data-grid-premium@8.12.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
148
+
149
+ Same changes as in `@mui/x-data-grid-pro@8.12.1`, plus:
150
+
151
+ - [DataGridPremium] Collect aggregated values properly for the charts integration context (#19714) @arminmeh
152
+
8
153
  ## 8.12.0
9
154
 
10
155
  _Sep 25, 2025_
@@ -10,13 +10,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
11
  var _internals = require("@mui/x-charts/internals");
12
12
  var _allPlugins = require("../internals/plugins/allPlugins");
13
- const _excluded = ["initialZoom", "zoomData", "onZoomChange", "plugins", "apiRef"];
13
+ const _excluded = ["initialZoom", "zoomData", "onZoomChange", "zoomInteractionConfig", "plugins", "apiRef"];
14
14
  const useChartContainerProProps = (props, ref) => {
15
15
  const _ref = props,
16
16
  {
17
17
  initialZoom,
18
18
  zoomData,
19
19
  onZoomChange,
20
+ zoomInteractionConfig,
20
21
  plugins,
21
22
  apiRef
22
23
  } = _ref,
@@ -30,6 +31,7 @@ const useChartContainerProProps = (props, ref) => {
30
31
  initialZoom,
31
32
  zoomData,
32
33
  onZoomChange,
34
+ zoomInteractionConfig,
33
35
  apiRef,
34
36
  plugins: plugins ?? _allPlugins.DEFAULT_PLUGINS
35
37
  });
@@ -18,7 +18,7 @@ var _material = require("../internals/material");
18
18
  var _allPlugins = require("../internals/plugins/allPlugins");
19
19
  var _useChartDataProviderProProps = require("./useChartDataProviderProProps");
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
- const releaseInfo = "MTc1ODc1MTIwMDAwMA==";
21
+ const releaseInfo = "MTc1OTI3NjgwMDAwMA==";
22
22
  const packageIdentifier = 'x-charts-pro';
23
23
  /**
24
24
  * Orchestrates the data providers for the chart components and hooks.
@@ -94,10 +94,7 @@ function computeAxisValue({
94
94
  axisExtremums[0] = min;
95
95
  axisExtremums[1] = max;
96
96
  }
97
- const rawTickNumber = (0, _internals.getTickNumber)((0, _extends2.default)({}, axis, {
98
- range,
99
- domain: axisExtremums
100
- }));
97
+ const rawTickNumber = (0, _internals.getTickNumber)(axis, axisExtremums, (0, _internals.getDefaultTickNumber)(Math.abs(range[1] - range[0])));
101
98
  const tickNumber = (0, _internals.scaleTickNumberByRange)(rawTickNumber, range);
102
99
  const scale = (0, _internals.getScale)(scaleType, axisExtremums, range);
103
100
  const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
@@ -1426,5 +1426,28 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
1426
1426
  axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
1427
1427
  end: _propTypes.default.number.isRequired,
1428
1428
  start: _propTypes.default.number.isRequired
1429
- }))
1429
+ })),
1430
+ /**
1431
+ * Configuration for zoom interactions.
1432
+ */
1433
+ zoomInteractionConfig: _propTypes.default.shape({
1434
+ pan: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(['drag']), _propTypes.default.shape({
1435
+ pointerMode: _propTypes.default.oneOf(['mouse', 'touch']),
1436
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1437
+ type: _propTypes.default.oneOf(['drag']).isRequired
1438
+ })]).isRequired),
1439
+ zoom: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(['pinch', 'tapAndDrag', 'wheel']), _propTypes.default.shape({
1440
+ pointerMode: _propTypes.default.any,
1441
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1442
+ type: _propTypes.default.oneOf(['wheel']).isRequired
1443
+ }), _propTypes.default.shape({
1444
+ pointerMode: _propTypes.default.any,
1445
+ requiredKeys: _propTypes.default.array,
1446
+ type: _propTypes.default.oneOf(['pinch']).isRequired
1447
+ }), _propTypes.default.shape({
1448
+ pointerMode: _propTypes.default.oneOf(['mouse', 'touch']),
1449
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1450
+ type: _propTypes.default.oneOf(['tapAndDrag']).isRequired
1451
+ })]).isRequired)
1452
+ })
1430
1453
  } : void 0;
@@ -1408,5 +1408,28 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
1408
1408
  axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
1409
1409
  end: _propTypes.default.number.isRequired,
1410
1410
  start: _propTypes.default.number.isRequired
1411
- }))
1411
+ })),
1412
+ /**
1413
+ * Configuration for zoom interactions.
1414
+ */
1415
+ zoomInteractionConfig: _propTypes.default.shape({
1416
+ pan: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(['drag']), _propTypes.default.shape({
1417
+ pointerMode: _propTypes.default.oneOf(['mouse', 'touch']),
1418
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1419
+ type: _propTypes.default.oneOf(['drag']).isRequired
1420
+ })]).isRequired),
1421
+ zoom: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(['pinch', 'tapAndDrag', 'wheel']), _propTypes.default.shape({
1422
+ pointerMode: _propTypes.default.any,
1423
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1424
+ type: _propTypes.default.oneOf(['wheel']).isRequired
1425
+ }), _propTypes.default.shape({
1426
+ pointerMode: _propTypes.default.any,
1427
+ requiredKeys: _propTypes.default.array,
1428
+ type: _propTypes.default.oneOf(['pinch']).isRequired
1429
+ }), _propTypes.default.shape({
1430
+ pointerMode: _propTypes.default.oneOf(['mouse', 'touch']),
1431
+ requiredKeys: _propTypes.default.arrayOf(_propTypes.default.string),
1432
+ type: _propTypes.default.oneOf(['tapAndDrag']).isRequired
1433
+ })]).isRequired)
1434
+ })
1412
1435
  } : void 0;
@@ -1416,6 +1416,29 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
1416
1416
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1417
1417
  end: PropTypes.number.isRequired,
1418
1418
  start: PropTypes.number.isRequired
1419
- }))
1419
+ })),
1420
+ /**
1421
+ * Configuration for zoom interactions.
1422
+ */
1423
+ zoomInteractionConfig: PropTypes.shape({
1424
+ pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag']), PropTypes.shape({
1425
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1426
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1427
+ type: PropTypes.oneOf(['drag']).isRequired
1428
+ })]).isRequired),
1429
+ zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
1430
+ pointerMode: PropTypes.any,
1431
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1432
+ type: PropTypes.oneOf(['wheel']).isRequired
1433
+ }), PropTypes.shape({
1434
+ pointerMode: PropTypes.any,
1435
+ requiredKeys: PropTypes.array,
1436
+ type: PropTypes.oneOf(['pinch']).isRequired
1437
+ }), PropTypes.shape({
1438
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1439
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1440
+ type: PropTypes.oneOf(['tapAndDrag']).isRequired
1441
+ })]).isRequired)
1442
+ })
1420
1443
  } : void 0;
1421
1444
  export { BarChartPro };
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["initialZoom", "zoomData", "onZoomChange", "plugins", "apiRef"];
5
+ const _excluded = ["initialZoom", "zoomData", "onZoomChange", "zoomInteractionConfig", "plugins", "apiRef"];
6
6
  import { useChartContainerProps } from '@mui/x-charts/internals';
7
7
  import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
8
8
  export const useChartContainerProProps = (props, ref) => {
@@ -11,6 +11,7 @@ export const useChartContainerProProps = (props, ref) => {
11
11
  initialZoom,
12
12
  zoomData,
13
13
  onZoomChange,
14
+ zoomInteractionConfig,
14
15
  plugins,
15
16
  apiRef
16
17
  } = _ref,
@@ -24,6 +25,7 @@ export const useChartContainerProProps = (props, ref) => {
24
25
  initialZoom,
25
26
  zoomData,
26
27
  onZoomChange,
28
+ zoomInteractionConfig,
27
29
  apiRef,
28
30
  plugins: plugins ?? DEFAULT_PLUGINS
29
31
  });
@@ -11,7 +11,7 @@ import { defaultSlotsMaterial } from "../internals/material/index.js";
11
11
  import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
12
12
  import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const releaseInfo = "MTc1ODc1MTIwMDAwMA==";
14
+ const releaseInfo = "MTc1OTI3NjgwMDAwMA==";
15
15
  const packageIdentifier = 'x-charts-pro';
16
16
  /**
17
17
  * Orchestrates the data providers for the chart components and hooks.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { scaleBand } from '@mui/x-charts-vendor/d3-scale';
3
- import { getAxisExtrema, isBandScaleConfig, getScale, getColorScale, getOrdinalColorScale, getTickNumber, scaleTickNumberByRange, getCartesianAxisTriggerTooltip, isDateData, createDateFormatter } from '@mui/x-charts/internals';
3
+ import { getAxisExtrema, isBandScaleConfig, getScale, getColorScale, getOrdinalColorScale, getTickNumber, scaleTickNumberByRange, getCartesianAxisTriggerTooltip, isDateData, createDateFormatter, getDefaultTickNumber } from '@mui/x-charts/internals';
4
4
  export const xRangeGetter = (drawingArea, reverse, removedSpace = 0) => {
5
5
  const range = [drawingArea.left, drawingArea.left + drawingArea.width - removedSpace];
6
6
  return reverse ? [range[1], range[0]] : [range[0], range[1]];
@@ -84,10 +84,7 @@ export function computeAxisValue({
84
84
  axisExtremums[0] = min;
85
85
  axisExtremums[1] = max;
86
86
  }
87
- const rawTickNumber = getTickNumber(_extends({}, axis, {
88
- range,
89
- domain: axisExtremums
90
- }));
87
+ const rawTickNumber = getTickNumber(axis, axisExtremums, getDefaultTickNumber(Math.abs(range[1] - range[0])));
91
88
  const tickNumber = scaleTickNumberByRange(rawTickNumber, range);
92
89
  const scale = getScale(scaleType, axisExtremums, range);
93
90
  const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
@@ -1419,6 +1419,29 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
1419
1419
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1420
1420
  end: PropTypes.number.isRequired,
1421
1421
  start: PropTypes.number.isRequired
1422
- }))
1422
+ })),
1423
+ /**
1424
+ * Configuration for zoom interactions.
1425
+ */
1426
+ zoomInteractionConfig: PropTypes.shape({
1427
+ pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag']), PropTypes.shape({
1428
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1429
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1430
+ type: PropTypes.oneOf(['drag']).isRequired
1431
+ })]).isRequired),
1432
+ zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
1433
+ pointerMode: PropTypes.any,
1434
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1435
+ type: PropTypes.oneOf(['wheel']).isRequired
1436
+ }), PropTypes.shape({
1437
+ pointerMode: PropTypes.any,
1438
+ requiredKeys: PropTypes.array,
1439
+ type: PropTypes.oneOf(['pinch']).isRequired
1440
+ }), PropTypes.shape({
1441
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1442
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1443
+ type: PropTypes.oneOf(['tapAndDrag']).isRequired
1444
+ })]).isRequired)
1445
+ })
1423
1446
  } : void 0;
1424
1447
  export { LineChartPro };
@@ -1401,6 +1401,29 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
1401
1401
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1402
1402
  end: PropTypes.number.isRequired,
1403
1403
  start: PropTypes.number.isRequired
1404
- }))
1404
+ })),
1405
+ /**
1406
+ * Configuration for zoom interactions.
1407
+ */
1408
+ zoomInteractionConfig: PropTypes.shape({
1409
+ pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag']), PropTypes.shape({
1410
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1411
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1412
+ type: PropTypes.oneOf(['drag']).isRequired
1413
+ })]).isRequired),
1414
+ zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
1415
+ pointerMode: PropTypes.any,
1416
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1417
+ type: PropTypes.oneOf(['wheel']).isRequired
1418
+ }), PropTypes.shape({
1419
+ pointerMode: PropTypes.any,
1420
+ requiredKeys: PropTypes.array,
1421
+ type: PropTypes.oneOf(['pinch']).isRequired
1422
+ }), PropTypes.shape({
1423
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1424
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1425
+ type: PropTypes.oneOf(['tapAndDrag']).isRequired
1426
+ })]).isRequired)
1427
+ })
1405
1428
  } : void 0;
1406
1429
  export { ScatterChartPro };
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts-pro v8.12.0
2
+ * @mui/x-charts-pro v8.13.0
3
3
  *
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  * This source code is licensed under the SEE LICENSE IN LICENSE license found in the
@@ -0,0 +1,22 @@
1
+ export declare const selectorZoomInteractionConfig: import("reselect").Selector<any, (Omit<import("./ZoomInteractionConfig.types.js").ZoomInteraction, "pointerMode"> & {
2
+ mouse: {
3
+ requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
4
+ };
5
+ touch: {
6
+ requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
7
+ };
8
+ pointerMode?: import("@mui/x-internal-gestures/core").PointerMode[];
9
+ }) | null, [interactionName: "wheel" | "pinch" | "tapAndDrag"]>;
10
+ export declare const selectorPanInteractionConfig: import("reselect").Selector<any, (Omit<{
11
+ type: "drag";
12
+ pointerMode?: import("./ZoomInteractionConfig.types.js").InteractionMode | undefined;
13
+ requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
14
+ }, "pointerMode"> & {
15
+ mouse: {
16
+ requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
17
+ };
18
+ touch: {
19
+ requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
20
+ };
21
+ pointerMode?: import("@mui/x-internal-gestures/core").PointerMode[];
22
+ }) | null, [interactionName: "drag"]>;
@@ -0,0 +1,4 @@
1
+ import { createSelector } from '@mui/x-charts/internals';
2
+ import { selectorChartZoomState } from "./useChartProZoom.selectors.js";
3
+ export const selectorZoomInteractionConfig = createSelector([selectorChartZoomState, (_state, interactionName) => interactionName], (zoomState, interactionName) => zoomState.zoomInteractionConfig.zoom[interactionName] ?? null);
4
+ export const selectorPanInteractionConfig = createSelector([selectorChartZoomState, (_state, interactionName) => interactionName], (zoomState, interactionName) => zoomState.zoomInteractionConfig.pan[interactionName] ?? null);
@@ -0,0 +1,92 @@
1
+ import type { KeyboardKey, PointerMode } from '@mui/x-internal-gestures/core';
2
+ export type ZoomInteractionConfig = {
3
+ /**
4
+ * Defines the interactions that trigger zooming.
5
+ * - `wheel`: Zooms in or out when the mouse wheel is scrolled.
6
+ * - `pinch`: Zooms in or out when a pinch gesture is detected.
7
+ * - `tapAndDrag`: Zooms in or out by tapping twice and then dragging vertically. Dragging up zooms in, dragging down zooms out.
8
+ *
9
+ * @default ['wheel', 'pinch']
10
+ */
11
+ zoom?: (ZoomInteraction | ZoomInteraction['type'])[];
12
+ /**
13
+ * Defines the interactions that trigger panning.
14
+ * - `drag`: Pans the chart when dragged with the mouse.
15
+ *
16
+ * @default ['drag']
17
+ */
18
+ pan?: (PanInteraction | PanInteraction['type'])[];
19
+ };
20
+ type Entry<T extends AnyInteraction> = { [K in T['type']]?: Omit<T, 'pointerMode'> & {
21
+ mouse: {
22
+ requiredKeys?: KeyboardKey[];
23
+ };
24
+ touch: {
25
+ requiredKeys?: KeyboardKey[];
26
+ };
27
+ pointerMode?: PointerMode[];
28
+ } };
29
+ export type DefaultizedZoomInteractionConfig = {
30
+ zoom: Entry<ZoomInteraction>;
31
+ pan: Entry<PanInteraction>;
32
+ };
33
+ export type ZoomInteraction = WheelInteraction | PinchInteraction | TapAndDragInteraction;
34
+ export type PanInteraction = DragInteraction;
35
+ export type ZoomInteractionName = ZoomInteraction['type'];
36
+ export type PanInteractionName = PanInteraction['type'];
37
+ export type InteractionMode = Exclude<PointerMode, 'pen'>;
38
+ type AllKeysProp = {
39
+ /**
40
+ * The keys that must be pressed to trigger the interaction.
41
+ */
42
+ requiredKeys?: KeyboardKey[];
43
+ };
44
+ type AllModeProp = {
45
+ /**
46
+ * Defines which type of pointer can trigger the interaction.
47
+ * - `mouse`: Only mouse interactions will trigger the interaction.
48
+ * - `touch`: Only touch interactions will trigger the interaction.
49
+ * - undefined: All interactions will trigger the interaction.
50
+ */
51
+ pointerMode?: InteractionMode;
52
+ };
53
+ type NoKeysProp = {
54
+ /**
55
+ * This interaction does not support key combinations.
56
+ */
57
+ requiredKeys?: any[];
58
+ };
59
+ type NoModeProp = {
60
+ /**
61
+ * This gesture only works on a specific pointer mode. Mode has no effect.
62
+ */
63
+ pointerMode?: any;
64
+ };
65
+ type Unpack<T> = { [K in keyof T]: T[K] extends object ? Unpack<T[K]> : T[K] };
66
+ export type WheelInteraction = Unpack<{
67
+ type: 'wheel';
68
+ } & NoModeProp & AllKeysProp>;
69
+ export type PinchInteraction = Unpack<{
70
+ type: 'pinch';
71
+ } & NoModeProp & NoKeysProp>;
72
+ export type DragInteraction = Unpack<{
73
+ type: 'drag';
74
+ } & AllModeProp & AllKeysProp>;
75
+ export type TapAndDragInteraction = Unpack<{
76
+ type: 'tapAndDrag';
77
+ } & AllModeProp & AllKeysProp>;
78
+ export type AnyInteraction = {
79
+ type: string;
80
+ pointerMode?: InteractionMode;
81
+ requiredKeys?: KeyboardKey[];
82
+ };
83
+ export type AnyEntry = Omit<AnyInteraction, 'pointerMode'> & {
84
+ mouse: {
85
+ requiredKeys?: KeyboardKey[];
86
+ };
87
+ touch: {
88
+ requiredKeys?: KeyboardKey[];
89
+ };
90
+ pointerMode?: PointerMode[];
91
+ };
92
+ export {};
@@ -4,6 +4,7 @@ import * as React from 'react';
4
4
  import { useSelector, selectorChartDrawingArea, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
5
5
  import { rafThrottle } from '@mui/x-internals/rafThrottle';
6
6
  import { translateZoom } from "./useZoom.utils.js";
7
+ import { selectorPanInteractionConfig } from "../ZoomInteractionConfig.selectors.js";
7
8
  export const usePanOnDrag = ({
8
9
  store,
9
10
  instance,
@@ -12,12 +13,26 @@ export const usePanOnDrag = ({
12
13
  const drawingArea = useSelector(store, selectorChartDrawingArea);
13
14
  const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
14
15
  const startRef = React.useRef(null);
16
+ const config = useSelector(store, selectorPanInteractionConfig, ['drag']);
17
+ const isPanOnDragEnabled = React.useMemo(() => Object.values(optionsLookup).some(v => v.panning) && config || false, [optionsLookup, config]);
18
+ React.useEffect(() => {
19
+ if (!isPanOnDragEnabled) {
20
+ return;
21
+ }
22
+ instance.updateZoomInteractionListeners('zoomPan', {
23
+ requiredKeys: config.requiredKeys,
24
+ pointerMode: config.pointerMode,
25
+ pointerOptions: {
26
+ mouse: config.mouse,
27
+ touch: config.touch
28
+ }
29
+ });
30
+ }, [isPanOnDragEnabled, config, instance]);
15
31
 
16
32
  // Add event for chart panning
17
- const isPanEnabled = React.useMemo(() => Object.values(optionsLookup).some(v => v.panning) || false, [optionsLookup]);
18
33
  React.useEffect(() => {
19
34
  const element = svgRef.current;
20
- if (element === null || !isPanEnabled) {
35
+ if (element === null || !isPanOnDragEnabled) {
21
36
  return () => {};
22
37
  }
23
38
  const handlePanStart = event => {
@@ -45,14 +60,14 @@ export const usePanOnDrag = ({
45
60
  }
46
61
  throttledCallback(event, zoomData);
47
62
  };
48
- const panHandler = instance.addInteractionListener('pan', handlePan);
49
- const panStartHandler = instance.addInteractionListener('panStart', handlePanStart);
50
- const panEndHandler = instance.addInteractionListener('panEnd', handlePanEnd);
63
+ const panHandler = instance.addInteractionListener('zoomPan', handlePan);
64
+ const panStartHandler = instance.addInteractionListener('zoomPanStart', handlePanStart);
65
+ const panEndHandler = instance.addInteractionListener('zoomPanEnd', handlePanEnd);
51
66
  return () => {
52
67
  panStartHandler.cleanup();
53
68
  panHandler.cleanup();
54
69
  panEndHandler.cleanup();
55
70
  throttledCallback.clear();
56
71
  };
57
- }, [instance, svgRef, isPanEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store, startRef]);
72
+ }, [instance, svgRef, isPanOnDragEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store, startRef]);
58
73
  };
@@ -39,7 +39,7 @@ export const zoomAtPoint = (centerRatio, scaleRatio, currentZoomData, options) =
39
39
  */
40
40
  export function isSpanValid(minRange, maxRange, isZoomIn, option) {
41
41
  const newSpanPercent = maxRange - minRange;
42
- if (isZoomIn && newSpanPercent < option.minSpan || !isZoomIn && newSpanPercent > option.maxSpan) {
42
+ if (newSpanPercent < 0 || isZoomIn && newSpanPercent < option.minSpan || !isZoomIn && newSpanPercent > option.maxSpan) {
43
43
  return false;
44
44
  }
45
45
  if (minRange < option.minStart || maxRange > option.maxEnd) {