@mui/x-charts 9.11.1 → 9.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 (124) hide show
  1. package/BarChart/BarChart.js +8 -1
  2. package/BarChart/BarChart.mjs +8 -1
  3. package/CHANGELOG.md +278 -0
  4. package/ChartsContainer/ChartsContainer.js +8 -1
  5. package/ChartsContainer/ChartsContainer.mjs +8 -1
  6. package/ChartsContainer/useChartsContainerProps.js +3 -1
  7. package/ChartsContainer/useChartsContainerProps.mjs +3 -1
  8. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -9
  9. package/ChartsTooltip/ChartsAxisTooltipContent.mjs +2 -9
  10. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  11. package/ChartsTooltip/ChartsItemTooltipContent.mjs +2 -2
  12. package/ChartsTooltip/ChartsTooltipContainer.js +6 -2
  13. package/ChartsTooltip/ChartsTooltipContainer.mjs +6 -2
  14. package/ChartsXAxis/useAxisTicksProps.js +2 -1
  15. package/ChartsXAxis/useAxisTicksProps.mjs +2 -1
  16. package/ChartsYAxis/shortenLabels.js +16 -26
  17. package/ChartsYAxis/shortenLabels.mjs +17 -27
  18. package/ChartsYAxis/useAxisTicksProps.js +2 -1
  19. package/ChartsYAxis/useAxisTicksProps.mjs +2 -1
  20. package/LineChart/CircleMarkElement.js +0 -4
  21. package/LineChart/CircleMarkElement.mjs +0 -4
  22. package/LineChart/LineChart.js +8 -1
  23. package/LineChart/LineChart.mjs +8 -1
  24. package/LineChart/MarkElement.js +13 -6
  25. package/LineChart/MarkElement.mjs +13 -6
  26. package/PieChart/PieChart.js +7 -0
  27. package/PieChart/PieChart.mjs +7 -0
  28. package/RadarChart/RadarChart.js +8 -1
  29. package/RadarChart/RadarChart.mjs +8 -1
  30. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +6 -2
  31. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +6 -2
  32. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +2 -1
  33. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.mjs +2 -1
  34. package/RadarChart/useRadarChartProps.js +3 -1
  35. package/RadarChart/useRadarChartProps.mjs +3 -1
  36. package/ScatterChart/ScatterChart.js +8 -1
  37. package/ScatterChart/ScatterChart.mjs +8 -1
  38. package/SparkLineChart/SparkLineChart.js +8 -1
  39. package/SparkLineChart/SparkLineChart.mjs +8 -1
  40. package/constants/index.d.mts +3 -1
  41. package/constants/index.d.ts +3 -1
  42. package/constants/index.js +5 -2
  43. package/constants/index.mjs +4 -1
  44. package/hooks/animation/index.d.mts +1 -0
  45. package/hooks/animation/index.d.ts +1 -0
  46. package/hooks/animation/index.js +11 -0
  47. package/hooks/animation/index.mjs +1 -0
  48. package/hooks/animation/useAnimateMark.d.mts +25 -0
  49. package/hooks/animation/useAnimateMark.d.ts +25 -0
  50. package/hooks/animation/useAnimateMark.js +45 -0
  51. package/hooks/animation/useAnimateMark.mjs +39 -0
  52. package/hooks/useInteractionItemProps.js +4 -0
  53. package/hooks/useInteractionItemProps.mjs +4 -0
  54. package/index.js +1 -1
  55. package/index.mjs +1 -1
  56. package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +13 -3
  57. package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +12 -3
  58. package/internals/components/ChartsAccessibilityProxy/focusAccessibilityProxy.d.mts +8 -0
  59. package/internals/components/ChartsAccessibilityProxy/focusAccessibilityProxy.d.ts +8 -0
  60. package/internals/components/ChartsAccessibilityProxy/focusAccessibilityProxy.js +25 -0
  61. package/internals/components/ChartsAccessibilityProxy/focusAccessibilityProxy.mjs +19 -0
  62. package/internals/components/ChartsAccessibilityProxy/index.d.mts +2 -1
  63. package/internals/components/ChartsAccessibilityProxy/index.d.ts +2 -1
  64. package/internals/components/ChartsAccessibilityProxy/index.js +11 -0
  65. package/internals/components/ChartsAccessibilityProxy/index.mjs +2 -1
  66. package/internals/domUtils.js +17 -16
  67. package/internals/domUtils.mjs +17 -15
  68. package/internals/ellipsize.d.mts +30 -0
  69. package/internals/ellipsize.d.ts +30 -0
  70. package/internals/ellipsize.js +60 -0
  71. package/internals/ellipsize.mjs +59 -0
  72. package/internals/index.d.mts +1 -0
  73. package/internals/index.d.ts +1 -0
  74. package/internals/index.js +8 -0
  75. package/internals/index.mjs +1 -0
  76. package/internals/plugins/corePlugins/useChartElementRef/useChartElementRef.js +3 -1
  77. package/internals/plugins/corePlugins/useChartElementRef/useChartElementRef.mjs +3 -1
  78. package/internals/plugins/corePlugins/useChartElementRef/useChartElementRef.types.d.mts +5 -0
  79. package/internals/plugins/corePlugins/useChartElementRef/useChartElementRef.types.d.ts +5 -0
  80. package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +10 -0
  81. package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.mjs +10 -0
  82. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.mts +3 -0
  83. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.ts +3 -0
  84. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.js +9 -5
  85. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.mjs +9 -5
  86. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.js +9 -4
  87. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.mjs +9 -4
  88. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +75 -3
  89. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.mjs +76 -3
  90. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.mts +6 -2
  91. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +6 -2
  92. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.mts +1 -0
  93. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +1 -0
  94. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +22 -0
  95. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +22 -0
  96. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +27 -1
  97. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.mjs +27 -1
  98. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.mts +20 -0
  99. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +20 -0
  100. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +242 -35
  101. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +244 -36
  102. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +3 -0
  103. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +3 -0
  104. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +12 -5
  105. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +11 -4
  106. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +29 -0
  107. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +29 -0
  108. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtAxisPosition.d.mts +28 -0
  109. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtAxisPosition.d.ts +28 -0
  110. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtAxisPosition.js +81 -0
  111. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtAxisPosition.mjs +76 -0
  112. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.d.mts +18 -0
  113. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.d.ts +18 -0
  114. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.js +65 -0
  115. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.mjs +60 -0
  116. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +43 -1
  117. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +43 -1
  118. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.mts +3 -2
  119. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +3 -2
  120. package/internals/useDefaultTickLabelStyle.d.mts +7 -0
  121. package/internals/useDefaultTickLabelStyle.d.ts +7 -0
  122. package/internals/useDefaultTickLabelStyle.js +34 -0
  123. package/internals/useDefaultTickLabelStyle.mjs +28 -0
  124. package/package.json +6 -6
