@mui/x-charts 8.8.0 → 8.9.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 (108) hide show
  1. package/BarChart/BarChart.d.ts +3 -2
  2. package/BarChart/BarChart.js +1 -1
  3. package/BarChart/barClasses.d.ts +1 -1
  4. package/BarChart/seriesConfig/seriesProcessor.js +5 -3
  5. package/BarChart/useBarPlotData.js +32 -5
  6. package/CHANGELOG.md +101 -24
  7. package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
  8. package/ChartsLabel/index.d.ts +1 -0
  9. package/ChartsLabel/index.js +18 -0
  10. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  11. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  12. package/LineChart/LineChart.d.ts +3 -2
  13. package/LineChart/LineChart.js +1 -1
  14. package/PieChart/PieArcLabelPlot.js +3 -0
  15. package/PieChart/PieArcPlot.js +3 -0
  16. package/PieChart/PieChart.d.ts +3 -2
  17. package/PieChart/PieChart.js +1 -1
  18. package/PieChart/pieClasses.d.ts +1 -1
  19. package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
  20. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
  21. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
  22. package/RadarChart/RadarChart.d.ts +2 -1
  23. package/RadarChart/RadarChart.js +23 -2
  24. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
  25. package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
  26. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
  27. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
  28. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
  29. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
  30. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
  31. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
  32. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  33. package/RadarChart/index.d.ts +1 -1
  34. package/RadarChart/useRadarChartProps.d.ts +3 -0
  35. package/RadarChart/useRadarChartProps.js +15 -3
  36. package/ScatterChart/ScatterChart.d.ts +3 -2
  37. package/ScatterChart/ScatterChart.js +1 -1
  38. package/esm/BarChart/BarChart.d.ts +3 -2
  39. package/esm/BarChart/BarChart.js +1 -1
  40. package/esm/BarChart/barClasses.d.ts +1 -1
  41. package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
  42. package/esm/BarChart/useBarPlotData.js +32 -5
  43. package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
  44. package/esm/ChartsLabel/index.d.ts +1 -0
  45. package/esm/ChartsLabel/index.js +1 -0
  46. package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  47. package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  48. package/esm/LineChart/LineChart.d.ts +3 -2
  49. package/esm/LineChart/LineChart.js +1 -1
  50. package/esm/PieChart/PieArcLabelPlot.js +3 -0
  51. package/esm/PieChart/PieArcPlot.js +3 -0
  52. package/esm/PieChart/PieChart.d.ts +3 -2
  53. package/esm/PieChart/PieChart.js +1 -1
  54. package/esm/PieChart/pieClasses.d.ts +1 -1
  55. package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
  56. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
  57. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
  58. package/esm/RadarChart/RadarChart.d.ts +2 -1
  59. package/esm/RadarChart/RadarChart.js +23 -2
  60. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
  61. package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
  62. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
  63. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
  64. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
  65. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
  66. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
  67. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
  68. package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  69. package/esm/RadarChart/index.d.ts +1 -1
  70. package/esm/RadarChart/useRadarChartProps.d.ts +3 -0
  71. package/esm/RadarChart/useRadarChartProps.js +15 -3
  72. package/esm/ScatterChart/ScatterChart.d.ts +3 -2
  73. package/esm/ScatterChart/ScatterChart.js +1 -1
  74. package/esm/hooks/useTicks.d.ts +6 -1
  75. package/esm/hooks/useTicks.js +94 -58
  76. package/esm/index.js +1 -1
  77. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
  78. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
  79. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
  80. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
  81. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
  82. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
  83. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
  84. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
  85. package/esm/models/axis.d.ts +27 -1
  86. package/esm/models/seriesType/bar.d.ts +11 -1
  87. package/esm/models/seriesType/common.d.ts +9 -3
  88. package/esm/models/seriesType/line.d.ts +3 -1
  89. package/esm/models/seriesType/scatter.d.ts +4 -1
  90. package/esm/tests/web-components.js +49 -0
  91. package/hooks/useTicks.d.ts +6 -1
  92. package/hooks/useTicks.js +95 -58
  93. package/index.js +1 -1
  94. package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
  95. package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
  96. package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
  97. package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
  98. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
  99. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
  100. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
  101. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
  102. package/models/axis.d.ts +27 -1
  103. package/models/seriesType/bar.d.ts +11 -1
  104. package/models/seriesType/common.d.ts +9 -3
  105. package/models/seriesType/line.d.ts +3 -1
  106. package/models/seriesType/scatter.d.ts +4 -1
  107. package/package.json +4 -4
  108. package/tests/web-components.js +55 -0
