@mui/x-charts 8.12.0 → 8.13.1

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 (52) hide show
  1. package/CHANGELOG.md +207 -0
  2. package/ChartsSurface/ChartsSurface.js +4 -3
  3. package/PieChart/PieArc.d.ts +3 -0
  4. package/PieChart/PieArc.js +13 -12
  5. package/PieChart/PieArcPlot.js +27 -3
  6. package/esm/ChartsSurface/ChartsSurface.js +4 -3
  7. package/esm/PieChart/PieArc.d.ts +3 -0
  8. package/esm/PieChart/PieArc.js +14 -13
  9. package/esm/PieChart/PieArcPlot.js +29 -5
  10. package/esm/index.js +1 -1
  11. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +60 -32
  12. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
  13. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +5 -2
  14. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -10
  15. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +7 -5
  16. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
  17. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +13 -4
  18. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
  19. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
  20. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
  21. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
  22. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +2 -1
  23. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
  24. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +115 -155
  25. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +14 -2
  26. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +27 -1
  27. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -0
  28. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -5
  29. package/esm/internals/ticks.d.ts +3 -5
  30. package/esm/internals/ticks.js +6 -5
  31. package/index.js +1 -1
  32. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +59 -31
  33. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
  34. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +5 -2
  35. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -11
  36. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +6 -4
  37. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
  38. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +14 -5
  39. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
  40. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
  41. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
  42. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
  43. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +3 -2
  44. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
  45. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +115 -155
  46. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +14 -2
  47. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +28 -2
  48. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -0
  49. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -4
  50. package/internals/ticks.d.ts +3 -5
  51. package/internals/ticks.js +7 -5
  52. package/package.json +5 -5
@@ -12,137 +12,91 @@ var React = _interopRequireWildcard(require("react"));
12
12
  var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
13
13
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
14
14
  var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.helpers");