@@ -11,34 +11,24 @@ var _domUtils = require("../internals/domUtils");
11
11
  function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelStyle) {
12
12
  const shortenedLabels = new Map();
13
13
  const angle = (0, _clampAngle.clampAngle)(tickLabelStyle?.angle ?? 0);
14
- let topBoundFactor = 1;
15
- let bottomBoundFactor = 1;
16
- if (tickLabelStyle?.textAnchor === 'start') {
17
- topBoundFactor = Infinity;
18
- bottomBoundFactor = 1;
19
- } else if (tickLabelStyle?.textAnchor === 'end') {
20
- topBoundFactor = 1;
21
- bottomBoundFactor = Infinity;
22
- } else {
23
- topBoundFactor = 2;
24
- bottomBoundFactor = 2;
25
- }
26
- if (angle > 180) {
27
- [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
28
- }
29
- if (isRtl) {
30
- [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
31
- }
14
+ const boundsConfig = {
15
+ angle,
16
+ textAnchor: tickLabelStyle?.textAnchor,
17
+ dominantBaseline: tickLabelStyle?.dominantBaseline,
18
+ isRtl
19
+ };
20
+ const svgHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
32
21
  for (const item of visibleLabels) {
33
22
  if (item.formattedValue) {
34
- // That maximum height of the tick depends on its proximity to the axis bounds.
35
- const height = Math.min((item.offset + item.labelOffset) * topBoundFactor, (drawingArea.top + drawingArea.height + drawingArea.bottom - item.offset - item.labelOffset) * bottomBoundFactor);
36
- const doesTextFit = text => (0, _ellipsize.doesTextFitInRect)(text, {
37
- width: maxWidth,
38
- height,
39
- angle,
40
- measureText: string => (0, _domUtils.getStringSize)(string, tickLabelStyle)
41
- });
23
+ // The label is anchored on the tick, so how far it can extend vertically depends on the
24
+ // proximity of the tick to the SVG bounds.
25
+ const anchor = item.offset + item.labelOffset;
26
+ const spaceAbove = anchor;
27
+ const spaceBelow = svgHeight - anchor;
28
+ const doesTextFit = text => {
29
+ const bounds = (0, _ellipsize.getRotatedTextBounds)((0, _domUtils.getStringSize)(text, tickLabelStyle), boundsConfig);
30
+ return bounds.width <= maxWidth && bounds.above <= spaceAbove && bounds.below <= spaceBelow;
31
+ };
42
32
  shortenedLabels.set(item, (0, _ellipsize.ellipsize)(item.formattedValue.toString(), doesTextFit));
43
33
  }
44
34
  }
@@ -1,39 +1,29 @@
1
1
  'use client';
2
2
 
3
3
  import { clampAngle } from "../internals/clampAngle.mjs";
4
- import { doesTextFitInRect, ellipsize } from "../internals/ellipsize.mjs";
4
+ import { ellipsize, getRotatedTextBounds } from "../internals/ellipsize.mjs";
5
5
  import { getStringSize } from "../internals/domUtils.mjs";
6
6
  export function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelStyle) {
7
7
  const shortenedLabels = new Map();
8
8
  const angle = clampAngle(tickLabelStyle?.angle ?? 0);
9
- let topBoundFactor = 1;
10
- let bottomBoundFactor = 1;
11
- if (tickLabelStyle?.textAnchor === 'start') {
12
- topBoundFactor = Infinity;
13
- bottomBoundFactor = 1;
14
- } else if (tickLabelStyle?.textAnchor === 'end') {
15
- topBoundFactor = 1;
16
- bottomBoundFactor = Infinity;
17
- } else {
18
- topBoundFactor = 2;
19
- bottomBoundFactor = 2;
20
- }
21
- if (angle > 180) {
22
- [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
23
- }
24
- if (isRtl) {
25
- [topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
26
- }
9
+ const boundsConfig = {
10
+ angle,
11
+ textAnchor: tickLabelStyle?.textAnchor,
12
+ dominantBaseline: tickLabelStyle?.dominantBaseline,
13
+ isRtl
14
+ };
15
+ const svgHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
27
16
  for (const item of visibleLabels) {
28
17
  if (item.formattedValue) {
29
- // That maximum height of the tick depends on its proximity to the axis bounds.
30
- const height = Math.min((item.offset + item.labelOffset) * topBoundFactor, (drawingArea.top + drawingArea.height + drawingArea.bottom - item.offset - item.labelOffset) * bottomBoundFactor);
31
- const doesTextFit = text => doesTextFitInRect(text, {
32
- width: maxWidth,
33
- height,
34
- angle,
35
- measureText: string => getStringSize(string, tickLabelStyle)
36
- });
18
+ // The label is anchored on the tick, so how far it can extend vertically depends on the
19
+ // proximity of the tick to the SVG bounds.
20
+ const anchor = item.offset + item.labelOffset;
21
+ const spaceAbove = anchor;
22
+ const spaceBelow = svgHeight - anchor;
23
+ const doesTextFit = text => {
24
+ const bounds = getRotatedTextBounds(getStringSize(text, tickLabelStyle), boundsConfig);
25
+ return bounds.width <= maxWidth && bounds.above <= spaceAbove && bounds.below <= spaceBelow;
26
+ };
37
27
  shortenedLabels.set(item, ellipsize(item.formattedValue.toString(), doesTextFit));
38
28
  }
39
29
  }
@@ -16,6 +16,7 @@ var _useAxis = require("../hooks/useAxis");
16
16
  var _defaultTextPlacement = require("../ChartsText/defaultTextPlacement");
17
17
  var _invertTextAnchor = require("../internals/invertTextAnchor");
18
18
  var _utilities = require("./utilities");
19
+ var _constants = require("../constants");
19
20
  const _excluded = ["scale", "tickNumber", "reverse"];
20
21
  function useAxisTicksProps(inProps) {
21
22
  const {
@@ -45,7 +46,7 @@ function useAxisTicksProps(inProps) {
45
46
  const isRtl = (0, _RtlProvider.useRtl)();
46
47
  const classes = (0, _utilities.useUtilityClasses)(defaultizedProps);
47
48
  const positionSign = position === 'right' ? 1 : -1;
48
- const tickFontSize = typeof tickLabelStyle?.fontSize === 'number' ? tickLabelStyle.fontSize : 12;
49
+ const tickFontSize = typeof tickLabelStyle?.fontSize === 'number' ? tickLabelStyle.fontSize : _constants.DEFAULT_TICK_LABEL_FONT_SIZE;
49
50
  const Tick = slots?.axisTick ?? 'line';
50
51
  const TickLabel = slots?.axisTickLabel ?? _ChartsText.ChartsText;
51
52
  const defaultTextAnchor = (0, _defaultTextPlacement.getDefaultTextAnchor)((position === 'right' ? -90 : 90) - (tickLabelStyle?.angle ?? 0));
@@ -11,6 +11,7 @@ import { useYAxes } from "../hooks/useAxis.mjs";
11
11
  import { getDefaultBaseline, getDefaultTextAnchor } from "../ChartsText/defaultTextPlacement.mjs";
12
12
  import { invertTextAnchor } from "../internals/invertTextAnchor.mjs";
13
13
  import { defaultProps, useUtilityClasses } from "./utilities.mjs";
14
+ import { DEFAULT_TICK_LABEL_FONT_SIZE } from "../constants/index.mjs";
14
15
  export function useAxisTicksProps(inProps) {
15
16
  const {
16
17
  yAxis,
@@ -39,7 +40,7 @@ export function useAxisTicksProps(inProps) {
39
40
  const isRtl = useRtl();
40
41
  const classes = useUtilityClasses(defaultizedProps);
41
42
  const positionSign = position === 'right' ? 1 : -1;
42
- const tickFontSize = typeof tickLabelStyle?.fontSize === 'number' ? tickLabelStyle.fontSize : 12;
43
+ const tickFontSize = typeof tickLabelStyle?.fontSize === 'number' ? tickLabelStyle.fontSize : DEFAULT_TICK_LABEL_FONT_SIZE;
43
44
  const Tick = slots?.axisTick ?? 'line';
44
45
  const TickLabel = slots?.axisTickLabel ?? ChartsText;
45
46
  const defaultTextAnchor = getDefaultTextAnchor((position === 'right' ? -90 : 90) - (tickLabelStyle?.angle ?? 0));
@@ -102,10 +102,6 @@ process.env.NODE_ENV !== "production" ? CircleMarkElement.propTypes = {
102
102
  */
103
103
  dataIndex: _propTypes.default.number.isRequired,
104
104
  seriesId: _propTypes.default.string.isRequired,
105
- /**
106
- * The shape of the marker.
107
- */
108
- shape: _propTypes.default.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired,
109
105
  /**
110
106
  * If `true`, animations are skipped.
111
107
  * @default false
@@ -95,10 +95,6 @@ process.env.NODE_ENV !== "production" ? CircleMarkElement.propTypes = {
95
95
  */
96
96
  dataIndex: PropTypes.number.isRequired,
97
97
  seriesId: PropTypes.string.isRequired,
98
- /**
99
- * The shape of the marker.
100
- */
101
- shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired,
102
98
  /**
103
99
  * If `true`, animations are skipped.
104
100
  * @default false
@@ -148,6 +148,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes /* remove-proptypes
148
148
  enablePositionBasedPointerInteraction: _propTypes.default.bool,
149
149
  keyboardActivation: _propTypes.default.bool
150
150
  }),
151
+ /**
152
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
153
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
154
+ * indicator stays hidden until the user presses a key.
155
+ * @default false
156
+ */
157
+ focusItemOnClick: _propTypes.default.bool,
151
158
  /**
152
159
  * Option to display a cartesian grid in the background.
153
160
  */
@@ -275,7 +282,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes /* remove-proptypes
275
282
  /**
276
283
  * The function called for onClick events.
277
284
  * The second argument contains information about all line/bar elements at the current mouse position.
278
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
285
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
279
286
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
280
287
  */
281
288
  onAxisClick: _propTypes.default.func,
@@ -141,6 +141,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes /* remove-proptypes
141
141
  enablePositionBasedPointerInteraction: PropTypes.bool,
142
142
  keyboardActivation: PropTypes.bool
143
143
  }),
144
+ /**
145
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
146
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
147
+ * indicator stays hidden until the user presses a key.
148
+ * @default false
149
+ */
150
+ focusItemOnClick: PropTypes.bool,
144
151
  /**
145
152
  * Option to display a cartesian grid in the background.
146
153
  */
@@ -268,7 +275,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes /* remove-proptypes
268
275
  /**
269
276
  * The function called for onClick events.
270
277
  * The second argument contains information about all line/bar elements at the current mouse position.
271
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
278
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
272
279
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
273
280
  */
274
281
  onAxisClick: PropTypes.func,
@@ -18,6 +18,7 @@ var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
18
18
  var _useChartExperimentalFeature = require("../internals/plugins/corePlugins/useChartExperimentalFeature");
19
19
  var _useStore = require("../internals/store/useStore");
20
20
  var _getSymbol = require("../internals/getSymbol");
21
+ var _useAnimateMark = require("../hooks/animation/useAnimateMark");
21
22
  var _lineClasses = require("./lineClasses");
22
23
  var _jsxRuntime = require("react/jsx-runtime");
23
24
  const _excluded = ["x", "y", "seriesId", "classes", "color", "shape", "dataIndex", "onClick", "skipAnimation", "isFaded", "isHighlighted", "hidden", "style"];
@@ -30,7 +31,8 @@ const MarkElementPath = (0, _styles.styled)('path', {
30
31
  fill: (theme.vars || theme).palette.background.paper,
31
32
  [`&.${_lineClasses.lineClasses.markAnimate}`]: {
32
33
  transitionDuration: `${_animation.ANIMATION_DURATION_MS}ms`,
33
- transitionProperty: 'transform, transform-origin, opacity',
34
+ // The position is animated in JS by `useAnimateMark`: Safari cannot transition the `transform` attribute.
35
+ transitionProperty: 'opacity',
34
36
  transitionTimingFunction: _animation.ANIMATION_TIMING_FUNCTION
35
37
  }
36
38
  }));
@@ -79,11 +81,16 @@ function MarkElement(props) {
79
81
  skipAnimation,
80
82
  classes: innerClasses
81
83
  });
82
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarkElementPath, (0, _extends2.default)({}, other, enablePositionBasedPointerInteraction ? {} : interactionProps, {
83
- style: (0, _extends2.default)({}, style, {
84
- transform: `translate(${x}px, ${y}px)`,
85
- transformOrigin: `${x}px ${y}px`
86
- }),
84
+
85
+ // Positions the mark with the `transform` attribute, in `viewBox` units. A CSS `px` transform lands in the wrong
86
+ // place in Safari under browser zoom, see https://github.com/mui/mui-x/issues/23377
87
+ const animatedProps = (0, _useAnimateMark.useAnimateMark)({
88
+ x: Number(x),
89
+ y: Number(y),
90
+ skipAnimation
91
+ });
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarkElementPath, (0, _extends2.default)({}, other, enablePositionBasedPointerInteraction ? {} : interactionProps, animatedProps, {
93
+ style: style,
87
94
  ownerState: ownerState,
88
95
  className: classes.mark,
89
96
  d: (0, _d3Shape.symbol)(_d3Shape.symbolsFill[(0, _getSymbol.getSymbol)(shape)])(),
@@ -12,6 +12,7 @@ import { useInteractionItemProps } from "../hooks/useInteractionItemProps.mjs";
12
12
  import { selectorChartExperimentalFeaturesState } from "../internals/plugins/corePlugins/useChartExperimentalFeature/index.mjs";
13
13
  import { useStore } from "../internals/store/useStore.mjs";
14
14
  import { getSymbol } from "../internals/getSymbol.mjs";
15
+ import { useAnimateMark } from "../hooks/animation/useAnimateMark.mjs";
15
16
  import { lineClasses, useUtilityClasses as useLineUtilityClasses } from "./lineClasses.mjs";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  const MarkElementPath = styled('path', {
@@ -23,7 +24,8 @@ const MarkElementPath = styled('path', {
23
24
  fill: (theme.vars || theme).palette.background.paper,
24
25
  [`&.${lineClasses.markAnimate}`]: {
25
26
  transitionDuration: `${ANIMATION_DURATION_MS}ms`,
26
- transitionProperty: 'transform, transform-origin, opacity',
27
+ // The position is animated in JS by `useAnimateMark`: Safari cannot transition the `transform` attribute.
28
+ transitionProperty: 'opacity',
27
29
  transitionTimingFunction: ANIMATION_TIMING_FUNCTION
28
30
  }
29
31
  }));
@@ -72,11 +74,16 @@ function MarkElement(props) {
72
74
  skipAnimation,
73
75
  classes: innerClasses
74
76
  });
75
- return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, enablePositionBasedPointerInteraction ? {} : interactionProps, {
76
- style: _extends({}, style, {
77
- transform: `translate(${x}px, ${y}px)`,
78
- transformOrigin: `${x}px ${y}px`
79
- }),
77
+
78
+ // Positions the mark with the `transform` attribute, in `viewBox` units. A CSS `px` transform lands in the wrong
79
+ // place in Safari under browser zoom, see https://github.com/mui/mui-x/issues/23377
80
+ const animatedProps = useAnimateMark({
81
+ x: Number(x),
82
+ y: Number(y),
83
+ skipAnimation
84
+ });
85
+ return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, enablePositionBasedPointerInteraction ? {} : interactionProps, animatedProps, {
86
+ style: style,
80
87
  ownerState: ownerState,
81
88
  className: classes.mark,
82
89
  d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
@@ -143,6 +143,13 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes /* remove-proptypes *
143
143
  experimentalFeatures: _propTypes.default.shape({
144
144
  keyboardActivation: _propTypes.default.bool
145
145
  }),
146
+ /**
147
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
148
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
149
+ * indicator stays hidden until the user presses a key.
150
+ * @default false
151
+ */
152
+ focusItemOnClick: _propTypes.default.bool,
146
153
  /**
147
154
  * The height of the chart in px. If not defined, it takes the height of the parent element.
148
155
  */
@@ -136,6 +136,13 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes /* remove-proptypes *
136
136
  experimentalFeatures: PropTypes.shape({
137
137
  keyboardActivation: PropTypes.bool
138
138
  }),
139
+ /**
140
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
141
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
142
+ * indicator stays hidden until the user presses a key.
143
+ * @default false
144
+ */
145
+ focusItemOnClick: PropTypes.bool,
139
146
  /**
140
147
  * The height of the chart in px. If not defined, it takes the height of the parent element.
141
148
  */
@@ -105,6 +105,13 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes /* remove-proptypes
105
105
  experimentalFeatures: _propTypes.default.shape({
106
106
  keyboardActivation: _propTypes.default.bool
107
107
  }),
108
+ /**
109
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
110
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
111
+ * indicator stays hidden until the user presses a key.
112
+ * @default false
113
+ */
114
+ focusItemOnClick: _propTypes.default.bool,
108
115
  /**
109
116
  * The height of the chart in px. If not defined, it takes the height of the parent element.
110
117
  */
@@ -224,7 +231,7 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes /* remove-proptypes
224
231
  /**
225
232
  * The function called for onClick events.
226
233
  * The second argument contains information about all line/bar elements at the current mouse position.
227
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
234
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
228
235
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
229
236
  */
230
237
  onAxisClick: _propTypes.default.func,
@@ -98,6 +98,13 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes /* remove-proptypes
98
98
  experimentalFeatures: PropTypes.shape({
99
99
  keyboardActivation: PropTypes.bool
100
100
  }),
101
+ /**
102
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
103
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
104
+ * indicator stays hidden until the user presses a key.
105
+ * @default false
106
+ */
107
+ focusItemOnClick: PropTypes.bool,
101
108
  /**
102
109
  * The height of the chart in px. If not defined, it takes the height of the parent element.
103
110
  */
@@ -217,7 +224,7 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes /* remove-proptypes
217
224
  /**
218
225
  * The function called for onClick events.
219
226
  * The second argument contains information about all line/bar elements at the current mouse position.
220
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
227
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
221
228
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
222
229
  */
223
230
  onAxisClick: PropTypes.func,
@@ -14,6 +14,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _useRadarSeriesData = require("./useRadarSeriesData");
15
15
  var _radarClasses = require("../radarClasses");
16
16
  var _useItemHighlightStateGetter = require("../../hooks/useItemHighlightStateGetter");
17
+ var _useInteractionAllItemProps = require("./useInteractionAllItemProps");
17
18
  var _useRegisterRadarItemActivation = require("./useRegisterRadarItemActivation");
18
19
  var _jsxRuntime = require("react/jsx-runtime");
19
20
  const _excluded = ["seriesId", "onItemClick", "classes"];
@@ -54,6 +55,9 @@ function RadarSeriesMarks(props) {
54
55
  const seriesCoordinates = (0, _useRadarSeriesData.useRadarSeriesData)(props.seriesId);
55
56
  const classes = (0, _radarClasses.useUtilityClasses)(inClasses);
56
57
  const getHighlightState = (0, _useItemHighlightStateGetter.useItemHighlightStateGetter)();
58
+ // Clickable marks cover the area, so they report the series the same way it does. The index
59
+ // still comes from the rotation axis, which is why the identifier stays series-level.
60
+ const interactionProps = (0, _useInteractionAllItemProps.useInteractionAllItemProps)(seriesCoordinates);
57
61
  (0, _useRegisterRadarItemActivation.useRegisterRadarItemActivation)(seriesId, onItemClick, _useRegisterRadarItemActivation.RADAR_ACTIVATION_PRIORITY.mark);
58
62
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
59
63
  children: seriesCoordinates?.map(({
@@ -62,7 +66,7 @@ function RadarSeriesMarks(props) {
62
66
  hideMark,
63
67
  fillArea,
64
68
  hidden
65
- }) => {
69
+ }, seriesIndex) => {
66
70
  if (hideMark || hidden) {
67
71
  return null;
68
72
  }
@@ -83,7 +87,7 @@ function RadarSeriesMarks(props) {
83
87
  dataIndex: index
84
88
  }),
85
89
  cursor: onItemClick ? 'pointer' : 'unset'
86
- }, other), index))
90
+ }, interactionProps[seriesIndex], other), index))
87
91
  }, id);
88
92
  })
89
93
  });
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { useRadarSeriesData } from "./useRadarSeriesData.mjs";
7
7
  import { useUtilityClasses } from "../radarClasses.mjs";
8
8
  import { useItemHighlightStateGetter } from "../../hooks/useItemHighlightStateGetter.mjs";
9
+ import { useInteractionAllItemProps } from "./useInteractionAllItemProps.mjs";
9
10
  import { RADAR_ACTIVATION_PRIORITY, useRegisterRadarItemActivation } from "./useRegisterRadarItemActivation.mjs";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  export function getCircleProps(params) {
@@ -45,6 +46,9 @@ function RadarSeriesMarks(props) {
45
46
  const seriesCoordinates = useRadarSeriesData(props.seriesId);
46
47
  const classes = useUtilityClasses(inClasses);
47
48
  const getHighlightState = useItemHighlightStateGetter();
49
+ // Clickable marks cover the area, so they report the series the same way it does. The index
50
+ // still comes from the rotation axis, which is why the identifier stays series-level.
51
+ const interactionProps = useInteractionAllItemProps(seriesCoordinates);
48
52
  useRegisterRadarItemActivation(seriesId, onItemClick, RADAR_ACTIVATION_PRIORITY.mark);
49
53
  return /*#__PURE__*/_jsx(React.Fragment, {
50
54
  children: seriesCoordinates?.map(({
@@ -53,7 +57,7 @@ function RadarSeriesMarks(props) {
53
57
  hideMark,
54
58
  fillArea,
55
59
  hidden
56
- }) => {
60
+ }, seriesIndex) => {
57
61
  if (hideMark || hidden) {
58
62
  return null;
59
63
  }
@@ -74,7 +78,7 @@ function RadarSeriesMarks(props) {
74
78
  dataIndex: index
75
79
  }),
76
80
  cursor: onItemClick ? 'pointer' : 'unset'
77
- }, other), index))
81
+ }, interactionProps[seriesIndex], other), index))
78
82
  }, id);
