@mui/x-charts 8.11.0 → 8.11.2

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 (90) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
  3. package/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +9 -52
  4. package/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
  5. package/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +15 -51
  6. package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  7. package/ChartsXAxis/ChartsXAxis.js +8 -5
  8. package/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
  9. package/ChartsXAxis/ChartsXAxisImpl.js +117 -0
  10. package/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +2 -497
  11. package/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -31
  12. package/ChartsXAxis/utilities.d.ts +1 -2
  13. package/ChartsXAxis/utilities.js +1 -7
  14. package/{esm/ChartsYAxis/ChartsGroupedYAxis.d.ts → ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
  15. package/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +9 -52
  16. package/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
  17. package/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +15 -50
  18. package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  19. package/ChartsYAxis/ChartsYAxis.js +10 -7
  20. package/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
  21. package/ChartsYAxis/ChartsYAxisImpl.js +133 -0
  22. package/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +2 -505
  23. package/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +5 -44
  24. package/ChartsYAxis/utilities.d.ts +0 -1
  25. package/ChartsYAxis/utilities.js +1 -7
  26. package/RadarChart/RadarAxis/RadarAxis.d.ts +2 -2
  27. package/RadarChart/RadarAxis/RadarAxis.js +2 -2
  28. package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +4 -4
  29. package/RadarChart/RadarAxis/RadarAxis.utils.js +4 -4
  30. package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
  31. package/esm/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +10 -53
  32. package/esm/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
  33. package/esm/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +16 -54
  34. package/esm/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  35. package/esm/ChartsXAxis/ChartsXAxis.js +8 -5
  36. package/esm/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
  37. package/esm/ChartsXAxis/ChartsXAxisImpl.js +110 -0
  38. package/esm/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +2 -497
  39. package/esm/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +3 -29
  40. package/esm/ChartsXAxis/utilities.d.ts +1 -2
  41. package/esm/ChartsXAxis/utilities.js +0 -6
  42. package/{ChartsYAxis/ChartsGroupedYAxis.d.ts → esm/ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
  43. package/esm/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +10 -53
  44. package/esm/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
  45. package/esm/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +16 -53
  46. package/esm/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  47. package/esm/ChartsYAxis/ChartsYAxis.js +9 -6
  48. package/esm/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
  49. package/esm/ChartsYAxis/ChartsYAxisImpl.js +126 -0
  50. package/esm/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +2 -505
  51. package/esm/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -42
  52. package/esm/ChartsYAxis/utilities.d.ts +0 -1
  53. package/esm/ChartsYAxis/utilities.js +0 -6
  54. package/esm/RadarChart/RadarAxis/RadarAxis.d.ts +2 -2
  55. package/esm/RadarChart/RadarAxis/RadarAxis.js +2 -2
  56. package/esm/RadarChart/RadarAxis/RadarAxis.utils.d.ts +4 -4
  57. package/esm/RadarChart/RadarAxis/RadarAxis.utils.js +4 -4
  58. package/esm/hooks/useInteractionItemProps.js +5 -4
  59. package/esm/hooks/useTicks.js +8 -1
  60. package/esm/index.js +1 -1
  61. package/esm/internals/dateHelpers.d.ts +4 -2
  62. package/esm/internals/dateHelpers.js +5 -4
  63. package/esm/internals/defaultValueFormatters.js +5 -0
  64. package/esm/internals/getWordsByLines.d.ts +6 -0
  65. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
  66. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  67. package/esm/locales/index.d.ts +2 -1
  68. package/esm/locales/index.js +1 -0
  69. package/esm/locales/svSE.d.ts +19 -0
  70. package/esm/locales/svSE.js +15 -0
  71. package/hooks/useInteractionItemProps.js +6 -4
  72. package/hooks/useTicks.js +8 -1
  73. package/index.js +1 -1
  74. package/internals/dateHelpers.d.ts +4 -2
  75. package/internals/dateHelpers.js +5 -4
  76. package/internals/defaultValueFormatters.js +5 -0
  77. package/internals/getWordsByLines.d.ts +6 -0
  78. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
  79. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  80. package/locales/index.d.ts +2 -1
  81. package/locales/index.js +11 -0
  82. package/locales/svSE.d.ts +19 -0
  83. package/locales/svSE.js +21 -0
  84. package/package.json +13 -13
  85. package/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
  86. package/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
  87. package/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
  88. package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
  89. package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
  90. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
@@ -4,11 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useUtilityClasses = exports.defaultProps = exports.YAxisRoot = exports.TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = void 0;
7
+ exports.useUtilityClasses = exports.defaultProps = exports.TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = void 0;
8
8
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
9
- var _styles = require("@mui/material/styles");
10
9
  var _axisClasses = require("../ChartsAxis/axisClasses");
11
- var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
12
10
  const useUtilityClasses = ownerState => {
13
11
  const {
14
12
  classes,
@@ -31,10 +29,6 @@ exports.useUtilityClasses = useUtilityClasses;
31
29
  const TICK_LABEL_GAP = exports.TICK_LABEL_GAP = 2;
32
30
  /* Gap between the axis label and tick labels. */
33
31
  const AXIS_LABEL_TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = 2;
34
- const YAxisRoot = exports.YAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
35
- name: 'MuiChartsYAxis',
36
- slot: 'Root'
37
- })({});
38
32
  const defaultProps = exports.defaultProps = {
39
33
  disableLine: false,
40
34
  disableTicks: false,
@@ -12,11 +12,11 @@ export interface RadarAxisProps extends UseRadarAxisParams {
12
12
  /**
13
13
  * The labels text anchor or a function returning the text anchor for a given axis angle (in degree).
14
14
  */
15
- textAnchor?: string | ((angle: number) => string);
15
+ textAnchor?: React.SVGProps<SVGTextElement>['textAnchor'] | ((angle: number) => React.SVGProps<SVGTextElement>['textAnchor']);
16
16
  /**
17
17
  * The labels dominant baseline or a function returning the dominant baseline for a given axis angle (in degree).
18
18
  */
19
- dominantBaseline?: string | ((angle: number) => string);
19
+ dominantBaseline?: React.SVGProps<SVGTextElement>['dominantBaseline'] | ((angle: number) => React.SVGProps<SVGTextElement>['dominantBaseline']);
20
20
  /**
21
21
  * Override or extend the styles applied to the component.
22
22
  */
@@ -81,7 +81,7 @@ process.env.NODE_ENV !== "production" ? RadarAxis.propTypes = {
81
81
  /**
82
82
  * The labels dominant baseline or a function returning the dominant baseline for a given axis angle (in degree).
83
83
  */
84
- dominantBaseline: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
84
+ dominantBaseline: _propTypes.default.oneOfType([_propTypes.default.oneOf(['alphabetic', 'auto', 'central', 'hanging', 'ideographic', 'inherit', 'mathematical', 'middle', 'no-change', 'reset-size', 'text-after-edge', 'text-before-edge', 'use-script']), _propTypes.default.func]),
85
85
  /**
86
86
  * Defines how label align with the axis.
87
87
  * - 'horizontal': labels stay horizontal and their placement change with the axis angle.
@@ -97,5 +97,5 @@ process.env.NODE_ENV !== "production" ? RadarAxis.propTypes = {
97
97
  /**
98
98
  * The labels text anchor or a function returning the text anchor for a given axis angle (in degree).
99
99
  */
100
- textAnchor: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string])
100
+ textAnchor: _propTypes.default.oneOfType([_propTypes.default.oneOf(['end', 'inherit', 'middle', 'start']), _propTypes.default.func])
101
101
  } : void 0;
@@ -7,14 +7,14 @@ interface GetLabelAttributesParams extends Required<Pick<RadarAxisProps, 'labelO
7
7
  export declare function getLabelAttributes(params: GetLabelAttributesParams): {
8
8
  x: number;
9
9
  y: number;
10
- textAnchor: string;
11
- dominantBaseline: string;
10
+ textAnchor: "inherit" | "end" | "start" | "middle" | undefined;
11
+ dominantBaseline: "inherit" | "auto" | "middle" | "alphabetic" | "hanging" | "ideographic" | "mathematical" | "text-before-edge" | "central" | "text-after-edge" | "use-script" | "no-change" | "reset-size" | undefined;
12
12
  transform?: undefined;
13
13
  } | {
14
14
  x: number;
15
15
  y: number;
16
- textAnchor: string;
17
- dominantBaseline: string;
16
+ textAnchor: "inherit" | "end" | "start" | "middle" | undefined;
17
+ dominantBaseline: "inherit" | "auto" | "middle" | "alphabetic" | "hanging" | "ideographic" | "mathematical" | "text-before-edge" | "central" | "text-after-edge" | "use-script" | "no-change" | "reset-size" | undefined;
18
18
  transform: string;
19
19
  };
20
20
  export {};
@@ -25,12 +25,12 @@ function getTextAnchor(angle) {
25
25
  }
26
26
  function getDominantBaseline(angle) {
27
27
  if (angle < 160) {
28
- return 'baseline';
28
+ return 'auto';
29
29
  }
30
30
  if (angle < 360 - 20) {
31
31
  return 'hanging';
32
32
  }
33
- return 'baseline';
33
+ return 'auto';
34
34
  }
35
35
  const LABEL_MARGIN = 2;
36
36
  function getLabelAttributes(params) {
@@ -43,7 +43,7 @@ function getLabelAttributes(params) {
43
43
  const textAnchor = typeof params.textAnchor === 'function' ? params.textAnchor(angle) : params.textAnchor ?? getTextAnchor(angle);
44
44
  const dominantBaseline = typeof params.dominantBaseline === 'function' ? params.dominantBaseline(angle) : params.dominantBaseline ?? getDominantBaseline(angle);
45
45
  const marginX = textAnchor === 'start' ? LABEL_MARGIN : -LABEL_MARGIN;
46
- const marginY = dominantBaseline === 'baseline' ? -LABEL_MARGIN : LABEL_MARGIN;
46
+ const marginY = dominantBaseline === 'auto' ? -LABEL_MARGIN : LABEL_MARGIN;
47
47
  return {
48
48
  x: x + marginX,
49
49
  y: y + marginY,
@@ -55,7 +55,7 @@ function getLabelAttributes(params) {
55
55
  // orientation='rotated'
56
56
 
57
57
  const textAnchor = typeof params.textAnchor === 'function' ? params.textAnchor(angle) : params.textAnchor ?? 'start';
58
- const dominantBaseline = typeof params.dominantBaseline === 'function' ? params.dominantBaseline(angle) : params.dominantBaseline ?? 'baseline';
58
+ const dominantBaseline = typeof params.dominantBaseline === 'function' ? params.dominantBaseline(angle) : params.dominantBaseline ?? 'auto';
59
59
  return {
60
60
  x,
61
61
  y,
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ChartsXAxisProps } from "../models/axis.js";
3
+ interface ChartsGroupedXAxisProps extends ChartsXAxisProps {}
4
+ /**
5
+ * @ignore - internal component.
6
+ */
7
+ declare function ChartsGroupedXAxisTicks(inProps: ChartsGroupedXAxisProps): React.JSX.Element;
8
+ export { ChartsGroupedXAxisTicks };
@@ -2,12 +2,11 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
- import { useDrawingArea } from "../hooks/useDrawingArea.js";
6
5
  import { isBandScale } from "../internals/isBandScale.js";
7
6
  import { useChartContext } from "../context/ChartProvider/useChartContext.js";
8
- import { TICK_LABEL_GAP, XAxisRoot } from "./utilities.js";
7
+ import { TICK_LABEL_GAP } from "./utilities.js";
9
8
  import { useTicksGrouped } from "../hooks/useTicksGrouped.js";
10
- import { useAxisProps } from "./useAxisProps.js";
9
+ import { useAxisTicksProps } from "./useAxisTicksProps.js";
11
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
11
  const DEFAULT_GROUPING_CONFIG = {
13
12
  tickSize: 6
@@ -20,58 +19,36 @@ const getGroupingConfig = (groups, groupIndex, tickSize) => {
20
19
  tickSize: config.tickSize ?? calculatedTickSize
21
20
  });
22
21
  };
23
-
24
22
  /**
25
23
  * @ignore - internal component.
26
24
  */
27
- function ChartsGroupedXAxis(inProps) {
25
+ function ChartsGroupedXAxisTicks(inProps) {
28
26
  const {
29
27
  xScale,
30
28
  defaultizedProps,
31
29
  tickNumber,
32
30
  positionSign,
33
- skipAxisRendering,
34
31
  classes,
35
- Line,
36
32
  Tick,
37
33
  TickLabel,
38
- Label,
39
- axisTickLabelProps,
40
- axisLabelProps
41
- } = useAxisProps(inProps);
34
+ axisTickLabelProps
35
+ } = useAxisTicksProps(inProps);
42
36
  if (!isBandScale(xScale)) {
43
37
  throw new Error('MUI X Charts: ChartsGroupedXAxis only supports the `band` and `point` scale types.');
44
38
  }
45
39
  const {
46
- position,
47
- disableLine,
48
40
  disableTicks,
49
- label,
50
41
  tickSize,
51
42
  valueFormatter,
52
43
  slotProps,
53
44
  tickInterval,
54
45
  tickPlacement,
55
- tickLabelPlacement,
56
- sx,
57
- offset,
58
- height: axisHeight
46
+ tickLabelPlacement
59
47
  } = defaultizedProps;
60
48
  const groups = defaultizedProps.groups;
61
- const drawingArea = useDrawingArea();
62
- const {
63
- left,
64
- top,
65
- width,
66
- height
67
- } = drawingArea;
68
49
  const {
69
50
  instance
70
51
  } = useChartContext();
71
- const labelRefPoint = {
72
- x: left + width / 2,
73
- y: positionSign * axisHeight
74
- };
75
52
  const xTicks = useTicksGrouped({
76
53
  scale: xScale,
77
54
  tickNumber,
@@ -82,23 +59,8 @@ function ChartsGroupedXAxis(inProps) {
82
59
  direction: 'x',
83
60
  groups
84
61
  });
85
-
86
- // Skip axis rendering if no data is available
87
- // - The domain is an empty array for band/point scales.
88
- // - The domains contains Infinity for continuous scales.
89
- // - The position is set to 'none'.
90
- if (skipAxisRendering) {
91
- return null;
92
- }
93
- return /*#__PURE__*/_jsxs(XAxisRoot, {
94
- transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
95
- className: classes.root,
96
- sx: sx,
97
- children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
98
- x1: left,
99
- x2: left + width,
100
- className: classes.line
101
- }, slotProps?.axisLine)), xTicks.map((item, index) => {
62
+ return /*#__PURE__*/_jsx(React.Fragment, {
63
+ children: xTicks.map((item, index) => {
102
64
  const {
103
65
  offset: tickOffset,
104
66
  labelOffset
@@ -126,12 +88,7 @@ function ChartsGroupedXAxis(inProps) {
126
88
  text: tickLabel
127
89
  }))]
128
90
  }, index);
129
- }), label && /*#__PURE__*/_jsx("g", {
130
- className: classes.label,
131
- children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
132
- text: label
133
- }))
134
- })]
91
+ })
135
92
  });