@@ -12,10 +12,7 @@ var _useStore = require("../../internals/store/useStore");
12
12
  var _useChartContext = require("../../context/ChartProvider/useChartContext");
13
13
  var _useChartPolarAxis = require("../../internals/plugins/featurePlugins/useChartPolarAxis");
14
14
  var _useChartPolarInteraction = require("../../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors");
15
- function useRadarAxisHighlight(params) {
16
- const {
17
- includesNeighbors = false
18
- } = params ?? {};
15
+ function useRadarAxisHighlight() {
19
16
  const radarSeries = (0, _useRadarSeries.useRadarSeries)();
20
17
  const rotationScale = (0, _useScale.useRotationScale)();
21
18
  const {
@@ -55,48 +52,14 @@ function useRadarAxisHighlight(params) {
55
52
  const value = series.data[highlightedIndex];
56
53
  const r = radiusScale(value);
57
54
  const [x, y] = instance.polar2svg(r, angle);
58
- const retrunedValue = {
59
- highlighted: {
60
- x,
61
- y,
62
- r,
63
- angle,
64
- value
65
- }
55
+ const returnedValue = {
56
+ x,
57
+ y,
58
+ r,
59
+ angle,
60
+ value
66
61
  };
67
- if (!includesNeighbors) {
68
- return retrunedValue;
69
- }
70
- const dataLength = series.data.length;
71
- const prevIndex = (dataLength + highlightedIndex - 1) % dataLength;
72
- const nextIndex = (highlightedIndex + 1) % dataLength;
73
- const prevValue = series.data[prevIndex];
74
- const nextValue = series.data[nextIndex];
75
- if (prevValue != null) {
76
- const prevR = radiusAxis[radiusAxisIds[prevIndex]].scale(prevValue);
77
- const prevAngle = rotationScale(rotationScale.domain()[prevIndex]);
78
- const [px, py] = instance.polar2svg(prevR, prevAngle);
79
- retrunedValue.previous = {
80
- x: px,
81
- y: py,
82
- r: prevR,
83
- angle: prevAngle,
84
- value: prevValue
85
- };
86
- }
87
- if (nextValue != null) {
88
- const nextR = radiusAxis[radiusAxisIds[nextIndex]].scale(nextValue);
89
- const nextAngle = rotationScale(rotationScale.domain()[nextIndex]);
90
- const [nx, ny] = instance.polar2svg(nextR, nextAngle);
91
- retrunedValue.next = {
92
- x: nx,
93
- y: ny,
94
- r: nextR,
95
- angle: nextAngle,
96
- value: nextValue
97
- };
98
- }
99
- return retrunedValue;
62
+ return returnedValue;
100
63
  })
101
64
  };
102
65
  }
@@ -5,13 +5,14 @@ import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
5
5
  import { ChartsWrapperProps } from "../internals/components/ChartsWrapper/index.js";
6
6
  import { RadarGridProps } from "./RadarGrid/index.js";
7
7
  import { RadarDataProviderProps } from "./RadarDataProvider/RadarDataProvider.js";
8
+ import { RadarSeriesPlotProps } from "./RadarSeriesPlot/index.js";
8
9
  import { RadarAxisHighlightProps } from "./RadarAxisHighlight/index.js";
9
10
  import { ChartsTooltipSlotProps, ChartsTooltipSlots } from "../ChartsTooltip/index.js";
10
11
  import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
11
12
  import { ChartsToolbarSlotProps, ChartsToolbarSlots } from "../Toolbar/index.js";
12
13
  export interface RadarChartSlots extends ChartsTooltipSlots, ChartsOverlaySlots, ChartsLegendSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
13
14
  export interface RadarChartSlotProps extends ChartsTooltipSlotProps, ChartsOverlaySlotProps, ChartsLegendSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
14
- export interface RadarChartProps extends RadarDataProviderProps, Omit<RadarGridProps, 'classes'>, Omit<Partial<RadarAxisHighlightProps>, 'classes'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ChartsWrapperProps, 'sx'>, Omit<ChartsSurfaceProps, 'sx'> {
15
+ export interface RadarChartProps extends RadarDataProviderProps, Omit<RadarGridProps, 'classes'>, Omit<Partial<RadarAxisHighlightProps>, 'classes'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ChartsWrapperProps, 'sx'>, Omit<ChartsSurfaceProps, 'sx'>, Pick<RadarSeriesPlotProps, 'onAreaClick' | 'onMarkClick'> {
15
16
  /**
16
17
  * If `true`, the legend is not rendered.
17
18
  */
@@ -42,6 +42,8 @@ const RadarChart = exports.RadarChart = /*#__PURE__*/React.forwardRef(function R
42
42
  chartsSurfaceProps,
43
43
  radarDataProviderProps,
44
44
  radarGrid,
45
+ radarSeriesAreaProps,
46
+ radarSeriesMarksProps,
45
47
  overlayProps,
46
48
  legendProps,
47
49
  highlight,
@@ -53,7 +55,7 @@ const RadarChart = exports.RadarChart = /*#__PURE__*/React.forwardRef(function R
53
55
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsWrapper.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
54
56
  children: [props.showToolbar && Toolbar ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Toolbar, (0, _extends2.default)({}, props.slotProps?.toolbar)) : null, !props.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
55
57
  ref: ref,
56
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarGrid.RadarGrid, (0, _extends2.default)({}, radarGrid)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarMetricLabels.RadarMetricLabels, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarSeriesPlot.RadarSeriesArea, {}), highlight === 'axis' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarAxisHighlight.RadarAxisHighlight, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarSeriesPlot.RadarSeriesMarks, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), children]
58
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarGrid.RadarGrid, (0, _extends2.default)({}, radarGrid)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarMetricLabels.RadarMetricLabels, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarSeriesPlot.RadarSeriesArea, (0, _extends2.default)({}, radarSeriesAreaProps)), highlight === 'axis' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarAxisHighlight.RadarAxisHighlight, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadarSeriesPlot.RadarSeriesMarks, (0, _extends2.default)({}, radarSeriesMarksProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), children]
57
59
  })), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, props.slotProps?.tooltip))]
