@mui/x-charts 8.13.0 → 8.14.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 (92) hide show
  1. package/BarChart/BarChart.js +44 -36
  2. package/CHANGELOG.md +171 -1
  3. package/ChartContainer/ChartContainer.js +68 -56
  4. package/ChartsTooltip/ChartsTooltipContainer.js +2 -0
  5. package/ChartsXAxis/useAxisTicksProps.d.ts +197 -355
  6. package/ChartsYAxis/useAxisTicksProps.d.ts +197 -355
  7. package/LineChart/LineChart.js +44 -36
  8. package/PieChart/PieArc.d.ts +18 -4
  9. package/PieChart/PieArc.js +11 -5
  10. package/PieChart/PieArcPlot.js +3 -1
  11. package/ScatterChart/ScatterChart.js +44 -36
  12. package/SparkLineChart/SparkLineChart.js +44 -36
  13. package/esm/BarChart/BarChart.js +44 -36
  14. package/esm/ChartContainer/ChartContainer.js +68 -56
  15. package/esm/ChartsTooltip/ChartsTooltipContainer.js +2 -0
  16. package/esm/ChartsXAxis/useAxisTicksProps.d.ts +197 -355
  17. package/esm/ChartsYAxis/useAxisTicksProps.d.ts +197 -355
  18. package/esm/LineChart/LineChart.js +44 -36
  19. package/esm/PieChart/PieArc.d.ts +18 -4
  20. package/esm/PieChart/PieArc.js +11 -5
  21. package/esm/PieChart/PieArcPlot.js +3 -1
  22. package/esm/ScatterChart/ScatterChart.js +44 -36
  23. package/esm/SparkLineChart/SparkLineChart.js +44 -36
  24. package/esm/hooks/animation/useAnimate.js +5 -3
  25. package/esm/hooks/useScale.d.ts +5 -1
  26. package/esm/index.js +1 -1
  27. package/esm/internals/animation/useAnimateInternal.d.ts +1 -1
  28. package/esm/internals/animation/useAnimateInternal.js +1 -1
  29. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +8 -8
  30. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +4 -2
  31. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +9 -11
  32. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -28
  33. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +4 -5
  34. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +3 -24
  35. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +20 -0
  36. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +77 -0
  37. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +4 -65
  38. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +7 -104
  39. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -3
  40. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +31 -39
  41. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +166 -6
  42. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +158 -47
  43. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +10 -3
  44. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -4
  45. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -2
  46. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +6 -0
  47. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +5 -1
  48. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +9 -1
  49. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -1
  50. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -1
  51. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  52. package/esm/internals/scaleGuards.d.ts +12 -6
  53. package/esm/internals/symlogScale.js +5 -0
  54. package/esm/locales/enUS.js +4 -4
  55. package/esm/locales/ptBR.js +97 -99
  56. package/esm/models/axis.d.ts +39 -17
  57. package/esm/models/axis.js +3 -0
  58. package/hooks/animation/useAnimate.js +4 -3
  59. package/hooks/useScale.d.ts +5 -1
  60. package/index.js +1 -1
  61. package/internals/animation/useAnimateInternal.d.ts +1 -1
  62. package/internals/animation/useAnimateInternal.js +1 -1
  63. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +7 -7
  64. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +4 -2
  65. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +9 -11
  66. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -28
  67. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +4 -5
  68. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +3 -25
  69. package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +20 -0
  70. package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +84 -0
  71. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +4 -65
  72. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -108
  73. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -3
  74. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +29 -37
  75. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +166 -6
  76. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +158 -47
  77. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +10 -3
  78. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -4
  79. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -2
  80. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +6 -0
  81. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +5 -1
  82. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +9 -1
  83. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -2
  84. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -1
  85. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -1
  86. package/internals/scaleGuards.d.ts +12 -6
  87. package/internals/symlogScale.js +5 -0
  88. package/locales/enUS.js +4 -4
  89. package/locales/ptBR.js +97 -99
  90. package/models/axis.d.ts +39 -17
  91. package/models/axis.js +4 -0
  92. package/package.json +6 -6
