@mui/x-charts 9.0.2 → 9.0.4

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 (150) hide show
  1. package/BarChart/BarChart.js +2 -1
  2. package/BarChart/BarChart.mjs +2 -1
  3. package/BarChart/BarPlot.js +2 -1
  4. package/BarChart/BarPlot.mjs +2 -1
  5. package/BarChart/FocusedBar.js +3 -0
  6. package/BarChart/FocusedBar.mjs +3 -0
  7. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +8 -8
  8. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +8 -8
  9. package/CHANGELOG.md +223 -0
  10. package/ChartsRadialGrid/ChartsRadialGrid.js +2 -0
  11. package/ChartsRadialGrid/ChartsRadialGrid.mjs +2 -0
  12. package/ChartsRadialGrid/ChartsRadiusGrid.d.mts +1 -0
  13. package/ChartsRadialGrid/ChartsRadiusGrid.d.ts +1 -0
  14. package/ChartsRadialGrid/ChartsRadiusGrid.js +1 -2
  15. package/ChartsRadialGrid/ChartsRadiusGrid.mjs +1 -2
  16. package/ChartsRadiusAxis/ChartsRadiusAxis.d.mts +48 -0
  17. package/ChartsRadiusAxis/ChartsRadiusAxis.d.ts +48 -0
  18. package/ChartsRadiusAxis/ChartsRadiusAxis.js +147 -0
  19. package/ChartsRadiusAxis/ChartsRadiusAxis.mjs +141 -0
  20. package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.mts +6 -0
  21. package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.ts +6 -0
  22. package/ChartsRadiusAxis/chartsRadiusAxisClasses.js +30 -0
  23. package/ChartsRadiusAxis/chartsRadiusAxisClasses.mjs +17 -0
  24. package/ChartsRadiusAxis/createGetLabelTextAnchors.d.mts +10 -0
  25. package/ChartsRadiusAxis/createGetLabelTextAnchors.d.ts +10 -0
  26. package/ChartsRadiusAxis/createGetLabelTextAnchors.js +46 -0
  27. package/ChartsRadiusAxis/createGetLabelTextAnchors.mjs +39 -0
  28. package/ChartsRadiusAxis/getLabelTransform.d.mts +11 -0
  29. package/ChartsRadiusAxis/getLabelTransform.d.ts +11 -0
  30. package/ChartsRadiusAxis/getLabelTransform.js +37 -0
  31. package/ChartsRadiusAxis/getLabelTransform.mjs +31 -0
  32. package/ChartsRadiusAxis/index.d.mts +3 -0
  33. package/ChartsRadiusAxis/index.d.ts +3 -0
  34. package/ChartsRadiusAxis/index.js +19 -0
  35. package/ChartsRadiusAxis/index.mjs +2 -0
  36. package/ChartsRadiusAxis/sharedRadialAxisClasses.d.mts +21 -0
  37. package/ChartsRadiusAxis/sharedRadialAxisClasses.d.ts +21 -0
  38. package/ChartsRadiusAxis/sharedRadialAxisClasses.js +14 -0
  39. package/ChartsRadiusAxis/sharedRadialAxisClasses.mjs +6 -0
  40. package/ChartsRotationAxis/ChartsRotationAxis.d.mts +48 -0
  41. package/ChartsRotationAxis/ChartsRotationAxis.d.ts +48 -0
  42. package/ChartsRotationAxis/ChartsRotationAxis.js +141 -0
  43. package/ChartsRotationAxis/ChartsRotationAxis.mjs +135 -0
  44. package/ChartsRotationAxis/chartsRotationAxisClasses.d.mts +5 -0
  45. package/ChartsRotationAxis/chartsRotationAxisClasses.d.ts +5 -0
  46. package/ChartsRotationAxis/chartsRotationAxisClasses.js +29 -0
  47. package/ChartsRotationAxis/chartsRotationAxisClasses.mjs +16 -0
  48. package/ChartsRotationAxis/getLabelTransform.d.mts +11 -0
  49. package/ChartsRotationAxis/getLabelTransform.d.ts +11 -0
  50. package/ChartsRotationAxis/getLabelTransform.js +37 -0
  51. package/ChartsRotationAxis/getLabelTransform.mjs +31 -0
  52. package/ChartsRotationAxis/index.d.mts +2 -0
  53. package/ChartsRotationAxis/index.d.ts +2 -0
  54. package/ChartsRotationAxis/index.js +19 -0
  55. package/ChartsRotationAxis/index.mjs +2 -0
  56. package/ChartsTooltip/useAxesTooltip.js +18 -7
  57. package/ChartsTooltip/useAxesTooltip.mjs +19 -8
  58. package/ChartsTooltip/useItemTooltip.d.mts +1 -1
  59. package/ChartsTooltip/useItemTooltip.d.ts +1 -1
  60. package/ChartsTooltip/useItemTooltip.js +17 -2
  61. package/ChartsTooltip/useItemTooltip.mjs +18 -3
  62. package/ChartsXAxis/useAxisTicksProps.d.mts +245 -164
  63. package/ChartsXAxis/useAxisTicksProps.d.ts +245 -164
  64. package/ChartsYAxis/useAxisTicksProps.d.mts +245 -164
  65. package/ChartsYAxis/useAxisTicksProps.d.ts +245 -164
  66. package/LineChart/FocusedLineMark.js +3 -0
  67. package/LineChart/FocusedLineMark.mjs +3 -0
  68. package/LineChart/seriesConfig/curveEvaluation.js +24 -19
  69. package/LineChart/seriesConfig/curveEvaluation.mjs +24 -19
  70. package/LineChart/seriesConfig/getItemAtPosition.js +25 -37
  71. package/LineChart/seriesConfig/getItemAtPosition.mjs +24 -36
  72. package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +4 -6
  73. package/LineChart/seriesConfig/getSeriesWithDefaultValues.mjs +4 -6
  74. package/LineChart/seriesConfig/seriesProcessor.d.mts +4 -2
  75. package/LineChart/seriesConfig/seriesProcessor.d.ts +4 -2
  76. package/LineChart/seriesConfig/seriesProcessor.js +2 -2
  77. package/LineChart/seriesConfig/seriesProcessor.mjs +2 -2
  78. package/PieChart/FocusedPieArc.js +3 -0
  79. package/PieChart/FocusedPieArc.mjs +3 -0
  80. package/RadarChart/FocusedRadarMark.js +3 -0
  81. package/RadarChart/FocusedRadarMark.mjs +3 -0
  82. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.mts +2 -2
  83. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  84. package/ScatterChart/FocusedScatterMark.js +3 -0
  85. package/ScatterChart/FocusedScatterMark.mjs +3 -0
  86. package/hooks/useAxis.d.mts +2 -2
  87. package/hooks/useAxis.d.ts +2 -2
  88. package/index.d.mts +2 -0
  89. package/index.d.ts +2 -0
  90. package/index.js +22 -2
  91. package/index.mjs +3 -1
  92. package/internals/commonNextFocusItem.js +62 -8
  93. package/internals/commonNextFocusItem.mjs +62 -8
  94. package/internals/cubiqSolver.d.mts +5 -0
  95. package/internals/cubiqSolver.d.ts +5 -0
  96. package/internals/cubiqSolver.js +62 -0
  97. package/internals/cubiqSolver.mjs +56 -0
  98. package/internals/findClosestIndex.d.mts +5 -0
  99. package/internals/findClosestIndex.d.ts +5 -0
  100. package/internals/findClosestIndex.js +27 -0
  101. package/internals/findClosestIndex.mjs +22 -0
  102. package/internals/getAsNumber.d.mts +1 -0
  103. package/internals/getAsNumber.d.ts +1 -0
  104. package/internals/getAsNumber.js +9 -0
  105. package/internals/getAsNumber.mjs +3 -0
  106. package/internals/index.d.mts +6 -1
  107. package/internals/index.d.ts +6 -1
  108. package/internals/index.js +59 -2
  109. package/internals/index.mjs +6 -1
  110. package/internals/isPolar.d.mts +3 -2
  111. package/internals/isPolar.d.ts +3 -2
  112. package/internals/isPolar.js +4 -0
  113. package/internals/isPolar.mjs +3 -0
  114. package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.mts +8 -9
  115. package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.ts +8 -9
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +4 -21
  117. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.mjs +4 -21
  118. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.mts +30 -0
  119. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.ts +30 -0
  120. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.js +57 -0
  121. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.mjs +51 -0
  122. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +7 -1
  123. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.mjs +7 -1
  124. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +7 -1
  125. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.mjs +7 -1
  126. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.mts +3 -2
  127. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.ts +3 -2
  128. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +25 -14
  129. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.mjs +25 -14
  130. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +9 -4
  131. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs +9 -3
  132. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +2 -2
  133. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
  134. package/models/axis.d.mts +2 -0
  135. package/models/axis.d.ts +2 -0
  136. package/models/seriesType/bar.d.mts +12 -7
  137. package/models/seriesType/bar.d.ts +12 -7
  138. package/models/seriesType/common.d.mts +10 -0
  139. package/models/seriesType/common.d.ts +10 -0
  140. package/models/seriesType/composition.d.mts +3 -1
  141. package/models/seriesType/composition.d.ts +3 -1
  142. package/models/seriesType/composition.js +6 -2
  143. package/models/seriesType/composition.mjs +5 -1
  144. package/models/seriesType/index.d.mts +3 -3
  145. package/models/seriesType/index.d.ts +3 -3
  146. package/models/seriesType/index.js +0 -22
  147. package/models/seriesType/index.mjs +0 -2
  148. package/models/seriesType/line.d.mts +13 -8
  149. package/models/seriesType/line.d.ts +13 -8
  150. package/package.json +32 -4
