@mui/x-charts 8.9.2 → 8.10.1

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 (120) hide show
  1. package/BarChart/BarChart.js +20 -0
  2. package/CHANGELOG.md +217 -6
  3. package/ChartContainer/ChartContainer.js +30 -0
  4. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  5. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -3
  6. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -3
  7. package/ChartsLabel/labelGradientClasses.d.ts +1 -1
  8. package/ChartsLabel/labelMarkClasses.d.ts +1 -1
  9. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  10. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  11. package/ChartsTooltip/ChartsTooltip.d.ts +2 -1
  12. package/ChartsTooltip/ChartsTooltip.js +3 -3
  13. package/ChartsTooltip/ChartsTooltipContainer.d.ts +5 -5
  14. package/ChartsTooltip/ChartsTooltipContainer.js +11 -5
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  16. package/ChartsTooltip/ChartsTooltipTable.js +1 -0
  17. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  18. package/ChartsXAxis/ChartsGroupedXAxis.d.ts +7 -0
  19. package/ChartsXAxis/ChartsGroupedXAxis.js +143 -0
  20. package/ChartsXAxis/ChartsSingleXAxis.d.ts +7 -0
  21. package/ChartsXAxis/ChartsSingleXAxis.js +144 -0
  22. package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  23. package/ChartsXAxis/ChartsXAxis.js +8 -210
  24. package/ChartsXAxis/getVisibleLabels.d.ts +2 -2
  25. package/ChartsXAxis/useAxisProps.d.ts +4526 -0
  26. package/ChartsXAxis/useAxisProps.js +105 -0
  27. package/ChartsXAxis/utilities.d.ts +11 -0
  28. package/ChartsXAxis/utilities.js +43 -0
  29. package/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  30. package/ChartsYAxis/ChartsGroupedYAxis.js +144 -0
  31. package/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  32. package/ChartsYAxis/ChartsSingleYAxis.js +133 -0
  33. package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  34. package/ChartsYAxis/ChartsYAxis.js +12 -211
  35. package/ChartsYAxis/useAxisProps.d.ts +4452 -0
  36. package/ChartsYAxis/useAxisProps.js +115 -0
  37. package/ChartsYAxis/utilities.d.ts +10 -0
  38. package/ChartsYAxis/utilities.js +42 -0
  39. package/LineChart/LineChart.js +20 -0
  40. package/RadarChart/index.d.ts +9 -2
  41. package/RadarChart/index.js +13 -14
  42. package/ScatterChart/ScatterChart.d.ts +8 -1
  43. package/ScatterChart/ScatterChart.js +20 -0
  44. package/SparkLineChart/SparkLineChart.d.ts +15 -5
  45. package/SparkLineChart/SparkLineChart.js +77 -34
  46. package/esm/BarChart/BarChart.js +20 -0
  47. package/esm/ChartContainer/ChartContainer.js +30 -0
  48. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  49. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -3
  50. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -3
  51. package/esm/ChartsLabel/labelGradientClasses.d.ts +1 -1
  52. package/esm/ChartsLabel/labelMarkClasses.d.ts +1 -1
  53. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  54. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  55. package/esm/ChartsTooltip/ChartsTooltip.d.ts +2 -1
  56. package/esm/ChartsTooltip/ChartsTooltip.js +3 -3
  57. package/esm/ChartsTooltip/ChartsTooltipContainer.d.ts +5 -5
  58. package/esm/ChartsTooltip/ChartsTooltipContainer.js +11 -5
  59. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  60. package/esm/ChartsTooltip/ChartsTooltipTable.js +1 -0
  61. package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  62. package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +7 -0
  63. package/esm/ChartsXAxis/ChartsGroupedXAxis.js +137 -0
  64. package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +7 -0
  65. package/esm/ChartsXAxis/ChartsSingleXAxis.js +140 -0
  66. package/esm/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  67. package/esm/ChartsXAxis/ChartsXAxis.js +7 -207
  68. package/esm/ChartsXAxis/getVisibleLabels.d.ts +2 -2
  69. package/esm/ChartsXAxis/useAxisProps.d.ts +4526 -0
  70. package/esm/ChartsXAxis/useAxisProps.js +98 -0
  71. package/esm/ChartsXAxis/utilities.d.ts +11 -0
  72. package/esm/ChartsXAxis/utilities.js +35 -0
  73. package/esm/ChartsYAxis/ChartsGroupedYAxis.d.ts +7 -0
  74. package/esm/ChartsYAxis/ChartsGroupedYAxis.js +138 -0
  75. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +7 -0
  76. package/esm/ChartsYAxis/ChartsSingleYAxis.js +129 -0
  77. package/esm/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  78. package/esm/ChartsYAxis/ChartsYAxis.js +10 -207
  79. package/esm/ChartsYAxis/useAxisProps.d.ts +4452 -0
  80. package/esm/ChartsYAxis/useAxisProps.js +108 -0
  81. package/esm/ChartsYAxis/utilities.d.ts +10 -0
  82. package/esm/ChartsYAxis/utilities.js +34 -0
  83. package/esm/LineChart/LineChart.js +20 -0
  84. package/esm/RadarChart/index.d.ts +9 -2
  85. package/esm/RadarChart/index.js +12 -2
  86. package/esm/ScatterChart/ScatterChart.d.ts +8 -1
  87. package/esm/ScatterChart/ScatterChart.js +20 -0
  88. package/esm/SparkLineChart/SparkLineChart.d.ts +15 -5
  89. package/esm/SparkLineChart/SparkLineChart.js +77 -34
  90. package/esm/hooks/useTicksGrouped.d.ts +28 -0
  91. package/esm/hooks/useTicksGrouped.js +98 -0
  92. package/esm/index.js +1 -1
  93. package/esm/internals/animation/Transition.js +2 -5
  94. package/esm/internals/configInit.js +2 -2
  95. package/esm/internals/getScale.d.ts +1 -1
  96. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -1
  97. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +32 -23
  98. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +1 -1
  99. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  100. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  101. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  102. package/esm/internals/plugins/utils/ChartStore.js +16 -18
  103. package/esm/models/axis.d.ts +46 -2
  104. package/esm/tests/web-components.js +2 -4
  105. package/hooks/useTicksGrouped.d.ts +28 -0
  106. package/hooks/useTicksGrouped.js +104 -0
  107. package/index.js +1 -1
  108. package/internals/animation/Transition.js +2 -5
  109. package/internals/configInit.js +2 -2
  110. package/internals/getScale.d.ts +1 -1
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -1
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +34 -23
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +1 -1
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +1 -1
  115. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -4
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +2 -2
  117. package/internals/plugins/utils/ChartStore.js +16 -18
  118. package/models/axis.d.ts +46 -2
  119. package/package.json +16 -18
  120. package/tests/web-components.js +2 -4
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useAxisProps = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
12
+ var _styles = require("@mui/material/styles");
13
+ var _RtlProvider = require("@mui/system/RtlProvider");
14
+ var _ChartsText = require("../ChartsText");
15
+ var _useAxis = require("../hooks/useAxis");
16
+ var _defaultTextPlacement = require("../ChartsText/defaultTextPlacement");
17
+ var _invertTextAnchor = require("../internals/invertTextAnchor");
18
+ var _utilities = require("./utilities");
19
+ var _isBandScale = require("../internals/isBandScale");
20
+ var _isInfinity = require("../internals/isInfinity");
21
+ const _excluded = ["scale", "tickNumber", "reverse"];
22
+ const useAxisProps = inProps => {
23
+ const {
24
+ xAxis,
25
+ xAxisIds
26
+ } = (0, _useAxis.useXAxes)();
27
+ const _xAxis = xAxis[inProps.axisId ?? xAxisIds[0]],
28
+ {
29
+ scale: xScale,
30
+ tickNumber,
31
+ reverse
32
+ } = _xAxis,
33
+ settings = (0, _objectWithoutPropertiesLoose2.default)(_xAxis, _excluded);
34
+
35
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
36
+ const themedProps = (0, _styles.useThemeProps)({
37
+ props: (0, _extends2.default)({}, settings, inProps),
38
+ name: 'MuiChartsXAxis'
39
+ });
40
+ const defaultizedProps = (0, _extends2.default)({}, _utilities.defaultProps, themedProps);
41
+ const {
42
+ position,
43
+ tickLabelStyle,
44
+ labelStyle,
45
+ slots,
46
+ slotProps
47
+ } = defaultizedProps;
48
+ const theme = (0, _styles.useTheme)();
49
+ const isRtl = (0, _RtlProvider.useRtl)();
50
+ const classes = (0, _utilities.useUtilityClasses)(defaultizedProps);
51
+ const positionSign = position === 'bottom' ? 1 : -1;
52
+ const Line = slots?.axisLine ?? 'line';
53
+ const Tick = slots?.axisTick ?? 'line';
54
+ const TickLabel = slots?.axisTickLabel ?? _ChartsText.ChartsText;
55
+ const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
56
+ const defaultTextAnchor = (0, _defaultTextPlacement.getDefaultTextAnchor)((position === 'bottom' ? 0 : 180) - (tickLabelStyle?.angle ?? 0));
57
+ const defaultDominantBaseline = (0, _defaultTextPlacement.getDefaultBaseline)((position === 'bottom' ? 0 : 180) - (tickLabelStyle?.angle ?? 0));
58
+ const axisTickLabelProps = (0, _useSlotProps.default)({
59
+ elementType: TickLabel,
60
+ externalSlotProps: slotProps?.axisTickLabel,
61
+ additionalProps: {
62
+ style: (0, _extends2.default)({}, theme.typography.caption, {
63
+ fontSize: 12,
64
+ lineHeight: 1.25,
65
+ textAnchor: isRtl ? (0, _invertTextAnchor.invertTextAnchor)(defaultTextAnchor) : defaultTextAnchor,
66
+ dominantBaseline: defaultDominantBaseline
67
+ }, tickLabelStyle)
68
+ },
69
+ className: classes.tickLabel,
70
+ ownerState: {}
71
+ });
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
+ const domain = xScale.domain();
86
+ const isScaleBand = (0, _isBandScale.isBandScale)(xScale);
87
+ const skipAxisRendering = isScaleBand && domain.length === 0 || !isScaleBand && domain.some(_isInfinity.isInfinity) || position === 'none';
88
+ return {
89
+ xScale,
90
+ defaultizedProps,
91
+ tickNumber,
92
+ positionSign,
93
+ skipAxisRendering,
94
+ classes,
95
+ Line,
96
+ Tick,
97
+ TickLabel,
98
+ Label,
99
+ axisTickLabelProps,
100
+ axisLabelProps,
101
+ reverse,
102
+ isRtl
103
+ };
104
+ };
105
+ exports.useAxisProps = useAxisProps;
@@ -0,0 +1,11 @@
1
+ import { AxisConfig, ChartsXAxisProps } from "../models/axis.js";
2
+ export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsXAxisProps>) => Record<"line" | "root" | "label" | "tickContainer" | "tick" | "tickLabel", string>;
3
+ export declare const TICK_LABEL_GAP = 3;
4
+ export declare const AXIS_LABEL_TICK_LABEL_GAP = 4;
5
+ export declare const XAxisRoot: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, keyof import("react").SVGProps<SVGGElement> | keyof import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
6
+ export declare const defaultProps: {
7
+ readonly disableLine: false;
8
+ readonly disableTicks: false;
9
+ readonly tickSize: 6;
10
+ readonly tickLabelMinGap: 4;
11
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useUtilityClasses = exports.defaultProps = exports.XAxisRoot = exports.TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = void 0;
8
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
9
+ var _styles = require("@mui/material/styles");
10
+ var _axisClasses = require("../ChartsAxis/axisClasses");
11
+ var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
12
+ const useUtilityClasses = ownerState => {
13
+ const {
14
+ classes,
15
+ position,
16
+ id
17
+ } = ownerState;
18
+ const slots = {
19
+ root: ['root', 'directionX', position, `id-${id}`],
20
+ line: ['line'],
21
+ tickContainer: ['tickContainer'],
22
+ tick: ['tick'],
23
+ tickLabel: ['tickLabel'],
24
+ label: ['label']
25
+ };
26
+ return (0, _composeClasses.default)(slots, _axisClasses.getAxisUtilityClass, classes);
27
+ };
28
+
29
+ /* Gap between a tick and its label. */
30
+ exports.useUtilityClasses = useUtilityClasses;
31
+ const TICK_LABEL_GAP = exports.TICK_LABEL_GAP = 3;
32
+ /* Gap between the axis label and tick labels. */
33
+ const AXIS_LABEL_TICK_LABEL_GAP = exports.AXIS_LABEL_TICK_LABEL_GAP = 4;
34
+ const XAxisRoot = exports.XAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
35
+ name: 'MuiChartsXAxis',
36
+ slot: 'Root'
37
+ })({});
38
+ const defaultProps = exports.defaultProps = {
39
+ disableLine: false,
40
+ disableTicks: false,
41
+ tickSize: 6,
42
+ tickLabelMinGap: 4
43
+ };
@@ -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 ChartsGroupedYAxis(inProps: ChartsYAxisProps): React.JSX.Element | null;
7
+ export { ChartsGroupedYAxis };
@@ -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
  }