79
83
  })
80
84
  });
@@ -66,13 +66,14 @@ function RadarSeriesPlot(props) {
66
66
  getHighlightState,
67
67
  classes
68
68
  }), {
69
+ pointerEvents: onMarkClick ? undefined : 'none',
69
70
  onClick: event => onMarkClick?.(event, {
70
71
  type: 'radar',
71
72
  seriesId,
72
73
  dataIndex: index
73
74
  }),
74
75
  cursor: onMarkClick ? 'pointer' : 'unset'
75
- }), index))]
76
+ }, interactionProps[seriesIndex]), index))]
76
77
  }, seriesId);
77
78
  })
78
79
  });
@@ -59,13 +59,14 @@ function RadarSeriesPlot(props) {
59
59
  getHighlightState,
60
60
  classes
61
61
  }), {
62
+ pointerEvents: onMarkClick ? undefined : 'none',
62
63
  onClick: event => onMarkClick?.(event, {
63
64
  type: 'radar',
64
65
  seriesId,
65
66
  dataIndex: index
66
67
  }),
67
68
  cursor: onMarkClick ? 'pointer' : 'unset'
68
- }), index))]
69
+ }, interactionProps[seriesIndex]), index))]
69
70
  }, seriesId);
70
71
  })
71
72
  });
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.useRadarChartProps = void 0;
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var _RadarChart = require("./RadarChart.plugins");
11
- const _excluded = ["apiRef", "series", "radar", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "hideLegend", "divisions", "shape", "stripeColor", "highlight", "showToolbar", "onAxisClick", "onAreaClick", "onMarkClick", "disableKeyboardNavigation", "experimentalFeatures", "className"];
11
+ const _excluded = ["apiRef", "series", "radar", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "hideLegend", "divisions", "shape", "stripeColor", "highlight", "showToolbar", "onAxisClick", "onAreaClick", "onMarkClick", "disableKeyboardNavigation", "focusItemOnClick", "experimentalFeatures", "className"];
12
12
  /**
13
13
  * A helper function that extracts RadarChartProps from the input props
14
14
  * and returns an object with props for the children components of RadarChart.
@@ -41,6 +41,7 @@ const useRadarChartProps = props => {
41
41
  onAreaClick,
42
42
  onMarkClick,
43
43
  disableKeyboardNavigation,
44
+ focusItemOnClick,
44
45
  experimentalFeatures,
45
46
  className
46
47
  } = props,
@@ -59,6 +60,7 @@ const useRadarChartProps = props => {
59
60
  skipAnimation,
60
61
  onAxisClick,
61
62
  disableKeyboardNavigation,
63
+ focusItemOnClick,
62
64
  experimentalFeatures,
63
65
  plugins: _RadarChart.RADAR_PLUGINS
64
66
  };
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
- const _excluded = ["apiRef", "series", "radar", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "hideLegend", "divisions", "shape", "stripeColor", "highlight", "showToolbar", "onAxisClick", "onAreaClick", "onMarkClick", "disableKeyboardNavigation", "experimentalFeatures", "className"];
4
+ const _excluded = ["apiRef", "series", "radar", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "hideLegend", "divisions", "shape", "stripeColor", "highlight", "showToolbar", "onAxisClick", "onAreaClick", "onMarkClick", "disableKeyboardNavigation", "focusItemOnClick", "experimentalFeatures", "className"];
5
5
  import { RADAR_PLUGINS } from "./RadarChart.plugins.mjs";
6
6
  /**
7
7
  * A helper function that extracts RadarChartProps from the input props
@@ -35,6 +35,7 @@ export const useRadarChartProps = props => {
35
35
  onAreaClick,
36
36
  onMarkClick,
37
37
  disableKeyboardNavigation,
38
+ focusItemOnClick,
38
39
  experimentalFeatures,
39
40
  className
40
41
  } = props,
@@ -53,6 +54,7 @@ export const useRadarChartProps = props => {
53
54
  skipAnimation,
54
55
  onAxisClick,
55
56
  disableKeyboardNavigation,
57
+ focusItemOnClick,
56
58
  experimentalFeatures,
57
59
  plugins: RADAR_PLUGINS
58
60
  };
@@ -152,6 +152,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes /* remove-proptyp
152
152
  keyboardActivation: _propTypes.default.bool,
153
153
  progressiveRendering: _propTypes.default.bool
154
154
  }),
155
+ /**
156
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
157
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
158
+ * indicator stays hidden until the user presses a key.
159
+ * @default false
160
+ */
161
+ focusItemOnClick: _propTypes.default.bool,
155
162
  /**
156
163
  * Option to display a cartesian grid in the background.
157
164
  */
