@mui/x-charts 8.11.1 → 8.11.3

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 (141) hide show
  1. package/BarChart/index.d.ts +1 -0
  2. package/BarChart/useBarChartProps.js +4 -3
  3. package/CHANGELOG.md +181 -0
  4. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
  5. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
  6. package/ChartsLegend/ChartsLegend.js +2 -1
  7. package/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
  8. package/ChartsLegend/PiecewiseColorLegend.js +32 -22
  9. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
  10. package/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
  11. package/ChartsSurface/ChartsSurface.js +2 -1
  12. package/ChartsWrapper/ChartsWrapper.d.ts +4 -0
  13. package/ChartsWrapper/ChartsWrapper.js +73 -25
  14. package/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
  15. package/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +11 -54
  16. package/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
  17. package/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +15 -51
  18. package/ChartsXAxis/ChartsXAxis.js +4 -6
  19. package/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
  20. package/ChartsXAxis/ChartsXAxisImpl.js +117 -0
  21. package/ChartsXAxis/getVisibleLabels.js +5 -1
  22. package/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -496
  23. package/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -31
  24. package/ChartsXAxis/utilities.d.ts +1 -2
  25. package/ChartsXAxis/utilities.js +1 -7
  26. package/{esm/ChartsYAxis/ChartsGroupedYAxis.d.ts → ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
  27. package/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +11 -54
  28. package/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
  29. package/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +15 -50
  30. package/ChartsYAxis/ChartsYAxis.js +6 -8
  31. package/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
  32. package/ChartsYAxis/ChartsYAxisImpl.js +133 -0
  33. package/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -504
  34. package/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +5 -44
  35. package/ChartsYAxis/utilities.d.ts +0 -1
  36. package/ChartsYAxis/utilities.js +1 -7
  37. package/LineChart/useAreaPlotData.js +2 -2
  38. package/LineChart/useLineChartProps.js +2 -1
  39. package/LineChart/useLinePlotData.js +2 -2
  40. package/PieChart/PieChart.js +1 -0
  41. package/RadarChart/RadarAxis/useRadarAxis.js +2 -2
  42. package/RadarChart/useRadarChartProps.js +2 -1
  43. package/ScatterChart/useScatterChartProps.js +2 -1
  44. package/Toolbar/Toolbar.js +2 -1
  45. package/esm/BarChart/index.d.ts +1 -0
  46. package/esm/BarChart/useBarChartProps.js +4 -3
  47. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
  48. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
  49. package/esm/ChartsLegend/ChartsLegend.js +2 -1
  50. package/esm/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
  51. package/esm/ChartsLegend/PiecewiseColorLegend.js +32 -22
  52. package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
  53. package/esm/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
  54. package/esm/ChartsSurface/ChartsSurface.js +2 -1
  55. package/esm/ChartsWrapper/ChartsWrapper.d.ts +4 -0
  56. package/esm/ChartsWrapper/ChartsWrapper.js +73 -25
  57. package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
  58. package/esm/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +12 -55
  59. package/esm/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
  60. package/esm/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +16 -54
  61. package/esm/ChartsXAxis/ChartsXAxis.js +4 -6
  62. package/esm/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
  63. package/esm/ChartsXAxis/ChartsXAxisImpl.js +110 -0
  64. package/esm/ChartsXAxis/getVisibleLabels.js +5 -1
  65. package/esm/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -496
  66. package/esm/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +3 -29
  67. package/esm/ChartsXAxis/utilities.d.ts +1 -2
  68. package/esm/ChartsXAxis/utilities.js +0 -6
  69. package/{ChartsYAxis/ChartsGroupedYAxis.d.ts → esm/ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
  70. package/esm/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +12 -55
  71. package/esm/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
  72. package/esm/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +16 -53
  73. package/esm/ChartsYAxis/ChartsYAxis.js +5 -7
  74. package/esm/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
  75. package/esm/ChartsYAxis/ChartsYAxisImpl.js +126 -0
  76. package/esm/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -504
  77. package/esm/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -42
  78. package/esm/ChartsYAxis/utilities.d.ts +0 -1
  79. package/esm/ChartsYAxis/utilities.js +0 -6
  80. package/esm/LineChart/useAreaPlotData.js +2 -2
  81. package/esm/LineChart/useLineChartProps.js +2 -1
  82. package/esm/LineChart/useLinePlotData.js +2 -2
  83. package/esm/PieChart/PieChart.js +1 -0
  84. package/esm/RadarChart/RadarAxis/useRadarAxis.js +2 -2
  85. package/esm/RadarChart/useRadarChartProps.js +2 -1
  86. package/esm/ScatterChart/useScatterChartProps.js +2 -1
  87. package/esm/Toolbar/Toolbar.js +2 -1
  88. package/esm/hooks/useInteractionItemProps.js +5 -4
  89. package/esm/hooks/useScale.js +2 -2
  90. package/esm/hooks/useTicks.js +10 -3
  91. package/esm/hooks/useTicksGrouped.js +2 -2
  92. package/esm/index.js +1 -1
  93. package/esm/internals/dateHelpers.d.ts +4 -2
  94. package/esm/internals/dateHelpers.js +5 -4
  95. package/esm/internals/defaultValueFormatters.js +5 -0
  96. package/esm/internals/index.d.ts +1 -1
  97. package/esm/internals/index.js +1 -1
  98. package/esm/internals/invertScale.js +2 -2
  99. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
  100. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
  101. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  102. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
  103. package/esm/internals/scaleGuards.d.ts +4 -0
  104. package/esm/internals/scaleGuards.js +3 -0
  105. package/esm/locales/index.d.ts +2 -1
  106. package/esm/locales/index.js +1 -0
  107. package/esm/locales/svSE.d.ts +19 -0
  108. package/esm/locales/svSE.js +15 -0
  109. package/esm/models/axis.d.ts +3 -0
  110. package/hooks/useInteractionItemProps.js +6 -4
  111. package/hooks/useScale.js +2 -2
  112. package/hooks/useTicks.js +10 -3
  113. package/hooks/useTicksGrouped.js +2 -2
  114. package/index.js +1 -1
  115. package/internals/dateHelpers.d.ts +4 -2
  116. package/internals/dateHelpers.js +5 -4
  117. package/internals/defaultValueFormatters.js +5 -0
  118. package/internals/index.d.ts +1 -1
  119. package/internals/index.js +4 -4
  120. package/internals/invertScale.js +2 -2
  121. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
  122. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
  123. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  124. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
  125. package/internals/scaleGuards.d.ts +4 -0
  126. package/internals/{isBandScale.js → scaleGuards.js} +2 -2
  127. package/locales/index.d.ts +2 -1
  128. package/locales/index.js +11 -0
  129. package/locales/svSE.d.ts +19 -0
  130. package/locales/svSE.js +21 -0
  131. package/models/axis.d.ts +3 -0
  132. package/package.json +5 -5
  133. package/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
  134. package/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
  135. package/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
  136. package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
  137. package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
  138. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
  139. package/esm/internals/isBandScale.d.ts +0 -5
  140. package/esm/internals/isBandScale.js +0 -3
  141. package/internals/isBandScale.d.ts +0 -5
@@ -6,15 +6,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.ChartsGroupedXAxis = ChartsGroupedXAxis;
9
+ exports.ChartsGroupedXAxisTicks = ChartsGroupedXAxisTicks;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
- var _useDrawingArea = require("../hooks/useDrawingArea");
13
- var _isBandScale = require("../internals/isBandScale");
12
+ var _scaleGuards = require("../internals/scaleGuards");
14
13
  var _useChartContext = require("../context/ChartProvider/useChartContext");
15
14
  var _utilities = require("./utilities");
16
15
  var _useTicksGrouped = require("../hooks/useTicksGrouped");
17
- var _useAxisProps = require("./useAxisProps");
16
+ var _useAxisTicksProps = require("./useAxisTicksProps");
18
17
  var _jsxRuntime = require("react/jsx-runtime");
19
18
  const DEFAULT_GROUPING_CONFIG = {
20
19
  tickSize: 6
@@ -27,58 +26,36 @@ const getGroupingConfig = (groups, groupIndex, tickSize) => {
27
26
  tickSize: config.tickSize ?? calculatedTickSize
28
27
  });
29
28
  };
30
-
31
29
  /**
32
30
  * @ignore - internal component.
33
31
  */
34
- function ChartsGroupedXAxis(inProps) {
32
+ function ChartsGroupedXAxisTicks(inProps) {
35
33
  const {
36
34
  xScale,
37
35
  defaultizedProps,
38
36
  tickNumber,
39
37
  positionSign,
40
- skipAxisRendering,
41
38
  classes,
42
- Line,
43
39
  Tick,
44
40
  TickLabel,
45
- Label,
46
- axisTickLabelProps,
47
- axisLabelProps
48
- } = (0, _useAxisProps.useAxisProps)(inProps);
49
- if (!(0, _isBandScale.isBandScale)(xScale)) {
41
+ axisTickLabelProps
42
+ } = (0, _useAxisTicksProps.useAxisTicksProps)(inProps);
43
+ if (!(0, _scaleGuards.isOrdinalScale)(xScale)) {
50
44
  throw new Error('MUI X Charts: ChartsGroupedXAxis only supports the `band` and `point` scale types.');
51
45
  }
52
46
  const {
53
- position,
54
- disableLine,
55
47
  disableTicks,
56
- label,
57
48
  tickSize,
58
49
  valueFormatter,
59
50
  slotProps,
60
51
  tickInterval,
61
52
  tickPlacement,
62
- tickLabelPlacement,
63
- sx,
64
- offset,
65
- height: axisHeight
53
+ tickLabelPlacement
66
54
  } = defaultizedProps;
67
55
  const groups = defaultizedProps.groups;
68
- const drawingArea = (0, _useDrawingArea.useDrawingArea)();
69
- const {
70
- left,
71
- top,
72
- width,
73
- height
74
- } = drawingArea;
75
56
  const {
76
57
  instance
77
58
  } = (0, _useChartContext.useChartContext)();
78
- const labelRefPoint = {
79
- x: left + width / 2,
80
- y: positionSign * axisHeight
81
- };
82
59
  const xTicks = (0, _useTicksGrouped.useTicksGrouped)({
83
60
  scale: xScale,
84
61
  tickNumber,
@@ -89,23 +66,8 @@ function ChartsGroupedXAxis(inProps) {
89
66
  direction: 'x',
90
67
  groups
91
68
  });
92
-
93
- // Skip axis rendering if no data is available
94
- // - The domain is an empty array for band/point scales.
95
- // - The domains contains Infinity for continuous scales.
96
- // - The position is set to 'none'.
97
- if (skipAxisRendering) {
98
- return null;
99
- }
100
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_utilities.XAxisRoot, {
101
- transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
102
- className: classes.root,
103
- sx: sx,
104
- children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
105
- x1: left,
106
- x2: left + width,
107
- className: classes.line
108
- }, slotProps?.axisLine)), xTicks.map((item, index) => {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
70
+ children: xTicks.map((item, index) => {
109
71
  const {
110
72
  offset: tickOffset,
111
73
  labelOffset
@@ -133,11 +95,6 @@ function ChartsGroupedXAxis(inProps) {
133
95
  text: tickLabel
134
96
  }))]
135
97
  }, index);
136
- }), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
137
- className: classes.label,
138
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
139
- text: label
140
- }))
141
- })]
98
+ })
142
99
  });