58
60
  }))
59
61
  }));
@@ -132,12 +134,31 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes = {
132
134
  right: _propTypes.default.number,
133
135
  top: _propTypes.default.number
134
136
  })]),
137
+ /**
138
+ * Callback fired when an area is clicked.
139
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
140
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
141
+ */
142
+ onAreaClick: _propTypes.default.func,
143
+ /**
144
+ * The function called for onClick events.
145
+ * The second argument contains information about all line/bar elements at the current mouse position.
146
+ * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
147
+ * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
148
+ */
149
+ onAxisClick: _propTypes.default.func,
135
150
  /**
136
151
  * The callback fired when the highlighted item changes.
137
152
  *
138
153
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
139
154
  */
140
155
  onHighlightChange: _propTypes.default.func,
156
+ /**
157
+ * Callback fired when a mark is clicked.
158
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
159
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
160
+ */
161
+ onMarkClick: _propTypes.default.func,
141
162
  /**
142
163
  * The configuration of the radar scales.
143
164
  */
@@ -154,7 +175,7 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes = {
154
175
  }).isRequired,
155
176
  /**
156
177
  * The series to display in the bar chart.
157
- * An array of [[RadarSeriesType]] objects.
178
+ * An array of [[RadarSeries]] objects.
158
179
  */
159
180
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
160
181
  /**
@@ -5,12 +5,13 @@ import { RadarSeriesType } from "../../models/seriesType/radar.js";
5
5
  import { ChartDataProviderProps } from "../../ChartDataProvider/index.js";
6
6
  import { RadarConfig } from "./radar.types.js";
7
7
  import { ChartAnyPluginSignature } from "../../internals/plugins/models/plugin.js";
8
+ export type RadarSeries = MakeOptional<RadarSeriesType, 'type'>;
8
9
  export type RadarDataProviderProps<TSignatures extends readonly ChartAnyPluginSignature[] = RadarChartPluginsSignatures> = Omit<ChartDataProviderProps<'radar', TSignatures>, 'series' | 'rotationAxis' | 'radiusAxis' | 'dataset' | 'experimentalFeatures'> & {
9
10
  /**
10
11
  * The series to display in the bar chart.
11
- * An array of [[RadarSeriesType]] objects.
12
+ * An array of [[RadarSeries]] objects.
12
13
  */
13
- series: Readonly<MakeOptional<RadarSeriesType, 'type'>>[];
14
+ series: Readonly<RadarSeries>[];
14
15
  /**
15
16
  * The configuration of the radar scales.
16
17
  */
@@ -27,14 +27,16 @@ function useRadarMetricData() {
27
27
  const radiusScale = radiusAxis[metric].scale;
28
28
  const r = radiusScale.range()[1] + labelGap;
29
29
  const angle = angles[dataIndex];
30
+ const defaultTickLabel = metric;
30
31
  return {
31
32
  x: cx + r * Math.sin(angle),
32
33
  y: cy - r * Math.cos(angle),
33
34
  angle: (0, _angleConversion.rad2deg)(angle),
34
35
  label: valueFormatter?.(metric, {
35
36
  location: 'tick',
36
- scale: rotationScale
37
- }) ?? metric
37
+ scale: rotationScale,
38
+ defaultTickLabel
39
+ }) ?? defaultTickLabel
38
40
  };
