@mui/x-charts 8.10.0 → 8.10.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 (76) hide show
  1. package/BarChart/BarChart.js +4 -0
  2. package/CHANGELOG.md +182 -0
  3. package/ChartContainer/ChartContainer.js +6 -0
  4. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  5. package/ChartsLabel/labelGradientClasses.d.ts +1 -1
  6. package/ChartsLabel/labelMarkClasses.d.ts +1 -1
  7. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  8. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  9. package/ChartsTooltip/ChartsTooltipContainer.js +8 -2
  10. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  11. package/ChartsTooltip/ChartsTooltipTable.js +1 -0
  12. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  13. package/ChartsXAxis/ChartsGroupedXAxis.js +1 -0
  14. package/ChartsXAxis/useAxisProps.d.ts +9 -9
  15. package/ChartsXAxis/utilities.d.ts +1 -1
  16. package/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  17. package/ChartsYAxis/ChartsGroupedYAxis.js +144 -0
  18. package/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  19. package/ChartsYAxis/ChartsSingleYAxis.js +133 -0
  20. package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  21. package/ChartsYAxis/ChartsYAxis.js +12 -211
  22. package/ChartsYAxis/useAxisProps.d.ts +4452 -0
  23. package/ChartsYAxis/useAxisProps.js +115 -0
  24. package/ChartsYAxis/utilities.d.ts +10 -0
  25. package/ChartsYAxis/utilities.js +42 -0
  26. package/LineChart/LineChart.js +4 -0
  27. package/ScatterChart/ScatterChart.js +4 -0
  28. package/SparkLineChart/SparkLineChart.d.ts +15 -5
  29. package/SparkLineChart/SparkLineChart.js +61 -34
  30. package/esm/BarChart/BarChart.js +4 -0
  31. package/esm/ChartContainer/ChartContainer.js +6 -0
  32. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  33. package/esm/ChartsLabel/labelGradientClasses.d.ts +1 -1
  34. package/esm/ChartsLabel/labelMarkClasses.d.ts +1 -1
  35. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  36. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  37. package/esm/ChartsTooltip/ChartsTooltipContainer.js +8 -2
  38. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  39. package/esm/ChartsTooltip/ChartsTooltipTable.js +1 -0
  40. package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  41. package/esm/ChartsXAxis/ChartsGroupedXAxis.js +1 -0
  42. package/esm/ChartsXAxis/useAxisProps.d.ts +9 -9
  43. package/esm/ChartsXAxis/utilities.d.ts +1 -1
  44. package/esm/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  45. package/esm/ChartsYAxis/ChartsGroupedYAxis.js +138 -0
  46. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  47. package/esm/ChartsYAxis/ChartsSingleYAxis.js +129 -0
  48. package/esm/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  49. package/esm/ChartsYAxis/ChartsYAxis.js +10 -207
  50. package/esm/ChartsYAxis/useAxisProps.d.ts +4452 -0
  51. package/esm/ChartsYAxis/useAxisProps.js +108 -0
  52. package/esm/ChartsYAxis/utilities.d.ts +10 -0
  53. package/esm/ChartsYAxis/utilities.js +34 -0
  54. package/esm/LineChart/LineChart.js +4 -0
  55. package/esm/ScatterChart/ScatterChart.js +4 -0
  56. package/esm/SparkLineChart/SparkLineChart.d.ts +15 -5
  57. package/esm/SparkLineChart/SparkLineChart.js +61 -34
  58. package/esm/index.js +1 -1
  59. package/esm/internals/animation/Transition.js +2 -5
  60. package/esm/internals/configInit.js +2 -2
  61. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  62. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  63. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  64. package/esm/internals/plugins/utils/ChartStore.js +16 -18
  65. package/esm/models/axis.d.ts +31 -48
  66. package/esm/tests/web-components.js +2 -4
  67. package/index.js +1 -1
  68. package/internals/animation/Transition.js +2 -5
  69. package/internals/configInit.js +2 -2
  70. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  71. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  72. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  73. package/internals/plugins/utils/ChartStore.js +16 -18
  74. package/models/axis.d.ts +31 -48
  75. package/package.json +16 -17
  76. package/tests/web-components.js +2 -4
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsGroupedYAxis = ChartsGroupedYAxis;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _useDrawingArea = require("../hooks/useDrawingArea");
13
+ var _isBandScale = require("../internals/isBandScale");
14
+ var _useChartContext = require("../context/ChartProvider/useChartContext");
15
+ var _utilities = require("./utilities");
16
+ var _useTicksGrouped = require("../hooks/useTicksGrouped");
17
+ var _useAxisProps = require("./useAxisProps");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const DEFAULT_GROUPING_CONFIG = {
20
+ tickSize: 6
21
+ };
22
+ const getGroupingConfig = (groups, groupIndex, tickSize) => {
23
+ const config = groups[groupIndex] ?? {};
24
+ const defaultTickSize = tickSize ?? DEFAULT_GROUPING_CONFIG.tickSize;
25
+ const calculatedTickSize = defaultTickSize * groupIndex * 2 + defaultTickSize;
26
+ return (0, _extends2.default)({}, DEFAULT_GROUPING_CONFIG, config, {
27
+ tickSize: config.tickSize ?? calculatedTickSize
28
+ });
29
+ };
30
+
31
+ /**
32
+ * @ignore - internal component.
33
+ */
34
+ function ChartsGroupedYAxis(inProps) {
35
+ const {
36
+ yScale,
37
+ defaultizedProps,
38
+ tickNumber,
39
+ positionSign,
40
+ skipAxisRendering,
41
+ classes,
42
+ Line,
43
+ Tick,
44
+ TickLabel,
45
+ Label,
46
+ axisTickLabelProps,
47
+ axisLabelProps,
48
+ lineProps
49
+ } = (0, _useAxisProps.useAxisProps)(inProps);
50
+ if (!(0, _isBandScale.isBandScale)(yScale)) {
51
+ throw new Error('MUI X Charts: ChartsGroupedYAxis only supports the `band` and `point` scale types.');
52
+ }
53
+ const {
54
+ position,
55
+ disableLine,
56
+ disableTicks,
57
+ label,
58
+ tickSize,
59
+ valueFormatter,
60
+ slotProps,
61
+ tickInterval,
62
+ tickPlacement,
63
+ tickLabelPlacement,
64
+ sx,
65
+ offset,
66
+ width: axisWidth
67
+ } = defaultizedProps;
68
+ const groups = defaultizedProps.groups;
69
+ const drawingArea = (0, _useDrawingArea.useDrawingArea)();
70
+ const {
71
+ left,
72
+ top,
73
+ width,
74
+ height
75
+ } = drawingArea;
76
+ const {
77
+ instance
78
+ } = (0, _useChartContext.useChartContext)();
79
+ const labelRefPoint = {
80
+ x: positionSign * axisWidth,
81
+ y: top + height / 2
82
+ };
83
+ const yTicks = (0, _useTicksGrouped.useTicksGrouped)({
84
+ scale: yScale,
85
+ tickNumber,
86
+ valueFormatter,
87
+ tickInterval,
88
+ tickPlacement,
89
+ tickLabelPlacement,
90
+ direction: 'y',
91
+ groups
92
+ });
93
+
94
+ // Skip axis rendering if no data is available
95
+ // - The domain is an empty array for band/point scales.
96
+ // - The domains contains Infinity for continuous scales.
97
+ // - The position is set to 'none'.
98
+ if (skipAxisRendering) {
99
+ return null;
100
+ }
101
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_utilities.YAxisRoot, {
102
+ transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
103
+ className: classes.root,
104
+ sx: sx,
105
+ children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
106
+ y1: top,
107
+ y2: top + height,
108
+ className: classes.line
109
+ }, lineProps)), yTicks.map((item, index) => {
110
+ const {
111
+ offset: tickOffset,
112
+ labelOffset
113
+ } = item;
114
+ const yTickLabel = labelOffset ?? 0;
115
+ const showTick = instance.isYInside(tickOffset);
116
+ const tickLabel = item.formattedValue;
117
+ const ignoreTick = item.ignoreTick ?? false;
118
+ const groupIndex = item.groupIndex ?? 0;
119
+ const groupConfig = getGroupingConfig(groups, groupIndex, tickSize);
120
+ const tickXSize = positionSign * groupConfig.tickSize;
121
+ const labelPositionX = positionSign * (groupConfig.tickSize + _utilities.TICK_LABEL_GAP);
122
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
123
+ transform: `translate(0, ${tickOffset})`,
124
+ className: classes.tickContainer,
125
+ "data-group-index": groupIndex,
126
+ children: [!disableTicks && !ignoreTick && showTick && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
127
+ x2: tickXSize,
128
+ className: classes.tick
129
+ }, slotProps?.axisTick)), tickLabel !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
130
+ x: labelPositionX,
131
+ y: yTickLabel
132
+ }, axisTickLabelProps, {
133
+ style: (0, _extends2.default)({}, axisTickLabelProps.style, groupConfig.tickLabelStyle),
134
+ text: tickLabel
135
+ }))]
136
+ }, 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
+ })]
143
+ });
144
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { ChartsYAxisProps } from "../models/axis.js";
3
+ /**
4
+ * @ignore - internal component.
5
+ */
6
+ declare function ChartsSingleYAxis(inProps: ChartsYAxisProps): React.JSX.Element | null;
7
+ export { ChartsSingleYAxis };
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsSingleYAxis = ChartsSingleYAxis;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _useIsHydrated = require("../hooks/useIsHydrated");
13
+ var _domUtils = require("../internals/domUtils");
14
+ var _useTicks = require("../hooks/useTicks");
15
+ var _useDrawingArea = require("../hooks/useDrawingArea");
16
+ var _ChartProvider = require("../context/ChartProvider");
17
+ var _shortenLabels = require("./shortenLabels");
18
+ var _utilities = require("./utilities");
19
+ var _useAxisProps = require("./useAxisProps");
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+ /**
22
+ * @ignore - internal component.
23
+ */function ChartsSingleYAxis(inProps) {
24
+ const {
25
+ yScale,
26
+ defaultizedProps,
27
+ tickNumber,
28
+ positionSign,
29
+ skipAxisRendering,
30
+ classes,
31
+ Line,
32
+ Tick,
33
+ TickLabel,
34
+ Label,
35
+ axisTickLabelProps,
36
+ axisLabelProps,
37
+ lineProps,
38
+ isRtl
39
+ } = (0, _useAxisProps.useAxisProps)(inProps);
40
+ const {
41
+ position,
42
+ disableLine,
43
+ disableTicks,
44
+ label,
45
+ tickSize: tickSizeProp,
46
+ valueFormatter,
47
+ slotProps,
48
+ tickPlacement,
49
+ tickLabelPlacement,
50
+ tickInterval,
51
+ tickLabelInterval,
52
+ sx,
53
+ offset,
54
+ width: axisWidth
55
+ } = defaultizedProps;
56
+ const drawingArea = (0, _useDrawingArea.useDrawingArea)();
57
+ const {
58
+ left,
59
+ top,
60
+ width,
61
+ height
62
+ } = drawingArea;
63
+ const {
64
+ instance
65
+ } = (0, _ChartProvider.useChartContext)();
66
+ const isHydrated = (0, _useIsHydrated.useIsHydrated)();
67
+ const tickSize = disableTicks ? 4 : tickSizeProp;
68
+ const yTicks = (0, _useTicks.useTicks)({
69
+ scale: yScale,
70
+ tickNumber,
71
+ valueFormatter,
72
+ tickPlacement,
73
+ tickLabelPlacement,
74
+ tickInterval,
75
+ direction: 'y'
76
+ });
77
+
78
+ // Skip axis rendering if no data is available
79
+ // - The domain is an empty array for band/point scales.
80
+ // - The domains contains Infinity for continuous scales.
81
+ // - The position is set to 'none'.
82
+ if (skipAxisRendering) {
83
+ return null;
84
+ }
85
+ const labelRefPoint = {
86
+ x: positionSign * axisWidth,
87
+ y: top + height / 2
88
+ };
89
+ /* If there's an axis title, the tick labels have less space to render */
90
+ const tickLabelsMaxWidth = Math.max(0, axisWidth - (label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height + _utilities.AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - _utilities.TICK_LABEL_GAP);
91
+ const tickLabels = isHydrated ? (0, _shortenLabels.shortenLabels)(yTicks, drawingArea, tickLabelsMaxWidth, isRtl, axisTickLabelProps.style) : new Map(Array.from(yTicks).map(item => [item, item.formattedValue]));
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_utilities.YAxisRoot, {
93
+ transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
94
+ className: classes.root,
95
+ sx: sx,
96
+ children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
97
+ y1: top,
98
+ y2: top + height,
99
+ className: classes.line
100
+ }, lineProps)), yTicks.map((item, index) => {
101
+ const {
102
+ offset: tickOffset,
103
+ labelOffset,
104
+ value
105
+ } = item;
106
+ const xTickLabel = positionSign * (tickSize + _utilities.TICK_LABEL_GAP);
107
+ const yTickLabel = labelOffset;
108
+ const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
109
+ const showLabel = instance.isYInside(tickOffset);
110
+ const tickLabel = tickLabels.get(item);
111
+ if (!showLabel) {
112
+ return null;
113
+ }
114
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
115
+ transform: `translate(0, ${tickOffset})`,
116
+ className: classes.tickContainer,
117
+ children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
118
+ x2: positionSign * tickSize,
119
+ className: classes.tick
120
+ }, slotProps?.axisTick)), tickLabel !== undefined && !skipLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
121
+ x: xTickLabel,
122
+ y: yTickLabel,
123
+ text: tickLabel
124
+ }, axisTickLabelProps))]
125
+ }, index);
126
+ }), label && isHydrated && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
127
+ className: classes.label,
128
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
129
+ text: label
130
+ }))
131
+ })]
132
+ });
133
+ }
@@ -9,7 +9,7 @@ import { ChartsYAxisProps } from "../models/axis.js";
9
9
  *
