@mui/x-charts 9.1.0 → 9.2.0

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 (62) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.mts +1 -1
  3. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.ts +1 -1
  4. package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.js +31 -14
  5. package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.mjs +32 -15
  6. package/ChartsRadiusAxis/ChartsRadiusAxis.d.mts +1 -47
  7. package/ChartsRadiusAxis/ChartsRadiusAxis.d.ts +1 -47
  8. package/ChartsRadiusAxis/ChartsRadiusAxis.js +20 -16
  9. package/ChartsRadiusAxis/ChartsRadiusAxis.mjs +21 -15
  10. package/ChartsRotationAxis/ChartsRotationAxis.d.mts +1 -47
  11. package/ChartsRotationAxis/ChartsRotationAxis.d.ts +1 -47
  12. package/ChartsRotationAxis/ChartsRotationAxis.js +16 -19
  13. package/ChartsRotationAxis/ChartsRotationAxis.mjs +17 -18
  14. package/ChartsTooltip/useAxesTooltip.d.mts +1 -1
  15. package/ChartsTooltip/useAxesTooltip.d.ts +1 -1
  16. package/ChartsTooltip/useAxesTooltip.js +11 -2
  17. package/ChartsTooltip/useAxesTooltip.mjs +12 -3
  18. package/RadarChart/RadarGrid/CircularRadarStripes.js +2 -3
  19. package/RadarChart/RadarGrid/CircularRadarStripes.mjs +2 -3
  20. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -1
  21. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.mjs +2 -2
  22. package/index.js +1 -1
  23. package/index.mjs +1 -1
  24. package/internals/getRingPath.d.mts +16 -0
  25. package/internals/getRingPath.d.ts +16 -0
  26. package/internals/getRingPath.js +39 -0
  27. package/internals/getRingPath.mjs +33 -0
  28. package/internals/index.d.mts +4 -2
  29. package/internals/index.d.ts +4 -2
  30. package/internals/index.js +22 -3
  31. package/internals/index.mjs +3 -2
  32. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.d.mts +3 -3
  33. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.d.ts +3 -3
  34. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.mts +1 -0
  35. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
  36. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +8 -0
  37. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs +1 -0
  38. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.mts +6 -1
  39. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +6 -1
  40. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +48 -36
  41. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.mjs +47 -36
  42. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +74 -1
  43. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +74 -1
  44. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +152 -2
  45. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +152 -2
  46. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.mts +2 -2
  47. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +2 -2
  48. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.mts +2 -2
  49. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.ts +2 -2
  50. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.mts +6 -1
  51. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.ts +6 -1
  52. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +36 -2
  53. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs +34 -1
  54. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -1
  55. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +2 -2
  56. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.mts +22 -2
  57. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +22 -2
  58. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +73 -12
  59. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs +74 -12
  60. package/models/axis.d.mts +55 -7
  61. package/models/axis.d.ts +55 -7
  62. package/package.json +4 -4
@@ -17,12 +17,12 @@ var _chartsRotationAxisClasses = require("./chartsRotationAxisClasses");
17
17
  var _createGetLabelTextAnchors = require("../ChartsRadiusAxis/createGetLabelTextAnchors");
18
18
  var _getLabelTransform = require("./getLabelTransform");
19
19
  var _jsxRuntime = require("react/jsx-runtime");
20
- /* Gap between a tick and its label. */
21
- const TICK_LABEL_GAP = 3;
20
+ /* Gap between a tick and its label. */const TICK_LABEL_GAP = 3;
22
21
  const getLabelTextAnchors = (0, _createGetLabelTextAnchors.createGetLabelTextAnchors)(_getLabelTransform.getLabelTransform);