@@ -273,7 +280,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes /* remove-proptyp
273
280
  /**
274
281
  * The function called for onClick events.
275
282
  * The second argument contains information about all line/bar elements at the current mouse position.
276
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
283
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
277
284
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
278
285
  */
279
286
  onAxisClick: _propTypes.default.func,
@@ -145,6 +145,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes /* remove-proptyp
145
145
  keyboardActivation: PropTypes.bool,
146
146
  progressiveRendering: PropTypes.bool
147
147
  }),
148
+ /**
149
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
150
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
151
+ * indicator stays hidden until the user presses a key.
152
+ * @default false
153
+ */
154
+ focusItemOnClick: PropTypes.bool,
148
155
  /**
149
156
  * Option to display a cartesian grid in the background.
150
157
  */
@@ -266,7 +273,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes /* remove-proptyp
266
273
  /**
267
274
  * The function called for onClick events.
268
275
  * The second argument contains information about all line/bar elements at the current mouse position.
269
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
276
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
270
277
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
271
278
  */
272
279
  onAxisClick: PropTypes.func,
@@ -259,6 +259,13 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes /* remove-propt
259
259
  keyboardActivation: _propTypes.default.bool,
260
260
  progressiveRendering: _propTypes.default.bool
261
261
  }),
262
+ /**
263
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
264
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
265
+ * indicator stays hidden until the user presses a key.
266
+ * @default false
267
+ */
268
+ focusItemOnClick: _propTypes.default.bool,
262
269
  /**
263
270
  * The height of the chart in px. If not defined, it takes the height of the parent element.
264
271
  */