39
41
  })
40
42
  };
@@ -17,8 +17,9 @@ var _getAreaPath = require("./getAreaPath");
17
17
  var _radarSeriesPlotClasses = require("./radarSeriesPlotClasses");
18
18
  var _useItemHighlightedGetter = require("../../hooks/useItemHighlightedGetter");
19
19
  var _useInteractionItemProps = require("../../hooks/useInteractionItemProps");
20
+ var _useRadarRotationIndex = require("./useRadarRotationIndex");
20
21
  var _jsxRuntime = require("react/jsx-runtime");
21
- const _excluded = ["seriesId"];
22
+ const _excluded = ["seriesId", "onItemClick"];
22
23
  function getPathProps(params) {
23
24
  const {
24
25
  isHighlighted,
@@ -47,10 +48,12 @@ function getPathProps(params) {
47
48
  }
48
49
  function RadarSeriesArea(props) {
49
50
  const {
50
- seriesId
51
+ seriesId,
52
+ onItemClick
51
53
  } = props,
52
54
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
53
55
  const seriesCoordinates = (0, _useRadarSeriesData.useRadarSeriesData)(seriesId);
56
+ const getRotationIndex = (0, _useRadarRotationIndex.useRadarRotationIndex)();
54
57
  const interactionProps = (0, _useInteractionItemProps.useInteractionAllItemProps)(seriesCoordinates);
55
58
  const {
56
59
  isFaded,
@@ -72,7 +75,14 @@ function RadarSeriesArea(props) {
72
75
  isFaded,
73
76
  isHighlighted,
74
77
  classes
75
- }), interactionProps[seriesIndex], other), id);
78
+ }), {
79
+ onClick: event => onItemClick?.(event, {
80
+ type: 'radar',
81
+ seriesId: id,
82
+ dataIndex: getRotationIndex(event)
83
+ }),
84
+ cursor: onItemClick ? 'pointer' : 'unset'
85
+ }, interactionProps[seriesIndex], other), id);
76
86
  })
77
87
  });
78
88
  }