23
22
  function ChartsRotationAxis(props) {
23
+ const rotationAxis = (0, _useAxis.useRotationAxis)(props.axisId);
24
+ const settings = (0, _extends2.default)({}, rotationAxis, props);
24
25
  const {
25
- axisId,
26
26
  disableLine,
27
27
  disableTicks,
28
28
  position = 'outside',
@@ -31,7 +31,7 @@ function ChartsRotationAxis(props) {
31
31
  tickSize = 6,
32
32
  className,
33
33
  classes: classesProp
34
- } = props;
34
+ } = settings;
35
35
  const classes = (0, _chartsRotationAxisClasses.useUtilityClasses)({
36
36
  classes: classesProp
37
37
  });
@@ -43,7 +43,6 @@ function ChartsRotationAxis(props) {
43
43
  cx,
44
44
  cy
45
45
  } = store.use(_useChartPolarAxis.selectorChartPolarCenter);
46
- const rotationAxis = (0, _useAxis.useRotationAxis)(axisId);
47
46
  const radiusAxis = (0, _useAxis.useRadiusAxis)();
48
47
  const ticks = (0, _useTicks.useTicks)({
49
48
  scale: rotationAxis.scale,
@@ -53,7 +52,7 @@ function ChartsRotationAxis(props) {
53
52
  valueFormatter: rotationAxis?.valueFormatter,
54
53
  direction: 'rotation'
55
54
  });
56
- if (!rotationAxis || !radiusAxis) {
55
+ if (!rotationAxis || !radiusAxis || settings.position === 'none') {
57
56
  return null;
58
57
  }
59
58
  const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
@@ -65,7 +64,6 @@ function ChartsRotationAxis(props) {
65
64
  x: cx + Math.sin(angle) * r,
66
65
  y: cy - Math.cos(angle) * r
67
66
  });
68
- const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
69
67
  const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
70
68
  const start = angleToPoint(startAngle, radius);
71
69
  const end = angleToPoint(endAngle, radius);
@@ -73,7 +71,7 @@ function ChartsRotationAxis(props) {
73
71
  const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
74
72
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
75
73
  className: (0, _clsx.default)(classes.root, className),
76
- children: [!disableLine && (isFullCircle ?
74
+ children: [!disableLine && (rotationAxis.isFullCircle ?
77
75
  /*#__PURE__*/
78
76
  // Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
79
77
  (0, _jsxRuntime.jsx)("circle", {
@@ -90,6 +88,7 @@ function ChartsRotationAxis(props) {
90
88
  className: classes.line
91
89
  })), ticks.map(({
92
90
  offset: angle,
91
+ labelOffset,
93
92
  formattedValue
94
93
  }, index) => {
95
94
  if (!formattedValue) {
@@ -99,23 +98,21 @@ function ChartsRotationAxis(props) {
99
98
  // Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
100
99
  const dx = Math.sin(angle);
101
100
  const dy = -Math.cos(angle);
101
+ const labelDx = labelOffset === 0 ? dx : Math.sin(angle + labelOffset);
102
+ const labelDy = labelOffset === 0 ? dy : -Math.cos(angle + labelOffset);
102
103
  const tx = cx + dx * radius;
103
104
  const ty = cy + dy * radius;
104
105
  const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
105
106
  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;
107
+ let tickLabelRadius = radius + (tickLabelPosition === 'after' ? 1 : -1) * TICK_LABEL_GAP;
114
108
  if (tickLabelPosition === tickPosition && !disableTicks) {
115
109
  // Add the size of the tick if they are in the same direction.
116
- labelX += tickDx;
117
- labelY += tickDy;
110
+ tickLabelRadius += tickSize;
118
111
  }
112
+
113
+ // Compute the label position.
114
+ const labelX = cx + labelDx * tickLabelRadius;
115
+ const labelY = cy + labelDy * tickLabelRadius;
119
116
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
120
117
  className: classes.tickContainer,
121
118
  children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
@@ -132,7 +129,7 @@ function ChartsRotationAxis(props) {
132
129
  fontSize: 12,
133
130
  className: classes.tickLabel,
134
131
  pointerEvents: "none"
135
- }, getLabelTextAnchors(dx, dy, tickLabelPosition), {
132
+ }, getLabelTextAnchors(labelDx, labelDy, tickLabelPosition), {
136
133
  children: formattedValue
137
134
  }))]
138
135
  }, index);
@@ -10,13 +10,15 @@ import { selectorChartPolarCenter } from "../internals/plugins/featurePlugins/us
10
10
  import { useUtilityClasses } from "./chartsRotationAxisClasses.mjs";
11
11
  import { createGetLabelTextAnchors } from "../ChartsRadiusAxis/createGetLabelTextAnchors.mjs";
12
12
  import { getLabelTransform } from "./getLabelTransform.mjs";
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+
14
14
  /* Gap between a tick and its label. */
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
16
  const TICK_LABEL_GAP = 3;
16
17
  const getLabelTextAnchors = createGetLabelTextAnchors(getLabelTransform);
17
18
  export function ChartsRotationAxis(props) {
19
+ const rotationAxis = useRotationAxis(props.axisId);
20
+ const settings = _extends({}, rotationAxis, props);
18
21
  const {
19
- axisId,
20
22
  disableLine,
21
23
  disableTicks,
22
24
  position = 'outside',
@@ -25,7 +27,7 @@ export function ChartsRotationAxis(props) {
25
27
  tickSize = 6,
26
28
  className,
27
29
  classes: classesProp
28
- } = props;
30
+ } = settings;
29
31
  const classes = useUtilityClasses({
30
32
  classes: classesProp
31
33
  });
@@ -37,7 +39,6 @@ export function ChartsRotationAxis(props) {
37
39
  cx,
38
40
  cy
39
41
  } = store.use(selectorChartPolarCenter);
40
- const rotationAxis = useRotationAxis(axisId);
41
42
  const radiusAxis = useRadiusAxis();
42
43
  const ticks = useTicks({
43
44
  scale: rotationAxis.scale,
@@ -47,7 +48,7 @@ export function ChartsRotationAxis(props) {
47
48
  valueFormatter: rotationAxis?.valueFormatter,
48
49
  direction: 'rotation'
49
50
  });
50
- if (!rotationAxis || !radiusAxis) {
51
+ if (!rotationAxis || !radiusAxis || settings.position === 'none') {
51
52
  return null;
52
53
  }
53
54
  const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
@@ -59,7 +60,6 @@ export function ChartsRotationAxis(props) {
59
60
  x: cx + Math.sin(angle) * r,
60
61
  y: cy - Math.cos(angle) * r
61
62
  });
62
- const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
63
63
  const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
64
64
  const start = angleToPoint(startAngle, radius);
65
65
  const end = angleToPoint(endAngle, radius);
@@ -67,7 +67,7 @@ export function ChartsRotationAxis(props) {
67
67
  const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
68
68
  return /*#__PURE__*/_jsxs("g", {
69
69
  className: clsx(classes.root, className),
70
- children: [!disableLine && (isFullCircle ?
70
+ children: [!disableLine && (rotationAxis.isFullCircle ?
71
71
  /*#__PURE__*/
72
72
  // Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
73
73
  _jsx("circle", {
@@ -84,6 +84,7 @@ export function ChartsRotationAxis(props) {
84
84
  className: classes.line
85
85
  })), ticks.map(({
86
86
  offset: angle,
87
+ labelOffset,
87
88
  formattedValue
88
89
  }, index) => {
89
90
  if (!formattedValue) {
@@ -93,23 +94,21 @@ export function ChartsRotationAxis(props) {
93
94
  // Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
94
95
  const dx = Math.sin(angle);
95
96
  const dy = -Math.cos(angle);
97
+ const labelDx = labelOffset === 0 ? dx : Math.sin(angle + labelOffset);
98
+ const labelDy = labelOffset === 0 ? dy : -Math.cos(angle + labelOffset);
96
99
  const tx = cx + dx * radius;
97
100
  const ty = cy + dy * radius;
98
101
  const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
99
102
  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;
103
+ let tickLabelRadius = radius + (tickLabelPosition === 'after' ? 1 : -1) * TICK_LABEL_GAP;
108
104
  if (tickLabelPosition === tickPosition && !disableTicks) {
109
105
  // Add the size of the tick if they are in the same direction.
110
- labelX += tickDx;
111
- labelY += tickDy;
106
+ tickLabelRadius += tickSize;
112
107
  }
108
+
109
+ // Compute the label position.
110
+ const labelX = cx + labelDx * tickLabelRadius;
111
+ const labelY = cy + labelDy * tickLabelRadius;
113
112
  return /*#__PURE__*/_jsxs("g", {
114
113
  className: classes.tickContainer,
115
114
  children: [!disableTicks && /*#__PURE__*/_jsx("line", {
@@ -126,7 +125,7 @@ export function ChartsRotationAxis(props) {
126
125
  fontSize: 12,
127
126
  className: classes.tickLabel,
128
127
  pointerEvents: "none"
129
- }, getLabelTextAnchors(dx, dy, tickLabelPosition), {
128
+ }, getLabelTextAnchors(labelDx, labelDy, tickLabelPosition), {
130
129
  children: formattedValue
131
130
  }))]
132
131
  }, index);
@@ -16,7 +16,7 @@ export interface UseAxesTooltipParams {
16
16
  * The axis directions to consider.
17
17
  * If not defined, all directions are considered
18
18
  */
19
- directions?: ('x' | 'y' | 'rotation')[];
19
+ directions?: ('x' | 'y' | 'rotation' | 'radius')[];
20
20
  }
21
21
  export interface SeriesItem<T extends CartesianChartSeriesType | PolarChartSeriesType> {
22
22
  seriesId: SeriesId;
@@ -16,7 +16,7 @@ export interface UseAxesTooltipParams {
16
16
  * The axis directions to consider.
17
17
  * If not defined, all directions are considered
18
18
  */
19
- directions?: ('x' | 'y' | 'rotation')[];
19
+ directions?: ('x' | 'y' | 'rotation' | 'radius')[];
20
20
  }
21
21
  export interface SeriesItem<T extends CartesianChartSeriesType | PolarChartSeriesType> {
22
22
  seriesId: SeriesId;
@@ -58,6 +58,7 @@ function useAxesTooltip(params) {
58
58
  const tooltipXAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipXAxes);
59
59
  const tooltipYAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipYAxes);
60
60
  const tooltipRotationAxes = store.use(_useChartPolarInteraction.selectorChartsInteractionTooltipRotationAxes);
61
+ const tooltipRadiusAxes = store.use(_useChartPolarInteraction.selectorChartsInteractionTooltipRadiusAxes);
61
62
  const series = (0, _useSeries.useSeries)();
62
63
  const {
63
64
  xAxis
@@ -77,7 +78,7 @@ function useAxesTooltip(params) {
77
78
  } = (0, _useAxis.useRadiusAxes)();
78
79
  const colorProcessors = (0, _useColorProcessor.useColorProcessor)();
79
80
  const isItemVisible = store.use(_useChartVisibilityManager.selectorIsItemVisibleGetter);
80
- if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
81
+ if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0 && tooltipRadiusAxes.length === 0) {
81
82
  return null;
82
83
  }
83
84
  const tooltipAxes = [];
@@ -105,6 +106,14 @@ function useAxesTooltip(params) {
105
106
  tooltipAxes.push(defaultAxisTooltipConfig(rotationAxis[axisId], dataIndex, 'rotation'));
106
107
  });
107
108
  }
109
+ if (directions === undefined || directions.includes('radius')) {
110
+ tooltipRadiusAxes.forEach(({
111
+ axisId,
112
+ dataIndex
113
+ }) => {
114
+ tooltipAxes.push(defaultAxisTooltipConfig(radiusAxis[axisId], dataIndex, 'radius'));
115
+ });
116
+ }
108
117
  Object.keys(series).filter(seriesType => _composition.composableCartesianSeriesTypes.has(seriesType)).forEach(seriesType => {
109
118
  const seriesOfType = series[seriesType];
110
119
  if (!seriesOfType) {
@@ -202,7 +211,7 @@ function useAxesTooltip(params) {
202
211
  const tooltipItemIndex = tooltipAxes.findIndex(({
203
212
  axisDirection,
204
213
  axisId
205
- }) => axisDirection === 'rotation' && axisId === providedRotationAxisId);
214
+ }) => axisDirection === 'rotation' && axisId === providedRotationAxisId || axisDirection === 'radius' && axisId === providedRadiusAxisId);
206
215
  // Test if the series uses the default axis
207
216
  if (tooltipItemIndex >= 0) {
208
217
  const {
@@ -8,7 +8,7 @@ import { utcFormatter } from "./utils.mjs";
8
8
  import { useRadiusAxes, useRadiusAxis, useRotationAxes, useRotationAxis, useXAxes, useXAxis, useYAxes, useYAxis } from "../hooks/useAxis.mjs";
9
9
  import { useZAxes } from "../hooks/useZAxis.mjs";
10
10
  import { selectorChartsInteractionTooltipXAxes, selectorChartsInteractionTooltipYAxes } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs";
11
- import { selectorChartsInteractionTooltipRotationAxes } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs";
11
+ import { selectorChartsInteractionTooltipRadiusAxes, selectorChartsInteractionTooltipRotationAxes } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs";
12
12
  import { isPolarSeriesType } from "../internals/isPolar.mjs";
13
13
  import { selectorIsItemVisibleGetter } from "../internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.mjs";
14
14
  import { composableCartesianSeriesTypes } from "../models/seriesType/composition.mjs";
@@ -53,6 +53,7 @@ export function useAxesTooltip(params) {
53
53
  const tooltipXAxes = store.use(selectorChartsInteractionTooltipXAxes);
54
54
  const tooltipYAxes = store.use(selectorChartsInteractionTooltipYAxes);
55
55
  const tooltipRotationAxes = store.use(selectorChartsInteractionTooltipRotationAxes);
56
+ const tooltipRadiusAxes = store.use(selectorChartsInteractionTooltipRadiusAxes);
56
57
  const series = useSeries();
57
58
  const {
58
59
  xAxis
@@ -72,7 +73,7 @@ export function useAxesTooltip(params) {
72
73
  } = useRadiusAxes();
73
74
  const colorProcessors = useColorProcessor();
74
75
  const isItemVisible = store.use(selectorIsItemVisibleGetter);
75
- if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
76
+ if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0 && tooltipRadiusAxes.length === 0) {
76
77
  return null;
77
78
  }
78
79
  const tooltipAxes = [];
@@ -100,6 +101,14 @@ export function useAxesTooltip(params) {
100
101
  tooltipAxes.push(defaultAxisTooltipConfig(rotationAxis[axisId], dataIndex, 'rotation'));
101
102
  });
102
103
  }
104
+ if (directions === undefined || directions.includes('radius')) {
105
+ tooltipRadiusAxes.forEach(({
106
+ axisId,
107
+ dataIndex
108
+ }) => {
109
+ tooltipAxes.push(defaultAxisTooltipConfig(radiusAxis[axisId], dataIndex, 'radius'));
110
+ });
111
+ }
103
112
  Object.keys(series).filter(seriesType => composableCartesianSeriesTypes.has(seriesType)).forEach(seriesType => {
104
113
  const seriesOfType = series[seriesType];
105
114
  if (!seriesOfType) {
@@ -197,7 +206,7 @@ export function useAxesTooltip(params) {
197
206
  const tooltipItemIndex = tooltipAxes.findIndex(({
198
207
  axisDirection,
199
208
  axisId
200
- }) => axisDirection === 'rotation' && axisId === providedRotationAxisId);
209
+ }) => axisDirection === 'rotation' && axisId === providedRotationAxisId || axisDirection === 'radius' && axisId === providedRadiusAxisId);
201
210
  // Test if the series uses the default axis
202
211
  if (tooltipItemIndex >= 0) {
203
212
  const {
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.CircularRadarStripes = CircularRadarStripes;
8
8
  var React = _interopRequireWildcard(require("react"));
9
+ var _getRingPath = require("../../internals/getRingPath");
9
10
  var _jsxRuntime = require("react/jsx-runtime");
10
- const getPath = (center, outerRadius, innerRadius) => [`M ${center.x - outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x + outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x - outerRadius} ${center.y} Z`, `M ${center.x - innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x + innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x - innerRadius} ${center.y} Z`].join('');
11
-
12
11
  /**
13
12
  * @ignore - internal component.
14
13
  */
@@ -27,7 +26,7 @@ function CircularRadarStripes(props) {
27
26
  children: divisionRadius.map((r, index) => {
28
27
  const smallerRadius = divisionRadius[index - 1] ?? 0;
29
28
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
30
- d: getPath(center, r, smallerRadius),
29
+ d: (0, _getRingPath.getRingPath)(center, r, smallerRadius),
31
30
  fillRule: "evenodd",
32
31
  fill: stripeColor?.(index) ?? 'none',
33
32
  fillOpacity: 0.1,
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { getRingPath } from "../../internals/getRingPath.mjs";
2
3
  import { jsx as _jsx } from "react/jsx-runtime";
3
- const getPath = (center, outerRadius, innerRadius) => [`M ${center.x - outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x + outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x - outerRadius} ${center.y} Z`, `M ${center.x - innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x + innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x - innerRadius} ${center.y} Z`].join('');
4
-
5
4
  /**
6
5
  * @ignore - internal component.
7
6
  */
@@ -20,7 +19,7 @@ export function CircularRadarStripes(props) {
20
19
  children: divisionRadius.map((r, index) => {
21
20
  const smallerRadius = divisionRadius[index - 1] ?? 0;
22
21
  return /*#__PURE__*/_jsx("path", {
23
- d: getPath(center, r, smallerRadius),
22
+ d: getRingPath(center, r, smallerRadius),
24
23
  fillRule: "evenodd",
25
24
  fill: stripeColor?.(index) ?? 'none',
26
25
  fillOpacity: 0.1,
@@ -32,7 +32,7 @@ function useRadarRotationIndex() {
32
32
  }
33
33
  const svgPoint = (0, _getChartPoint.getChartPoint)(element, event);
34
34
  const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
35
- const rotationIndex = (0, _getAxisIndex.getAxisIndex)(rotationAxis, rotation);
35
+ const rotationIndex = (0, _getAxisIndex.getRotationAxisIndex)(rotationAxis, rotation);
36
36
  return rotationIndex;
37
37
  }, [center, rotationAxis, chartsLayerContainerRef]);
38
38
  return rotationIndexGetter;
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.mjs";
4
4
  import { getChartPoint } from "../../internals/getChartPoint.mjs";
5
5
  import { generateSvg2rotation } from "../../internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.mjs";
6
- import { getAxisIndex } from "../../internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs";
6
+ import { getRotationAxisIndex } from "../../internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs";
7
7
  import { useStore } from "../../internals/store/useStore.mjs";
8
8
  import { useChartsLayerContainerRef } from "../../hooks/useChartsLayerContainerRef.mjs";
9
9
  import { useRotationAxis } from "../../hooks/useAxis.mjs";
@@ -25,7 +25,7 @@ export function useRadarRotationIndex() {
25
25
  }
26
26
  const svgPoint = getChartPoint(element, event);
27
27
  const rotation = generateSvg2rotation(center)(svgPoint.x, svgPoint.y);
28
- const rotationIndex = getAxisIndex(rotationAxis, rotation);
28
+ const rotationIndex = getRotationAxisIndex(rotationAxis, rotation);
29
29
  return rotationIndex;
30
30
  }, [center, rotationAxis, chartsLayerContainerRef]);
31
31
  return rotationIndexGetter;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v9.1.0
2
+ * @mui/x-charts v9.2.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v9.1.0
2
+ * @mui/x-charts v9.2.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Get the SVG path to display a ring (a donut shape) defined by an outer radius and an inner radius.
3
+ *
4
+ * @param center - The center of the ring.
5
+ * @param outerRadius - The outer radius of the ring.
6
+ * @param innerRadius - The inner radius of the ring.
7
+ * @param angles - The start and end angles of the ring in radians. If not provided, it defaults to a full circle.
8
+ * @returns The SVG path string to display the ring.
9
+ */
10
+ export declare function getRingPath(center: {
11
+ x: number;
12
+ y: number;
13
+ }, outerRadius: number, innerRadius: number, angles?: {
14
+ start: number;
15
+ end: number;
16
+ } | undefined): string;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Get the SVG path to display a ring (a donut shape) defined by an outer radius and an inner radius.
3
+ *
4
+ * @param center - The center of the ring.
5
+ * @param outerRadius - The outer radius of the ring.
6
+ * @param innerRadius - The inner radius of the ring.
7
+ * @param angles - The start and end angles of the ring in radians. If not provided, it defaults to a full circle.
8
+ * @returns The SVG path string to display the ring.
9
+ */
10
+ export declare function getRingPath(center: {
11
+ x: number;
12
+ y: number;
13
+ }, outerRadius: number, innerRadius: number, angles?: {
14
+ start: number;
15
+ end: number;
16
+ } | undefined): string;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRingPath = getRingPath;
7
+ /**
8
+ * Get the SVG path to display a ring (a donut shape) defined by an outer radius and an inner radius.
9
+ *
10
+ * @param center - The center of the ring.
11
+ * @param outerRadius - The outer radius of the ring.
12
+ * @param innerRadius - The inner radius of the ring.
13
+ * @param angles - The start and end angles of the ring in radians. If not provided, it defaults to a full circle.
14
+ * @returns The SVG path string to display the ring.
15
+ */
16
+ function getRingPath(center, outerRadius, innerRadius, angles) {
17
+ if (!angles) {
18
+ return [`M ${center.x - outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x + outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x - outerRadius} ${center.y} Z`, `M ${center.x - innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x + innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x - innerRadius} ${center.y} Z`].join('');
19
+ }
20
+ const isLargeArc = Math.abs(angles.end - angles.start) > Math.PI;
21
+ const isDirectArc = angles.end > angles.start;
22
+ const startOuterPoint = {
23
+ x: center.x + outerRadius * Math.sin(angles.start),
24
+ y: center.y - outerRadius * Math.cos(angles.start)
25
+ };
26
+ const endOuterPoint = {
27
+ x: center.x + outerRadius * Math.sin(angles.end),
28
+ y: center.y - outerRadius * Math.cos(angles.end)
29
+ };
30
+ const startInnerPoint = {
31
+ x: center.x + innerRadius * Math.sin(angles.start),
32
+ y: center.y - innerRadius * Math.cos(angles.start)
33
+ };
34
+ const endInnerPoint = {
35
+ x: center.x + innerRadius * Math.sin(angles.end),
36
+ y: center.y - innerRadius * Math.cos(angles.end)
37
+ };
38
+ return [`M ${startOuterPoint.x} ${startOuterPoint.y}`, `A ${outerRadius} ${outerRadius} 0 ${isLargeArc ? 1 : 0} ${isDirectArc ? 1 : 0} ${endOuterPoint.x} ${endOuterPoint.y}`, `L ${endInnerPoint.x} ${endInnerPoint.y}`, `A ${innerRadius} ${innerRadius} 0 ${isLargeArc ? 1 : 0} ${!isDirectArc ? 1 : 0} ${startInnerPoint.x} ${startInnerPoint.y} Z`].join('');
39
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Get the SVG path to display a ring (a donut shape) defined by an outer radius and an inner radius.
3
+ *
4
+ * @param center - The center of the ring.
5
+ * @param outerRadius - The outer radius of the ring.
6
+ * @param innerRadius - The inner radius of the ring.
7
+ * @param angles - The start and end angles of the ring in radians. If not provided, it defaults to a full circle.
8
+ * @returns The SVG path string to display the ring.
9
+ */
10
+ export function getRingPath(center, outerRadius, innerRadius, angles) {
11
+ if (!angles) {
12
+ return [`M ${center.x - outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x + outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x - outerRadius} ${center.y} Z`, `M ${center.x - innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x + innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x - innerRadius} ${center.y} Z`].join('');
13
+ }
14
+ const isLargeArc = Math.abs(angles.end - angles.start) > Math.PI;
15
+ const isDirectArc = angles.end > angles.start;
16
+ const startOuterPoint = {
17
+ x: center.x + outerRadius * Math.sin(angles.start),
18
+ y: center.y - outerRadius * Math.cos(angles.start)
19
+ };
20
+ const endOuterPoint = {
21
+ x: center.x + outerRadius * Math.sin(angles.end),
22
+ y: center.y - outerRadius * Math.cos(angles.end)
23
+ };
24
+ const startInnerPoint = {
25
+ x: center.x + innerRadius * Math.sin(angles.start),
26
+ y: center.y - innerRadius * Math.cos(angles.start)
27
+ };
28
+ const endInnerPoint = {
29
+ x: center.x + innerRadius * Math.sin(angles.end),
30
+ y: center.y - innerRadius * Math.cos(angles.end)
31
+ };
32
+ return [`M ${startOuterPoint.x} ${startOuterPoint.y}`, `A ${outerRadius} ${outerRadius} 0 ${isLargeArc ? 1 : 0} ${isDirectArc ? 1 : 0} ${endOuterPoint.x} ${endOuterPoint.y}`, `L ${endInnerPoint.x} ${endInnerPoint.y}`, `A ${innerRadius} ${innerRadius} 0 ${isLargeArc ? 1 : 0} ${!isDirectArc ? 1 : 0} ${startInnerPoint.x} ${startInnerPoint.y} Z`].join('');
33
+ }
@@ -13,7 +13,8 @@ export { useLineChartProps } from "../LineChart/useLineChartProps.mjs";
13
13
  export { useAreaPlotData } from "../LineChart/useAreaPlotData.mjs";
14
14
  export { useLinePlotData } from "../LineChart/useLinePlotData.mjs";
15
15
  export * from "../BarChart/useBarChartProps.mjs";
16
- export { processBarDataForPlot } from "../BarChart/useBarPlotData.mjs";
16
+ export { processBarDataForPlot, useBarPlotData } from "../BarChart/useBarPlotData.mjs";
17
+ export type { BorderRadiusSide, MaskData, ProcessedBarData, ProcessedBarSeriesData } from "../BarChart/types.mjs";
17
18
  export { useRadarChartProps } from "../RadarChart/useRadarChartProps.mjs";
18
19
  export * from "../ChartsContainer/useChartsContainerProps.mjs";
19
20
  export * from "../ChartsDataProvider/useChartsDataProviderProps.mjs";
@@ -40,7 +41,7 @@ export * from "./plugins/featurePlugins/useChartItemClick/index.mjs";
40
41
  export * from "./plugins/utils/selectors.mjs";
41
42
  export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.mjs";
42
43
  export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.mjs";
43
- export { getAxisIndex as getPolarAxisIndex } from "./plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs";
44
+ export { getRotationAxisIndex } from "./plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs";
44
45
  export * from "./store/useCharts.mjs";
45
46
  export * from "./store/useStore.mjs";
46
47
  export * from "../BarChart/BarChart.plugins.mjs";
@@ -53,6 +54,7 @@ export * from "./clampAngle.mjs";
53
54
  export * from "./getLabel.mjs";
54
55
  export * from "./legendUtils.mjs";
55
56
  export * from "./getChartPoint.mjs";
57
+ export * from "./plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.mjs";
56
58
  export * from "./isDefined.mjs";
57
59
  export * from "./getScale.mjs";
58
60
  export * from "./getAsNumber.mjs";
@@ -13,7 +13,8 @@ export { useLineChartProps } from "../LineChart/useLineChartProps.js";
13
13
  export { useAreaPlotData } from "../LineChart/useAreaPlotData.js";
14
14
  export { useLinePlotData } from "../LineChart/useLinePlotData.js";
15
15
  export * from "../BarChart/useBarChartProps.js";
16
- export { processBarDataForPlot } from "../BarChart/useBarPlotData.js";
16
+ export { processBarDataForPlot, useBarPlotData } from "../BarChart/useBarPlotData.js";
17
+ export type { BorderRadiusSide, MaskData, ProcessedBarData, ProcessedBarSeriesData } from "../BarChart/types.js";
17
18
  export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
18
19
  export * from "../ChartsContainer/useChartsContainerProps.js";
19
20
  export * from "../ChartsDataProvider/useChartsDataProviderProps.js";
@@ -40,7 +41,7 @@ export * from "./plugins/featurePlugins/useChartItemClick/index.js";
40
41
  export * from "./plugins/utils/selectors.js";
41
42
  export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
42
43
  export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
43
- export { getAxisIndex as getPolarAxisIndex } from "./plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js";
44
+ export { getRotationAxisIndex } from "./plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js";
44
45
  export * from "./store/useCharts.js";
45
46
  export * from "./store/useStore.js";
46
47
  export * from "../BarChart/BarChart.plugins.js";
@@ -53,6 +54,7 @@ export * from "./clampAngle.js";
53
54
  export * from "./getLabel.js";
54
55
  export * from "./legendUtils.js";
55
56
  export * from "./getChartPoint.js";
57
+ export * from "./plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js";
56
58
  export * from "./isDefined.js";
57
59
  export * from "./getScale.js";
58
60
  export * from "./getAsNumber.js";
@@ -15,12 +15,13 @@ var _exportNames = {
15
15
  useAreaPlotData: true,
16
16
  useLinePlotData: true,
17
17
  processBarDataForPlot: true,
18
+ useBarPlotData: true,
18
19
  useRadarChartProps: true,
19
20
  useSkipAnimation: true,
20
21
  useRegisterPointerInteractions: true,
21
22
  getCartesianAxisTriggerTooltip: true,
22
23
  getCartesianAxisIndex: true,
23
- getPolarAxisIndex: true,
24
+ getRotationAxisIndex: true,
24
25
  createCommonKeyboardFocusHandler: true,
25
26
  getSeriesColorFn: true,
26
27
  checkBarChartScaleErrors: true,
@@ -92,10 +93,10 @@ Object.defineProperty(exports, "getLineItemAtPosition", {
92
93
  return _getItemAtPosition.default;
93
94
  }
94
95
  });
95
- Object.defineProperty(exports, "getPolarAxisIndex", {
96
+ Object.defineProperty(exports, "getRotationAxisIndex", {
96
97
  enumerable: true,
97
98
  get: function () {
98
- return _getAxisIndex.getAxisIndex;
99
+ return _getAxisIndex.getRotationAxisIndex;
99
100
  }
100
101
  });
101
102
  Object.defineProperty(exports, "getSeriesColorFn", {
@@ -122,6 +123,12 @@ Object.defineProperty(exports, "useAreaPlotData", {
122
123
  return _useAreaPlotData.useAreaPlotData;
123
124
  }
124
125
  });
126
+ Object.defineProperty(exports, "useBarPlotData", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _useBarPlotData.useBarPlotData;
130
+ }
131
+ });
125
132
  Object.defineProperty(exports, "useChartsTooltipUtilityClasses", {
126
133
  enumerable: true,
127
134
  get: function () {
@@ -672,6 +679,18 @@ Object.keys(_getChartPoint).forEach(function (key) {
672
679
  }
673
680
  });
674
681
  });
682
+ var _coordinateTransformation = require("./plugins/featurePlugins/useChartPolarAxis/coordinateTransformation");
683
+ Object.keys(_coordinateTransformation).forEach(function (key) {
684
+ if (key === "default" || key === "__esModule") return;
685
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
686
+ if (key in exports && exports[key] === _coordinateTransformation[key]) return;
687
+ Object.defineProperty(exports, key, {
688
+ enumerable: true,
689
+ get: function () {
690
+ return _coordinateTransformation[key];
691
+ }
692
+ });
693
+ });
675
694
  var _isDefined = require("./isDefined");
676
695
  Object.keys(_isDefined).forEach(function (key) {
677
696
  if (key === "default" || key === "__esModule") return;