@@ -453,7 +460,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes /* remove-propt
453
460
  /**
454
461
  * The function called for onClick events.
455
462
  * The second argument contains information about all line/bar elements at the current mouse position.
456
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
463
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
457
464
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
458
465
  */
459
466
  onAxisClick: _propTypes.default.func,
@@ -252,6 +252,13 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes /* remove-propt
252
252
  keyboardActivation: PropTypes.bool,
253
253
  progressiveRendering: PropTypes.bool
254
254
  }),
255
+ /**
256
+ * If `true`, clicking an item immediately shows the keyboard focus indicator on it.
257
+ * By default, clicking sets the item that keyboard navigation starts from, but the focus
258
+ * indicator stays hidden until the user presses a key.
259
+ * @default false
260
+ */
261
+ focusItemOnClick: PropTypes.bool,
255
262
  /**
256
263
  * The height of the chart in px. If not defined, it takes the height of the parent element.
257
264
  */
@@ -446,7 +453,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes /* remove-propt
446
453
  /**
447
454
  * The function called for onClick events.
448
455
  * The second argument contains information about all line/bar elements at the current mouse position.
449
- * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
456
+ * @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
450
457
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
451
458
  */
452
459
  onAxisClick: PropTypes.func,
@@ -10,4 +10,6 @@ export declare const DEFAULT_MARGINS: {
10
10
  };
11
11
  export declare const DEFAULT_AXIS_SIZE_WIDTH = 45;
12
12
  export declare const DEFAULT_AXIS_SIZE_HEIGHT = 25;
13
- export declare const AXIS_LABEL_DEFAULT_HEIGHT = 20;
13
+ export declare const AXIS_LABEL_DEFAULT_HEIGHT = 20;
14
+ /** Font size the axes render their tick labels with, unless `tickLabelStyle` overrides it. */
15
+ export declare const DEFAULT_TICK_LABEL_FONT_SIZE = 12;