@@ -85,6 +95,12 @@ process.env.NODE_ENV !== "production" ? RadarSeriesArea.propTypes = {
85
95
  * Override or extend the styles applied to the component.
86
96
  */
87
97
  classes: _propTypes.default.object,
98
+ /**
99
+ * Callback fired when an area is clicked.
100
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
101
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
102
+ */
103
+ onItemClick: _propTypes.default.func,
88
104
  /**
89
105
  * The id of the series to display.
90
106
  * If undefined all series are displayed.
@@ -16,7 +16,7 @@ var _useRadarSeriesData = require("./useRadarSeriesData");
16
16
  var _useItemHighlightedGetter = require("../../hooks/useItemHighlightedGetter");
17
17
  var _radarSeriesPlotClasses = require("./radarSeriesPlotClasses");
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
- const _excluded = ["seriesId"];
19
+ const _excluded = ["seriesId", "onItemClick"];
20
20
  function getCircleProps(params) {
21
21
  const {
22
22
  isHighlighted,
@@ -40,12 +40,14 @@ function getCircleProps(params) {
40
40
  fill: color,
41
41
  stroke: color,
42
42
  opacity: fillArea && isItemFaded ? 0.5 : 1,
43
- pointerEvents: 'none',
44
43
  className: (0, _clsx.clsx)(classes.mark, isItemHighlighted && classes.highlighted || isItemFaded && classes.faded)
45
44
  };
46
45
  }
47
46
  function RadarSeriesMarks(props) {
48
- const other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
47
+ const {
48
+ onItemClick
49
+ } = props,
50
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
49
51
  const seriesCoordinates = (0, _useRadarSeriesData.useRadarSeriesData)(props.seriesId);
50
52
  const classes = (0, _radarSeriesPlotClasses.useUtilityClasses)(props.classes);
51
53
  const {
@@ -72,7 +74,15 @@ function RadarSeriesMarks(props) {
72
74
  isFaded,
73
75
  isHighlighted,
74
76
  classes
75
- }), other), index))
77
+ }), {
78
+ pointerEvents: onItemClick ? undefined : 'none',
79
+ onClick: event => onItemClick?.(event, {
80
+ type: 'radar',
81
+ seriesId: id,
82
+ dataIndex: index
83
+ }),
84
+ cursor: onItemClick ? 'pointer' : 'unset'
85
+ }, other), index))
76
86
  }, id);
77
87
  })
78
88
  });
@@ -86,6 +96,12 @@ process.env.NODE_ENV !== "production" ? RadarSeriesMarks.propTypes = {
86
96
  * Override or extend the styles applied to the component.
87
97
  */
88
98
  classes: _propTypes.default.object,
99
+ /**
100
+ * Callback fired when a mark is clicked.
101
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
102
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
103
+ */
104
+ onItemClick: _propTypes.default.func,
89
105
  /**
90
106
  * The id of the series to display.
91
107
  * If undefined all series are displayed.
@@ -15,15 +15,23 @@ var _useItemHighlightedGetter = require("../../hooks/useItemHighlightedGetter");
15
15
  var _radarSeriesPlotClasses = require("./radarSeriesPlotClasses");
16
16
  var _RadarSeriesArea = require("./RadarSeriesArea");
17
17
  var _RadarSeriesMarks = require("./RadarSeriesMarks");
18
+ var _useRadarRotationIndex = require("./useRadarRotationIndex");
18
19
  var _jsxRuntime = require("react/jsx-runtime");
19
20
  function RadarSeriesPlot(props) {
20
- const seriesCoordinates = (0, _useRadarSeriesData.useRadarSeriesData)(props.seriesId);
21
+ const {
22
+ seriesId: inSeriesId,
23
+ classes: inClasses,
24
+ onAreaClick,
25
+ onMarkClick
26
+ } = props;
27
+ const seriesCoordinates = (0, _useRadarSeriesData.useRadarSeriesData)(inSeriesId);
28
+ const getRotationIndex = (0, _useRadarRotationIndex.useRadarRotationIndex)();
21
29
  const interactionProps = (0, _useInteractionItemProps.useInteractionAllItemProps)(seriesCoordinates);
22
30
  const {
23
31
  isFaded,
24
32
  isHighlighted
25
33
  } = (0, _useItemHighlightedGetter.useItemHighlightedGetter)();
26
- const classes = (0, _radarSeriesPlotClasses.useUtilityClasses)(props.classes);
34
+ const classes = (0, _radarSeriesPlotClasses.useUtilityClasses)(inClasses);
27
35
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
28
36
  className: classes.root,
29
37
  children: seriesCoordinates?.map(({
@@ -42,7 +50,14 @@ function RadarSeriesPlot(props) {
42
50
  isFaded,
43
51
  isHighlighted,
44
52
  classes
45
- }), interactionProps[seriesIndex]), seriesId), !hideMark && points.map((point, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({}, (0, _RadarSeriesMarks.getCircleProps)({
53
+ }), {
54
+ onClick: event => onAreaClick?.(event, {
55
+ type: 'radar',
56
+ seriesId,
57
+ dataIndex: getRotationIndex(event)
58
+ }),
59
+ cursor: onAreaClick ? 'pointer' : 'unset'
60
+ }, interactionProps[seriesIndex]), seriesId), !hideMark && points.map((point, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({}, (0, _RadarSeriesMarks.getCircleProps)({
46
61
  seriesId,
47
62
  point,
48
63
  color,
@@ -50,7 +65,14 @@ function RadarSeriesPlot(props) {
50
65
  isFaded,
51
66
  isHighlighted,
52
67
  classes
53
- })), index))]
68
+ }), {
69
+ onClick: event => onMarkClick?.(event, {
70
+ type: 'radar',
71
+ seriesId,
72
+ dataIndex: index
73
+ }),
74
+ cursor: onMarkClick ? 'pointer' : 'unset'
75
+ }), index))]
54
76
  }, seriesId);
55
77
  })
56
78
  });
@@ -64,6 +86,18 @@ process.env.NODE_ENV !== "production" ? RadarSeriesPlot.propTypes = {
64
86
  * Override or extend the styles applied to the component.
65
87
  */
66
88
  classes: _propTypes.default.object,
89
+ /**
90
+ * Callback fired when an area is clicked.
91
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
92
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
93
+ */
94
+ onAreaClick: _propTypes.default.func,
95
+ /**
96
+ * Callback fired when a mark is clicked.
97
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
98
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
99
+ */
100
+ onMarkClick: _propTypes.default.func,
67
101
  /**
68
102
  * The id of the series to display.
69
103
  * If undefined all series are displayed.
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { RadarSeriesPlotClasses } from "./radarSeriesPlotClasses.js";
3
+ import { RadarItemIdentifier } from "../../models/seriesType/radar.js";
3
4
  interface CommonRadarSeriesPlotProps {
4
5
  /**
5
6
  * The id of the series to display.
@@ -11,7 +12,35 @@ interface CommonRadarSeriesPlotProps {
11
12
  */
12
13
  classes?: Partial<RadarSeriesPlotClasses>;
13
14
  }