143
100
  }
@@ -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 };
@@ -6,11 +6,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.ChartsSingleXAxis = ChartsSingleXAxis;
9
+ exports.ChartsSingleXAxisTicks = ChartsSingleXAxisTicks;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
+ var _RtlProvider = require("@mui/system/RtlProvider");
12
13
  var _useIsHydrated = require("../hooks/useIsHydrated");
13
- var _domUtils = require("../internals/domUtils");
14
14
  var _useTicks = require("../hooks/useTicks");
15
15
  var _useMounted = require("../hooks/useMounted");
16
16
  var _useDrawingArea = require("../hooks/useDrawingArea");
@@ -18,33 +18,30 @@ var _useChartContext = require("../context/ChartProvider/useChartContext");
18
18
  var _shortenLabels = require("./shortenLabels");
19
19
  var _getVisibleLabels = require("./getVisibleLabels");
20
20
  var _utilities = require("./utilities");
21
- var _useAxisProps = require("./useAxisProps");
21
+ var _useAxisTicksProps = require("./useAxisTicksProps");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
  /**
24
24
  * @ignore - internal component.
25
- */function ChartsSingleXAxis(inProps) {
25
+ */
26
+ function ChartsSingleXAxisTicks(inProps) {
27
+ const {
28
+ axisLabelHeight
29
+ } = inProps;
26
30
  const {
27
31
  xScale,
28
32
  defaultizedProps,
29
33
  tickNumber,
30
34
  positionSign,
31
- skipAxisRendering,
32
35
  classes,
33
- Line,
34
36
  Tick,
35
37
  TickLabel,
36
- Label,
37
38
  axisTickLabelProps,
38
- axisLabelProps,
39
- reverse,
40
- isRtl
41
- } = (0, _useAxisProps.useAxisProps)(inProps);
39
+ reverse
40
+ } = (0, _useAxisTicksProps.useAxisTicksProps)(inProps);
41
+ const isRtl = (0, _RtlProvider.useRtl)();
42
42
  const isMounted = (0, _useMounted.useMounted)();
43
43
  const {
44
- position,
45
- disableLine,
46
44
  disableTicks,
47
- label,
48
45
  tickSize: tickSizeProp,
49
46
  valueFormatter,
50
47
  slotProps,
@@ -53,17 +50,9 @@ var _jsxRuntime = require("react/jsx-runtime");
53
50
  tickPlacement,
54
51
  tickLabelPlacement,
55
52
  tickLabelMinGap,
56
- sx,
57
- offset,
58
53
  height: axisHeight
59
54
  } = defaultizedProps;
60
55
  const drawingArea = (0, _useDrawingArea.useDrawingArea)();
61
- const {
62
- left,
63
- top,
64
- width,
65
- height
66
- } = drawingArea;
67
56
  const {
68
57
  instance
69
58
  } = (0, _useChartContext.useChartContext)();
@@ -87,31 +76,11 @@ var _jsxRuntime = require("react/jsx-runtime");
87
76
  isXInside: instance.isXInside
88
77
  });
