@mui/x-charts 9.0.2 → 9.0.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/BarChart.js +2 -1
- package/BarChart/BarChart.mjs +2 -1
- package/BarChart/BarPlot.js +2 -1
- package/BarChart/BarPlot.mjs +2 -1
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +8 -8
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +8 -8
- package/CHANGELOG.md +136 -0
- package/ChartsRadialGrid/ChartsRadialGrid.js +2 -0
- package/ChartsRadialGrid/ChartsRadialGrid.mjs +2 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.d.mts +1 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.d.ts +1 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.js +1 -2
- package/ChartsRadialGrid/ChartsRadiusGrid.mjs +1 -2
- package/ChartsRadiusAxis/ChartsRadiusAxis.d.mts +48 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.d.ts +48 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.js +147 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.mjs +141 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.mts +6 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.ts +6 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.js +30 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.mjs +17 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.d.mts +10 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.d.ts +10 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.js +46 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.mjs +39 -0
- package/ChartsRadiusAxis/getLabelTransform.d.mts +11 -0
- package/ChartsRadiusAxis/getLabelTransform.d.ts +11 -0
- package/ChartsRadiusAxis/getLabelTransform.js +37 -0
- package/ChartsRadiusAxis/getLabelTransform.mjs +31 -0
- package/ChartsRadiusAxis/index.d.mts +3 -0
- package/ChartsRadiusAxis/index.d.ts +3 -0
- package/ChartsRadiusAxis/index.js +19 -0
- package/ChartsRadiusAxis/index.mjs +2 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.d.mts +21 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.d.ts +21 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.js +14 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.mjs +6 -0
- package/ChartsRotationAxis/ChartsRotationAxis.d.mts +48 -0
- package/ChartsRotationAxis/ChartsRotationAxis.d.ts +48 -0
- package/ChartsRotationAxis/ChartsRotationAxis.js +141 -0
- package/ChartsRotationAxis/ChartsRotationAxis.mjs +135 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.d.mts +5 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.d.ts +5 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.js +29 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.mjs +16 -0
- package/ChartsRotationAxis/getLabelTransform.d.mts +11 -0
- package/ChartsRotationAxis/getLabelTransform.d.ts +11 -0
- package/ChartsRotationAxis/getLabelTransform.js +37 -0
- package/ChartsRotationAxis/getLabelTransform.mjs +31 -0
- package/ChartsRotationAxis/index.d.mts +2 -0
- package/ChartsRotationAxis/index.d.ts +2 -0
- package/ChartsRotationAxis/index.js +19 -0
- package/ChartsRotationAxis/index.mjs +2 -0
- package/ChartsTooltip/useAxesTooltip.js +7 -4
- package/ChartsTooltip/useAxesTooltip.mjs +8 -5
- package/ChartsTooltip/useItemTooltip.d.mts +1 -1
- package/ChartsTooltip/useItemTooltip.d.ts +1 -1
- package/ChartsTooltip/useItemTooltip.js +17 -2
- package/ChartsTooltip/useItemTooltip.mjs +18 -3
- package/ChartsXAxis/useAxisTicksProps.d.mts +245 -164
- package/ChartsXAxis/useAxisTicksProps.d.ts +245 -164
- package/ChartsYAxis/useAxisTicksProps.d.mts +245 -164
- package/ChartsYAxis/useAxisTicksProps.d.ts +245 -164
- package/LineChart/seriesConfig/curveEvaluation.js +24 -19
- package/LineChart/seriesConfig/curveEvaluation.mjs +24 -19
- package/LineChart/seriesConfig/getItemAtPosition.js +14 -3
- package/LineChart/seriesConfig/getItemAtPosition.mjs +14 -3
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +4 -6
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.mjs +4 -6
- package/LineChart/seriesConfig/seriesProcessor.d.mts +4 -2
- package/LineChart/seriesConfig/seriesProcessor.d.ts +4 -2
- package/LineChart/seriesConfig/seriesProcessor.js +2 -2
- package/LineChart/seriesConfig/seriesProcessor.mjs +2 -2
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.mts +2 -2
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/hooks/useAxis.d.mts +2 -2
- package/hooks/useAxis.d.ts +2 -2
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/index.js +22 -2
- package/index.mjs +3 -1
- package/internals/cubiqSolver.d.mts +5 -0
- package/internals/cubiqSolver.d.ts +5 -0
- package/internals/cubiqSolver.js +62 -0
- package/internals/cubiqSolver.mjs +56 -0
- package/internals/index.d.mts +5 -1
- package/internals/index.d.ts +5 -1
- package/internals/index.js +47 -2
- package/internals/index.mjs +5 -1
- package/internals/isPolar.d.mts +3 -2
- package/internals/isPolar.d.ts +3 -2
- package/internals/isPolar.js +4 -0
- package/internals/isPolar.mjs +3 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.mts +8 -9
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.ts +8 -9
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.mts +3 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.ts +3 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +23 -13
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.mjs +23 -13
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
- package/models/axis.d.mts +2 -0
- package/models/axis.d.ts +2 -0
- package/models/seriesType/bar.d.mts +12 -7
- package/models/seriesType/bar.d.ts +12 -7
- package/models/seriesType/common.d.mts +10 -0
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/composition.d.mts +3 -1
- package/models/seriesType/composition.d.ts +3 -1
- package/models/seriesType/composition.js +6 -2
- package/models/seriesType/composition.mjs +5 -1
- package/models/seriesType/index.d.mts +3 -3
- package/models/seriesType/index.d.ts +3 -3
- package/models/seriesType/index.js +0 -22
- package/models/seriesType/index.mjs +0 -2
- package/models/seriesType/line.d.mts +13 -8
- package/models/seriesType/line.d.ts +13 -8
- package/package.json +161 -133
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useTheme } from '@mui/material/styles';
|
|
6
|
+
import { useTicks } from "../hooks/useTicks.mjs";
|
|
7
|
+
import { useRadiusAxis, useRotationAxis } from "../hooks/useAxis.mjs";
|
|
8
|
+
import { useChartsContext } from "../context/ChartsProvider/index.mjs";
|
|
9
|
+
import { selectorChartPolarCenter } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.mjs";
|
|
10
|
+
import { useUtilityClasses } from "./chartsRadiusAxisClasses.mjs";
|
|
11
|
+
import { createGetLabelTextAnchors } from "./createGetLabelTextAnchors.mjs";
|
|
12
|
+
import { getLabelTransform } from "./getLabelTransform.mjs";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
/* Gap between a tick and its label. */
|
|
15
|
+
const TICK_LABEL_GAP = 3;
|
|
16
|
+
const getLabelTextAnchors = createGetLabelTextAnchors(getLabelTransform);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get the angle to use to display the radius axis.
|
|
20
|
+
* @param position The position props
|
|
21
|
+
* @param rotationAxis The default rotation axis
|
|
22
|
+
* @returns the angle in radians to use.
|
|
23
|
+
*/
|
|
24
|
+
function getAxisAngleInRadians(position, rotationAxis) {
|
|
25
|
+
if (position === 'start') {
|
|
26
|
+
return rotationAxis?.scale.range()[0] ?? 0;
|
|
27
|
+
}
|
|
28
|
+
if (position === 'end') {
|
|
29
|
+
return rotationAxis?.scale.range()[1] ?? 0;
|
|
30
|
+
}
|
|
31
|
+
if (typeof position === 'number') {
|
|
32
|
+
return position * Math.PI / 180;
|
|
33
|
+
}
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
export function ChartsRadiusAxis(props) {
|
|
37
|
+
const {
|
|
38
|
+
axisId,
|
|
39
|
+
position = 'start',
|
|
40
|
+
disableLine,
|
|
41
|
+
disableTicks,
|
|
42
|
+
tickLabelPosition = 'after',
|
|
43
|
+
tickPosition = 'after',
|
|
44
|
+
tickSize = 6,
|
|
45
|
+
className,
|
|
46
|
+
classes: classesProp
|
|
47
|
+
} = props;
|
|
48
|
+
const isCentered = tickLabelPosition === 'center';
|
|
49
|
+
const classes = useUtilityClasses({
|
|
50
|
+
classes: classesProp,
|
|
51
|
+
isCentered
|
|
52
|
+
});
|
|
53
|
+
const theme = useTheme();
|
|
54
|
+
const {
|
|
55
|
+
store
|
|
56
|
+
} = useChartsContext();
|
|
57
|
+
const {
|
|
58
|
+
cx,
|
|
59
|
+
cy
|
|
60
|
+
} = store.use(selectorChartPolarCenter);
|
|
61
|
+
const radiusAxis = useRadiusAxis(axisId);
|
|
62
|
+
const rotationAxis = useRotationAxis();
|
|
63
|
+
const ticks = useTicks({
|
|
64
|
+
scale: radiusAxis.scale,
|
|
65
|
+
tickNumber: radiusAxis?.tickNumber ?? 5,
|
|
66
|
+
tickInterval: radiusAxis?.tickInterval,
|
|
67
|
+
tickSpacing: radiusAxis?.tickSpacing,
|
|
68
|
+
valueFormatter: radiusAxis?.valueFormatter,
|
|
69
|
+
direction: 'radius'
|
|
70
|
+
});
|
|
71
|
+
if (!radiusAxis) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const angle = getAxisAngleInRadians(position, rotationAxis);
|
|
75
|
+
// Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
|
|
76
|
+
const dx = Math.sin(angle);
|
|
77
|
+
const dy = -Math.cos(angle);
|
|
78
|
+
// Perpendicular offset for tick marks (rotated 90° clockwise).
|
|
79
|
+
const px = -dy;
|
|
80
|
+
const py = dx;
|
|
81
|
+
const [innerRadius, outerRadius] = radiusAxis.scale.range();
|
|
82
|
+
const stroke = (theme.vars ?? theme).palette.text.primary;
|
|
83
|
+
const tickDx = (tickPosition === 'after' ? 1 : -1) * px * tickSize;
|
|
84
|
+
const tickDy = (tickPosition === 'after' ? 1 : -1) * py * tickSize;
|
|
85
|
+
const tickLabelGap = isCentered ? 0 : TICK_LABEL_GAP;
|
|
86
|
+
const tickLabelGapDx = (tickLabelPosition === 'after' ? 1 : -1) * px * tickLabelGap;
|
|
87
|
+
const tickLabelGapDy = (tickLabelPosition === 'after' ? 1 : -1) * py * tickLabelGap;
|
|
88
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
89
|
+
className: clsx(classes.root, className),
|
|
90
|
+
children: [!disableLine && /*#__PURE__*/_jsx("line", {
|
|
91
|
+
x1: cx + dx * innerRadius,
|
|
92
|
+
y1: cy + dy * innerRadius,
|
|
93
|
+
x2: cx + dx * outerRadius,
|
|
94
|
+
y2: cy + dy * outerRadius,
|
|
95
|
+
stroke: stroke,
|
|
96
|
+
className: classes.line
|
|
97
|
+
}), ticks.map(({
|
|
98
|
+
offset: radius,
|
|
99
|
+
formattedValue
|
|
100
|
+
}, index) => {
|
|
101
|
+
if (!formattedValue) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const tx = cx + dx * radius;
|
|
105
|
+
const ty = cy + dy * radius;
|
|
106
|
+
|
|
107
|
+
// Compute the label position.
|
|
108
|
+
let labelX = tx;
|
|
109
|
+
let labelY = ty;
|
|
110
|
+
if (tickLabelGap !== 0) {
|
|
111
|
+
labelX += tickLabelGapDx;
|
|
112
|
+
labelY += tickLabelGapDy;
|
|
113
|
+
}
|
|
114
|
+
if (!isCentered && tickLabelPosition === tickPosition && !disableTicks) {
|
|
115
|
+
// Add the size of the tick if they are in the same direction.
|
|
116
|
+
labelX += tickDx;
|
|
117
|
+
labelY += tickDy;
|
|
118
|
+
}
|
|
119
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
120
|
+
className: classes.tickContainer,
|
|
121
|
+
children: [!disableTicks && /*#__PURE__*/_jsx("line", {
|
|
122
|
+
x1: tx,
|
|
123
|
+
y1: ty,
|
|
124
|
+
x2: tx + tickDx,
|
|
125
|
+
y2: ty + tickDy,
|
|
126
|
+
stroke: stroke,
|
|
127
|
+
className: classes.tick
|
|
128
|
+
}), /*#__PURE__*/_jsx("text", _extends({
|
|
129
|
+
x: labelX,
|
|
130
|
+
y: labelY,
|
|
131
|
+
fill: stroke,
|
|
132
|
+
fontSize: 12,
|
|
133
|
+
className: classes.tickLabel,
|
|
134
|
+
pointerEvents: "none"
|
|
135
|
+
}, getLabelTextAnchors(dx, dy, tickLabelPosition), {
|
|
136
|
+
children: formattedValue
|
|
137
|
+
}))]
|
|
138
|
+
}, index);
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ChartsRadialAxisClasses } from "./sharedRadialAxisClasses.mjs";
|
|
2
|
+
export declare const useUtilityClasses: (props: {
|
|
3
|
+
classes?: Partial<ChartsRadialAxisClasses>;
|
|
4
|
+
isCentered?: boolean;
|
|
5
|
+
}) => Record<"root" | "line" | "tickContainer" | "tick" | "tickLabel", string>;
|
|
6
|
+
export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "./sharedRadialAxisClasses.mjs";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ChartsRadialAxisClasses } from "./sharedRadialAxisClasses.js";
|
|
2
|
+
export declare const useUtilityClasses: (props: {
|
|
3
|
+
classes?: Partial<ChartsRadialAxisClasses>;
|
|
4
|
+
isCentered?: boolean;
|
|
5
|
+
}) => Record<"root" | "line" | "tickContainer" | "tick" | "tickLabel", string>;
|
|
6
|
+
export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "./sharedRadialAxisClasses.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "chartsRadialAxisClasses", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _sharedRadialAxisClasses.chartsRadialAxisClasses;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.useUtilityClasses = void 0;
|
|
14
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
15
|
+
var _sharedRadialAxisClasses = require("./sharedRadialAxisClasses");
|
|
16
|
+
const useUtilityClasses = props => {
|
|
17
|
+
const {
|
|
18
|
+
classes,
|
|
19
|
+
isCentered
|
|
20
|
+
} = props;
|
|
21
|
+
const slots = {
|
|
22
|
+
root: ['root', 'radius'],
|
|
23
|
+
line: ['line'],
|
|
24
|
+
tickContainer: ['tickContainer'],
|
|
25
|
+
tick: ['tick'],
|
|
26
|
+
tickLabel: ['tickLabel', isCentered && 'centered']
|
|
27
|
+
};
|
|
28
|
+
return (0, _composeClasses.default)(slots, _sharedRadialAxisClasses.getRadialAxisUtilityClass, classes);
|
|
29
|
+
};
|
|
30
|
+
exports.useUtilityClasses = useUtilityClasses;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import { getRadialAxisUtilityClass } from "./sharedRadialAxisClasses.mjs";
|
|
3
|
+
export const useUtilityClasses = props => {
|
|
4
|
+
const {
|
|
5
|
+
classes,
|
|
6
|
+
isCentered
|
|
7
|
+
} = props;
|
|
8
|
+
const slots = {
|
|
9
|
+
root: ['root', 'radius'],
|
|
10
|
+
line: ['line'],
|
|
11
|
+
tickContainer: ['tickContainer'],
|
|
12
|
+
tick: ['tick'],
|
|
13
|
+
tickLabel: ['tickLabel', isCentered && 'centered']
|
|
14
|
+
};
|
|
15
|
+
return composeClasses(slots, getRadialAxisUtilityClass, classes);
|
|
16
|
+
};
|
|
17
|
+
export { chartsRadialAxisClasses } from "./sharedRadialAxisClasses.mjs";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher order function that transform a `getLabelTransform` to the <text /> anchor props.
|
|
3
|
+
*/
|
|
4
|
+
export declare const createGetLabelTextAnchors: (getLabelTransform: (px: number, py: number, tickLabelPosition: "center" | "after" | "before") => {
|
|
5
|
+
verticalAlign: "start" | "middle" | "end";
|
|
6
|
+
horizontalAlign: "start" | "middle" | "end";
|
|
7
|
+
}) => (px: number, py: number, tickLabelPosition: "center" | "after" | "before") => {
|
|
8
|
+
textAnchor: "start" | "middle" | "end";
|
|
9
|
+
dominantBaseline: "hanging" | "middle" | "auto";
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher order function that transform a `getLabelTransform` to the <text /> anchor props.
|
|
3
|
+
*/
|
|
4
|
+
export declare const createGetLabelTextAnchors: (getLabelTransform: (px: number, py: number, tickLabelPosition: "center" | "after" | "before") => {
|
|
5
|
+
verticalAlign: "start" | "middle" | "end";
|
|
6
|
+
horizontalAlign: "start" | "middle" | "end";
|
|
7
|
+
}) => (px: number, py: number, tickLabelPosition: "center" | "after" | "before") => {
|
|
8
|
+
textAnchor: "start" | "middle" | "end";
|
|
9
|
+
dominantBaseline: "hanging" | "middle" | "auto";
|
|
10
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createGetLabelTextAnchors = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Higher order function that transform a `getLabelTransform` to the <text /> anchor props.
|
|
9
|
+
*/
|
|
10
|
+
const createGetLabelTextAnchors = getLabelTransform => (px, py, tickLabelPosition) => {
|
|
11
|
+
const {
|
|
12
|
+
verticalAlign,
|
|
13
|
+
horizontalAlign
|
|
14
|
+
} = getLabelTransform(px, py, tickLabelPosition);
|
|
15
|
+
let textAnchor;
|
|
16
|
+
let dominantBaseline;
|
|
17
|
+
switch (verticalAlign) {
|
|
18
|
+
case 'start':
|
|
19
|
+
dominantBaseline = 'hanging';
|
|
20
|
+
break;
|
|
21
|
+
case 'middle':
|
|
22
|
+
dominantBaseline = 'middle';
|
|
23
|
+
break;
|
|
24
|
+
case 'end':
|
|
25
|
+
default:
|
|
26
|
+
dominantBaseline = 'auto';
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
switch (horizontalAlign) {
|
|
30
|
+
case 'start':
|
|
31
|
+
textAnchor = 'start';
|
|
32
|
+
break;
|
|
33
|
+
case 'middle':
|
|
34
|
+
textAnchor = 'middle';
|
|
35
|
+
break;
|
|
36
|
+
case 'end':
|
|
37
|
+
default:
|
|
38
|
+
textAnchor = 'end';
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
textAnchor,
|
|
43
|
+
dominantBaseline
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.createGetLabelTextAnchors = createGetLabelTextAnchors;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher order function that transform a `getLabelTransform` to the <text /> anchor props.
|
|
3
|
+
*/
|
|
4
|
+
export const createGetLabelTextAnchors = getLabelTransform => (px, py, tickLabelPosition) => {
|
|
5
|
+
const {
|
|
6
|
+
verticalAlign,
|
|
7
|
+
horizontalAlign
|
|
8
|
+
} = getLabelTransform(px, py, tickLabelPosition);
|
|
9
|
+
let textAnchor;
|
|
10
|
+
let dominantBaseline;
|
|
11
|
+
switch (verticalAlign) {
|
|
12
|
+
case 'start':
|
|
13
|
+
dominantBaseline = 'hanging';
|
|
14
|
+
break;
|
|
15
|
+
case 'middle':
|
|
16
|
+
dominantBaseline = 'middle';
|
|
17
|
+
break;
|
|
18
|
+
case 'end':
|
|
19
|
+
default:
|
|
20
|
+
dominantBaseline = 'auto';
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
switch (horizontalAlign) {
|
|
24
|
+
case 'start':
|
|
25
|
+
textAnchor = 'start';
|
|
26
|
+
break;
|
|
27
|
+
case 'middle':
|
|
28
|
+
textAnchor = 'middle';
|
|
29
|
+
break;
|
|
30
|
+
case 'end':
|
|
31
|
+
default:
|
|
32
|
+
textAnchor = 'end';
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
textAnchor,
|
|
37
|
+
dominantBaseline
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
3
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
4
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
5
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
6
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLabelTransform(px: number, py: number, tickLabelPosition: 'center' | 'after' | 'before'): {
|
|
9
|
+
verticalAlign: 'start' | 'middle' | 'end';
|
|
10
|
+
horizontalAlign: 'start' | 'middle' | 'end';
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
3
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
4
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
5
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
6
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLabelTransform(px: number, py: number, tickLabelPosition: 'center' | 'after' | 'before'): {
|
|
9
|
+
verticalAlign: 'start' | 'middle' | 'end';
|
|
10
|
+
horizontalAlign: 'start' | 'middle' | 'end';
|
|
11
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLabelTransform = getLabelTransform;
|
|
7
|
+
/**
|
|
8
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
9
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
10
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
11
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
12
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
13
|
+
*/
|
|
14
|
+
function getLabelTransform(px, py, tickLabelPosition) {
|
|
15
|
+
if (tickLabelPosition === 'center') {
|
|
16
|
+
return {
|
|
17
|
+
verticalAlign: 'middle',
|
|
18
|
+
horizontalAlign: 'middle'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
let verticalAlign = 'middle';
|
|
22
|
+
let horizontalAlign = 'middle';
|
|
23
|
+
if (px > 0.3) {
|
|
24
|
+
verticalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
25
|
+
} else if (px < -0.3) {
|
|
26
|
+
verticalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
27
|
+
}
|
|
28
|
+
if (py > 0.3) {
|
|
29
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
30
|
+
} else if (py < -0.3) {
|
|
31
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
verticalAlign,
|
|
35
|
+
horizontalAlign
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
3
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
4
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
5
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
6
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
7
|
+
*/
|
|
8
|
+
export function getLabelTransform(px, py, tickLabelPosition) {
|
|
9
|
+
if (tickLabelPosition === 'center') {
|
|
10
|
+
return {
|
|
11
|
+
verticalAlign: 'middle',
|
|
12
|
+
horizontalAlign: 'middle'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let verticalAlign = 'middle';
|
|
16
|
+
let horizontalAlign = 'middle';
|
|
17
|
+
if (px > 0.3) {
|
|
18
|
+
verticalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
19
|
+
} else if (px < -0.3) {
|
|
20
|
+
verticalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
21
|
+
}
|
|
22
|
+
if (py > 0.3) {
|
|
23
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
24
|
+
} else if (py < -0.3) {
|
|
25
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
verticalAlign,
|
|
29
|
+
horizontalAlign
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type ChartsRadiusAxisProps, ChartsRadiusAxis as Unstable_ChartsRadiusAxis } from "./ChartsRadiusAxis.mjs";
|
|
2
|
+
export { chartsRadialAxisClasses } from "./chartsRadiusAxisClasses.mjs";
|
|
3
|
+
export type { ChartsRadialAxisClasses, ChartsRadialAxisClassKey } from "./chartsRadiusAxisClasses.mjs";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type ChartsRadiusAxisProps, ChartsRadiusAxis as Unstable_ChartsRadiusAxis } from "./ChartsRadiusAxis.js";
|
|
2
|
+
export { chartsRadialAxisClasses } from "./chartsRadiusAxisClasses.js";
|
|
3
|
+
export type { ChartsRadialAxisClasses, ChartsRadialAxisClassKey } from "./chartsRadiusAxisClasses.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Unstable_ChartsRadiusAxis", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ChartsRadiusAxis.ChartsRadiusAxis;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "chartsRadialAxisClasses", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _chartsRadiusAxisClasses.chartsRadialAxisClasses;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _ChartsRadiusAxis = require("./ChartsRadiusAxis");
|
|
19
|
+
var _chartsRadiusAxisClasses = require("./chartsRadiusAxisClasses");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ChartsRadialAxisClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the root element of radius axis. */
|
|
5
|
+
radius: string;
|
|
6
|
+
/** Styles applied to the root element of rotation axis. */
|
|
7
|
+
rotation: string;
|
|
8
|
+
/** Styles applied to the main line element. */
|
|
9
|
+
line: string;
|
|
10
|
+
/** Styles applied to the group including the tick and its label. */
|
|
11
|
+
tickContainer: string;
|
|
12
|
+
/** Styles applied to ticks. */
|
|
13
|
+
tick: string;
|
|
14
|
+
/** Styles applied to the tick label. */
|
|
15
|
+
tickLabel: string;
|
|
16
|
+
/** Styles applied to the tick label when centered. */
|
|
17
|
+
centered: string;
|
|
18
|
+
}
|
|
19
|
+
export type ChartsRadialAxisClassKey = keyof ChartsRadialAxisClasses;
|
|
20
|
+
export declare function getRadialAxisUtilityClass(slot: string): string;
|
|
21
|
+
export declare const chartsRadialAxisClasses: ChartsRadialAxisClasses;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ChartsRadialAxisClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the root element of radius axis. */
|
|
5
|
+
radius: string;
|
|
6
|
+
/** Styles applied to the root element of rotation axis. */
|
|
7
|
+
rotation: string;
|
|
8
|
+
/** Styles applied to the main line element. */
|
|
9
|
+
line: string;
|
|
10
|
+
/** Styles applied to the group including the tick and its label. */
|
|
11
|
+
tickContainer: string;
|
|
12
|
+
/** Styles applied to ticks. */
|
|
13
|
+
tick: string;
|
|
14
|
+
/** Styles applied to the tick label. */
|
|
15
|
+
tickLabel: string;
|
|
16
|
+
/** Styles applied to the tick label when centered. */
|
|
17
|
+
centered: string;
|
|
18
|
+
}
|
|
19
|
+
export type ChartsRadialAxisClassKey = keyof ChartsRadialAxisClasses;
|
|
20
|
+
export declare function getRadialAxisUtilityClass(slot: string): string;
|
|
21
|
+
export declare const chartsRadialAxisClasses: ChartsRadialAxisClasses;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.chartsRadialAxisClasses = void 0;
|
|
8
|
+
exports.getRadialAxisUtilityClass = getRadialAxisUtilityClass;
|
|
9
|
+
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
10
|
+
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
11
|
+
function getRadialAxisUtilityClass(slot) {
|
|
12
|
+
return (0, _generateUtilityClass.default)('MuiChartsRadialAxis', slot);
|
|
13
|
+
}
|
|
14
|
+
const chartsRadialAxisClasses = exports.chartsRadialAxisClasses = (0, _generateUtilityClasses.default)('MuiChartsRadialAxis', ['root', 'radius', 'rotation', 'line', 'tickContainer', 'tick', 'tickLabel', 'centered']);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
export function getRadialAxisUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiChartsRadialAxis', slot);
|
|
5
|
+
}
|
|
6
|
+
export const chartsRadialAxisClasses = generateUtilityClasses('MuiChartsRadialAxis', ['root', 'radius', 'rotation', 'line', 'tickContainer', 'tick', 'tickLabel', 'centered']);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AxisId } from "../models/axis.mjs";
|
|
2
|
+
import { type ChartsRadialAxisClasses } from "./chartsRotationAxisClasses.mjs";
|
|
3
|
+
export interface ChartsRotationAxisProps {
|
|
4
|
+
/**
|
|
5
|
+
* Id of the rotation axis to render.
|
|
6
|
+
* If not provided, it will use the first defined rotation axis.
|
|
7
|
+
*/
|
|
8
|
+
axisId?: AxisId;
|
|
9
|
+
/**
|
|
10
|
+
* If `true`, the axis line is not rendered.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
disableLine?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* If `true`, the ticks are not rendered.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
disableTicks?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The position of the rotation axis.
|
|
21
|
+
* It can be 'inside' or 'outside'.
|
|
22
|
+
* @default 'outside'
|
|
23
|
+
*/
|
|
24
|
+
position?: 'inside' | 'outside';
|
|
25
|
+
/**
|
|
26
|
+
* The size (in pixels) of the tick marks.
|
|
27
|
+
* @default 6
|
|
28
|
+
*/
|
|
29
|
+
tickSize?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Set the position of the tick labels relative to the axis line.
|
|
32
|
+
* `'after'` places them outside the arc, `'before'` inside.
|
|
33
|
+
* @default position === 'outside' ? 'after' : 'before'
|
|
34
|
+
*/
|
|
35
|
+
tickLabelPosition?: 'after' | 'before';
|
|
36
|
+
/**
|
|
37
|
+
* Set the position of the tick relative to the axis line.
|
|
38
|
+
* `'after'` places them outside the arc, `'before'` inside.
|
|
39
|
+
* @default position === 'outside' ? 'after' : 'before'
|
|
40
|
+
*/
|
|
41
|
+
tickPosition?: 'after' | 'before';
|
|
42
|
+
/**
|
|
43
|
+
* A CSS class name applied to the root element.
|
|
44
|
+
*/
|
|
45
|
+
className?: string;
|
|
46
|
+
classes?: Partial<ChartsRadialAxisClasses>;
|
|
47
|
+
}
|
|
48
|
+
export declare function ChartsRotationAxis(props: ChartsRotationAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AxisId } from "../models/axis.js";
|
|
2
|
+
import { type ChartsRadialAxisClasses } from "./chartsRotationAxisClasses.js";
|
|
3
|
+
export interface ChartsRotationAxisProps {
|
|
4
|
+
/**
|
|
5
|
+
* Id of the rotation axis to render.
|
|
6
|
+
* If not provided, it will use the first defined rotation axis.
|
|
7
|
+
*/
|
|
8
|
+
axisId?: AxisId;
|
|
9
|
+
/**
|
|
10
|
+
* If `true`, the axis line is not rendered.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
disableLine?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* If `true`, the ticks are not rendered.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
disableTicks?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The position of the rotation axis.
|
|
21
|
+
* It can be 'inside' or 'outside'.
|
|
22
|
+
* @default 'outside'
|
|
23
|
+
*/
|
|
24
|
+
position?: 'inside' | 'outside';
|
|
25
|
+
/**
|
|
26
|
+
* The size (in pixels) of the tick marks.
|
|
27
|
+
* @default 6
|
|
28
|
+
*/
|
|
29
|
+
tickSize?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Set the position of the tick labels relative to the axis line.
|
|
32
|
+
* `'after'` places them outside the arc, `'before'` inside.
|
|
33
|
+
* @default position === 'outside' ? 'after' : 'before'
|
|
34
|
+
*/
|
|
35
|
+
tickLabelPosition?: 'after' | 'before';
|
|
36
|
+
/**
|
|
37
|
+
* Set the position of the tick relative to the axis line.
|
|
38
|
+
* `'after'` places them outside the arc, `'before'` inside.
|
|
39
|
+
* @default position === 'outside' ? 'after' : 'before'
|
|
40
|
+
*/
|
|
41
|
+
tickPosition?: 'after' | 'before';
|
|
42
|
+
/**
|
|
43
|
+
* A CSS class name applied to the root element.
|
|
44
|
+
*/
|
|
45
|
+
className?: string;
|
|
46
|
+
classes?: Partial<ChartsRadialAxisClasses>;
|
|
47
|
+
}
|
|
48
|
+
export declare function ChartsRotationAxis(props: ChartsRotationAxisProps): import("react/jsx-runtime").JSX.Element | null;
|