136
93
  }
137
- export { ChartsGroupedXAxis };
94
+ export { ChartsGroupedXAxisTicks };
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ChartsXAxisProps } from "../models/axis.js";
3
+ interface ChartsSingleXAxisProps extends ChartsXAxisProps {
4
+ axisLabelHeight: number;
5
+ }
6
+ /**
7
+ * @ignore - internal component.
8
+ */
9
+ declare function ChartsSingleXAxisTicks(inProps: ChartsSingleXAxisProps): React.JSX.Element;
10
+ export { ChartsSingleXAxisTicks };
@@ -2,44 +2,39 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
+ import { useRtl } from '@mui/system/RtlProvider';
5
6
  import { useIsHydrated } from "../hooks/useIsHydrated.js";
6
- import { getStringSize } from "../internals/domUtils.js";
7
7
  import { useTicks } from "../hooks/useTicks.js";
8
8
  import { useMounted } from "../hooks/useMounted.js";
9
9
  import { useDrawingArea } from "../hooks/useDrawingArea.js";
10
10
  import { useChartContext } from "../context/ChartProvider/useChartContext.js";
11
11
  import { shortenLabels } from "./shortenLabels.js";
12
12
  import { getVisibleLabels } from "./getVisibleLabels.js";
13
- import { AXIS_LABEL_TICK_LABEL_GAP, TICK_LABEL_GAP, XAxisRoot } from "./utilities.js";
14
- import { useAxisProps } from "./useAxisProps.js";
15
-
13
+ import { AXIS_LABEL_TICK_LABEL_GAP, TICK_LABEL_GAP } from "./utilities.js";
14
+ import { useAxisTicksProps } from "./useAxisTicksProps.js";
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  /**
17
17
  * @ignore - internal component.
18
18
  */