14
- export interface RadarSeriesPlotProps extends CommonRadarSeriesPlotProps {}
15
- export interface RadarSeriesMarksProps extends CommonRadarSeriesPlotProps, React.SVGAttributes<SVGCircleElement> {}
16
- export interface RadarSeriesAreaProps extends CommonRadarSeriesPlotProps, React.SVGAttributes<SVGPathElement> {}
15
+ export interface RadarSeriesPlotProps extends CommonRadarSeriesPlotProps {
16
+ /**
17
+ * Callback fired when an area is clicked.
18
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
19
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
20
+ */
21
+ onAreaClick?: RadarSeriesAreaProps['onItemClick'];
22
+ /**
23
+ * Callback fired when a mark is clicked.
24
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
25
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
26
+ */
27
+ onMarkClick?: RadarSeriesMarksProps['onItemClick'];
28
+ }
29
+ type RadarClickIdentifier = Required<RadarItemIdentifier>;
30
+ export interface RadarSeriesMarksProps extends CommonRadarSeriesPlotProps, React.SVGAttributes<SVGCircleElement> {
31
+ /**
32
+ * Callback fired when a mark is clicked.
33
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
34
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
35
+ */
36
+ onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, radarItemIdentifier: RadarClickIdentifier) => void;
37
+ }
38
+ export interface RadarSeriesAreaProps extends CommonRadarSeriesPlotProps, React.SVGAttributes<SVGPathElement> {
39
+ /**
40
+ * Callback fired when an area is clicked.
41
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
42
+ * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
43
+ */
44
+ onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, radarItemIdentifier: RadarClickIdentifier) => void;
45
+ }
17
46
  export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This hook provides a function that from pointer event returns the rotation index.
3
+ * @return {(event: { clientX: number; clientY: number }) => number | null} rotationIndexGetter Returns the rotation data index.
4
+ */
5
+ export declare function useRadarRotationIndex(): (event: {
6
+ clientX: number;
7
+ clientY: number;
8
+ }) => number;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useRadarRotationIndex = useRadarRotationIndex;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _useChartPolarAxis = require("../../internals/plugins/featurePlugins/useChartPolarAxis");
10
+ var _getSVGPoint = require("../../internals/getSVGPoint");
11
+ var _coordinateTransformation = require("../../internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation");
12
+ var _useSelector = require("../../internals/store/useSelector");
13
+ var _getAxisIndex = require("../../internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex");
14
+ var _useStore = require("../../internals/store/useStore");
15
+ var _useSvgRef = require("../../hooks/useSvgRef");
16
+ var _useAxis = require("../../hooks/useAxis");
17
+ /**
18
+ * This hook provides a function that from pointer event returns the rotation index.
19
+ * @return {(event: { clientX: number; clientY: number }) => number | null} rotationIndexGetter Returns the rotation data index.
20
+ */
21
+ function useRadarRotationIndex() {
22
+ const svgRef = (0, _useSvgRef.useSvgRef)();
23
+ const store = (0, _useStore.useStore)();
24
+ const rotationAxis = (0, _useAxis.useRotationAxis)();
25
+ const center = (0, _useSelector.useSelector)(store, _useChartPolarAxis.selectorChartPolarCenter);
26
+ const rotationIndexGetter = React.useCallback(function rotationIndexGetter(event) {
27
+ const element = svgRef.current;
28
+ if (!element || !rotationAxis) {
29
+ // Should never append
30
+ throw new Error(`MUI X Charts: The ${!element ? 'SVG' : 'rotation axis'} was not found to compute radar dataIndex.`);
31
+ }
32
+ const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, event);
33
+ const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
34
+ const rotationIndex = (0, _getAxisIndex.getAxisIndex)(rotationAxis, rotation);
35
+ return rotationIndex;
36
+ }, [center, rotationAxis, svgRef]);
37
+ return rotationIndexGetter;
38
+ }
@@ -17,8 +17,8 @@ export declare function useRadarSeriesData(querySeriesId?: SeriesId): {
17
17
  }[];
18
18
  type: "radar";
19
19
  label?: string | ((location: "tooltip" | "legend") => string) | undefined;