10
10
  * - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
11
11
  */
12
- declare function ChartsYAxis(inProps: ChartsYAxisProps): React.JSX.Element | null;
12
+ declare function ChartsYAxis(inProps: ChartsYAxisProps): React.JSX.Element;
13
13
  declare namespace ChartsYAxis {
14
14
  var propTypes: any;
15
15
  }
@@ -1,67 +1,19 @@
1
1
  "use strict";
2
2
  'use client';
3
3
 
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.ChartsYAxis = ChartsYAxis;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
11
  var React = _interopRequireWildcard(require("react"));
13
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
- var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
15
- var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
16
- var _styles = require("@mui/material/styles");
17
- var _RtlProvider = require("@mui/system/RtlProvider");
18
- var _useIsHydrated = require("../hooks/useIsHydrated");
19
- var _defaultTextPlacement = require("../ChartsText/defaultTextPlacement");
20
- var _domUtils = require("../internals/domUtils");
21
- var _useTicks = require("../hooks/useTicks");
22
- var _useDrawingArea = require("../hooks/useDrawingArea");
23
- var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
24
- var _ChartsText = require("../ChartsText");
25
- var _axisClasses = require("../ChartsAxis/axisClasses");
26
- var _isInfinity = require("../internals/isInfinity");
27
- var _isBandScale = require("../internals/isBandScale");
28
- var _ChartProvider = require("../context/ChartProvider");
29
- var _hooks = require("../hooks");
30
- var _invertTextAnchor = require("../internals/invertTextAnchor");
31
- var _shortenLabels = require("./shortenLabels");
13
+ var _useAxis = require("../hooks/useAxis");
14
+ var _ChartsSingleYAxis = require("./ChartsSingleYAxis");
15
+ var _ChartsGroupedYAxis = require("./ChartsGroupedYAxis");
32
16
  var _jsxRuntime = require("react/jsx-runtime");