15
+ function getNextIndexFocusedItem(state) {
16
+ let {
17
+ type,
18
+ seriesId
19
+ } = state.keyboardNavigation.item ?? {};
20
+ if (type === undefined ||
21
+ // @ts-ignore sankey is not in MIT version
22
+ type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
23
+ const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
24
+ if (nextSeries === null) {
25
+ return null;
26
+ }
27
+ type = nextSeries.type;
28
+ seriesId = nextSeries.seriesId;
29
+ }
30
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
31
+ return {
32
+ type,
33
+ seriesId,
34
+ dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
35
+ };
36
+ }
37
+ function getPreviousIndexFocusedItem(state) {
38
+ let {
39
+ type,
40
+ seriesId
41
+ } = state.keyboardNavigation.item ?? {};
42
+ if (type === undefined ||
43
+ // @ts-ignore sankey is not in MIT version
44
+ type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
45
+ const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
46
+ if (previousSeries === null) {
47
+ return null;
48
+ }
49
+ type = previousSeries.type;
50
+ seriesId = previousSeries.seriesId;
51
+ }
52
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
53
+ return {
54
+ type,
55
+ seriesId,
56
+ dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
57
+ };
58
+ }
59
+ function getNextSeriesFocusedItem(state) {
60
+ let {
61
+ type,
62
+ seriesId
63
+ } = state.keyboardNavigation.item ?? {};
64
+ const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
65
+ if (nextSeries === null) {
66
+ return null; // No series to move the focus to.
67
+ }
68
+ type = nextSeries.type;
69
+ seriesId = nextSeries.seriesId;
70
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
71
+ return {
72
+ type,
73
+ seriesId,
74
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
75
+ };
76
+ }
77
+ function getPreviousSeriesFocusedItem(state) {
78
+ let {
79
+ type,
80
+ seriesId
81
+ } = state.keyboardNavigation.item ?? {};
82
+ const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
83
+ if (previousSeries === null) {
84
+ return null; // No series to move the focus to.
85
+ }
86
+ type = previousSeries.type;
87
+ seriesId = previousSeries.seriesId;
88
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
89
+ return {
90
+ type,
91
+ seriesId,
92
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
93
+ };
94
+ }
15
95
  const useChartKeyboardNavigation = ({
16
96
  params,
17
97
  store,
18
98
  svgRef
19
99
  }) => {
20
- const focusNextItem = (0, _useEventCallback.default)(function focusNextItem() {
21
- store.update(state => {
22
- let {
23
- type,
24
- seriesId
25
- } = state.keyboardNavigation.item ?? {};
26
- if (type === undefined ||
27
- // @ts-ignore sankey is not in MIT version
28
- type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
29
- const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
30
- if (nextSeries === null) {
31
- return (0, _extends2.default)({}, state, {
32
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
33
- item: null // No series to move the focus too.
34
- })
35
- });
36
- }
37
- type = nextSeries.type;
38
- seriesId = nextSeries.seriesId;
39
- }
40
- const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
41
- return (0, _extends2.default)({}, state, {
42
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
43
- item: {
44
- type,
45
- seriesId,
46
- dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
47
- }
48
- })
49
- });
50
- });
51
- });
52
- const focusPreviousItem = (0, _useEventCallback.default)(function focusPreviousItem() {
53
- store.update(state => {
54
- let {
55
- type,
56
- seriesId
57
- } = state.keyboardNavigation.item ?? {};
58
- if (type === undefined ||
59
- // @ts-ignore sankey is not in MIT version
60
- type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
61
- const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
62
- if (previousSeries === null) {
63
- return (0, _extends2.default)({}, state, {
64
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
65
- item: null // No series to move the focus too.} };
66
- })
67
- });
68
- }
69
- type = previousSeries.type;
70
- seriesId = previousSeries.seriesId;
71
- }
72
- const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
73
- return (0, _extends2.default)({}, state, {
74
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
75
- item: {
76
- type,
77
- seriesId,
78
- dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
79
- }
80
- })
81
- });
82
- });
83
- });
84
- const focusPreviousSeries = (0, _useEventCallback.default)(function focusPreviousSeries() {
85
- let setNewSeries = false;
86
- store.update(state => {
87
- let {
88
- type,
89
- seriesId
90
- } = state.keyboardNavigation.item ?? {};
91
- const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
92
- if (previousSeries === null) {
93
- return (0, _extends2.default)({}, state, {
94
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
95
- item: null // No series to move the focus too.
96
- })
97
- });
98
- }
99
- type = previousSeries.type;
100
- seriesId = previousSeries.seriesId;
101
- const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
102
- setNewSeries = true;
103
- return (0, _extends2.default)({}, state, {
104
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
105
- item: {
106
- type,
107
- seriesId,
108
- dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
109
- }
110
- })
111
- });
112
- });
113
- return setNewSeries;
114
- });
115
- const focusNextSeries = (0, _useEventCallback.default)(function focusNextSeries() {
116
- let setNewSeries = false;
117
- store.update(state => {
118
- let {
119
- type,
120
- seriesId
121
- } = state.keyboardNavigation.item ?? {};
122
- const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
123
- if (nextSeries === null) {
124
- return (0, _extends2.default)({}, state, {
125
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
126
- item: null // No series to move the focus too.
127
- })
128
- });
129
- }
130
- type = nextSeries.type;
131
- seriesId = nextSeries.seriesId;
132
- const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
133
- setNewSeries = true;
134
- return (0, _extends2.default)({}, state, {
135
- keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
136
- item: {
137
- type,
138
- seriesId,
139
- dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
140
- }
141
- })
142
- });
143
- });
144
- return setNewSeries;
145
- });
146
100
  const removeFocus = (0, _useEventCallback.default)(function removeFocus() {
147
101
  store.update(state => {
148
102
  if (state.keyboardNavigation.item === null) {
@@ -161,34 +115,42 @@ const useChartKeyboardNavigation = ({
161
115
  return undefined;
162
116
  }
163
117
  function keyboardHandler(event) {
164
- switch (event.key) {
165
- case 'ArrowRight':
166
- focusNextItem();
167
- break;
168
- case 'ArrowLeft':
169
- focusPreviousItem();
170
- break;
171
- case 'ArrowDown':
172
- {
173
- const updatedStore = focusPreviousSeries();
174
- if (updatedStore) {
175
- // prevents scrolling
176
- event.preventDefault();
177
- }
118
+ store.update(prevState => {
119
+ let newFocusedItem = prevState.keyboardNavigation.item;
120
+ switch (event.key) {
121
+ case 'ArrowRight':
122
+ newFocusedItem = getNextIndexFocusedItem(prevState);
123
+ break;
124
+ case 'ArrowLeft':
125
+ newFocusedItem = getPreviousIndexFocusedItem(prevState);
178
126
  break;
179
- }
180
- case 'ArrowUp':
181
- {
182
- const updatedStore = focusNextSeries();
183
- if (updatedStore) {
184
- // prevents scrolling
185
- event.preventDefault();
127
+ case 'ArrowDown':
128
+ {
129
+ newFocusedItem = getPreviousSeriesFocusedItem(prevState);
130
+ break;
186
131
  }
132
+ case 'ArrowUp':
133
+ {
134
+ newFocusedItem = getNextSeriesFocusedItem(prevState);
135
+ break;
136
+ }
137
+ default:
187
138
  break;
188
- }
189
- default:
190
- break;
191
- }
139
+ }
140
+ if (newFocusedItem !== prevState.keyboardNavigation.item) {
141
+ event.preventDefault();
142
+ return (0, _extends2.default)({}, prevState, prevState.interaction && {
143
+ interaction: (0, _extends2.default)({}, prevState.interaction, {
144
+ lastUpdate: 'keyboard'
145
+ })
146
+ }, {
147
+ keyboardNavigation: (0, _extends2.default)({}, prevState.keyboardNavigation, {
148
+ item: newFocusedItem
149
+ })
150
+ });
151
+ }
152
+ return prevState;
153
+ });
192
154
  }
193
155
  element.addEventListener('keydown', keyboardHandler);
194
156
  element.addEventListener('blur', removeFocus);
@@ -196,15 +158,13 @@ const useChartKeyboardNavigation = ({
196
158
  element.removeEventListener('keydown', keyboardHandler);
197
159
  element.removeEventListener('blur', removeFocus);
198
160
  };
199
- }, [svgRef, focusNextItem, focusPreviousItem, removeFocus, focusPreviousSeries, focusNextSeries, params.enableKeyboardNavigation]);
161
+ }, [svgRef, removeFocus, params.enableKeyboardNavigation, store]);
200
162
  (0, _useEnhancedEffect.default)(() => store.update(prev => prev.keyboardNavigation.enableKeyboardNavigation === params.enableKeyboardNavigation ? prev : (0, _extends2.default)({}, prev, {
201
163
  keyboardNavigation: (0, _extends2.default)({}, prev.keyboardNavigation, {
202
164
  enableKeyboardNavigation: !!params.enableKeyboardNavigation
203
165
  })
204
166
  })), [store, params.enableKeyboardNavigation]);
205
- return {
206
- instance: {}
207
- };
167
+ return {};
208
168
  };
209
169
  exports.useChartKeyboardNavigation = useChartKeyboardNavigation;
210
170
  useChartKeyboardNavigation.getInitialState = params => ({
@@ -1,3 +1,5 @@
1
+ import { SeriesId } from "../../../../models/seriesType/common.js";
2
+ import { AxisItemIdentifier } from "../../../../models/axis.js";
1
3
  export declare const selectorChartsHasFocusedItem: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
2
4
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
3
5
  } & {
@@ -12,7 +14,7 @@ export declare const selectorChartsFocusedSeriesId: import("reselect").Selector<
12
14
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
13
15
  } & {
14
16
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
15
- }, import("../../../index.js").SeriesId | undefined, any[]>;
17
+ }, SeriesId | undefined, any[]>;
16
18
  export declare const selectorChartsFocusedDataIndex: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
17
19
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
18
20
  } & {
@@ -22,4 +24,14 @@ export declare const selectorChartsIsKeyboardNavigationEnabled: import("reselect
22
24
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
23
25
  } & {
24
26
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
25
- }, boolean, any[]>;
27
+ }, boolean, any[]>;
28
+ export declare const selectorChartsKeyboardXAxisIndex: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
29
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
30
+ } & {
31
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
32
+ } & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier | undefined, any[]>;
33
+ export declare const selectorChartsKeyboardYAxisIndex: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
34
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
35
+ } & {
36
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
37
+ } & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier | undefined, any[]>;
@@ -3,11 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
6
+ exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
7
7
  var _selectors = require("../../utils/selectors");