20
- highlightScope?: Partial<import("../../index.js").HighlightScope> | undefined;
21
- labelMarkType?: "line" | "square" | "circle" | import("react").ComponentType<import("../../index.js").ChartsLabelCustomMarkProps> | undefined;
20
+ highlightScope?: import("../../index.js").HighlightScope | undefined;
21
+ labelMarkType?: import("../../internals/index.js").ChartsLabelMarkType | undefined;
22
22
  hideMark?: boolean | undefined;
23
23
  fillArea?: boolean | undefined;
24
24
  data: number[];
@@ -3,7 +3,7 @@ export { RadarChart } from "./RadarChart.js";
3
3
  export { RadarDataProvider as Unstable_RadarDataProvider } from "./RadarDataProvider/index.js";
4
4
  export { RadarDataProvider } from "./RadarDataProvider/index.js";
5
5
  export type { RadarChartProps, RadarChartSlots, RadarChartSlotProps } from "./RadarChart.js";
6
- export type { RadarDataProviderProps } from "./RadarDataProvider/index.js";
6
+ export type { RadarDataProviderProps, RadarSeries } from "./RadarDataProvider/index.js";
7
7
  export * from "./RadarGrid/index.js";
8
8
  export * from "./RadarAxisHighlight/index.js";
9
9
  export * from "./RadarMetricLabels/index.js";
@@ -6,6 +6,7 @@ import { RadarDataProviderProps } from "./RadarDataProvider/RadarDataProvider.js
6
6
  import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
7
7
  import { RadarGridProps } from "./RadarGrid/index.js";
8
8
  import { RadarChartPluginsSignatures } from "./RadarChart.plugins.js";
9
+ import { RadarSeriesAreaProps, RadarSeriesMarksProps } from "./RadarSeriesPlot/index.js";
9
10
  /**
10
11
  * A helper function that extracts RadarChartProps from the input props
11
12
  * and returns an object with props for the children components of RadarChart.
@@ -19,6 +20,8 @@ export declare const useRadarChartProps: (props: RadarChartProps) => {
19
20
  chartsSurfaceProps: ChartsSurfaceProps;
20
21
  radarDataProviderProps: RadarDataProviderProps<RadarChartPluginsSignatures>;
21
22
  radarGrid: RadarGridProps;
23
+ radarSeriesAreaProps: RadarSeriesAreaProps;
24
+ radarSeriesMarksProps: RadarSeriesMarksProps;
22
25
  overlayProps: ChartsOverlayProps;
23
26
  legendProps: ChartsLegendSlotExtension;
24
27
  children: import("react").ReactNode;
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.useRadarChartProps = void 0;
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
- const _excluded = ["apiRef", "series", "radar", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "hideLegend", "divisions", "shape", "stripeColor", "highlight", "showToolbar"];
10
+ const _excluded = ["apiRef", "series", "radar", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "hideLegend", "divisions", "shape", "stripeColor", "highlight", "showToolbar", "onAxisClick", "onAreaClick", "onMarkClick"];
11
11
  /**
12
12
  * A helper function that extracts RadarChartProps from the input props
13
13
  * and returns an object with props for the children components of RadarChart.
@@ -35,7 +35,10 @@ const useRadarChartProps = props => {
35
35
  divisions,
36
36
  shape,
37
37
  stripeColor,
38
- highlight = 'axis'
38
+ highlight = 'axis',
39
+ onAxisClick,
40
+ onAreaClick,
41
+ onMarkClick
39
42
  } = props,
40
43
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
41
44
  const radarDataProviderProps = {
@@ -49,7 +52,8 @@ const useRadarChartProps = props => {
49
52
  colors,
50
53
  highlightedItem,
51
54
  onHighlightChange,
52
- skipAnimation
55
+ skipAnimation,
56
+ onAxisClick
53
57
  };
54
58
  const overlayProps = {
55
59
  slots,
@@ -68,6 +72,12 @@ const useRadarChartProps = props => {
68
72
  shape,
69
73
  stripeColor
70
74
  };
75
+ const radarSeriesAreaProps = {
76
+ onItemClick: onAreaClick
77
+ };
78
+ const radarSeriesMarksProps = {
79
+ onItemClick: onMarkClick
80
+ };
71
81
  const chartsSurfaceProps = other;
72
82
  return {
73
83
  highlight,
@@ -75,6 +85,8 @@ const useRadarChartProps = props => {
75
85
  chartsSurfaceProps,
76
86
  radarDataProviderProps,
77
87
  radarGrid,
88
+ radarSeriesAreaProps,
89
+ radarSeriesMarksProps,
78
90
  overlayProps,
79
91
  legendProps,
80
92
  children
@@ -16,12 +16,13 @@ import { UseChartVoronoiSignature } from "../internals/plugins/featurePlugins/us
16
16
  import { ScatterChartPluginsSignatures } from "./ScatterChart.plugins.js";
17
17
  export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
18
18
  export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
19
+ export type ScatterSeries = MakeOptional<ScatterSeriesType, 'type'>;
19
20
  export interface ScatterChartProps extends Omit<ChartContainerProps<'scatter', ScatterChartPluginsSignatures>, 'series' | 'plugins' | 'onItemClick' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
20
21
  /**
21
22
  * The series to display in the scatter chart.
22
- * An array of [[ScatterSeriesType]] objects.
23
+ * An array of [[ScatterSeries]] objects.
23
24
  */