33
- const _excluded = ["scale", "tickNumber"];
34
- const useUtilityClasses = ownerState => {
35
- const {
36
- classes,
37
- position,
38
- id
39
- } = ownerState;
40
- const slots = {
41
- root: ['root', 'directionY', position, `id-${id}`],
42
- line: ['line'],
43
- tickContainer: ['tickContainer'],
44
- tick: ['tick'],
45
- tickLabel: ['tickLabel'],
46
- label: ['label']
47
- };
48
- return (0, _composeClasses.default)(slots, _axisClasses.getAxisUtilityClass, classes);
49
- };
50
-
51
- /* Gap between a tick and its label. */
52
- const TICK_LABEL_GAP = 2;
53
- /* Gap between the axis label and tick labels. */
54
- const AXIS_LABEL_TICK_LABEL_GAP = 2;
55
- const YAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
56
- name: 'MuiChartsYAxis',
57
- slot: 'Root'
58
- })({});
59
- const defaultProps = {
60
- disableLine: false,
61
- disableTicks: false,
62
- tickSize: 6
63
- };
64
-
65
17
  /**
66
18
  * Demos:
67
19
  *
@@ -70,167 +22,16 @@ const defaultProps = {
70
22
  * API:
71
23
  *
72
24
  * - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
73
- */
74
- function ChartsYAxis(inProps) {
25
+ */function ChartsYAxis(inProps) {
75
26
  const {
76
- yAxisIds,
77
- yAxis
78
- } = (0, _hooks.useYAxes)();
79
- const _yAxis = yAxis[inProps.axisId ?? yAxisIds[0]],
80
- {
81
- scale: yScale,
82
- tickNumber
83
- } = _yAxis,
84
- settings = (0, _objectWithoutPropertiesLoose2.default)(_yAxis, _excluded);
85
- const themedProps = (0, _styles.useThemeProps)({
86
- props: (0, _extends2.default)({}, settings, inProps),
87
- name: 'MuiChartsYAxis'
88
- });
89
- const defaultizedProps = (0, _extends2.default)({}, defaultProps, themedProps);
90
- const {
91
- position,
92
- disableLine,
93
- disableTicks,
94
- label,
95
- labelStyle,
96
- tickLabelStyle,
97
- tickSize: tickSizeProp,
98
- valueFormatter,
99
- slots,
100
- slotProps,
101
- tickPlacement,
102
- tickLabelPlacement,
103
- tickInterval,
104
- tickLabelInterval,
105
- sx,
106
- offset,
107
- width: axisWidth
108
- } = defaultizedProps;
109
- const theme = (0, _styles.useTheme)();
110
- const isRtl = (0, _RtlProvider.useRtl)();
111
- const isHydrated = (0, _useIsHydrated.useIsHydrated)();
112
- const classes = useUtilityClasses(defaultizedProps);
113
- const {
114
- instance
115
- } = (0, _ChartProvider.useChartContext)();
116
- const drawingArea = (0, _useDrawingArea.useDrawingArea)();
117
- const {
118
- left,
119
- top,
120
- width,
121
- height
122
- } = drawingArea;
123
- const tickSize = disableTicks ? 4 : tickSizeProp;
124
- const yTicks = (0, _useTicks.useTicks)({
125
- scale: yScale,
126
- tickNumber,
127
- valueFormatter,
128
- tickPlacement,
129
- tickLabelPlacement,
130
- tickInterval,
131
- direction: 'y'
132
- });
133
- const positionSign = position === 'right' ? 1 : -1;
134
- const tickFontSize = typeof tickLabelStyle?.fontSize === 'number' ? tickLabelStyle.fontSize : 12;
135
- const Line = slots?.axisLine ?? 'line';
136
- const Tick = slots?.axisTick ?? 'line';
137
- const TickLabel = slots?.axisTickLabel ?? _ChartsText.ChartsText;
138
- const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
139
- const defaultTextAnchor = (0, _defaultTextPlacement.getDefaultTextAnchor)((position === 'right' ? -90 : 90) - (tickLabelStyle?.angle ?? 0));
140
- const defaultDominantBaseline = (0, _defaultTextPlacement.getDefaultBaseline)((position === 'right' ? -90 : 90) - (tickLabelStyle?.angle ?? 0));
141
- const axisTickLabelProps = (0, _useSlotProps.default)({
142
- elementType: TickLabel,
143
- externalSlotProps: slotProps?.axisTickLabel,
144
- additionalProps: {
145
- style: (0, _extends2.default)({}, theme.typography.caption, {
146
- fontSize: tickFontSize,
147
- textAnchor: isRtl ? (0, _invertTextAnchor.invertTextAnchor)(defaultTextAnchor) : defaultTextAnchor,
148
- dominantBaseline: defaultDominantBaseline
149
- }, tickLabelStyle)
150
- },
151
- className: classes.tickLabel,
152
- ownerState: {}
153
- });
154
- const axisLabelProps = (0, _useSlotProps.default)({
155
- elementType: Label,
156
- externalSlotProps: slotProps?.axisLabel,
157
- additionalProps: {
158
- style: (0, _extends2.default)({}, theme.typography.body1, {
159
- lineHeight: 1,
160
- fontSize: 14,
161
- angle: positionSign * 90,
162
- textAnchor: 'middle',
163
- dominantBaseline: 'text-before-edge'
164
- }, labelStyle)
165
- },
166
- ownerState: {}
167
- });
168
- const lineSlotProps = (0, _useSlotProps.default)({
169
- elementType: Line,
170
- externalSlotProps: slotProps?.axisLine,
171
- additionalProps: {
172
- strokeLinecap: 'square'
173
- },
174
- ownerState: {}
175
- });
176
- const domain = yScale.domain();
177
- const ordinalAxis = (0, _isBandScale.isBandScale)(yScale);
178
-
179
- // Skip axis rendering if no data is available
180
- // - The domain is an empty array for band/point scales.
181
- // - The domains contains Infinity for continuous scales.
182
- // - The position is 'none'.
183
- if (ordinalAxis && domain.length === 0 || !ordinalAxis && domain.some(_isInfinity.isInfinity) || position === 'none') {
184
- return null;
27
+ yAxis,
28
+ yAxisIds
29
+ } = (0, _useAxis.useYAxes)();
30
+ const axis = yAxis[inProps.axisId ?? yAxisIds[0]];
31
+ if ('groups' in axis && Array.isArray(axis.groups)) {
32
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGroupedYAxis.ChartsGroupedYAxis, (0, _extends2.default)({}, inProps));
185
33
  }
186
- const labelRefPoint = {
187
- x: positionSign * axisWidth,
188
- y: top + height / 2
189
- };
190
- /* If there's an axis title, the tick labels have less space to render */
191
- const tickLabelsMaxWidth = Math.max(0, axisWidth - (label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height + AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - TICK_LABEL_GAP);
192
- const tickLabels = isHydrated ? (0, _shortenLabels.shortenLabels)(yTicks, drawingArea, tickLabelsMaxWidth, isRtl, axisTickLabelProps.style) : new Map(Array.from(yTicks).map(item => [item, item.formattedValue]));
193
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(YAxisRoot, {
194
- transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
195
- className: classes.root,
196
- sx: sx,
197
- children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
198
- y1: top,
199
- y2: top + height,
200
- className: classes.line
201
- }, lineSlotProps)), yTicks.map((item, index) => {
202
- const {
203
- offset: tickOffset,
204
- labelOffset,
205
- value
206
- } = item;
207
- const xTickLabel = positionSign * (tickSize + TICK_LABEL_GAP);
208
- const yTickLabel = labelOffset;
209
- const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
210
- const showLabel = instance.isYInside(tickOffset);
211
- const tickLabel = tickLabels.get(item);
212
- if (!showLabel) {
213
- return null;
214
- }
215
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
216
- transform: `translate(0, ${tickOffset})`,
217
- className: classes.tickContainer,
218
- children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
219
- x2: positionSign * tickSize,
220
- className: classes.tick
221
- }, slotProps?.axisTick)), tickLabel !== undefined && !skipLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
222
- x: xTickLabel,
223
- y: yTickLabel,
224
- text: tickLabel
225
- }, axisTickLabelProps))]
226
- }, index);
227
- }), label && isHydrated && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
228
- className: classes.label,
229
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
230
- text: label
231
- }))
232
- })]
233
- });
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleYAxis.ChartsSingleYAxis, (0, _extends2.default)({}, inProps));
234
35
  }
235
36
  process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
236
37
  // ----------------------------- Warning --------------------------------