19
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
- function ChartsSingleXAxis(inProps) {
19
+ function ChartsSingleXAxisTicks(inProps) {
20
+ const {
21
+ axisLabelHeight
22
+ } = inProps;
21
23
  const {
22
24
  xScale,
23
25
  defaultizedProps,
24
26
  tickNumber,
25
27
  positionSign,
26
- skipAxisRendering,
27
28
  classes,
28
- Line,
29
29
  Tick,
30
30
  TickLabel,
31
- Label,
32
31
  axisTickLabelProps,
33
- axisLabelProps,
34
- reverse,
35
- isRtl
36
- } = useAxisProps(inProps);
32
+ reverse
33
+ } = useAxisTicksProps(inProps);
34
+ const isRtl = useRtl();
37
35
  const isMounted = useMounted();
38
36
  const {
39
- position,
40
- disableLine,
41
37
  disableTicks,
42
- label,
43
38
  tickSize: tickSizeProp,
44
39
  valueFormatter,
45
40
  slotProps,
@@ -48,17 +43,9 @@ function ChartsSingleXAxis(inProps) {
48
43
  tickPlacement,
49
44
  tickLabelPlacement,
50
45
  tickLabelMinGap,
51
- sx,
52
- offset,
53
46
  height: axisHeight
54
47
  } = defaultizedProps;
55
48
  const drawingArea = useDrawingArea();
56
- const {
57
- left,
58
- top,
59
- width,
60
- height
61
- } = drawingArea;
62
49
  const {
63
50
  instance
64
51
  } = useChartContext();
@@ -82,31 +69,11 @@ function ChartsSingleXAxis(inProps) {
82
69
  isXInside: instance.isXInside
83
70
  });
84
71
 
85
- // Skip axis rendering if no data is available
86
- // - The domain is an empty array for band/point scales.
87
- // - The domains contains Infinity for continuous scales.
88
- // - The position is set to 'none'.
89
- if (skipAxisRendering) {
90
- return null;
91
- }
92
- const labelHeight = label ? getStringSize(label, axisLabelProps.style).height : 0;
93
- const labelRefPoint = {
94
- x: left + width / 2,
95
- y: positionSign * axisHeight
96
- };
97
-
98
72
  /* If there's an axis title, the tick labels have less space to render */
99
- const tickLabelsMaxHeight = Math.max(0, axisHeight - (label ? labelHeight + AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - TICK_LABEL_GAP);
73
+ const tickLabelsMaxHeight = Math.max(0, axisHeight - (axisLabelHeight > 0 ? axisLabelHeight + AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - TICK_LABEL_GAP);
100
74
  const tickLabels = isHydrated ? shortenLabels(visibleLabels, drawingArea, tickLabelsMaxHeight, isRtl, axisTickLabelProps.style) : new Map(Array.from(visibleLabels).map(item => [item, item.formattedValue]));
101
- return /*#__PURE__*/_jsxs(XAxisRoot, {
102
- transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
103
- className: classes.root,
104
- sx: sx,
105
- children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
106
- x1: left,
107
- x2: left + width,
108
- className: classes.line
109
- }, slotProps?.axisLine)), xTicks.map((item, index) => {
75
+ return /*#__PURE__*/_jsx(React.Fragment, {
76
+ children: xTicks.map((item, index) => {
110
77
  const {
111
78
  offset: tickOffset,
112
79
  labelOffset
@@ -129,12 +96,7 @@ function ChartsSingleXAxis(inProps) {
129
96
  text: tickLabel
130
97
  }))]
131
98
  }, index);
132
- }), label && /*#__PURE__*/_jsx("g", {
133
- className: classes.label,
134
- children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
135
- text: label
136
- }))
137
- })]
99
+ })
138
100
  });