89
78
 
90
- // Skip axis rendering if no data is available
91
- // - The domain is an empty array for band/point scales.
92
- // - The domains contains Infinity for continuous scales.
93
- // - The position is set to 'none'.
94
- if (skipAxisRendering) {
95
- return null;
96
- }
97
- const labelHeight = label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height : 0;
98
- const labelRefPoint = {
99
- x: left + width / 2,
100
- y: positionSign * axisHeight
101
- };
102
-
103
79
  /* If there's an axis title, the tick labels have less space to render */
104
- const tickLabelsMaxHeight = Math.max(0, axisHeight - (label ? labelHeight + _utilities.AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - _utilities.TICK_LABEL_GAP);
80
+ const tickLabelsMaxHeight = Math.max(0, axisHeight - (axisLabelHeight > 0 ? axisLabelHeight + _utilities.AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - _utilities.TICK_LABEL_GAP);
105
81
  const tickLabels = isHydrated ? (0, _shortenLabels.shortenLabels)(visibleLabels, drawingArea, tickLabelsMaxHeight, isRtl, axisTickLabelProps.style) : new Map(Array.from(visibleLabels).map(item => [item, item.formattedValue]));
106
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_utilities.XAxisRoot, {
107
- transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
108
- className: classes.root,
109
- sx: sx,
110
- children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
111
- x1: left,
112
- x2: left + width,
113
- className: classes.line
114
- }, slotProps?.axisLine)), xTicks.map((item, index) => {
82
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
83
+ children: xTicks.map((item, index) => {
115
84
  const {
116
85
  offset: tickOffset,
117
86
  labelOffset
@@ -134,11 +103,6 @@ var _jsxRuntime = require("react/jsx-runtime");
134
103
  text: tickLabel
135
104
  }))]
136
105
  }, index);