@@ -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;
@@ -0,0 +1,141 @@
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.ChartsRotationAxis = ChartsRotationAxis;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _clsx = _interopRequireDefault(require("clsx"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _useTicks = require("../hooks/useTicks");
13
+ var _useAxis = require("../hooks/useAxis");
14
+ var _ChartsProvider = require("../context/ChartsProvider");
15
+ var _useChartPolarAxis = require("../internals/plugins/featurePlugins/useChartPolarAxis");
16
+ var _chartsRotationAxisClasses = require("./chartsRotationAxisClasses");
17
+ var _createGetLabelTextAnchors = require("../ChartsRadiusAxis/createGetLabelTextAnchors");
18
+ var _getLabelTransform = require("./getLabelTransform");
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ /* Gap between a tick and its label. */
21
+ const TICK_LABEL_GAP = 3;
22
+ const getLabelTextAnchors = (0, _createGetLabelTextAnchors.createGetLabelTextAnchors)(_getLabelTransform.getLabelTransform);
23
+ function ChartsRotationAxis(props) {
24
+ const {
25
+ axisId,
26
+ disableLine,
27
+ disableTicks,
28
+ position = 'outside',
29
+ tickLabelPosition = position === 'outside' ? 'after' : 'before',
30
+ tickPosition = position === 'outside' ? 'after' : 'before',
31
+ tickSize = 6,
32
+ className,
33
+ classes: classesProp
34
+ } = props;
35
+ const classes = (0, _chartsRotationAxisClasses.useUtilityClasses)({
36
+ classes: classesProp
37
+ });
38
+ const theme = (0, _styles.useTheme)();
39
+ const {
40
+ store
41
+ } = (0, _ChartsProvider.useChartsContext)();
42
+ const {
43
+ cx,
44
+ cy
45
+ } = store.use(_useChartPolarAxis.selectorChartPolarCenter);
46
+ const rotationAxis = (0, _useAxis.useRotationAxis)(axisId);
47
+ const radiusAxis = (0, _useAxis.useRadiusAxis)();
48
+ const ticks = (0, _useTicks.useTicks)({
49
+ scale: rotationAxis.scale,
50
+ tickNumber: rotationAxis?.tickNumber ?? 5,
51
+ tickInterval: rotationAxis?.tickInterval,
52
+ tickSpacing: rotationAxis?.tickSpacing,
53
+ valueFormatter: rotationAxis?.valueFormatter,
54
+ direction: 'rotation'
55
+ });
56
+ if (!rotationAxis || !radiusAxis) {
57
+ return null;
58
+ }
59
+ const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
60
+ const [startAngle, endAngle] = rotationAxis.scale.range();
61
+ const stroke = (theme.vars ?? theme).palette.text.primary;
62
+
63
+ // Convert "0 = up" convention to SVG coordinates (y-down).
64
+ const angleToPoint = (angle, r) => ({
65
+ x: cx + Math.sin(angle) * r,
66
+ y: cy - Math.cos(angle) * r
67
+ });
68
+ const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
69
+ const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
70
+ const start = angleToPoint(startAngle, radius);
71
+ const end = angleToPoint(endAngle, radius);
72
+ const largeArcFlag = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
73
+ const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
75
+ className: (0, _clsx.default)(classes.root, className),
76
+ children: [!disableLine && (isFullCircle ?
77
+ /*#__PURE__*/
78
+ // Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
79
+ (0, _jsxRuntime.jsx)("circle", {
80
+ cx: cx,
81
+ cy: cy,
82
+ r: radius,
83
+ stroke: stroke,
84
+ fill: "none",
85
+ className: classes.line
86
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
87
+ d: arcPath,
88
+ stroke: stroke,
89
+ fill: "none",
90
+ className: classes.line
91
+ })), ticks.map(({
92
+ offset: angle,
93
+ formattedValue
94
+ }, index) => {
95
+ if (!formattedValue) {
96
+ return null;
97
+ }
98
+
99
+ // Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
100
+ const dx = Math.sin(angle);
101
+ const dy = -Math.cos(angle);
102
+ const tx = cx + dx * radius;
103
+ const ty = cy + dy * radius;
104
+ const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
105
+ const tickDy = (tickPosition === 'after' ? 1 : -1) * dy * tickSize;
106
+ const tickLabelGapDx = (tickLabelPosition === 'after' ? 1 : -1) * dx * TICK_LABEL_GAP;
107
+ const tickLabelGapDy = (tickLabelPosition === 'after' ? 1 : -1) * dy * TICK_LABEL_GAP;
108
+
109
+ // Compute the label position.
110
+ let labelX = tx;
111
+ let labelY = ty;
112
+ labelX += tickLabelGapDx;
113
+ labelY += tickLabelGapDy;
114
+ if (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__*/(0, _jsxRuntime.jsxs)("g", {
120
+ className: classes.tickContainer,
121
+ children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.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__*/(0, _jsxRuntime.jsx)("text", (0, _extends2.default)({
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,135 @@
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 "./chartsRotationAxisClasses.mjs";
11
+ import { createGetLabelTextAnchors } from "../ChartsRadiusAxis/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
+ export function ChartsRotationAxis(props) {
18
+ const {
19
+ axisId,
20
+ disableLine,
21
+ disableTicks,
22
+ position = 'outside',
23
+ tickLabelPosition = position === 'outside' ? 'after' : 'before',
24
+ tickPosition = position === 'outside' ? 'after' : 'before',
25
+ tickSize = 6,
26
+ className,
27
+ classes: classesProp
28
+ } = props;
29
+ const classes = useUtilityClasses({
30
+ classes: classesProp
31
+ });
32
+ const theme = useTheme();
33
+ const {
34
+ store
35
+ } = useChartsContext();
36
+ const {
37
+ cx,
38
+ cy
39
+ } = store.use(selectorChartPolarCenter);
40
+ const rotationAxis = useRotationAxis(axisId);
41
+ const radiusAxis = useRadiusAxis();
42
+ const ticks = useTicks({
43
+ scale: rotationAxis.scale,
44
+ tickNumber: rotationAxis?.tickNumber ?? 5,
45
+ tickInterval: rotationAxis?.tickInterval,
46
+ tickSpacing: rotationAxis?.tickSpacing,
47
+ valueFormatter: rotationAxis?.valueFormatter,
48
+ direction: 'rotation'
49
+ });
50
+ if (!rotationAxis || !radiusAxis) {
51
+ return null;
52
+ }
53
+ const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
54
+ const [startAngle, endAngle] = rotationAxis.scale.range();
55
+ const stroke = (theme.vars ?? theme).palette.text.primary;
56
+
57
+ // Convert "0 = up" convention to SVG coordinates (y-down).
58
+ const angleToPoint = (angle, r) => ({
59
+ x: cx + Math.sin(angle) * r,
60
+ y: cy - Math.cos(angle) * r
61
+ });
62
+ const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
63
+ const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
64
+ const start = angleToPoint(startAngle, radius);
65
+ const end = angleToPoint(endAngle, radius);
66
+ const largeArcFlag = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
67
+ const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
68
+ return /*#__PURE__*/_jsxs("g", {
69
+ className: clsx(classes.root, className),
70
+ children: [!disableLine && (isFullCircle ?
71
+ /*#__PURE__*/
72
+ // Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
73
+ _jsx("circle", {
74
+ cx: cx,
75
+ cy: cy,
76
+ r: radius,
77
+ stroke: stroke,
78
+ fill: "none",
79
+ className: classes.line
80
+ }) : /*#__PURE__*/_jsx("path", {
81
+ d: arcPath,
82
+ stroke: stroke,
83
+ fill: "none",
84
+ className: classes.line
85
+ })), ticks.map(({
86
+ offset: angle,
87
+ formattedValue
88
+ }, index) => {
89
+ if (!formattedValue) {
90
+ return null;
91
+ }
92
+
93
+ // Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
94
+ const dx = Math.sin(angle);
95
+ const dy = -Math.cos(angle);
96
+ const tx = cx + dx * radius;
97
+ const ty = cy + dy * radius;
98
+ const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
99
+ const tickDy = (tickPosition === 'after' ? 1 : -1) * dy * tickSize;
100
+ const tickLabelGapDx = (tickLabelPosition === 'after' ? 1 : -1) * dx * TICK_LABEL_GAP;
101
+ const tickLabelGapDy = (tickLabelPosition === 'after' ? 1 : -1) * dy * TICK_LABEL_GAP;
102
+
103
+ // Compute the label position.
104
+ let labelX = tx;
105
+ let labelY = ty;
106
+ labelX += tickLabelGapDx;
107
+ labelY += tickLabelGapDy;
108
+ if (tickLabelPosition === tickPosition && !disableTicks) {
109
+ // Add the size of the tick if they are in the same direction.
110
+ labelX += tickDx;
111
+ labelY += tickDy;
112
+ }
113
+ return /*#__PURE__*/_jsxs("g", {
114
+ className: classes.tickContainer,
115
+ children: [!disableTicks && /*#__PURE__*/_jsx("line", {
116
+ x1: tx,
117
+ y1: ty,
118
+ x2: tx + tickDx,
119
+ y2: ty + tickDy,
120
+ stroke: stroke,
121
+ className: classes.tick
122
+ }), /*#__PURE__*/_jsx("text", _extends({
123
+ x: labelX,
124
+ y: labelY,
125
+ fill: stroke,
126
+ fontSize: 12,
127
+ className: classes.tickLabel,
128
+ pointerEvents: "none"
129
+ }, getLabelTextAnchors(dx, dy, tickLabelPosition), {
130
+ children: formattedValue
131
+ }))]
132
+ }, index);
133
+ })]
134
+ });
135
+ }
@@ -0,0 +1,5 @@
1
+ import { type ChartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
2
+ export declare const useUtilityClasses: (props: {
3
+ classes?: Partial<ChartsRadialAxisClasses>;
4
+ }) => Record<"root" | "line" | "tickContainer" | "tick" | "tickLabel", string>;
5
+ export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
@@ -0,0 +1,5 @@
1
+ import { type ChartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.js";
2
+ export declare const useUtilityClasses: (props: {
3
+ classes?: Partial<ChartsRadialAxisClasses>;
4
+ }) => Record<"root" | "line" | "tickContainer" | "tick" | "tickLabel", string>;
5
+ export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.js";
@@ -0,0 +1,29 @@
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("../ChartsRadiusAxis/sharedRadialAxisClasses");
16
+ const useUtilityClasses = props => {
17
+ const {
18
+ classes
19
+ } = props;
20
+ const slots = {
21
+ root: ['root', 'rotation'],
22
+ line: ['line'],
23
+ tickContainer: ['tickContainer'],
24
+ tick: ['tick'],
25
+ tickLabel: ['tickLabel']
26
+ };
27
+ return (0, _composeClasses.default)(slots, _sharedRadialAxisClasses.getRadialAxisUtilityClass, classes);
28
+ };
29
+ exports.useUtilityClasses = useUtilityClasses;
@@ -0,0 +1,16 @@
1
+ import composeClasses from '@mui/utils/composeClasses';
2
+ import { getRadialAxisUtilityClass } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
3
+ export const useUtilityClasses = props => {
4
+ const {
5
+ classes
6
+ } = props;
7
+ const slots = {
8
+ root: ['root', 'rotation'],
9
+ line: ['line'],
10
+ tickContainer: ['tickContainer'],
11
+ tick: ['tick'],
12
+ tickLabel: ['tickLabel']
13
+ };
14
+ return composeClasses(slots, getRadialAxisUtilityClass, classes);
15
+ };
16
+ export { chartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
@@ -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
+ horizontalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
25
+ } else if (px < -0.3) {
26
+ horizontalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
27
+ }
28
+ if (py > 0.3) {
29
+ verticalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
30
+ } else if (py < -0.3) {
31
+ verticalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
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
+ horizontalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
19
+ } else if (px < -0.3) {
20
+ horizontalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
21
+ }
22
+ if (py > 0.3) {
23
+ verticalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
24
+ } else if (py < -0.3) {
25
+ verticalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
26
+ }
27
+ return {
28
+ verticalAlign,
29
+ horizontalAlign
30
+ };
31
+ }
@@ -0,0 +1,2 @@
1
+ export { type ChartsRotationAxisProps, ChartsRotationAxis as Unstable_ChartsRotationAxis } from "./ChartsRotationAxis.mjs";
2
+ export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "./chartsRotationAxisClasses.mjs";
@@ -0,0 +1,2 @@
1
+ export { type ChartsRotationAxisProps, ChartsRotationAxis as Unstable_ChartsRotationAxis } from "./ChartsRotationAxis.js";
2
+ export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "./chartsRotationAxisClasses.js";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Unstable_ChartsRotationAxis", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ChartsRotationAxis.ChartsRotationAxis;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "chartsRadialAxisClasses", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _chartsRotationAxisClasses.chartsRadialAxisClasses;
16
+ }
17
+ });
18
+ var _ChartsRotationAxis = require("./ChartsRotationAxis");
19
+ var _chartsRotationAxisClasses = require("./chartsRotationAxisClasses");
@@ -0,0 +1,2 @@
1
+ export { ChartsRotationAxis as Unstable_ChartsRotationAxis } from "./ChartsRotationAxis.mjs";
2
+ export { chartsRadialAxisClasses } from "./chartsRotationAxisClasses.mjs";
@@ -34,7 +34,15 @@ function defaultAxisTooltipConfig(axis, dataIndex, axisDirection) {
34
34
  seriesItems: []
35
35
  };
36
36
  }
37
-
37
+ function getSeriesMark(series) {
38
+ if (!('showMark' in series) || !series.showMark) {
39
+ return undefined;
40
+ }
41
+ if ('shape' in series && series.shape) {
42
+ return series.shape;
43
+ }
44
+ return 'circle';
45
+ }
38
46
  /**
39
47
  * Returns the axes to display in the tooltip and the series item related to them.
40
48
  */
@@ -45,6 +53,7 @@ function useAxesTooltip(params) {
45
53
  const defaultXAxis = (0, _useAxis.useXAxis)();
46
54
  const defaultYAxis = (0, _useAxis.useYAxis)();
47
55
  const defaultRotationAxis = (0, _useAxis.useRotationAxis)();
56
+ const defaultRadiusAxis = (0, _useAxis.useRadiusAxis)();
48
57
  const store = (0, _useStore.useStore)();
49
58
  const tooltipXAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipXAxes);
50
59
  const tooltipYAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipYAxes);
@@ -63,6 +72,9 @@ function useAxesTooltip(params) {
63
72
  const {
64
73
  rotationAxis
65
74
  } = (0, _useAxis.useRotationAxes)();
75
+ const {
76
+ radiusAxis
77
+ } = (0, _useAxis.useRadiusAxes)();
66
78
  const colorProcessors = (0, _useColorProcessor.useColorProcessor)();
67
79
  const isItemVisible = store.use(_useChartVisibilityManager.selectorIsItemVisibleGetter);
68
80
  if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
@@ -165,7 +177,7 @@ function useAxesTooltip(params) {
165
177
  formattedValue,
166
178
  formattedLabel,
167
179
  markType: seriesToAdd.labelMarkType,
168
- markShape: 'showMark' in seriesToAdd && seriesToAdd.showMark ? seriesToAdd.shape ?? 'circle' : undefined
180
+ markShape: getSeriesMark(seriesToAdd)
169
181
  });
170
182
  }
171
183
  });
@@ -185,9 +197,8 @@ function useAxesTooltip(params) {
185
197
  })) {
186
198
  return;
187
199
  }
188
- const providedRotationAxisId =
189
- // @ts-expect-error Should be fixed when we introduce a polar series with a rotationAxisId
190
- seriesToAdd.rotationAxisId ?? defaultRotationAxis?.id;
200
+ const providedRotationAxisId = ('rotationAxisId' in seriesToAdd ? seriesToAdd.rotationAxisId : undefined) ?? defaultRotationAxis?.id;
201
+ const providedRadiusAxisId = ('radiusAxisId' in seriesToAdd ? seriesToAdd.radiusAxisId : undefined) ?? defaultRadiusAxis?.id;
191
202
  const tooltipItemIndex = tooltipAxes.findIndex(({
192
203
  axisDirection,
193
204
  axisId
@@ -197,7 +208,7 @@ function useAxesTooltip(params) {
197
208
  const {
198
209
  dataIndex
199
210
  } = tooltipAxes[tooltipItemIndex];
200
- const color = colorProcessors[seriesType]?.(seriesToAdd)(dataIndex) ?? '';
211
+ const color = colorProcessors[seriesType]?.(seriesToAdd, providedRotationAxisId !== undefined ? rotationAxis[providedRotationAxisId] : undefined, providedRadiusAxisId !== undefined ? radiusAxis[providedRadiusAxisId] : undefined)(dataIndex) ?? '';
201
212
  const value = seriesToAdd.data[dataIndex] ?? null;
202
213
  const formattedValue = seriesToAdd.valueFormatter(value, {
203
214
  dataIndex
@@ -210,7 +221,7 @@ function useAxesTooltip(params) {
210
221
  formattedValue,
211
222
  formattedLabel,
212
223
  markType: seriesToAdd.labelMarkType,
213
- markShape: 'showMark' in seriesToAdd && seriesToAdd.showMark ? 'circle' : undefined
224
+ markShape: getSeriesMark(seriesToAdd)
214
225
  });
215
226
  }
216
227
  });