139
101
  }
140
- export { ChartsSingleXAxis };
102
+ export { ChartsSingleXAxisTicks };
@@ -9,7 +9,7 @@ import { ChartsXAxisProps } from "../models/axis.js";
9
9
  *
10
10
  * - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
11
11
  */
12
- declare function ChartsXAxis(inProps: ChartsXAxisProps): React.JSX.Element;
12
+ declare function ChartsXAxis(inProps: ChartsXAxisProps): React.JSX.Element | null;
13
13
  declare namespace ChartsXAxis {
14
14
  var propTypes: any;
15
15
  }
@@ -3,9 +3,9 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import { warnOnce } from '@mui/x-internals/warning';
6
7
  import { useXAxes } from "../hooks/useAxis.js";
7
- import { ChartsSingleXAxis } from "./ChartsSingleXAxis.js";
8
- import { ChartsGroupedXAxis } from "./ChartsGroupedXAxis.js";
8
+ import { ChartsXAxisImpl } from "./ChartsXAxisImpl.js";
9
9
 
10
10
  /**
11
11
  * Demos:
@@ -23,10 +23,13 @@ function ChartsXAxis(inProps) {
23
23
  xAxisIds
24
24
  } = useXAxes();
25
25
  const axis = xAxis[inProps.axisId ?? xAxisIds[0]];
26
- if ('groups' in axis && Array.isArray(axis.groups)) {
27
- return /*#__PURE__*/_jsx(ChartsGroupedXAxis, _extends({}, inProps));
26
+ if (!axis) {
27
+ warnOnce(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
28
+ return null;
28
29
  }
29
- return /*#__PURE__*/_jsx(ChartsSingleXAxis, _extends({}, inProps));
30
+ return /*#__PURE__*/_jsx(ChartsXAxisImpl, _extends({}, inProps, {
31
+ axis: axis
32
+ }));
30
33
  }