@@ -391,8 +391,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
391
391
  ignoreTooltip: PropTypes.bool,
392
392
  label: PropTypes.string,
393
393
  labelStyle: PropTypes.object,
394
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
395
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
396
394
  offset: PropTypes.number,
397
395
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
398
396
  reverse: PropTypes.bool,
@@ -445,8 +443,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
445
443
  ignoreTooltip: PropTypes.bool,
446
444
  label: PropTypes.string,
447
445
  labelStyle: PropTypes.object,
448
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
449
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
450
446
  offset: PropTypes.number,
451
447
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
452
448
  reverse: PropTypes.bool,
@@ -489,8 +485,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
489
485
  ignoreTooltip: PropTypes.bool,
490
486
  label: PropTypes.string,
491
487
  labelStyle: PropTypes.object,
492
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
493
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
488
+ max: PropTypes.number,
489
+ min: PropTypes.number,
494
490
  offset: PropTypes.number,
495
491
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
496
492
  reverse: PropTypes.bool,
@@ -534,8 +530,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
534
530
  ignoreTooltip: PropTypes.bool,
535
531
  label: PropTypes.string,
536
532
  labelStyle: PropTypes.object,
537
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
538
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
533
+ max: PropTypes.number,
534
+ min: PropTypes.number,
539
535
  offset: PropTypes.number,
540
536
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
541
537
  reverse: PropTypes.bool,
@@ -578,8 +574,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
578
574
  ignoreTooltip: PropTypes.bool,
579
575
  label: PropTypes.string,
580
576
  labelStyle: PropTypes.object,
581
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
582
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
577
+ max: PropTypes.number,
578
+ min: PropTypes.number,
583
579
  offset: PropTypes.number,
584
580
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
585
581
  reverse: PropTypes.bool,
@@ -622,8 +618,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
622
618
  ignoreTooltip: PropTypes.bool,
623
619
  label: PropTypes.string,
624
620
  labelStyle: PropTypes.object,
625
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
626
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
621
+ max: PropTypes.number,
622
+ min: PropTypes.number,
627
623
  offset: PropTypes.number,
628
624
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
629
625
  reverse: PropTypes.bool,
@@ -666,8 +662,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
666
662
  ignoreTooltip: PropTypes.bool,
667
663
  label: PropTypes.string,
668
664
  labelStyle: PropTypes.object,
669
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
670
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
665
+ max: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
666
+ valueOf: PropTypes.func.isRequired
667
+ })]),
668
+ min: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
669
+ valueOf: PropTypes.func.isRequired
670
+ })]),
671
671
  offset: PropTypes.number,
672
672
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
673
673
  reverse: PropTypes.bool,
@@ -710,8 +710,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
710
710
  ignoreTooltip: PropTypes.bool,
711
711
  label: PropTypes.string,
712
712
  labelStyle: PropTypes.object,
713
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
714
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
713
+ max: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
714
+ valueOf: PropTypes.func.isRequired
715
+ })]),
716
+ min: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
717
+ valueOf: PropTypes.func.isRequired
718
+ })]),
715
719
  offset: PropTypes.number,
716
720
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
717
721
  reverse: PropTypes.bool,
@@ -754,8 +758,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
754
758
  ignoreTooltip: PropTypes.bool,
755
759
  label: PropTypes.string,
756
760
  labelStyle: PropTypes.object,
757
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
758
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
761
+ max: PropTypes.number,
762
+ min: PropTypes.number,
759
763
  offset: PropTypes.number,
760
764
  position: PropTypes.oneOf(['bottom', 'none', 'top']),
761
765
  reverse: PropTypes.bool,
@@ -814,8 +818,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
814
818
  ignoreTooltip: PropTypes.bool,
815
819
  label: PropTypes.string,
816
820
  labelStyle: PropTypes.object,
817
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
818
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
819
821
  offset: PropTypes.number,
820
822
  position: PropTypes.oneOf(['left', 'none', 'right']),
821
823
  reverse: PropTypes.bool,