24
- series: Readonly<MakeOptional<ScatterSeriesType, 'type'>[]>;
25
+ series: Readonly<ScatterSeries[]>;
25
26
  /**
26
27
  * The configuration of axes highlight.
27
28
  * @see See {@link https://mui.com/x/react-charts/highlighting/ highlighting docs} for more details.
@@ -180,7 +180,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
180
180
  onItemClick: _propTypes.default.func,
181
181
  /**
182
182
  * The series to display in the scatter chart.
183
- * An array of [[ScatterSeriesType]] objects.
183
+ * An array of [[ScatterSeries]] objects.
184
184
  */
185
185
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
186
186
  /**
@@ -15,12 +15,13 @@ import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "
15
15
  import { BarChartPluginsSignatures } from "./BarChart.plugins.js";
16
16
  export interface BarChartSlots extends ChartsAxisSlots, BarPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
17
17
  export interface BarChartSlotProps extends ChartsAxisSlotProps, BarPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
18
+ export type BarSeries = MakeOptional<BarSeriesType, 'type'>;
18
19
  export interface BarChartProps extends Omit<ChartContainerProps<'bar', BarChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis' | 'experimentalFeatures'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<BarPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
19
20
  /**
20
21
  * The series to display in the bar chart.
21
- * An array of [[BarSeriesType]] objects.
22
+ * An array of [[BarSeries]] objects.
22
23
  */
23
- series: Readonly<MakeOptional<BarSeriesType, 'type'>[]>;
24
+ series: Readonly<BarSeries[]>;
24
25
  /**
25
26
  * Option to display a cartesian grid in the background.
26
27
  */
@@ -203,7 +203,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
203
203
  onItemClick: PropTypes.func,
204
204
  /**
205
205
  * The series to display in the bar chart.
206
- * An array of [[BarSeriesType]] objects.
206
+ * An array of [[BarSeries]] objects.
207
207
  */
208
208
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
209
209
  /**
@@ -9,4 +9,4 @@ export interface BarClasses {
9
9
  export type BarClassKey = keyof BarClasses;
10
10
  export declare function getBarUtilityClass(slot: string): string;
11
11
  export declare const barClasses: BarClasses;
12
- export declare const useUtilityClasses: (classes?: Partial<BarClasses>) => Record<"root" | "series" | "seriesLabels", string>;
12
+ export declare const useUtilityClasses: (classes?: Partial<BarClasses>) => Record<"series" | "root" | "seriesLabels", string>;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
3
3
  import { warnOnce } from '@mui/x-internals/warning';
4
4
  import { getStackingGroups } from "../../internals/stackSeries.js";
5
- import { defaultizeValueFormatter } from "../../internals/defaultizeValueFormatter.js";
5
+ const barValueFormatter = v => v == null ? '' : v.toLocaleString();
6
6
  const seriesProcessor = (params, dataset) => {
7
7
  const {
8
8
  seriesOrder,
@@ -46,7 +46,9 @@ const seriesProcessor = (params, dataset) => {
46
46
  const dataKey = series[id].dataKey;
47
47
  completedSeries[id] = _extends({
48
48
  layout: 'vertical',
49
- labelMarkType: 'square'
49
+ labelMarkType: 'square',
50
+ minBarSize: 0,
51
+ valueFormatter: series[id].valueFormatter ?? barValueFormatter
50
52
  }, series[id], {
51
53
  data: dataKey ? dataset.map(data => {
52
54
  const value = data[dataKey];
@@ -67,7 +69,7 @@ const seriesProcessor = (params, dataset) => {
67
69
  return {
68
70
  seriesOrder,
69
71
  stackingGroups,
70
- series: defaultizeValueFormatter(completedSeries, v => v == null ? '' : v.toLocaleString())
72
+ series: completedSeries
71
73
  };
72
74
  };
73
75
  export default seriesProcessor;