31
34
  process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
32
35
  // ----------------------------- Warning --------------------------------
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { AxisScaleConfig, ChartsXAxisProps, ComputedAxis } from "../models/axis.js";
3
+ interface ChartsXAxisImplProps extends Omit<ChartsXAxisProps, 'axis'> {
4
+ axis: ComputedAxis<keyof AxisScaleConfig, any, ChartsXAxisProps>;
5
+ }
6
+ /**
7
+ * @ignore - internal component. Use `ChartsXAxis` instead.
8
+ */
9
+ export declare function ChartsXAxisImpl({
10
+ axis,
11
+ ...inProps
12
+ }: ChartsXAxisImplProps): React.JSX.Element | null;
13
+ export {};
@@ -0,0 +1,110 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["axis"],
6
+ _excluded2 = ["scale", "tickNumber", "reverse"];
7
+ import * as React from 'react';
8
+ import useSlotProps from '@mui/utils/useSlotProps';
9
+ import { styled, useTheme, useThemeProps } from '@mui/material/styles';
10
+ import { ChartsSingleXAxisTicks } from "./ChartsSingleXAxisTicks.js";
11
+ import { ChartsGroupedXAxisTicks } from "./ChartsGroupedXAxisTicks.js";
12
+ import { ChartsText } from "../ChartsText/index.js";
13
+ import { isBandScale } from "../internals/isBandScale.js";
14
+ import { isInfinity } from "../internals/isInfinity.js";
15
+ import { defaultProps, useUtilityClasses } from "./utilities.js";
16
+ import { useDrawingArea } from "../hooks/index.js";
17
+ import { getStringSize } from "../internals/domUtils.js";
18
+ import { AxisRoot } from "../internals/components/AxisSharedComponents.js";
19
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
+ const XAxisRoot = styled(AxisRoot, {
21
+ name: 'MuiChartsXAxis',
22
+ slot: 'Root'
23
+ })({});
24
+ /**
25
+ * @ignore - internal component. Use `ChartsXAxis` instead.
26
+ */
27
+ export function ChartsXAxisImpl(_ref) {
28
+ let {
29
+ axis
30
+ } = _ref,
31
+ inProps = _objectWithoutPropertiesLoose(_ref, _excluded);
32
+ const {
33
+ scale: xScale
34
+ } = axis,
35
+ settings = _objectWithoutPropertiesLoose(axis, _excluded2);
36
+
37
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
38
+ const themedProps = useThemeProps({
39
+ props: _extends({}, settings, inProps),
40
+ name: 'MuiChartsXAxis'
41
+ });
42
+ const defaultizedProps = _extends({}, defaultProps, themedProps);
43
+ const {
44
+ position,
45
+ labelStyle,
46
+ offset,
47
+ slots,
48
+ slotProps,
49
+ sx,
50
+ disableLine,
51
+ label,
52
+ height: axisHeight
53
+ } = defaultizedProps;
54
+ const theme = useTheme();
55
+ const classes = useUtilityClasses(defaultizedProps);
56
+ const {
57
+ left,
58
+ top,
59
+ width,
60
+ height
61
+ } = useDrawingArea();
62
+ const positionSign = position === 'bottom' ? 1 : -1;
63
+ const Line = slots?.axisLine ?? 'line';
64
+ const Label = slots?.axisLabel ?? ChartsText;
65
+ const axisLabelProps = useSlotProps({
66
+ elementType: Label,
67
+ externalSlotProps: slotProps?.axisLabel,
68
+ additionalProps: {
69
+ style: _extends({}, theme.typography.body1, {
70
+ lineHeight: 1,
71
+ fontSize: 14,
72
+ textAnchor: 'middle',
73
+ dominantBaseline: position === 'bottom' ? 'text-after-edge' : 'text-before-edge'
74
+ }, labelStyle)
75
+ },
76
+ ownerState: {}
77
+ });
78
+ if (position === 'none') {
79
+ return null;
80
+ }
81
+ const labelHeight = label ? getStringSize(label, axisLabelProps.style).height : 0;
82
+ const domain = xScale.domain();
83
+ const isScaleBand = isBandScale(xScale);
84
+ const skipTickRendering = isScaleBand && domain.length === 0 || !isScaleBand && domain.some(isInfinity);
85
+ let children = null;
86
+ if (!skipTickRendering) {
87
+ children = 'groups' in axis && Array.isArray(axis.groups) ? /*#__PURE__*/_jsx(ChartsGroupedXAxisTicks, _extends({}, inProps)) : /*#__PURE__*/_jsx(ChartsSingleXAxisTicks, _extends({}, inProps, {
88
+ axisLabelHeight: labelHeight
89
+ }));
90
+ }
91
+ const labelRefPoint = {
92
+ x: left + width / 2,
93
+ y: positionSign * axisHeight
94
+ };
95
+ return /*#__PURE__*/_jsxs(XAxisRoot, {
96
+ transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
97
+ className: classes.root,
98
+ sx: sx,
99
+ children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
100
+ x1: left,
101
+ x2: left + width,
102
+ className: classes.line
103
+ }, slotProps?.axisLine)), children, label && /*#__PURE__*/_jsx("g", {
104
+ className: classes.label,
105
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
106
+ text: label
107
+ }))
108
+ })]
109
+ });
110
+ }