@@ -867,8 +869,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
867
869
  ignoreTooltip: PropTypes.bool,
868
870
  label: PropTypes.string,
869
871
  labelStyle: PropTypes.object,
870
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
871
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
872
872
  offset: PropTypes.number,
873
873
  position: PropTypes.oneOf(['left', 'none', 'right']),
874
874
  reverse: PropTypes.bool,
@@ -910,8 +910,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
910
910
  ignoreTooltip: PropTypes.bool,
911
911
  label: PropTypes.string,
912
912
  labelStyle: PropTypes.object,
913
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
914
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
913
+ max: PropTypes.number,
914
+ min: PropTypes.number,
915
915
  offset: PropTypes.number,
916
916
  position: PropTypes.oneOf(['left', 'none', 'right']),
917
917
  reverse: PropTypes.bool,
@@ -954,8 +954,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
954
954
  ignoreTooltip: PropTypes.bool,
955
955
  label: PropTypes.string,
956
956
  labelStyle: PropTypes.object,
957
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
958
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
957
+ max: PropTypes.number,
958
+ min: PropTypes.number,
959
959
  offset: PropTypes.number,
960
960
  position: PropTypes.oneOf(['left', 'none', 'right']),
961
961
  reverse: PropTypes.bool,
@@ -997,8 +997,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
997
997
  ignoreTooltip: PropTypes.bool,
998
998
  label: PropTypes.string,
999
999
  labelStyle: PropTypes.object,
1000
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1001
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1000
+ max: PropTypes.number,
1001
+ min: PropTypes.number,
1002
1002
  offset: PropTypes.number,
1003
1003
  position: PropTypes.oneOf(['left', 'none', 'right']),
1004
1004
  reverse: PropTypes.bool,
@@ -1040,8 +1040,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
1040
1040
  ignoreTooltip: PropTypes.bool,
1041
1041
  label: PropTypes.string,
1042
1042
  labelStyle: PropTypes.object,
1043
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1044
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1043
+ max: PropTypes.number,
1044
+ min: PropTypes.number,
1045
1045
  offset: PropTypes.number,
1046
1046
  position: PropTypes.oneOf(['left', 'none', 'right']),
1047
1047
  reverse: PropTypes.bool,
@@ -1083,8 +1083,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
1083
1083
  ignoreTooltip: PropTypes.bool,
1084
1084
  label: PropTypes.string,
1085
1085
  labelStyle: PropTypes.object,
1086
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1087
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1086
+ max: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
1087
+ valueOf: PropTypes.func.isRequired
1088
+ })]),
1089
+ min: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
1090
+ valueOf: PropTypes.func.isRequired
1091
+ })]),
1088
1092
  offset: PropTypes.number,
1089
1093
  position: PropTypes.oneOf(['left', 'none', 'right']),
1090
1094
  reverse: PropTypes.bool,
@@ -1126,8 +1130,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
1126
1130
  ignoreTooltip: PropTypes.bool,
1127
1131
  label: PropTypes.string,
1128
1132
  labelStyle: PropTypes.object,
1129
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1130
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1133
+ max: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
1134
+ valueOf: PropTypes.func.isRequired
1135
+ })]),
1136
+ min: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
1137
+ valueOf: PropTypes.func.isRequired
1138
+ })]),
1131
1139
  offset: PropTypes.number,
1132
1140
  position: PropTypes.oneOf(['left', 'none', 'right']),
1133
1141
  reverse: PropTypes.bool,
@@ -1169,8 +1177,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
1169
1177
  ignoreTooltip: PropTypes.bool,
1170
1178
  label: PropTypes.string,
1171
1179
  labelStyle: PropTypes.object,
1172
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1173
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
1180
+ max: PropTypes.number,
1181
+ min: PropTypes.number,
1174
1182
  offset: PropTypes.number,
1175
1183
  position: PropTypes.oneOf(['left', 'none', 'right']),
1176
1184
  reverse: PropTypes.bool,
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import useForkRef from '@mui/utils/useForkRef';
3
5
  import { useAnimateInternal } from "../../internals/animation/useAnimateInternal.js";