137
- }), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
138
- className: classes.label,
139
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
140
- text: label
141
- }))
142
- })]
106
+ })
143
107
  });
144
108
  }
@@ -12,8 +12,7 @@ var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _warning = require("@mui/x-internals/warning");
14
14
  var _useAxis = require("../hooks/useAxis");
15
- var _ChartsSingleXAxis = require("./ChartsSingleXAxis");
16
- var _ChartsGroupedXAxis = require("./ChartsGroupedXAxis");
15
+ var _ChartsXAxisImpl = require("./ChartsXAxisImpl");
17
16
  var _jsxRuntime = require("react/jsx-runtime");
18
17
  /**
19
18
  * Demos:
@@ -33,10 +32,9 @@ var _jsxRuntime = require("react/jsx-runtime");
33
32
  (0, _warning.warnOnce)(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
34
33
  return null;
35
34
  }
36
- if ('groups' in axis && Array.isArray(axis.groups)) {
37
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGroupedXAxis.ChartsGroupedXAxis, (0, _extends2.default)({}, inProps));
38
- }
39
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleXAxis.ChartsSingleXAxis, (0, _extends2.default)({}, inProps));
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXAxisImpl.ChartsXAxisImpl, (0, _extends2.default)({}, inProps, {
36
+ axis: axis
37
+ }));
40
38
  }
41
39
  process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
42
40
  // ----------------------------- 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,117 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsXAxisImpl = ChartsXAxisImpl;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _ChartsSingleXAxisTicks = require("./ChartsSingleXAxisTicks");
16
+ var _ChartsGroupedXAxisTicks = require("./ChartsGroupedXAxisTicks");
17
+ var _ChartsText = require("../ChartsText");
18
+ var _scaleGuards = require("../internals/scaleGuards");
19
+ var _isInfinity = require("../internals/isInfinity");
20
+ var _utilities = require("./utilities");
21
+ var _hooks = require("../hooks");
22
+ var _domUtils = require("../internals/domUtils");
23
+ var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+ const _excluded = ["axis"],
26
+ _excluded2 = ["scale", "tickNumber", "reverse"];
27
+ const XAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
28
+ name: 'MuiChartsXAxis',
29
+ slot: 'Root'
30
+ })({});
31
+ /**
32
+ * @ignore - internal component. Use `ChartsXAxis` instead.
33
+ */
34
+ function ChartsXAxisImpl(_ref) {
35
+ let {
36
+ axis
37
+ } = _ref,
38
+ inProps = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
39
+ const {
40
+ scale: xScale
41
+ } = axis,
42
+ settings = (0, _objectWithoutPropertiesLoose2.default)(axis, _excluded2);
43
+
44
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
45
+ const themedProps = (0, _styles.useThemeProps)({
46
+ props: (0, _extends2.default)({}, settings, inProps),
47
+ name: 'MuiChartsXAxis'
48
+ });
49
+ const defaultizedProps = (0, _extends2.default)({}, _utilities.defaultProps, themedProps);
50
+ const {
51
+ position,
52
+ labelStyle,
53
+ offset,
54
+ slots,
55
+ slotProps,
56
+ sx,
57
+ disableLine,
58
+ label,
59
+ height: axisHeight
60
+ } = defaultizedProps;
61
+ const theme = (0, _styles.useTheme)();
62
+ const classes = (0, _utilities.useUtilityClasses)(defaultizedProps);
63
+ const {
64
+ left,
65
+ top,
66
+ width,
67
+ height
68
+ } = (0, _hooks.useDrawingArea)();
69
+ const positionSign = position === 'bottom' ? 1 : -1;
70
+ const Line = slots?.axisLine ?? 'line';
71
+ const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
72
+ const axisLabelProps = (0, _useSlotProps.default)({
73
+ elementType: Label,
74
+ externalSlotProps: slotProps?.axisLabel,
75
+ additionalProps: {
76
+ style: (0, _extends2.default)({}, theme.typography.body1, {
77
+ lineHeight: 1,
78
+ fontSize: 14,
79
+ textAnchor: 'middle',
80
+ dominantBaseline: position === 'bottom' ? 'text-after-edge' : 'text-before-edge'
81
+ }, labelStyle)
82
+ },
83
+ ownerState: {}
84
+ });
85
+ if (position === 'none') {
86
+ return null;
87
+ }
88
+ const labelHeight = label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height : 0;
89
+ const domain = xScale.domain();
90
+ const isScaleOrdinal = (0, _scaleGuards.isOrdinalScale)(xScale);
91
+ const skipTickRendering = isScaleOrdinal ? domain.length === 0 : domain.some(_isInfinity.isInfinity);
92
+ let children = null;
93
+ if (!skipTickRendering) {
94
+ children = 'groups' in axis && Array.isArray(axis.groups) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGroupedXAxisTicks.ChartsGroupedXAxisTicks, (0, _extends2.default)({}, inProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleXAxisTicks.ChartsSingleXAxisTicks, (0, _extends2.default)({}, inProps, {
95
+ axisLabelHeight: labelHeight
96
+ }));
97
+ }
98
+ const labelRefPoint = {
99
+ x: left + width / 2,
100
+ y: positionSign * axisHeight
101
+ };
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(XAxisRoot, {
103
+ transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
104
+ className: classes.root,
105
+ sx: sx,
106
+ children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
107
+ x1: left,
108
+ x2: left + width,
109
+ className: classes.line
110
+ }, slotProps?.axisLine)), children, label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
111
+ className: classes.label,
112
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
113
+ text: label
114
+ }))
115
+ })]
116
+ });
117
+ }
@@ -43,8 +43,12 @@ function getVisibleLabels(xTicks, {
43
43
  return new Set(xTicks.filter((item, labelIndex) => {
44
44
  const {
45
45
  offset,
46
- labelOffset
46
+ labelOffset,
47
+ formattedValue
47
48
  } = item;
49
+ if (formattedValue === '') {
50
+ return false;
51
+ }
48
52
  const textPosition = offset + labelOffset;
49
53
  if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
50
54
  return false;