@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.
- package/BarChart/index.d.ts +1 -0
- package/BarChart/useBarChartProps.js +4 -3
- package/CHANGELOG.md +181 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
- package/ChartsLegend/ChartsLegend.js +2 -1
- package/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
- package/ChartsLegend/PiecewiseColorLegend.js +32 -22
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
- package/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
- package/ChartsSurface/ChartsSurface.js +2 -1
- package/ChartsWrapper/ChartsWrapper.d.ts +4 -0
- package/ChartsWrapper/ChartsWrapper.js +73 -25
- package/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
- package/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +11 -54
- 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/getVisibleLabels.js +5 -1
- 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} +11 -54
- 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/LineChart/useAreaPlotData.js +2 -2
- package/LineChart/useLineChartProps.js +2 -1
- package/LineChart/useLinePlotData.js +2 -2
- package/PieChart/PieChart.js +1 -0
- package/RadarChart/RadarAxis/useRadarAxis.js +2 -2
- package/RadarChart/useRadarChartProps.js +2 -1
- package/ScatterChart/useScatterChartProps.js +2 -1
- package/Toolbar/Toolbar.js +2 -1
- package/esm/BarChart/index.d.ts +1 -0
- package/esm/BarChart/useBarChartProps.js +4 -3
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -1
- package/esm/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
- package/esm/ChartsLegend/PiecewiseColorLegend.js +32 -22
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
- package/esm/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
- package/esm/ChartsSurface/ChartsSurface.js +2 -1
- package/esm/ChartsWrapper/ChartsWrapper.d.ts +4 -0
- package/esm/ChartsWrapper/ChartsWrapper.js +73 -25
- package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
- package/esm/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +12 -55
- 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/getVisibleLabels.js +5 -1
- 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} +12 -55
- 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/LineChart/useAreaPlotData.js +2 -2
- package/esm/LineChart/useLineChartProps.js +2 -1
- package/esm/LineChart/useLinePlotData.js +2 -2
- package/esm/PieChart/PieChart.js +1 -0
- package/esm/RadarChart/RadarAxis/useRadarAxis.js +2 -2
- package/esm/RadarChart/useRadarChartProps.js +2 -1
- package/esm/ScatterChart/useScatterChartProps.js +2 -1
- package/esm/Toolbar/Toolbar.js +2 -1
- package/esm/hooks/useInteractionItemProps.js +5 -4
- package/esm/hooks/useScale.js +2 -2
- package/esm/hooks/useTicks.js +10 -3
- package/esm/hooks/useTicksGrouped.js +2 -2
- 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/index.d.ts +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/invertScale.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
- package/esm/internals/scaleGuards.d.ts +4 -0
- package/esm/internals/scaleGuards.js +3 -0
- 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/esm/models/axis.d.ts +3 -0
- package/hooks/useInteractionItemProps.js +6 -4
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.js +10 -3
- package/hooks/useTicksGrouped.js +2 -2
- 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/index.d.ts +1 -1
- package/internals/index.js +4 -4
- package/internals/invertScale.js +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
- package/internals/scaleGuards.d.ts +4 -0
- package/internals/{isBandScale.js → scaleGuards.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/models/axis.d.ts +3 -0
- package/package.json +5 -5
- 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
- package/esm/internals/isBandScale.d.ts +0 -5
- package/esm/internals/isBandScale.js +0 -3
- package/internals/isBandScale.d.ts +0 -5
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import { isBandScale } from "../internals/isBandScale.js";
|
|
5
|
+
import { isOrdinalScale } from "../internals/scaleGuards.js";
|
|
7
6
|
import { useChartContext } from "../context/ChartProvider/useChartContext.js";
|
|
8
|
-
import { TICK_LABEL_GAP
|
|
7
|
+
import { TICK_LABEL_GAP } from "./utilities.js";
|
|
9
8
|
import { useTicksGrouped } from "../hooks/useTicksGrouped.js";
|
|
10
|
-
import {
|
|
9
|
+
import { useAxisTicksProps } from "./useAxisTicksProps.js";
|
|
11
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
11
|
const DEFAULT_GROUPING_CONFIG = {
|
|
13
12
|
tickSize: 6
|
|
@@ -24,55 +23,33 @@ const getGroupingConfig = (groups, groupIndex, tickSize) => {
|
|
|
24
23
|
/**
|
|
25
24
|
* @ignore - internal component.
|
|
26
25
|
*/
|
|
27
|
-
function
|
|
26
|
+
function ChartsGroupedYAxisTicks(inProps) {
|
|
28
27
|
const {
|
|
29
28
|
yScale,
|
|
30
29
|
defaultizedProps,
|
|
31
30
|
tickNumber,
|
|
32
31
|
positionSign,
|
|
33
|
-
skipAxisRendering,
|
|
34
32
|
classes,
|
|
35
|
-
Line,
|
|
36
33
|
Tick,
|
|
37
34
|
TickLabel,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
lineProps
|
|
42
|
-
} = useAxisProps(inProps);
|
|
43
|
-
if (!isBandScale(yScale)) {
|
|
35
|
+
axisTickLabelProps
|
|
36
|
+
} = useAxisTicksProps(inProps);
|
|
37
|
+
if (!isOrdinalScale(yScale)) {
|
|
44
38
|
throw new Error('MUI X Charts: ChartsGroupedYAxis only supports the `band` and `point` scale types.');
|
|
45
39
|
}
|
|
46
40
|
const {
|
|
47
|
-
position,
|
|
48
|
-
disableLine,
|
|
49
41
|
disableTicks,
|
|
50
|
-
label,
|
|
51
42
|
tickSize,
|
|
52
43
|
valueFormatter,
|
|
53
44
|
slotProps,
|
|
54
45
|
tickInterval,
|
|
55
46
|
tickPlacement,
|
|
56
|
-
tickLabelPlacement
|
|
57
|
-
sx,
|
|
58
|
-
offset,
|
|
59
|
-
width: axisWidth
|
|
47
|
+
tickLabelPlacement
|
|
60
48
|
} = defaultizedProps;
|
|
61
49
|
const groups = defaultizedProps.groups;
|
|
62
|
-
const drawingArea = useDrawingArea();
|
|
63
|
-
const {
|
|
64
|
-
left,
|
|
65
|
-
top,
|
|
66
|
-
width,
|
|
67
|
-
height
|
|
68
|
-
} = drawingArea;
|
|
69
50
|
const {
|
|
70
51
|
instance
|
|
71
52
|
} = useChartContext();
|
|
72
|
-
const labelRefPoint = {
|
|
73
|
-
x: positionSign * axisWidth,
|
|
74
|
-
y: top + height / 2
|
|
75
|
-
};
|
|
76
53
|
const yTicks = useTicksGrouped({
|
|
77
54
|
scale: yScale,
|
|
78
55
|
tickNumber,
|
|
@@ -83,23 +60,8 @@ function ChartsGroupedYAxis(inProps) {
|
|
|
83
60
|
direction: 'y',
|
|
84
61
|
groups
|
|
85
62
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// - The domain is an empty array for band/point scales.
|
|
89
|
-
// - The domains contains Infinity for continuous scales.
|
|
90
|
-
// - The position is set to 'none'.
|
|
91
|
-
if (skipAxisRendering) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
return /*#__PURE__*/_jsxs(YAxisRoot, {
|
|
95
|
-
transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
|
|
96
|
-
className: classes.root,
|
|
97
|
-
sx: sx,
|
|
98
|
-
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
99
|
-
y1: top,
|
|
100
|
-
y2: top + height,
|
|
101
|
-
className: classes.line
|
|
102
|
-
}, lineProps)), yTicks.map((item, index) => {
|
|
63
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
64
|
+
children: yTicks.map((item, index) => {
|
|
103
65
|
const {
|
|
104
66
|
offset: tickOffset,
|
|
105
67
|
labelOffset
|
|
@@ -127,12 +89,7 @@ function ChartsGroupedYAxis(inProps) {
|
|
|
127
89
|
text: tickLabel
|
|
128
90
|
}))]
|
|
129
91
|
}, index);
|
|
130
|
-
})
|
|
131
|
-
className: classes.label,
|
|
132
|
-
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
133
|
-
text: label
|
|
134
|
-
}))
|
|
135
|
-
})]
|
|
92
|
+
})
|
|
136
93
|
});
|
|
137
94
|
}
|
|
138
|
-
export {
|
|
95
|
+
export { ChartsGroupedYAxisTicks };
|
|
@@ -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 };
|
|
@@ -2,41 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
5
6
|
import { useIsHydrated } from "../hooks/useIsHydrated.js";
|
|
6
|
-
import { getStringSize } from "../internals/domUtils.js";
|
|
7
7
|
import { useTicks } from "../hooks/useTicks.js";
|
|
8
8
|
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
9
9
|
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
10
10
|
import { shortenLabels } from "./shortenLabels.js";
|
|
11
|
-
import { AXIS_LABEL_TICK_LABEL_GAP, TICK_LABEL_GAP
|
|
12
|
-
import {
|
|
13
|
-
|
|
11
|
+
import { AXIS_LABEL_TICK_LABEL_GAP, TICK_LABEL_GAP } from "./utilities.js";
|
|
12
|
+
import { useAxisTicksProps } from "./useAxisTicksProps.js";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
/**
|
|
15
15
|
* @ignore - internal component.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
function ChartsSingleYAxisTicks(inProps) {
|
|
18
|
+
const {
|
|
19
|
+
axisLabelHeight
|
|
20
|
+
} = inProps;
|
|
19
21
|
const {
|
|
20
22
|
yScale,
|
|
21
23
|
defaultizedProps,
|
|
22
24
|
tickNumber,
|
|
23
25
|
positionSign,
|
|
24
|
-
skipAxisRendering,
|
|
25
26
|
classes,
|
|
26
|
-
Line,
|
|
27
27
|
Tick,
|
|
28
28
|
TickLabel,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
lineProps,
|
|
33
|
-
isRtl
|
|
34
|
-
} = useAxisProps(inProps);
|
|
29
|
+
axisTickLabelProps
|
|
30
|
+
} = useAxisTicksProps(inProps);
|
|
31
|
+
const isRtl = useRtl();
|
|
35
32
|
const {
|
|
36
|
-
position,
|
|
37
|
-
disableLine,
|
|
38
33
|
disableTicks,
|
|
39
|
-
label,
|
|
40
34
|
tickSize: tickSizeProp,
|
|
41
35
|
valueFormatter,
|
|
42
36
|
slotProps,
|
|
@@ -44,17 +38,9 @@ function ChartsSingleYAxis(inProps) {
|
|
|
44
38
|
tickLabelPlacement,
|
|
45
39
|
tickInterval,
|
|
46
40
|
tickLabelInterval,
|
|
47
|
-
sx,
|
|
48
|
-
offset,
|
|
49
41
|
width: axisWidth
|
|
50
42
|
} = defaultizedProps;
|
|
51
43
|
const drawingArea = useDrawingArea();
|
|
52
|
-
const {
|
|
53
|
-
left,
|
|
54
|
-
top,
|
|
55
|
-
width,
|
|
56
|
-
height
|
|
57
|
-
} = drawingArea;
|
|
58
44
|
const {
|
|
59
45
|
instance
|
|
60
46
|
} = useChartContext();
|
|
@@ -70,29 +56,11 @@ function ChartsSingleYAxis(inProps) {
|
|
|
70
56
|
direction: 'y'
|
|
71
57
|
});
|
|
72
58
|
|
|
73
|
-
// Skip axis rendering if no data is available
|
|
74
|
-
// - The domain is an empty array for band/point scales.
|
|
75
|
-
// - The domains contains Infinity for continuous scales.
|
|
76
|
-
// - The position is set to 'none'.
|
|
77
|
-
if (skipAxisRendering) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const labelRefPoint = {
|
|
81
|
-
x: positionSign * axisWidth,
|
|
82
|
-
y: top + height / 2
|
|
83
|
-
};
|
|
84
59
|
/* If there's an axis title, the tick labels have less space to render */
|
|
85
|
-
const tickLabelsMaxWidth = Math.max(0, axisWidth - (
|
|
60
|
+
const tickLabelsMaxWidth = Math.max(0, axisWidth - (axisLabelHeight > 0 ? axisLabelHeight + AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - TICK_LABEL_GAP);
|
|
86
61
|
const tickLabels = isHydrated ? shortenLabels(yTicks, drawingArea, tickLabelsMaxWidth, isRtl, axisTickLabelProps.style) : new Map(Array.from(yTicks).map(item => [item, item.formattedValue]));
|
|
87
|
-
return /*#__PURE__*/
|
|
88
|
-
|
|
89
|
-
className: classes.root,
|
|
90
|
-
sx: sx,
|
|
91
|
-
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
92
|
-
y1: top,
|
|
93
|
-
y2: top + height,
|
|
94
|
-
className: classes.line
|
|
95
|
-
}, lineProps)), yTicks.map((item, index) => {
|
|
62
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
63
|
+
children: yTicks.map((item, index) => {
|
|
96
64
|
const {
|
|
97
65
|
offset: tickOffset,
|
|
98
66
|
labelOffset,
|
|
@@ -118,12 +86,7 @@ function ChartsSingleYAxis(inProps) {
|
|
|
118
86
|
text: tickLabel
|
|
119
87
|
}, axisTickLabelProps))]
|
|
120
88
|
}, index);
|
|
121
|
-
})
|
|
122
|
-
className: classes.label,
|
|
123
|
-
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
124
|
-
text: label
|
|
125
|
-
}))
|
|
126
|
-
})]
|
|
89
|
+
})
|
|
127
90
|
});
|
|
128
91
|
}
|
|
129
|
-
export {
|
|
92
|
+
export { ChartsSingleYAxisTicks };
|
|
@@ -4,9 +4,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
7
|
-
import { useYAxes } from "../hooks/
|
|
8
|
-
import {
|
|
9
|
-
import { ChartsGroupedYAxis } from "./ChartsGroupedYAxis.js";
|
|
7
|
+
import { useYAxes } from "../hooks/index.js";
|
|
8
|
+
import { ChartsYAxisImpl } from "./ChartsYAxisImpl.js";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Demos:
|
|
@@ -28,10 +27,9 @@ function ChartsYAxis(inProps) {
|
|
|
28
27
|
warnOnce(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
|
|
29
28
|
return null;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return /*#__PURE__*/_jsx(ChartsSingleYAxis, _extends({}, inProps));
|
|
30
|
+
return /*#__PURE__*/_jsx(ChartsYAxisImpl, _extends({}, inProps, {
|
|
31
|
+
axis: axis
|
|
32
|
+
}));
|
|
35
33
|
}
|
|
36
34
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
37
35
|
// ----------------------------- 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,126 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["axis"],
|
|
6
|
+
_excluded2 = ["scale", "tickNumber", "reverse"];
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
9
|
+
import { useThemeProps, useTheme, styled } from '@mui/material/styles';
|
|
10
|
+
import { ChartsSingleYAxisTicks } from "./ChartsSingleYAxisTicks.js";
|
|
11
|
+
import { ChartsGroupedYAxisTicks } from "./ChartsGroupedYAxisTicks.js";
|
|
12
|
+
import { ChartsText } from "../ChartsText/index.js";
|
|
13
|
+
import { defaultProps, useUtilityClasses } from "./utilities.js";
|
|
14
|
+
import { isInfinity } from "../internals/isInfinity.js";
|
|
15
|
+
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
16
|
+
import { useIsHydrated } from "../hooks/useIsHydrated.js";
|
|
17
|
+
import { isOrdinalScale } from "../internals/scaleGuards.js";
|
|
18
|
+
import { getStringSize } from "../internals/domUtils.js";
|
|
19
|
+
import { AxisRoot } from "../internals/components/AxisSharedComponents.js";
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
const YAxisRoot = styled(AxisRoot, {
|
|
22
|
+
name: 'MuiChartsYAxis',
|
|
23
|
+
slot: 'Root'
|
|
24
|
+
})({});
|
|
25
|
+
/**
|
|
26
|
+
* @ignore - internal component. Use `ChartsYAxis` instead.
|
|
27
|
+
*/
|
|
28
|
+
export function ChartsYAxisImpl(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
axis
|
|
31
|
+
} = _ref,
|
|
32
|
+
inProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
33
|
+
const {
|
|
34
|
+
scale: yScale
|
|
35
|
+
} = axis,
|
|
36
|
+
settings = _objectWithoutPropertiesLoose(axis, _excluded2);
|
|
37
|
+
const isHydrated = useIsHydrated();
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
40
|
+
const themedProps = useThemeProps({
|
|
41
|
+
props: _extends({}, settings, inProps),
|
|
42
|
+
name: 'MuiChartsYAxis'
|
|
43
|
+
});
|
|
44
|
+
const defaultizedProps = _extends({}, defaultProps, themedProps);
|
|
45
|
+
const {
|
|
46
|
+
position,
|
|
47
|
+
disableLine,
|
|
48
|
+
label,
|
|
49
|
+
labelStyle,
|
|
50
|
+
offset,
|
|
51
|
+
width: axisWidth,
|
|
52
|
+
sx,
|
|
53
|
+
slots,
|
|
54
|
+
slotProps
|
|
55
|
+
} = defaultizedProps;
|
|
56
|
+
const theme = useTheme();
|
|
57
|
+
const classes = useUtilityClasses(defaultizedProps);
|
|
58
|
+
const {
|
|
59
|
+
left,
|
|
60
|
+
top,
|
|
61
|
+
width,
|
|
62
|
+
height
|
|
63
|
+
} = useDrawingArea();
|
|
64
|
+
const positionSign = position === 'right' ? 1 : -1;
|
|
65
|
+
const Line = slots?.axisLine ?? 'line';
|
|
66
|
+
const Label = slots?.axisLabel ?? ChartsText;
|
|
67
|
+
const lineProps = useSlotProps({
|
|
68
|
+
elementType: Line,
|
|
69
|
+
externalSlotProps: slotProps?.axisLine,
|
|
70
|
+
additionalProps: {
|
|
71
|
+
strokeLinecap: 'square'
|
|
72
|
+
},
|
|
73
|
+
ownerState: {}
|
|
74
|
+
});
|
|
75
|
+
const axisLabelProps = useSlotProps({
|
|
76
|
+
elementType: Label,
|
|
77
|
+
externalSlotProps: slotProps?.axisLabel,
|
|
78
|
+
additionalProps: {
|
|
79
|
+
style: _extends({}, theme.typography.body1, {
|
|
80
|
+
lineHeight: 1,
|
|
81
|
+
fontSize: 14,
|
|
82
|
+
angle: positionSign * 90,
|
|
83
|
+
textAnchor: 'middle',
|
|
84
|
+
dominantBaseline: 'text-before-edge'
|
|
85
|
+
}, labelStyle)
|
|
86
|
+
},
|
|
87
|
+
ownerState: {}
|
|
88
|
+
});
|
|
89
|
+
|
|
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 (position === 'none') {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const labelRefPoint = {
|
|
98
|
+
x: positionSign * axisWidth,
|
|
99
|
+
y: top + height / 2
|
|
100
|
+
};
|
|
101
|
+
const axisLabelHeight = label == null ? 0 : getStringSize(label, axisLabelProps.style).height;
|
|
102
|
+
const domain = yScale.domain();
|
|
103
|
+
const isScaleOrdinal = isOrdinalScale(yScale);
|
|
104
|
+
const skipTickRendering = isScaleOrdinal ? domain.length === 0 : domain.some(isInfinity);
|
|
105
|
+
let children = null;
|
|
106
|
+
if (!skipTickRendering) {
|
|
107
|
+
children = 'groups' in axis && Array.isArray(axis.groups) ? /*#__PURE__*/_jsx(ChartsGroupedYAxisTicks, _extends({}, inProps)) : /*#__PURE__*/_jsx(ChartsSingleYAxisTicks, _extends({}, inProps, {
|
|
108
|
+
axisLabelHeight: axisLabelHeight
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
return /*#__PURE__*/_jsxs(YAxisRoot, {
|
|
112
|
+
transform: `translate(${position === 'right' ? left + width + offset : left - offset}, 0)`,
|
|
113
|
+
className: classes.root,
|
|
114
|
+
sx: sx,
|
|
115
|
+
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
116
|
+
y1: top,
|
|
117
|
+
y2: top + height,
|
|
118
|
+
className: classes.line
|
|
119
|
+
}, lineProps)), children, label && isHydrated && /*#__PURE__*/_jsx("g", {
|
|
120
|
+
className: classes.label,
|
|
121
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
122
|
+
text: label
|
|
123
|
+
}))
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
126
|
+
}
|