@@ -34,14 +36,14 @@ export function useAnimate(props, {
34
36
  ref
35
37
  }) {
36
38
  const transform = transformProps ?? (p => p);
37
- const animateRef = useAnimateInternal(props, {
39
+ const [animateRef, lastInterpolatedProps] = useAnimateInternal(props, {
38
40
  initialProps,
39
41
  createInterpolator,
40
42
  applyProps: (element, animatedProps) => applyProps(element, transform(animatedProps)),
41
43
  skip
42
44
  });
43
- const usedProps = skip ? props : initialProps;
44
- return _extends({}, transformProps(usedProps), {
45
+ const usedProps = skip ? transformProps(props) : transformProps(lastInterpolatedProps);
46
+ return _extends({}, usedProps, {
45
47
  ref: useForkRef(animateRef, ref)
46
48
  });
47
49
  }
@@ -5,7 +5,11 @@ import { AxisId, AxisScaleConfig, D3Scale, ScaleName } from "../models/axis.js";
5
5
  * @param {D3Scale} scale The scale to use
6
6
  * @returns {(value: any) => number} A function that map value to their position
7
7
  */
8
- export declare function getValueToPositionMapper(scale: D3Scale): (value: any) => number;
8
+ export declare function getValueToPositionMapper<Domain extends {
9
+ toString(): string;
10
+ } = {
11
+ toString(): string;
12
+ }, Range = number>(scale: D3Scale<Domain, Range>): (value: any) => number;
9
13
  /**
10
14
  * Get the X scale.
11
15
  *
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.13.0
2
+ * @mui/x-charts v8.14.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -18,4 +18,4 @@ export declare function useAnimateInternal<Props extends {}, Elem extends Elemen
18
18
  applyProps: (element: Elem, props: Props) => void;
19
19
  skip?: boolean;
20
20
  initialProps?: Props;
21
- }): (element: Elem | null) => void;
21
+ }): readonly [(element: Elem | null) => void, Props];
@@ -72,5 +72,5 @@ export function useAnimateInternal(props, {
72
72
  animate(element);
73
73
  }
74
74
  }, [animate, props, skip]);
75
- return setRef;
75
+ return [setRef, lastInterpolatedPropsRef.current];
76
76
  }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { GestureManager, MoveGesture, PanGesture, PinchGesture, PressGesture, TapAndDragGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
4
+ import { GestureManager, MoveGesture, PanGesture, PinchGesture, PressAndDragGesture, PressGesture, TapAndDragGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
5
5
  const preventDefault = event => event.preventDefault();
6
6
  export const useChartInteractionListener = ({
7
7
  svgRef
@@ -22,7 +22,7 @@ export const useChartInteractionListener = ({
22
22
  name: 'zoomPan',
23
23
  threshold: 0,
24
24
  maxPointers: 1,
25
- preventIf: ['zoomTapAndDrag']
25
+ preventIf: ['zoomTapAndDrag', 'zoomPressAndDrag']
26
26
  }), new MoveGesture({
27
27
  name: 'move',
28
28
  preventIf: ['pan', 'zoomPinch', 'zoomPan'] // Prevent move gesture when pan is active
@@ -36,17 +36,17 @@ export const useChartInteractionListener = ({
36
36
  initialDelta: 1
37
37
  }), new TapGesture({
38
38
  name: 'tap',
39
- maxDistance: 10,
40
39
  preventIf: ['pan', 'zoomPan', 'zoomPinch']
41
40
  }), new PressGesture({
42
41
  name: 'quickPress',
43
- duration: 50,
44
- maxDistance: 10
42
+ duration: 50
45
43
  }), new TapAndDragGesture({
46
44
  name: 'zoomTapAndDrag',
47
- tapMaxDistance: 10,
45
+ dragThreshold: 10
46
+ }), new PressAndDragGesture({
47
+ name: 'zoomPressAndDrag',
48
48
  dragThreshold: 10,
49
- dragTimeout: 1000
49
+ preventIf: ['zoomPinch']
50
50
  })]
51
51
  });
52
52
  }
@@ -56,7 +56,7 @@ export const useChartInteractionListener = ({
56
56
  if (!svg || !gestureManager) {
57
57
  return undefined;
58
58
  }
59
- gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag'], svg);
59
+ gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag'], svg);
60
60
  return () => {
61
61
  // Cleanup gesture manager
62
62
  gestureManager.unregisterAllGestures(svg);
@@ -1,6 +1,6 @@
1
- import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
1
+ import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
2
2
  import { ChartPluginSignature } from "../../models/index.js";
3
- export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'move' | 'moveStart' | 'moveEnd' | 'quickPress' | 'quickPressEnd' | 'zoomTurnWheel' | 'tap';
3
+ export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd';
4
4
  export type InteractionListenerResult = {
5
5
  cleanup: () => void;
6
6
  };
@@ -12,12 +12,14 @@ export type AddInteractionListener = {
12
12
  <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
13
13
  <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
14
14
  <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd', callback: (event: TapAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
15
+ <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd', callback: (event: PressAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
15
16
  };
16
17
  export type UpdateZoomInteractionListeners = {
17
18
  (interaction: 'zoomPan', options?: Omit<PanGestureOptions<'zoomPan'>, 'name'>): void;
18
19
  (interaction: 'zoomPinch', options?: Omit<PinchGestureOptions<'zoomPinch'>, 'name'>): void;
19
20
  (interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
20
21
  (interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
22
+ (interaction: 'zoomPressAndDrag', options?: Omit<PressAndDragGestureOptions<'zoomPressAndDrag'>, 'name'>): void;
21
23
  };
22
24
  export interface UseChartInteractionListenerParameters {}
23
25
  export interface UseChartInteractionListenerState {}
@@ -1,27 +1,25 @@
1
- import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps, AxisId, DefaultedXAxis, DefaultedYAxis } from "../../../../models/axis.js";
1
+ import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
2
+ import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps, AxisId, DefaultedXAxis, DefaultedYAxis, D3Scale } from "../../../../models/axis.js";
2
3
  import { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
4
  import type { ChartDrawingArea } from "../../../../hooks/index.js";
4
5
  import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
5
- import { ComputedAxisConfig, DefaultizedZoomOptions } from "./useChartCartesianAxis.types.js";
6
+ import { ComputedAxisConfig } from "./useChartCartesianAxis.types.js";
6
7
  import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
7
- import { GetZoomAxisFilters, ZoomData } from "./zoom.types.js";
8
- import { ScaleDefinition } from "./getAxisScale.js";
8
+ import { ZoomData } from "./zoom.types.js";
9
9
  export type ComputeResult<T extends ChartsAxisProps> = {
10
10
  axis: ComputedAxisConfig<T>;
11
11
  axisIds: AxisId[];
12
12
  };
13
13
  type ComputeCommonParams<T extends ChartSeriesType = ChartSeriesType> = {
14
- scales: Record<AxisId, ScaleDefinition>;
14
+ scales: Record<AxisId, D3Scale>;
15
15
  drawingArea: ChartDrawingArea;
16
16
  formattedSeries: ProcessedSeries<T>;
17
17
  seriesConfig: ChartSeriesConfig<T>;
18
18
  zoomMap?: Map<AxisId, ZoomData>;
19
- zoomOptions?: Record<AxisId, DefaultizedZoomOptions>;
20
- getFilters?: GetZoomAxisFilters;
21
- /**
22
- * @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
23
- */
24
- preferStrictDomainInLineCharts?: boolean;
19
+ domains: Record<AxisId, {
20
+ domain: ReadonlyArray<string | NumberValue>;
21
+ tickNumber?: number;
22
+ }>;
25
23
  };
26
24
  export declare function computeAxisValue<T extends ChartSeriesType>(options: ComputeCommonParams<T> & {
27
25
  axis?: DefaultedYAxis[];
@@ -5,9 +5,7 @@ import { getColorScale, getOrdinalColorScale, getSequentialColorScale } from "..
5
5
  import { scaleTickNumberByRange } from "../../../ticks.js";
6
6
  import { getScale } from "../../../getScale.js";
7
7
  import { isDateData, createDateFormatter } from "../../../dateHelpers.js";
8
- import { getAxisExtrema } from "./getAxisExtrema.js";
9
8
  import { getAxisTriggerTooltip } from "./getAxisTriggerTooltip.js";
10
- import { applyDomainLimit, getActualAxisExtrema, getDomainLimit } from "./getAxisScale.js";
11
9
  import { isBandScale, isOrdinalScale } from "../../../scaleGuards.js";
12
10
  function getRange(drawingArea, axisDirection,
13
11
  // | 'rotation' | 'radius',
@@ -25,9 +23,7 @@ export function computeAxisValue({
25
23
  seriesConfig,
26
24
  axisDirection,
27
25
  zoomMap,
28
- zoomOptions,
29
- getFilters,
30
- preferStrictDomainInLineCharts
26
+ domains
31
27
  }) {
32
28
  if (allAxis === undefined) {
33
29
  return {
@@ -37,11 +33,9 @@ export function computeAxisValue({
37
33
  }
38
34
  const axisIdsTriggeringTooltip = getAxisTriggerTooltip(axisDirection, seriesConfig, formattedSeries, allAxis[0].id);
39
35
  const completeAxis = {};
40
- allAxis.forEach((eachAxis, axisIndex) => {
36
+ allAxis.forEach(eachAxis => {
41
37
  const axis = eachAxis;
42
- const scaleDefinition = scales[axis.id];
43
- let scale = scaleDefinition.scale;
44
- const zoomOption = zoomOptions?.[axis.id];
38
+ const scale = scales[axis.id];
45
39
  const zoom = zoomMap?.get(axis.id);
46
40
  const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
47
41
  const range = getRange(drawingArea, axisDirection, axis.reverse ?? false);
@@ -92,28 +86,10 @@ export function computeAxisValue({
92
86
  // Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
93
87
  return;
94
88
  }
95
- const rawTickNumber = scaleDefinition.tickNumber;
89
+ const rawTickNumber = domains[axis.id].tickNumber;
96
90
  const continuousAxis = axis;
97
91
  const scaleType = continuousAxis.scaleType ?? 'linear';
98
92
  const tickNumber = scaleTickNumberByRange(rawTickNumber, zoomRange);
99
- const filter = zoom === undefined && !zoomOption ? getFilters : undefined; // Do not apply filtering if zoom is already defined.
100
- if (filter) {
101
- const [minData, maxData] = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, filter);
102
- scale = scale.copy();
103
- scale.domain([minData, maxData]);
104
- const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
105
- const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
106
- if (typeof domainLimit === 'function') {
107
- const {
108
- min,
109
- max
110
- } = domainLimit(minData, maxData);
111
- axisExtrema[0] = min;
112
- axisExtrema[1] = max;
113
- }
114
- scale.domain(axisExtrema);
115
- applyDomainLimit(scale, axis, domainLimit, rawTickNumber);
116
- }
117
93
  completeAxis[axis.id] = _extends({
118
94
  offset: 0,
119
95
  height: 0,
@@ -1,8 +1,7 @@
1
- import { AxisId, D3ContinuousScale, D3Scale } from "../../../../models/axis.js";
1
+ import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
2
2
  import { AxisConfig } from "../../../../models/index.js";
3
- import { DefaultizedZoomOptions, ExtremumFilter } from "./useChartCartesianAxis.types.js";
4
- import { GetZoomAxisFilters, ZoomAxisFilters, ZoomData } from "./zoom.types.js";
5
- export declare function createAxisFilterMapper(zoomMap: Map<AxisId, ZoomData>, zoomOptions: Record<AxisId, DefaultizedZoomOptions>, direction: 'x' | 'y'): (axisId: AxisId, axisData: AxisConfig['data'], scale: D3Scale) => ExtremumFilter | null;
3
+ import { ExtremumFilter } from "./useChartCartesianAxis.types.js";
4
+ import { GetZoomAxisFilters, ZoomAxisFilters } from "./zoom.types.js";
6
5
  export declare function createDiscreteScaleGetAxisFilter(axisData: AxisConfig['data'], zoomStart: number, zoomEnd: number, direction: 'x' | 'y'): ExtremumFilter;
7
- export declare function createContinuousScaleGetAxisFilter(scale: D3ContinuousScale, zoomStart: number, zoomEnd: number, direction: 'x' | 'y', axisData: AxisConfig['data']): ExtremumFilter;
6
+ export declare function createContinuousScaleGetAxisFilter(domain: readonly NumberValue[], zoomStart: number, zoomEnd: number, direction: 'x' | 'y', axisData: AxisConfig['data']): ExtremumFilter;
8
7
  export declare const createGetAxisFilters: (filters: ZoomAxisFilters) => GetZoomAxisFilters;
@@ -1,22 +1,4 @@
1
1
  import { isDefined } from "../../../isDefined.js";
2
- import { isOrdinalScale } from "../../../scaleGuards.js";
3
- export function createAxisFilterMapper(zoomMap, zoomOptions, direction) {
4
- return (axisId, axisData, scale) => {
5
- const zoomOption = zoomOptions[axisId];
6
- if (!zoomOption || zoomOption.filterMode !== 'discard') {
7
- return null;
8
- }
9
- const zoom = zoomMap?.get(axisId);
10
- if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
11
- // No zoom, or zoom with all data visible
12
- return null;
13
- }
14
- if (isOrdinalScale(scale)) {
15
- return createDiscreteScaleGetAxisFilter(axisData, zoom.start, zoom.end, direction);
16
- }
17
- return createContinuousScaleGetAxisFilter(scale, zoom.start, zoom.end, direction, axisData);
18
- };
19
- }
20
2
  export function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, direction) {
21
3
  const maxIndex = axisData?.length ?? 0;
22
4
  const minVal = Math.floor(zoomStart * maxIndex / 100);
@@ -30,12 +12,9 @@ export function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, d
30
12
  return dataIndex >= minVal && dataIndex < maxVal;
31
13
  };
32
14
  }
33
- export function createContinuousScaleGetAxisFilter(scale, zoomStart, zoomEnd, direction, axisData) {
34
- let min;
35
- let max;
36
- [min, max] = scale.domain();
37
- min = min instanceof Date ? min.getTime() : min;
38
- max = max instanceof Date ? max.getTime() : max;
15
+ export function createContinuousScaleGetAxisFilter(domain, zoomStart, zoomEnd, direction, axisData) {
16
+ const min = domain[0].valueOf();
17
+ const max = domain[1].valueOf();
39
18
  const minVal = min + zoomStart * (max - min) / 100;
40
19
  const maxVal = min + zoomEnd * (max - min) / 100;
41
20
  return function filterAxis(value, dataIndex) {
@@ -0,0 +1,20 @@
1
+ import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
2
+ import { ContinuousScaleName, DefaultedAxis } from "../../../../models/axis.js";
3
+ import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
4
+ import { TickParams } from "../../../../hooks/useTicks.js";
5
+ /**
6
+ * Calculates the initial domain and tick number for a given axis.
7
+ * The domain should still run through the zoom filterMode after this step.
8
+ */
9
+ export declare function calculateInitialDomainAndTickNumber(axis: DefaultedAxis<ContinuousScaleName>, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], defaultTickNumber: number, preferStrictDomainInLineCharts: boolean | undefined): {
10
+ domain: [NumberValue, NumberValue];
11
+ tickNumber: number;
12
+ };
13
+ /**
14
+ * Calculates the final domain for an axis.
15
+ * After this step, the domain can be used to create the axis scale.
16
+ */
17
+ export declare function calculateFinalDomain(axis: Pick<DefaultedAxis<ContinuousScaleName>, 'id' | 'domainLimit' | 'scaleType'> & TickParams & {
18
+ min?: NumberValue;
19
+ max?: NumberValue;
20
+ }, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], tickNumber: number, preferStrictDomainInLineCharts: boolean | undefined): NumberValue[];
@@ -0,0 +1,77 @@
1
+ import { getScale } from "../../../getScale.js";
2
+ import { getAxisDomainLimit } from "./getAxisDomainLimit.js";
3
+ import { getTickNumber } from "../../../ticks.js";
4
+ function niceDomain(scaleType, domain, tickNumber) {
5
+ return getScale(scaleType ?? 'linear', domain, [0, 1]).nice(tickNumber).domain();
6
+ }
7
+
8
+ /**
9
+ * Calculates the initial domain and tick number for a given axis.
10
+ * The domain should still run through the zoom filterMode after this step.
11
+ */
12
+ export function calculateInitialDomainAndTickNumber(axis, axisDirection, axisIndex, formattedSeries, [minData, maxData], defaultTickNumber, preferStrictDomainInLineCharts) {
13
+ const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
14
+ let axisExtrema = getActualAxisExtrema(axis, minData, maxData);
15
+ if (typeof domainLimit === 'function') {
16
+ const {
17
+ min,
18
+ max
19
+ } = domainLimit(minData.valueOf(), maxData.valueOf());
20
+ axisExtrema[0] = min;
21
+ axisExtrema[1] = max;
22
+ }
23
+ const tickNumber = getTickNumber(axis, axisExtrema, defaultTickNumber);
24
+ if (domainLimit === 'nice') {
25
+ axisExtrema = niceDomain(axis.scaleType, axisExtrema, tickNumber);
26
+ }
27
+ axisExtrema = ['min' in axis ? axis.min ?? axisExtrema[0] : axisExtrema[0], 'max' in axis ? axis.max ?? axisExtrema[1] : axisExtrema[1]];
28
+ return {
29
+ domain: axisExtrema,
30
+ tickNumber
31
+ };
32
+ }
33
+
34
+ /**
35
+ * Calculates the final domain for an axis.
36
+ * After this step, the domain can be used to create the axis scale.
37
+ */
38
+ export function calculateFinalDomain(axis, axisDirection, axisIndex, formattedSeries, [minData, maxData], tickNumber, preferStrictDomainInLineCharts) {
39
+ const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
40
+ let axisExtrema = getActualAxisExtrema(axis, minData, maxData);
41
+ if (typeof domainLimit === 'function') {
42
+ const {
43
+ min,
44
+ max
45
+ } = domainLimit(minData.valueOf(), maxData.valueOf());
46
+ axisExtrema[0] = min;
47
+ axisExtrema[1] = max;
48
+ }
49
+ if (domainLimit === 'nice') {
50
+ axisExtrema = niceDomain(axis.scaleType, axisExtrema, tickNumber);
51
+ }
52
+ return [axis.min ?? axisExtrema[0], axis.max ?? axisExtrema[1]];
53
+ }
54
+ function getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts) {
55
+ return preferStrictDomainInLineCharts ? getAxisDomainLimit(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
56
+ }
57
+
58
+ /**
59
+ * Get the actual axis extrema considering the user defined min and max values.
60
+ * @param axisExtrema User defined axis extrema.
61
+ * @param minData Minimum value from the data.
62
+ * @param maxData Maximum value from the data.
63
+ */
64
+ function getActualAxisExtrema(axisExtrema, minData, maxData) {
65
+ let min = minData;
66
+ let max = maxData;
67
+ if ('max' in axisExtrema && axisExtrema.max != null && axisExtrema.max < minData) {
68
+ min = axisExtrema.max;
69
+ }
70
+ if ('min' in axisExtrema && axisExtrema.min != null && axisExtrema.min > minData) {
71
+ max = axisExtrema.min;
72
+ }
73
+ if (!('min' in axisExtrema) && !('max' in axisExtrema)) {
74
+ return [min, max];
75
+ }
76
+ return [axisExtrema.min ?? min, axisExtrema.max ?? max];
77
+ }