8
+ var _useChartSeries = require("../../corePlugins/useChartSeries");
9
+ var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
8
10
  const selectKeyboardNavigation = state => state.keyboardNavigation;
9
11
  const selectorChartsHasFocusedItem = exports.selectorChartsHasFocusedItem = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item != null);
10
12
  const selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesType = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.type);
11
13
  const selectorChartsFocusedSeriesId = exports.selectorChartsFocusedSeriesId = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
12
14
  const selectorChartsFocusedDataIndex = exports.selectorChartsFocusedDataIndex = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
13
- const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
15
+ const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
16
+
17
+ /**
18
+ * Selectors to override highlight behavior.
19
+ */
20
+
21
+ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis, series) => {
22
+ if (type === undefined || seriesId === undefined || dataIndex === undefined) {
23
+ return undefined;
24
+ }
25
+ const seriesConfig = series[type]?.series[seriesId];
26
+ if (!seriesConfig) {
27
+ return undefined;
28
+ }
29
+ let axisId = direction === 'x' ? 'xAxisId' in seriesConfig && seriesConfig.xAxisId : 'yAxisId' in seriesConfig && seriesConfig.yAxisId;
30
+ if (axisId === undefined || axisId === false) {
31
+ axisId = axis.axisIds[0];
32
+ }
33
+ return {
34
+ axisId,
35
+ dataIndex
36
+ };
37
+ };
38
+ const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _selectors.createSelector)([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartSeries.selectorChartSeriesProcessed], createSelectAxisHighlight('x'));
39
+ const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _selectors.createSelector)([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed], createSelectAxisHighlight('y'));
@@ -1,6 +1,7 @@
1
1
  import { ChartPluginSignature } from "../../models/index.js";
