@mui/x-charts 8.11.1 → 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.
- package/CHANGELOG.md +95 -0
- package/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
- package/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +9 -52
- package/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
- package/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +15 -51
- package/ChartsXAxis/ChartsXAxis.js +4 -6
- package/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
- package/ChartsXAxis/ChartsXAxisImpl.js +117 -0
- package/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -496
- package/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -31
- package/ChartsXAxis/utilities.d.ts +1 -2
- package/ChartsXAxis/utilities.js +1 -7
- package/{esm/ChartsYAxis/ChartsGroupedYAxis.d.ts → ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
- package/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +9 -52
- package/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
- package/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +15 -50
- package/ChartsYAxis/ChartsYAxis.js +6 -8
- package/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
- package/ChartsYAxis/ChartsYAxisImpl.js +133 -0
- package/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -504
- package/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +5 -44
- package/ChartsYAxis/utilities.d.ts +0 -1
- package/ChartsYAxis/utilities.js +1 -7
- package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
- package/esm/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +10 -53
- package/esm/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
- package/esm/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +16 -54
- package/esm/ChartsXAxis/ChartsXAxis.js +4 -6
- package/esm/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
- package/esm/ChartsXAxis/ChartsXAxisImpl.js +110 -0
- package/esm/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -496
- package/esm/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +3 -29
- package/esm/ChartsXAxis/utilities.d.ts +1 -2
- package/esm/ChartsXAxis/utilities.js +0 -6
- package/{ChartsYAxis/ChartsGroupedYAxis.d.ts → esm/ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
- package/esm/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +10 -53
- package/esm/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
- package/esm/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +16 -53
- package/esm/ChartsYAxis/ChartsYAxis.js +5 -7
- package/esm/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
- package/esm/ChartsYAxis/ChartsYAxisImpl.js +126 -0
- package/esm/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -504
- package/esm/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -42
- package/esm/ChartsYAxis/utilities.d.ts +0 -1
- package/esm/ChartsYAxis/utilities.js +0 -6
- package/esm/hooks/useInteractionItemProps.js +5 -4
- package/esm/hooks/useTicks.js +8 -1
- package/esm/index.js +1 -1
- package/esm/internals/dateHelpers.d.ts +4 -2
- package/esm/internals/dateHelpers.js +5 -4
- package/esm/internals/defaultValueFormatters.js +5 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
- package/esm/locales/index.d.ts +2 -1
- package/esm/locales/index.js +1 -0
- package/esm/locales/svSE.d.ts +19 -0
- package/esm/locales/svSE.js +15 -0
- package/hooks/useInteractionItemProps.js +6 -4
- package/hooks/useTicks.js +8 -1
- package/index.js +1 -1
- package/internals/dateHelpers.d.ts +4 -2
- package/internals/dateHelpers.js +5 -4
- package/internals/defaultValueFormatters.js +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
- package/locales/index.d.ts +2 -1
- package/locales/index.js +11 -0
- package/locales/svSE.d.ts +19 -0
- package/locales/svSE.js +21 -0
- package/package.json +4 -4
- package/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
- package/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
- package/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
- package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
- package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
- package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
|
@@ -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.
|
|
9
|
+
exports.ChartsGroupedYAxisTicks = ChartsGroupedYAxisTicks;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
-
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
13
12
|
var _isBandScale = require("../internals/isBandScale");
|
|
14
13
|
var _useChartContext = require("../context/ChartProvider/useChartContext");
|
|
15
14
|
var _utilities = require("./utilities");
|
|
16
15
|
var _useTicksGrouped = require("../hooks/useTicksGrouped");
|
|
17
|
-
var
|
|
16
|
+
var _useAxisTicksProps = require("./useAxisTicksProps");
|
|
18
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
18
|
const DEFAULT_GROUPING_CONFIG = {
|
|
20
19
|
tickSize: 6
|
|
@@ -31,55 +30,33 @@ const getGroupingConfig = (groups, groupIndex, tickSize) => {
|
|
|
31
30
|
/**
|
|
32
31
|
* @ignore - internal component.
|
|
33
32
|
*/
|
|
34
|
-
function
|
|
33
|
+
function ChartsGroupedYAxisTicks(inProps) {
|
|
35
34
|
const {
|
|
36
35
|
yScale,
|
|
37
36
|
defaultizedProps,
|
|
38
37
|
tickNumber,
|
|
39
38
|
positionSign,
|
|
40
|
-
skipAxisRendering,
|
|
41
39
|
classes,
|
|
42
|
-
Line,
|
|
43
40
|
Tick,
|
|
44
41
|
TickLabel,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
axisLabelProps,
|
|
48
|
-
lineProps
|
|
49
|
-
} = (0, _useAxisProps.useAxisProps)(inProps);
|
|
42
|
+
axisTickLabelProps
|
|
43
|
+
} = (0, _useAxisTicksProps.useAxisTicksProps)(inProps);
|
|
50
44
|
if (!(0, _isBandScale.isBandScale)(yScale)) {
|
|
51
45
|
throw new Error('MUI X Charts: ChartsGroupedYAxis only supports the `band` and `point` scale types.');
|
|
52
46
|
}
|
|
53
47
|
const {
|
|
54
|
-
position,
|
|
55
|
-
disableLine,
|
|
56
48
|
disableTicks,
|
|
57
|
-
label,
|
|
58
49
|
tickSize,
|
|
59
50
|
valueFormatter,
|
|
60
51
|
slotProps,
|
|
61
52
|
tickInterval,
|
|
62
53
|
tickPlacement,
|
|
63
|
-
tickLabelPlacement
|
|
64
|
-
sx,
|
|
65
|
-
offset,
|
|
66
|
-
width: axisWidth
|
|
54
|
+
tickLabelPlacement
|
|
67
55
|
} = defaultizedProps;
|
|
68
56
|
const groups = defaultizedProps.groups;
|
|
69
|
-
const drawingArea = (0, _useDrawingArea.useDrawingArea)();
|
|
70
|
-
const {
|
|
71
|
-
left,
|
|
72
|
-
top,
|
|
73
|
-
width,
|
|
74
|
-
height
|
|
75
|
-
} = drawingArea;
|
|
76
57
|
const {
|
|
77
58
|
instance
|
|
78
59
|
} = (0, _useChartContext.useChartContext)();
|
|
79
|
-
const labelRefPoint = {
|
|
80
|
-
x: positionSign * axisWidth,
|
|
81
|
-
y: top + height / 2
|
|
82
|
-
};
|
|
83
60
|
const yTicks = (0, _useTicksGrouped.useTicksGrouped)({
|
|
84
61
|
scale: yScale,
|
|
85
62
|
tickNumber,
|
|
@@ -90,23 +67,8 @@ function ChartsGroupedYAxis(inProps) {
|
|
|
90
67
|
direction: 'y',
|
|
91
68
|
groups
|
|
92
69
|
});
|
|
93
|
-
|
|
94
|
-
|
|
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) => {
|
|
70
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
|
|
71
|
+
children: yTicks.map((item, index) => {
|
|
110
72
|
const {
|
|
111
73
|
offset: tickOffset,
|
|
112
74
|
labelOffset
|
|
@@ -134,11 +96,6 @@ function ChartsGroupedYAxis(inProps) {
|
|
|
134
96
|
text: tickLabel
|
|
135
97
|
}))]
|
|
136
98
|
}, index);
|
|
137
|
-
})
|
|
138
|
-
className: classes.label,
|
|
139
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
|
|
140
|
-
text: label
|
|
141
|
-
}))
|
|
142
|
-
})]
|
|
99
|
+
})
|
|
143
100
|
});
|
|
144
101
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsYAxisProps } from "../models/axis.js";
|
|
3
|
+
interface ChartsSingleYAxisProps extends ChartsYAxisProps {
|
|
4
|
+
axisLabelHeight: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @ignore - internal component.
|
|
8
|
+
*/
|
|
9
|
+
declare function ChartsSingleYAxisTicks(inProps: ChartsSingleYAxisProps): React.JSX.Element;
|
|
10
|
+
export { ChartsSingleYAxisTicks };
|
|
@@ -6,42 +6,38 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
9
|
+
exports.ChartsSingleYAxisTicks = ChartsSingleYAxisTicks;
|
|
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 _useDrawingArea = require("../hooks/useDrawingArea");
|
|
16
16
|
var _ChartProvider = require("../context/ChartProvider");
|
|
17
17
|
var _shortenLabels = require("./shortenLabels");
|
|
18
18
|
var _utilities = require("./utilities");
|
|
19
|
-
var
|
|
19
|
+
var _useAxisTicksProps = require("./useAxisTicksProps");
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
21
|
/**
|
|
22
22
|
* @ignore - internal component.
|
|
23
|
-
*/
|
|
23
|
+
*/
|
|
24
|
+
function ChartsSingleYAxisTicks(inProps) {
|
|
25
|
+
const {
|
|
26
|
+
axisLabelHeight
|
|
27
|
+
} = inProps;
|
|
24
28
|
const {
|
|
25
29
|
yScale,
|
|
26
30
|
defaultizedProps,
|
|
27
31
|
tickNumber,
|
|
28
32
|
positionSign,
|
|
29
|
-
skipAxisRendering,
|
|
30
33
|
classes,
|
|
31
|
-
Line,
|
|
32
34
|
Tick,
|
|
33
35
|
TickLabel,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
lineProps,
|
|
38
|
-
isRtl
|
|
39
|
-
} = (0, _useAxisProps.useAxisProps)(inProps);
|
|
36
|
+
axisTickLabelProps
|
|
37
|
+
} = (0, _useAxisTicksProps.useAxisTicksProps)(inProps);
|
|
38
|
+
const isRtl = (0, _RtlProvider.useRtl)();
|
|
40
39
|
const {
|
|
41
|
-
position,
|
|
42
|
-
disableLine,
|
|
43
40
|
disableTicks,
|
|
44
|
-
label,
|
|
45
41
|
tickSize: tickSizeProp,
|
|
46
42
|
valueFormatter,
|
|
47
43
|
slotProps,
|
|
@@ -49,17 +45,9 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
49
45
|
tickLabelPlacement,
|
|
50
46
|
tickInterval,
|
|
51
47
|
tickLabelInterval,
|
|
52
|
-
sx,
|
|
53
|
-
offset,
|
|
54
48
|
width: axisWidth
|
|
55
49
|
} = defaultizedProps;
|
|
56
50
|
const drawingArea = (0, _useDrawingArea.useDrawingArea)();
|
|
57
|
-
const {
|
|
58
|
-
left,
|
|
59
|
-
top,
|
|
60
|
-
width,
|
|
61
|
-
height
|
|
62
|
-
} = drawingArea;
|
|
63
51
|
const {
|
|
64
52
|
instance
|
|
65
53
|
} = (0, _ChartProvider.useChartContext)();
|
|
@@ -75,29 +63,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
75
63
|
direction: 'y'
|
|
76
64
|
});
|
|
77
65
|
|
|
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
66
|
/* If there's an axis title, the tick labels have less space to render */
|
|
90
|
-
const tickLabelsMaxWidth = Math.max(0, axisWidth - (
|
|
67
|
+
const tickLabelsMaxWidth = Math.max(0, axisWidth - (axisLabelHeight > 0 ? axisLabelHeight + _utilities.AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - _utilities.TICK_LABEL_GAP);
|
|
91
68
|
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.
|
|
93
|
-
|
|
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) => {
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
|
|
70
|
+
children: yTicks.map((item, index) => {
|
|
101
71
|
const {
|
|
102
72
|
offset: tickOffset,
|
|
103
73
|
labelOffset,
|
|
@@ -123,11 +93,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
123
93
|
text: tickLabel
|
|
124
94
|
}, axisTickLabelProps))]
|
|
125
95
|
}, index);
|
|
126
|
-
})
|
|
127
|
-
className: classes.label,
|
|
128
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
|
|
129
|
-
text: label
|
|
130
|
-
}))
|
|
131
|
-
})]
|
|
96
|
+
})
|
|
132
97
|
});
|
|
133
98
|
}
|
|
@@ -11,9 +11,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var _warning = require("@mui/x-internals/warning");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var _ChartsGroupedYAxis = require("./ChartsGroupedYAxis");
|
|
14
|
+
var _hooks = require("../hooks");
|
|
15
|
+
var _ChartsYAxisImpl = require("./ChartsYAxisImpl");
|
|
17
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
17
|
/**
|
|
19
18
|
* Demos:
|
|
@@ -27,16 +26,15 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
27
26
|
const {
|
|
28
27
|
yAxis,
|
|
29
28
|
yAxisIds
|
|
30
|
-
} = (0,
|
|
29
|
+
} = (0, _hooks.useYAxes)();
|
|
31
30
|
const axis = yAxis[inProps.axisId ?? yAxisIds[0]];
|
|
32
31
|
if (!axis) {
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleYAxis.ChartsSingleYAxis, (0, _extends2.default)({}, inProps));
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYAxisImpl.ChartsYAxisImpl, (0, _extends2.default)({}, inProps, {
|
|
36
|
+
axis: axis
|
|
37
|
+
}));
|
|
40
38
|
}
|
|
41
39
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
42
40
|
// ----------------------------- Warning --------------------------------
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AxisScaleConfig, ChartsYAxisProps, ComputedAxis } from "../models/axis.js";
|
|
3
|
+
interface ChartsYAxisImplProps extends Omit<ChartsYAxisProps, 'axis'> {
|
|
4
|
+
axis: ComputedAxis<keyof AxisScaleConfig, any, ChartsYAxisProps>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @ignore - internal component. Use `ChartsYAxis` instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ChartsYAxisImpl({
|
|
10
|
+
axis,
|
|
11
|
+
...inProps
|
|
12
|
+
}: ChartsYAxisImplProps): React.JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
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.ChartsYAxisImpl = ChartsYAxisImpl;
|
|
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 _ChartsSingleYAxisTicks = require("./ChartsSingleYAxisTicks");
|
|
16
|
+
var _ChartsGroupedYAxisTicks = require("./ChartsGroupedYAxisTicks");
|
|
17
|
+
var _ChartsText = require("../ChartsText");
|
|
18
|
+
var _utilities = require("./utilities");
|
|
19
|
+
var _isInfinity = require("../internals/isInfinity");
|
|
20
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
21
|
+
var _useIsHydrated = require("../hooks/useIsHydrated");
|
|
22
|
+
var _isBandScale = require("../internals/isBandScale");
|
|
23
|
+
var _domUtils = require("../internals/domUtils");
|
|
24
|
+
var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
|
|
25
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
+
const _excluded = ["axis"],
|
|
27
|
+
_excluded2 = ["scale", "tickNumber", "reverse"];
|
|
28
|
+
const YAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
|
|
29
|
+
name: 'MuiChartsYAxis',
|
|
30
|
+
slot: 'Root'
|
|
31
|
+
})({});
|
|
32
|
+
/**
|
|
33
|
+
* @ignore - internal component. Use `ChartsYAxis` instead.
|
|
34
|
+
*/
|
|
35
|
+
function ChartsYAxisImpl(_ref) {
|
|
36
|
+
let {
|
|
37
|
+
axis
|
|
38
|
+
} = _ref,
|
|
39
|
+
inProps = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
40
|
+
const {
|
|
41
|
+
scale: yScale
|
|
42
|
+
} = axis,
|
|
43
|
+
settings = (0, _objectWithoutPropertiesLoose2.default)(axis, _excluded2);
|
|
44
|
+
const isHydrated = (0, _useIsHydrated.useIsHydrated)();
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
47
|
+
const themedProps = (0, _styles.useThemeProps)({
|
|
48
|
+
props: (0, _extends2.default)({}, settings, inProps),
|
|
49
|
+
name: 'MuiChartsYAxis'
|
|
50
|
+
});
|
|
51
|
+
const defaultizedProps = (0, _extends2.default)({}, _utilities.defaultProps, themedProps);
|
|
52
|
+
const {
|
|
53
|
+
position,
|
|
54
|
+
disableLine,
|
|
55
|
+
label,
|
|
56
|
+
labelStyle,
|
|
57
|
+
offset,
|
|
58
|
+
width: axisWidth,
|
|
59
|
+
sx,
|
|
60
|
+
slots,
|
|
61
|
+
slotProps
|
|
62
|
+
} = defaultizedProps;
|
|
63
|
+
const theme = (0, _styles.useTheme)();
|
|
64
|
+
const classes = (0, _utilities.useUtilityClasses)(defaultizedProps);
|
|
65
|
+
const {
|
|
66
|
+
left,
|
|
67
|
+
top,
|
|
68
|
+
width,
|
|
69
|
+
height
|
|
70
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
71
|
+
const positionSign = position === 'right' ? 1 : -1;
|
|
72
|
+
const Line = slots?.axisLine ?? 'line';
|
|
73
|
+
const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
|
|
74
|
+
const lineProps = (0, _useSlotProps.default)({
|
|
75
|
+
elementType: Line,
|
|
76
|
+
externalSlotProps: slotProps?.axisLine,
|
|
77
|
+
additionalProps: {
|
|
78
|
+
strokeLinecap: 'square'
|
|
79
|
+
},
|
|
80
|
+
ownerState: {}
|
|
81
|
+
});
|
|
82
|
+
const axisLabelProps = (0, _useSlotProps.default)({
|
|
83
|
+
elementType: Label,
|
|
84
|
+
externalSlotProps: slotProps?.axisLabel,
|
|
85
|
+
additionalProps: {
|
|
86
|
+
style: (0, _extends2.default)({}, theme.typography.body1, {
|
|
87
|
+
lineHeight: 1,
|
|
88
|
+
fontSize: 14,
|
|
89
|
+
angle: positionSign * 90,
|
|
90
|
+
textAnchor: 'middle',
|
|
91
|
+
dominantBaseline: 'text-before-edge'
|
|
92
|
+
}, labelStyle)
|
|
93
|
+
},
|
|
94
|
+
ownerState: {}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Skip axis rendering if no data is available
|
|
98
|
+
// - The domain is an empty array for band/point scales.
|
|
99
|
+
// - The domains contains Infinity for continuous scales.
|
|
100
|
+
// - The position is set to 'none'.
|
|
101
|
+
if (position === 'none') {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const labelRefPoint = {
|
|
105
|
+
x: positionSign * axisWidth,
|
|
106
|
+
y: top + height / 2
|
|
107
|
+
};
|
|
108
|
+
const axisLabelHeight = label == null ? 0 : (0, _domUtils.getStringSize)(label, axisLabelProps.style).height;
|
|
109
|
+
const domain = yScale.domain();
|
|
110
|
+
const isScaleBand = (0, _isBandScale.isBandScale)(yScale);
|
|
111
|
+
const skipTickRendering = isScaleBand && domain.length === 0 || !isScaleBand && domain.some(_isInfinity.isInfinity);
|
|
112
|
+
let children = null;
|
|
113
|
+
if (!skipTickRendering) {
|
|
114
|
+
children = 'groups' in axis && Array.isArray(axis.groups) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGroupedYAxisTicks.ChartsGroupedYAxisTicks, (0, _extends2.default)({}, inProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleYAxisTicks.ChartsSingleYAxisTicks, (0, _extends2.default)({}, inProps, {
|
|
115
|
+
axisLabelHeight: axisLabelHeight
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(YAxisRoot, {
|
|
119
|
+
transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
|
|
120
|
+
className: classes.root,
|
|
121
|
+
sx: sx,
|
|
122
|
+
children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
|
|
123
|
+
y1: top,
|
|
124
|
+
y2: top + height,
|
|
125
|
+
className: classes.line
|
|
126
|
+
}, lineProps)), children, 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
|
+
}
|