2
2
  import { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
3
  import { SeriesId } from "../../../../models/seriesType/common.js";
4
+ import { UseChartInteractionSignature } from "../useChartInteraction/index.js";
4
5
  export interface UseChartKeyboardNavigationInstance {}
5
6
  type SeriesItemIdentifier = {
6
7
  /**
@@ -30,5 +31,6 @@ export type UseChartKeyboardNavigationSignature = ChartPluginSignature<{
30
31
  defaultizedParams: UseChartKeyboardNavigationParameters;
31
32
  instance: UseChartKeyboardNavigationInstance;
32
33
  state: UseChartKeyboardNavigationState;
34
+ optionalDependencies: [UseChartInteractionSignature];
33
35
  }>;
34
36
  export {};
@@ -106,10 +106,7 @@ function computeAxisValue({
106
106
  axisExtremums[0] = min;
107
107
  axisExtremums[1] = max;
108
108
  }
109
- const rawTickNumber = (0, _ticks.getTickNumber)((0, _extends2.default)({}, axis, {
110
- range,
111
- domain: axisExtremums
112
- }));
109
+ const rawTickNumber = (0, _ticks.getTickNumber)(axis, axisExtremums, (0, _ticks.getDefaultTickNumber)(Math.abs(range[1] - range[0])));
113
110
  const tickNumber = (0, _ticks.scaleTickNumberByRange)(rawTickNumber, range);
114
111
  const scale = (0, _getScale.getScale)(scaleType, axisExtremums, range);
115
112
  const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
@@ -1,6 +1,4 @@
1
1
  import type { TickParams } from "../hooks/useTicks.js";
2
- export declare function getTickNumber(params: TickParams & {
3
- range: number[];
4
- domain: any[];
5
- }): number;
6
- export declare function scaleTickNumberByRange(tickNumber: number, range: number[]): number;
2
+ export declare function getTickNumber(params: TickParams, domain: any[], defaultTickNumber: number): number;
3
+ export declare function scaleTickNumberByRange(tickNumber: number, range: number[]): number;
4
+ export declare function getDefaultTickNumber(dimension: number): number;
@@ -3,19 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getDefaultTickNumber = getDefaultTickNumber;
6
7
  exports.getTickNumber = getTickNumber;
7
8
  exports.scaleTickNumberByRange = scaleTickNumberByRange;
8
- function getTickNumber(params) {
9
+ function getTickNumber(params, domain, defaultTickNumber) {
9
10
  const {
10
11
  tickMaxStep,
11
12
  tickMinStep,
12
- tickNumber,
13
- range,
14
- domain
13
+ tickNumber
15
14
  } = params;
16
15
  const maxTicks = tickMinStep === undefined ? 999 : Math.floor(Math.abs(domain[1] - domain[0]) / tickMinStep);
17
16
  const minTicks = tickMaxStep === undefined ? 2 : Math.ceil(Math.abs(domain[1] - domain[0]) / tickMaxStep);
18
- const defaultizedTickNumber = tickNumber ?? Math.floor(Math.abs(range[1] - range[0]) / 50);
17
+ const defaultizedTickNumber = tickNumber ?? defaultTickNumber;
19
18
  return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
20
19
  }
21
20
  function scaleTickNumberByRange(tickNumber, range) {
@@ -26,4 +25,7 @@ function scaleTickNumberByRange(tickNumber, range) {
26
25
  return 1;
27
26
  }
28
27
  return tickNumber / ((range[1] - range[0]) / 100);
28
+ }
29
+ function getDefaultTickNumber(dimension) {
30
+ return Math.floor(Math.abs(dimension) / 50);
29
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.12.0",
3
+ "version": "8.13.1",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of MUI X Charts components.",
6
6
  "license": "MIT",
@@ -27,16 +27,16 @@
27
27
  "directory": "packages/x-charts"
28
28
  },
29
29
  "dependencies": {
30
- "@babel/runtime": "^7.28.2",
30
+ "@babel/runtime": "^7.28.4",
31
31
  "@mui/utils": "^7.3.2",
32
32
  "bezier-easing": "^2.1.0",
33
33
  "clsx": "^2.1.1",
34
34
  "prop-types": "^15.8.1",
35
35
  "reselect": "^5.1.1",
36
36
  "use-sync-external-store": "^1.5.0",
37
- "@mui/x-charts-vendor": "8.12.0",
38
- "@mui/x-internal-gestures": "0.3.0",
39
- "@mui/x-internals": "8.12.0"
37
+ "@mui/x-internal-gestures": "0.3.2",
38
+ "@mui/x-internals": "8.13.1",
39
+ "@mui/x-charts-vendor": "8.12.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@emotion/react": "^11.9.0",