@mui/x-charts 7.5.0 → 7.6.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 (245) hide show
  1. package/BarChart/BarChart.js +30 -3
  2. package/BarChart/BarElement.d.ts +0 -3
  3. package/BarChart/BarElement.js +8 -19
  4. package/BarChart/BarLabel/BarLabel.d.ts +1342 -0
  5. package/BarChart/BarLabel/BarLabel.js +60 -0
  6. package/BarChart/BarLabel/BarLabel.types.d.ts +39 -0
  7. package/BarChart/BarLabel/BarLabel.types.js +5 -0
  8. package/BarChart/BarLabel/BarLabelItem.d.ts +53 -0
  9. package/BarChart/BarLabel/BarLabelItem.js +127 -0
  10. package/BarChart/BarLabel/BarLabelPlot.d.ts +16 -0
  11. package/BarChart/BarLabel/BarLabelPlot.js +106 -0
  12. package/BarChart/BarLabel/barLabelClasses.d.ts +13 -0
  13. package/BarChart/BarLabel/barLabelClasses.js +29 -0
  14. package/BarChart/BarLabel/getBarLabel.d.ts +10 -0
  15. package/BarChart/BarLabel/getBarLabel.js +31 -0
  16. package/BarChart/BarLabel/index.d.ts +6 -0
  17. package/BarChart/BarLabel/index.js +25 -0
  18. package/BarChart/BarPlot.d.ts +15 -4
  19. package/BarChart/BarPlot.js +22 -34
  20. package/BarChart/checkScaleErrors.d.ts +11 -0
  21. package/BarChart/checkScaleErrors.js +33 -0
  22. package/BarChart/index.d.ts +1 -0
  23. package/BarChart/index.js +11 -0
  24. package/BarChart/types.d.ts +0 -2
  25. package/CHANGELOG.md +148 -5418
  26. package/ChartContainer/ChartContainer.d.ts +3 -2
  27. package/ChartContainer/ChartContainer.js +20 -3
  28. package/ChartsAxis/ChartsAxis.js +1 -1
  29. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  30. package/ChartsClipPath/ChartsClipPath.js +1 -1
  31. package/ChartsGrid/ChartsGrid.js +1 -1
  32. package/ChartsLegend/ChartsLegend.js +1 -1
  33. package/ChartsLegend/DefaultChartsLegend.js +1 -1
  34. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  35. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  36. package/ChartsSurface.js +1 -1
  37. package/ChartsText/ChartsText.js +1 -1
  38. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  39. package/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
  40. package/ChartsTooltip/ChartsTooltip.js +1 -1
  41. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  42. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  43. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
  44. package/ChartsXAxis/ChartsXAxis.js +1 -1
  45. package/ChartsYAxis/ChartsYAxis.js +1 -1
  46. package/Gauge/Gauge.js +1 -1
  47. package/Gauge/GaugeContainer.js +1 -1
  48. package/Gauge/GaugeValueText.js +1 -1
  49. package/LineChart/AnimatedArea.js +1 -1
  50. package/LineChart/AnimatedLine.js +1 -1
  51. package/LineChart/AreaElement.d.ts +0 -2
  52. package/LineChart/AreaElement.js +8 -18
  53. package/LineChart/AreaPlot.js +1 -3
  54. package/LineChart/LineChart.js +19 -2
  55. package/LineChart/LineElement.d.ts +0 -2
  56. package/LineChart/LineElement.js +8 -18
  57. package/LineChart/LineHighlightElement.js +1 -1
  58. package/LineChart/LineHighlightPlot.js +1 -1
  59. package/LineChart/LinePlot.js +1 -3
  60. package/LineChart/MarkElement.d.ts +0 -2
  61. package/LineChart/MarkElement.js +11 -33
  62. package/LineChart/MarkPlot.js +1 -2
  63. package/PieChart/PieArc.d.ts +4 -1
  64. package/PieChart/PieArc.js +8 -4
  65. package/PieChart/PieArcLabel.js +1 -1
  66. package/PieChart/PieArcLabelPlot.d.ts +1 -1
  67. package/PieChart/PieArcLabelPlot.js +2 -8
  68. package/PieChart/PieArcPlot.d.ts +1 -1
  69. package/PieChart/PieArcPlot.js +6 -8
  70. package/PieChart/PieChart.js +19 -2
  71. package/PieChart/PiePlot.js +3 -7
  72. package/PieChart/dataTransform/useTransformData.d.ts +1 -1
  73. package/PieChart/dataTransform/useTransformData.js +10 -25
  74. package/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
  75. package/ScatterChart/Scatter.js +15 -11
  76. package/ScatterChart/ScatterChart.js +19 -2
  77. package/ScatterChart/ScatterPlot.js +1 -1
  78. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  79. package/SparkLineChart/SparkLineChart.js +14 -1
  80. package/context/HighlightedProvider/HighlightedContext.d.ts +65 -0
  81. package/context/HighlightedProvider/HighlightedContext.js +36 -0
  82. package/context/HighlightedProvider/HighlightedProvider.d.ts +20 -0
  83. package/context/HighlightedProvider/HighlightedProvider.js +97 -0
  84. package/context/HighlightedProvider/createIsFaded.d.ts +2 -0
  85. package/context/HighlightedProvider/createIsFaded.js +19 -0
  86. package/context/HighlightedProvider/createIsHighlighted.d.ts +2 -0
  87. package/context/HighlightedProvider/createIsHighlighted.js +19 -0
  88. package/context/HighlightedProvider/index.d.ts +4 -0
  89. package/context/HighlightedProvider/index.js +49 -0
  90. package/context/HighlightedProvider/useHighlighted.d.ts +9 -0
  91. package/context/HighlightedProvider/useHighlighted.js +24 -0
  92. package/context/HighlightedProvider/useItemHighlighted.d.ts +21 -0
  93. package/context/HighlightedProvider/useItemHighlighted.js +37 -0
  94. package/context/ZAxisContextProvider.js +1 -1
  95. package/context/index.d.ts +1 -1
  96. package/context/index.js +15 -0
  97. package/esm/BarChart/BarChart.js +30 -3
  98. package/esm/BarChart/BarElement.js +9 -20
  99. package/esm/BarChart/BarLabel/BarLabel.js +51 -0
  100. package/esm/BarChart/BarLabel/BarLabel.types.js +1 -0
  101. package/esm/BarChart/BarLabel/BarLabelItem.js +119 -0
  102. package/esm/BarChart/BarLabel/BarLabelPlot.js +98 -0
  103. package/esm/BarChart/BarLabel/barLabelClasses.js +19 -0
  104. package/esm/BarChart/BarLabel/getBarLabel.js +24 -0
  105. package/esm/BarChart/BarLabel/index.js +2 -0
  106. package/esm/BarChart/BarPlot.js +22 -34
  107. package/esm/BarChart/checkScaleErrors.js +27 -0
  108. package/esm/BarChart/index.js +2 -1
  109. package/esm/ChartContainer/ChartContainer.js +20 -3
  110. package/esm/ChartsAxis/ChartsAxis.js +1 -1
  111. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  112. package/esm/ChartsClipPath/ChartsClipPath.js +1 -1
  113. package/esm/ChartsGrid/ChartsGrid.js +1 -1
  114. package/esm/ChartsLegend/ChartsLegend.js +1 -1
  115. package/esm/ChartsLegend/DefaultChartsLegend.js +1 -1
  116. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  117. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  118. package/esm/ChartsSurface.js +1 -1
  119. package/esm/ChartsText/ChartsText.js +1 -1
  120. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  121. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
  122. package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
  123. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  124. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  125. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
  126. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  127. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  128. package/esm/Gauge/Gauge.js +1 -1
  129. package/esm/Gauge/GaugeContainer.js +1 -1
  130. package/esm/Gauge/GaugeValueText.js +1 -1
  131. package/esm/LineChart/AnimatedArea.js +1 -1
  132. package/esm/LineChart/AnimatedLine.js +1 -1
  133. package/esm/LineChart/AreaElement.js +9 -19
  134. package/esm/LineChart/AreaPlot.js +1 -3
  135. package/esm/LineChart/LineChart.js +19 -2
  136. package/esm/LineChart/LineElement.js +9 -19
  137. package/esm/LineChart/LineHighlightElement.js +1 -1
  138. package/esm/LineChart/LineHighlightPlot.js +1 -1
  139. package/esm/LineChart/LinePlot.js +1 -3
  140. package/esm/LineChart/MarkElement.js +12 -34
  141. package/esm/LineChart/MarkPlot.js +1 -2
  142. package/esm/PieChart/PieArc.js +8 -4
  143. package/esm/PieChart/PieArcLabel.js +1 -1
  144. package/esm/PieChart/PieArcLabelPlot.js +2 -8
  145. package/esm/PieChart/PieArcPlot.js +6 -8
  146. package/esm/PieChart/PieChart.js +19 -2
  147. package/esm/PieChart/PiePlot.js +3 -7
  148. package/esm/PieChart/dataTransform/useTransformData.js +10 -25
  149. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
  150. package/esm/ScatterChart/Scatter.js +16 -12
  151. package/esm/ScatterChart/ScatterChart.js +19 -2
  152. package/esm/ScatterChart/ScatterPlot.js +1 -1
  153. package/esm/SparkLineChart/SparkLineChart.js +14 -1
  154. package/esm/context/HighlightedProvider/HighlightedContext.js +29 -0
  155. package/esm/context/HighlightedProvider/HighlightedProvider.js +89 -0
  156. package/esm/context/HighlightedProvider/createIsFaded.js +12 -0
  157. package/esm/context/HighlightedProvider/createIsHighlighted.js +12 -0
  158. package/esm/context/HighlightedProvider/index.js +4 -0
  159. package/esm/context/HighlightedProvider/useHighlighted.js +17 -0
  160. package/esm/context/HighlightedProvider/useItemHighlighted.js +29 -0
  161. package/esm/context/ZAxisContextProvider.js +1 -1
  162. package/esm/context/index.js +1 -0
  163. package/esm/hooks/useInteractionItemProps.js +9 -41
  164. package/hooks/useInteractionItemProps.d.ts +1 -4
  165. package/hooks/useInteractionItemProps.js +11 -45
  166. package/index.js +1 -1
  167. package/internals/colorScale.d.ts +1 -1
  168. package/internals/defaultizeColor.d.ts +13 -13
  169. package/models/seriesType/common.d.ts +4 -1
  170. package/modern/BarChart/BarChart.js +30 -3
  171. package/modern/BarChart/BarElement.js +9 -20
  172. package/modern/BarChart/BarLabel/BarLabel.js +51 -0
  173. package/modern/BarChart/BarLabel/BarLabel.types.js +1 -0
  174. package/modern/BarChart/BarLabel/BarLabelItem.js +119 -0
  175. package/modern/BarChart/BarLabel/BarLabelPlot.js +98 -0
  176. package/modern/BarChart/BarLabel/barLabelClasses.js +19 -0
  177. package/modern/BarChart/BarLabel/getBarLabel.js +24 -0
  178. package/modern/BarChart/BarLabel/index.js +2 -0
  179. package/modern/BarChart/BarPlot.js +22 -34
  180. package/modern/BarChart/checkScaleErrors.js +27 -0
  181. package/modern/BarChart/index.js +2 -1
  182. package/modern/ChartContainer/ChartContainer.js +20 -3
  183. package/modern/ChartsAxis/ChartsAxis.js +1 -1
  184. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  185. package/modern/ChartsClipPath/ChartsClipPath.js +1 -1
  186. package/modern/ChartsGrid/ChartsGrid.js +1 -1
  187. package/modern/ChartsLegend/ChartsLegend.js +1 -1
  188. package/modern/ChartsLegend/DefaultChartsLegend.js +1 -1
  189. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  190. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  191. package/modern/ChartsSurface.js +1 -1
  192. package/modern/ChartsText/ChartsText.js +1 -1
  193. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  194. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
  195. package/modern/ChartsTooltip/ChartsTooltip.js +1 -1
  196. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  197. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  198. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
  199. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  200. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  201. package/modern/Gauge/Gauge.js +1 -1
  202. package/modern/Gauge/GaugeContainer.js +1 -1
  203. package/modern/Gauge/GaugeValueText.js +1 -1
  204. package/modern/LineChart/AnimatedArea.js +1 -1
  205. package/modern/LineChart/AnimatedLine.js +1 -1
  206. package/modern/LineChart/AreaElement.js +9 -19
  207. package/modern/LineChart/AreaPlot.js +1 -3
  208. package/modern/LineChart/LineChart.js +19 -2
  209. package/modern/LineChart/LineElement.js +9 -19
  210. package/modern/LineChart/LineHighlightElement.js +1 -1
  211. package/modern/LineChart/LineHighlightPlot.js +1 -1
  212. package/modern/LineChart/LinePlot.js +1 -3
  213. package/modern/LineChart/MarkElement.js +12 -34
  214. package/modern/LineChart/MarkPlot.js +1 -2
  215. package/modern/PieChart/PieArc.js +8 -4
  216. package/modern/PieChart/PieArcLabel.js +1 -1
  217. package/modern/PieChart/PieArcLabelPlot.js +2 -8
  218. package/modern/PieChart/PieArcPlot.js +6 -8
  219. package/modern/PieChart/PieChart.js +19 -2
  220. package/modern/PieChart/PiePlot.js +3 -7
  221. package/modern/PieChart/dataTransform/useTransformData.js +10 -25
  222. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
  223. package/modern/ScatterChart/Scatter.js +16 -12
  224. package/modern/ScatterChart/ScatterChart.js +19 -2
  225. package/modern/ScatterChart/ScatterPlot.js +1 -1
  226. package/modern/SparkLineChart/SparkLineChart.js +14 -1
  227. package/modern/context/HighlightedProvider/HighlightedContext.js +29 -0
  228. package/modern/context/HighlightedProvider/HighlightedProvider.js +89 -0
  229. package/modern/context/HighlightedProvider/createIsFaded.js +12 -0
  230. package/modern/context/HighlightedProvider/createIsHighlighted.js +12 -0
  231. package/modern/context/HighlightedProvider/index.js +4 -0
  232. package/modern/context/HighlightedProvider/useHighlighted.js +17 -0
  233. package/modern/context/HighlightedProvider/useItemHighlighted.js +29 -0
  234. package/modern/context/ZAxisContextProvider.js +1 -1
  235. package/modern/context/index.js +1 -0
  236. package/modern/hooks/useInteractionItemProps.js +9 -41
  237. package/modern/index.js +1 -1
  238. package/package.json +3 -3
  239. package/themeAugmentation/components.d.ts +4 -0
  240. package/themeAugmentation/overrides.d.ts +3 -0
  241. package/themeAugmentation/props.d.ts +2 -0
  242. package/context/HighlightProvider.d.ts +0 -45
  243. package/context/HighlightProvider.js +0 -60
  244. package/esm/context/HighlightProvider.js +0 -51
  245. package/modern/context/HighlightProvider.js +0 -51
@@ -99,7 +99,7 @@ function LineHighlightPlot(props) {
99
99
  process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
100
100
  // ----------------------------- Warning --------------------------------
101
101
  // | These PropTypes are generated from the TypeScript type definitions |
102
- // | To update them edit the TypeScript types and run "yarn proptypes" |
102
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
103
103
  // ----------------------------------------------------------------------
104
104
  /**
105
105
  * The props used for each component slot.
@@ -103,7 +103,6 @@ function LinePlot(props) {
103
103
  d,
104
104
  seriesId,
105
105
  color,
106
- highlightScope,
107
106
  gradientUsed
108
107
  }) => {
109
108
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineElement.LineElement, {
@@ -111,7 +110,6 @@ function LinePlot(props) {
111
110
  d: d,
112
111
  color: color,
113
112
  gradientId: gradientUsed && getGradientId(...gradientUsed),
114
- highlightScope: highlightScope,
115
113
  skipAnimation: skipAnimation,
116
114
  slots: slots,
117
115
  slotProps: slotProps,
@@ -126,7 +124,7 @@ function LinePlot(props) {
126
124
  process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
127
125
  // ----------------------------- Warning --------------------------------
128
126
  // | These PropTypes are generated from the TypeScript type definitions |
129
- // | To update them edit the TypeScript types and run "yarn proptypes" |
127
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
130
128
  // ----------------------------------------------------------------------
131
129
  /**
132
130
  * Callback fired when a line item is clicked.
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { HighlightScope } from '../context/HighlightProvider';
3
2
  import { SeriesId } from '../models/seriesType/common';
4
3
  export interface MarkElementClasses {
5
4
  /** Styles applied to the root element. */
@@ -33,7 +32,6 @@ export type MarkElementProps = Omit<MarkElementOwnerState, 'isFaded' | 'isHighli
33
32
  * The index to the element in the series' data array.
34
33
  */
35
34
  dataIndex: number;
36
- highlightScope?: Partial<HighlightScope>;
37
35
  };
38
36
  /**
39
37
  * Demos:
@@ -20,8 +20,9 @@ var _web = require("@react-spring/web");
20
20
  var _utils = require("../internals/utils");
21
21
  var _InteractionProvider = require("../context/InteractionProvider");
22
22
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
23
+ var _context = require("../context");
23
24
  var _jsxRuntime = require("react/jsx-runtime");
24
- const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "highlightScope", "onClick", "skipAnimation"];
25
+ const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "onClick", "skipAnimation"];
25
26
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
26
27
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
27
28
  function getMarkElementUtilityClass(slot) {
@@ -52,21 +53,6 @@ const MarkElementPath = (0, _styles.styled)(_web.animated.path, {
52
53
  stroke: ownerState.color,
53
54
  strokeWidth: 2
54
55
  }));
55
- MarkElementPath.propTypes = {
56
- // ----------------------------- Warning --------------------------------
57
- // | These PropTypes are generated from the TypeScript type definitions |
58
- // | To update them edit the TypeScript types and run "yarn proptypes" |
59
- // ----------------------------------------------------------------------
60
- as: _propTypes.default.elementType,
61
- ownerState: _propTypes.default.shape({
62
- classes: _propTypes.default.object,
63
- color: _propTypes.default.string.isRequired,
64
- id: _propTypes.default.string.isRequired,
65
- isFaded: _propTypes.default.bool.isRequired,
66
- isHighlighted: _propTypes.default.bool.isRequired
67
- }).isRequired,
68
- sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
69
- };
70
56
  /**
71
57
  * Demos:
72
58
  *
@@ -86,24 +72,20 @@ function MarkElement(props) {
86
72
  color,
87
73
  shape,
88
74
  dataIndex,
89
- highlightScope,
90
75
  onClick,
91
76
  skipAnimation
92
77
  } = props,
93
78
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
94
- const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
79
+ const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)();
80
+ const {
81
+ isFaded,
82
+ isHighlighted
83
+ } = (0, _context.useItemHighlighted)({
84
+ seriesId: id
85
+ });
95
86
  const {
96
- item,
97
87
  axis
98
88
  } = React.useContext(_InteractionProvider.InteractionContext);
99
- const isHighlighted = axis.x?.index === dataIndex || (0, _useInteractionItemProps.getIsHighlighted)(item, {
100
- type: 'line',
101
- seriesId: id
102
- }, highlightScope);
103
- const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, {
104
- type: 'line',
105
- seriesId: id
106
- }, highlightScope);
107
89
  const position = (0, _web.useSpring)({
108
90
  x,
109
91
  y,
@@ -112,7 +94,7 @@ function MarkElement(props) {
112
94
  const ownerState = {
113
95
  id,
114
96
  classes: innerClasses,
115
- isHighlighted,
97
+ isHighlighted: axis.x?.index === dataIndex || isHighlighted,
116
98
  isFaded,
117
99
  color
118
100
  };
@@ -136,17 +118,13 @@ function MarkElement(props) {
136
118
  process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
137
119
  // ----------------------------- Warning --------------------------------
138
120
  // | These PropTypes are generated from the TypeScript type definitions |
139
- // | To update them edit the TypeScript types and run "yarn proptypes" |
121
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
140
122
  // ----------------------------------------------------------------------
141
123
  classes: _propTypes.default.object,
142
124
  /**
143
125
  * The index to the element in the series' data array.
144
126
  */
145
127
  dataIndex: _propTypes.default.number.isRequired,
146
- highlightScope: _propTypes.default.shape({
147
- faded: _propTypes.default.oneOf(['global', 'none', 'series']),
148
- highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
149
- }),
150
128
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
151
129
  /**
152
130
  * The shape of the marker.
@@ -148,7 +148,6 @@ function MarkPlot(props) {
148
148
  x: x,
149
149
  y: y // Don't know why TS doesn't get from the filter that y can't be null
150
150
  ,
151
- highlightScope: series[seriesId].highlightScope,
152
151
  skipAnimation: skipAnimation,
153
152
  onClick: onItemClick && (event => onItemClick(event, {
154
153
  type: 'line',
@@ -165,7 +164,7 @@ function MarkPlot(props) {
165
164
  process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
166
165
  // ----------------------------- Warning --------------------------------
167
166
  // | These PropTypes are generated from the TypeScript type definitions |
168
- // | To update them edit the TypeScript types and run "yarn proptypes" |
167
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
169
168
  // ----------------------------------------------------------------------
170
169
  /**
171
170
  * Callback fired when a line mark item is clicked.
@@ -1,8 +1,8 @@
1
1
  /// <reference types="@react-spring/core" />
2
2
  import * as React from 'react';
3
3
  import { SpringValue } from '@react-spring/web';
4
- import { HighlightScope } from '../context/HighlightProvider';
5
4
  import { PieItemId } from '../models';
5
+ import { HighlightScope } from '../context';
6
6
  export interface PieArcClasses {
7
7
  /** Styles applied to the root element. */
8
8
  root: string;
@@ -25,6 +25,9 @@ export declare const pieArcClasses: PieArcClasses;
25
25
  export type PieArcProps = Omit<React.SVGProps<SVGPathElement>, 'ref' | 'id'> & PieArcOwnerState & {
26
26
  cornerRadius: SpringValue<number>;
27
27
  endAngle: SpringValue<number>;
28
+ /**
29
+ * @deprecated Use the `isFaded` or `isHighlighted` props instead.
30
+ */
28
31
  highlightScope?: Partial<HighlightScope>;
29
32
  innerRadius: SpringValue<number>;
30
33
  onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
@@ -19,7 +19,7 @@ var _styles = require("@mui/material/styles");
19
19
  var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
20
20
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
21
21
  var _jsxRuntime = require("react/jsx-runtime");
22
- const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "highlightScope", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle"];
22
+ const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle", "highlightScope"];
23
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
25
  function getPieArcUtilityClass(slot) {
@@ -56,7 +56,6 @@ function PieArc(props) {
56
56
  cornerRadius,
57
57
  dataIndex,
58
58
  endAngle,
59
- highlightScope,
60
59
  id,
61
60
  innerRadius,
62
61
  isFaded,
@@ -76,7 +75,7 @@ function PieArc(props) {
76
75
  isHighlighted
77
76
  };
78
77
  const classes = useUtilityClasses(ownerState);
79
- const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
78
+ const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)();
80
79
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(PieArcRoot, (0, _extends2.default)({
81
80
  d: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], (sA, eA, pA, iR, oR, cR) => (0, _d3Shape.arc)().cornerRadius(cR)({
82
81
  padAngle: pA,
@@ -98,12 +97,17 @@ function PieArc(props) {
98
97
  process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
99
98
  // ----------------------------- Warning --------------------------------
100
99
  // | These PropTypes are generated from the TypeScript type definitions |
101
- // | To update them edit the TypeScript types and run "yarn proptypes" |
100
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
102
101
  // ----------------------------------------------------------------------
103
102
  classes: _propTypes.default.object,
104
103
  dataIndex: _propTypes.default.number.isRequired,
104
+ /**
105
+ * @deprecated Use the `isFaded` or `isHighlighted` props instead.
106
+ */
105
107
  highlightScope: _propTypes.default.shape({
108
+ fade: _propTypes.default.oneOf(['global', 'none', 'series']),
106
109
  faded: _propTypes.default.oneOf(['global', 'none', 'series']),
110
+ highlight: _propTypes.default.oneOf(['item', 'none', 'series']),
107
111
  highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
108
112
  }),
109
113
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
@@ -106,7 +106,7 @@ function PieArcLabel(props) {
106
106
  process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
107
107
  // ----------------------------- Warning --------------------------------
108
108
  // | These PropTypes are generated from the TypeScript type definitions |
109
- // | To update them edit the TypeScript types and run "yarn proptypes" |
109
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
110
110
  // ----------------------------------------------------------------------
111
111
  classes: _propTypes.default.object,
112
112
  color: _propTypes.default.string.isRequired,
@@ -7,7 +7,7 @@ export interface PieArcLabelPlotSlots {
7
7
  export interface PieArcLabelPlotSlotProps {
8
8
  pieArcLabel?: Partial<PieArcLabelProps>;
9
9
  }
10
- export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle' | 'id' | 'highlightScope'>, ComputedPieRadius {
10
+ export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle' | 'id'>, ComputedPieRadius {
11
11
  /**
12
12
  * Override the arc attributes when it is faded.
13
13
  * @default { additionalRadius: -5 }
@@ -15,7 +15,7 @@ var _useTransformData = require("./dataTransform/useTransformData");
15
15
  var _PieArcLabel = require("./PieArcLabel");
16
16
  var _getLabel = require("../internals/getLabel");
17
17
  var _jsxRuntime = require("react/jsx-runtime");
18
- const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "highlightScope", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
18
+ const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
19
19
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
20
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -52,7 +52,6 @@ function PieArcLabelPlot(props) {
52
52
  additionalRadius: -5
53
53
  },
54
54
  highlighted,
55
- highlightScope,
56
55
  id,
57
56
  innerRadius,
58
57
  outerRadius,
@@ -69,7 +68,6 @@ function PieArcLabelPlot(props) {
69
68
  cornerRadius,
70
69
  paddingAngle,
71
70
  id,
72
- highlightScope,
73
71
  highlighted,
74
72
  faded,
75
73
  data
@@ -114,7 +112,7 @@ function PieArcLabelPlot(props) {
114
112
  process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
115
113
  // ----------------------------- Warning --------------------------------
116
114
  // | These PropTypes are generated from the TypeScript type definitions |
117
- // | To update them edit the TypeScript types and run "yarn proptypes" |
115
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
118
116
  // ----------------------------------------------------------------------
119
117
  /**
120
118
  * The label displayed into the arc.
@@ -171,10 +169,6 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
171
169
  outerRadius: _propTypes.default.number,
172
170
  paddingAngle: _propTypes.default.number
173
171
  }),
174
- highlightScope: _propTypes.default.shape({
175
- faded: _propTypes.default.oneOf(['global', 'none', 'series']),
176
- highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
177
- }),
178
172
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
179
173
  /**
180
174
  * The radius between circle center and the beginning of the arc.
@@ -7,7 +7,7 @@ export interface PieArcPlotSlots {
7
7
  export interface PieArcPlotSlotProps {
8
8
  pieArc?: Partial<PieArcProps>;
9
9
  }
10
- export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'id' | 'highlightScope'>, ComputedPieRadius {
10
+ export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'id'>, ComputedPieRadius {
11
11
  /**
12
12
  * Override the arc attributes when it is faded.
13
13
  * @default { additionalRadius: -5 }
@@ -13,8 +13,9 @@ var _web = require("@react-spring/web");
13
13
  var _PieArc = require("./PieArc");
14
14
  var _transition = require("./dataTransform/transition");
15
15
  var _useTransformData = require("./dataTransform/useTransformData");
16
+ var _context = require("../context");
16
17
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
18
+ const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
18
19
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
19
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -27,7 +28,6 @@ function PieArcPlot(props) {
27
28
  cornerRadius = 0,
28
29
  paddingAngle = 0,
29
30
  id,
30
- highlightScope,
31
31
  highlighted,
32
32
  faded = {
33
33
  additionalRadius: -5
@@ -43,7 +43,6 @@ function PieArcPlot(props) {
43
43
  cornerRadius,
44
44
  paddingAngle,
45
45
  id,
46
- highlightScope,
47
46
  highlighted,
48
47
  faded,
49
48
  data
@@ -51,6 +50,9 @@ function PieArcPlot(props) {
51
50
  const transition = (0, _web.useTransition)(transformedData, (0, _extends2.default)({}, _transition.defaultTransitionConfig, {
52
51
  immediate: skipAnimation
53
52
  }));
53
+ const {
54
+ highlightScope
55
+ } = (0, _context.useHighlighted)();
54
56
  if (data.length === 0) {
55
57
  return null;
56
58
  }
@@ -94,7 +96,7 @@ function PieArcPlot(props) {
94
96
  process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
95
97
  // ----------------------------- Warning --------------------------------
96
98
  // | These PropTypes are generated from the TypeScript type definitions |
97
- // | To update them edit the TypeScript types and run "yarn proptypes" |
99
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
98
100
  // ----------------------------------------------------------------------
99
101
  /**
100
102
  * The radius between circle center and the arc label in px.
@@ -142,10 +144,6 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
142
144
  outerRadius: _propTypes.default.number,
143
145
  paddingAngle: _propTypes.default.number
144
146
  }),
145
- highlightScope: _propTypes.default.shape({
146
- faded: _propTypes.default.oneOf(['global', 'none', 'series']),
147
- highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
148
- }),
149
147
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
150
148
  /**
151
149
  * The radius between circle center and the beginning of the arc.
@@ -70,7 +70,9 @@ function PieChart(props) {
70
70
  slots,
71
71
  slotProps,
72
72
  onItemClick,
73
- loading
73
+ loading,
74
+ highlightedItem,
75
+ onHighlightChange
74
76
  } = props;
75
77
  const isRTL = (0, _useIsRTL.useIsRTL)();
76
78
  const margin = (0, _extends2.default)({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
@@ -97,6 +99,8 @@ function PieChart(props) {
97
99
  colors: colors,
98
100
  sx: sx,
99
101
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
102
+ highlightedItem: highlightedItem,
103
+ onHighlightChange: onHighlightChange,
100
104
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
101
105
  topAxis: topAxis,
102
106
  leftAxis: leftAxis,
@@ -125,7 +129,7 @@ function PieChart(props) {
125
129
  process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
126
130
  // ----------------------------- Warning --------------------------------
127
131
  // | These PropTypes are generated from the TypeScript type definitions |
128
- // | To update them edit the TypeScript types and run "yarn proptypes" |
132
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
129
133
  // ----------------------------------------------------------------------
130
134
  /**
131
135
  * The configuration of axes highlight.
@@ -164,6 +168,13 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
164
168
  * The height of the chart in px. If not defined, it takes the height of the parent element.
165
169
  */
166
170
  height: _propTypes.default.number,
171
+ /**
172
+ * The item currently highlighted. Turns highlighting into a controlled prop.
173
+ */
174
+ highlightedItem: _propTypes.default.shape({
175
+ dataIndex: _propTypes.default.number,
176
+ seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
177
+ }),
167
178
  /**
168
179
  * Indicate which axis to display the left of the charts.
169
180
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -203,6 +214,12 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
203
214
  right: _propTypes.default.number,
204
215
  top: _propTypes.default.number
205
216
  }),
217
+ /**
218
+ * The callback fired when the highlighted item changes.
219
+ *
220
+ * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
221
+ */
222
+ onHighlightChange: _propTypes.default.func,
206
223
  /**
207
224
  * Callback fired when a pie arc is clicked.
208
225
  */
@@ -58,8 +58,7 @@ function PiePlot(props) {
58
58
  cx: cxParam,
59
59
  cy: cyParam,
60
60
  highlighted,
61
- faded,
62
- highlightScope
61
+ faded
63
62
  } = series[seriesId];
64
63
  const {
65
64
  cx,
@@ -84,7 +83,6 @@ function PiePlot(props) {
84
83
  id: seriesId,
85
84
  data: data,
86
85
  skipAnimation: skipAnimation,
87
- highlightScope: highlightScope,
88
86
  highlighted: highlighted,
89
87
  faded: faded,
90
88
  onItemClick: onItemClick,
@@ -103,8 +101,7 @@ function PiePlot(props) {
103
101
  arcLabelMinAngle,
104
102
  data,
105
103
  cx: cxParam,
106
- cy: cyParam,
107
- highlightScope
104
+ cy: cyParam
108
105
  } = series[seriesId];
109
106
  const {
110
107
  cx,
@@ -133,7 +130,6 @@ function PiePlot(props) {
133
130
  skipAnimation: skipAnimation,
134
131
  arcLabel: arcLabel,
135
132
  arcLabelMinAngle: arcLabelMinAngle,
136
- highlightScope: highlightScope,
137
133
  slots: slots,
138
134
  slotProps: slotProps
139
135
  })
@@ -144,7 +140,7 @@ function PiePlot(props) {
144
140
  process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
145
141
  // ----------------------------- Warning --------------------------------
146
142
  // | These PropTypes are generated from the TypeScript type definitions |
147
- // | To update them edit the TypeScript types and run "yarn proptypes" |
143
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
148
144
  // ----------------------------------------------------------------------
149
145
  /**
150
146
  * Callback fired when a pie item is clicked.
@@ -12,4 +12,4 @@ export interface ValueWithHighlight extends DefaultizedPieValueType, AnimatedObj
12
12
  isFaded: boolean;
13
13
  isHighlighted: boolean;
14
14
  }
15
- export declare function useTransformData(series: Pick<DefaultizedPieSeriesType, 'cornerRadius' | 'paddingAngle' | 'id' | 'highlightScope' | 'highlighted' | 'faded' | 'data'> & ComputedPieRadius): ValueWithHighlight[];
15
+ export declare function useTransformData(series: Pick<DefaultizedPieSeriesType, 'cornerRadius' | 'paddingAngle' | 'id' | 'highlighted' | 'faded' | 'data'> & ComputedPieRadius): ValueWithHighlight[];
@@ -7,14 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.useTransformData = useTransformData;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
- var _InteractionProvider = require("../../context/InteractionProvider");
11
- var _useInteractionItemProps = require("../../hooks/useInteractionItemProps");
10
+ var _context = require("../../context");
12
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
13
  function useTransformData(series) {
15
14
  const {
16
15
  id: seriesId,
17
- highlightScope,
18
16
  data,
19
17
  faded,
20
18
  highlighted,
@@ -25,29 +23,16 @@ function useTransformData(series) {
25
23
  cornerRadius: baseCornerRadius = 0
26
24
  } = series;
27
25
  const {
28
- item: highlightedItem
29
- } = React.useContext(_InteractionProvider.InteractionContext);
30
- const getHighlightStatus = React.useCallback(dataIndex => {
31
- const isHighlighted = (0, _useInteractionItemProps.getIsHighlighted)(highlightedItem, {
32
- type: 'pie',
33
- seriesId,
34
- dataIndex
35
- }, highlightScope);
36
- const isFaded = !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(highlightedItem, {
37
- type: 'pie',
26
+ isFaded: isItemFaded,
27
+ isHighlighted: isItemHighlighted
28
+ } = (0, _context.useHighlighted)();
29
+ const dataWithHighlight = React.useMemo(() => data.map((item, itemIndex) => {
30
+ const currentItem = {
38
31
  seriesId,
39
- dataIndex
40
- }, highlightScope);
41
- return {
42
- isHighlighted,
43
- isFaded
32
+ dataIndex: itemIndex
44
33
  };
45
- }, [highlightScope, highlightedItem, seriesId]);
46
- const dataWithHighlight = React.useMemo(() => data.map((item, itemIndex) => {
47
- const {
48
- isHighlighted,
49
- isFaded
50
- } = getHighlightStatus(itemIndex);
34
+ const isHighlighted = isItemHighlighted(currentItem);
35
+ const isFaded = !isHighlighted && isItemFaded(currentItem);
51
36
  const attributesOverride = (0, _extends2.default)({
52
37
  additionalRadius: 0
53
38
  }, isFaded && faded || isHighlighted && highlighted || {});
@@ -65,6 +50,6 @@ function useTransformData(series) {
65
50
  cornerRadius,
66
51
  arcLabelRadius
67
52
  });
68
- }), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, getHighlightStatus, highlighted]);
53
+ }), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, highlighted, isItemFaded, isItemHighlighted, seriesId]);
69
54
  return dataWithHighlight;
70
55
  }
@@ -59,7 +59,7 @@ const ResponsiveChartContainer = exports.ResponsiveChartContainer = /*#__PURE__*
59
59
  process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
60
60
  // ----------------------------- Warning --------------------------------
61
61
  // | These PropTypes are generated from the TypeScript type definitions |
62
- // | To update them edit the TypeScript types and run "yarn proptypes" |
62
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
63
63
  // ----------------------------------------------------------------------
64
64
  children: _propTypes.default.node,
65
65
  className: _propTypes.default.string,
@@ -83,6 +83,13 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
83
83
  * The height of the chart in px. If not defined, it takes the height of the parent element.
84
84
  */
85
85
  height: _propTypes.default.number,
86
+ /**
87
+ * The item currently highlighted. Turns highlighting into a controlled prop.
88
+ */
89
+ highlightedItem: _propTypes.default.shape({
90
+ dataIndex: _propTypes.default.number,
91
+ seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
92
+ }),
86
93
  /**
87
94
  * The margin between the SVG and the drawing area.
88
95
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -95,6 +102,12 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
95
102
  right: _propTypes.default.number,
96
103
  top: _propTypes.default.number
97
104
  }),
105
+ /**
106
+ * The callback fired when the highlighted item changes.
107
+ *
108
+ * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
109
+ */
110
+ onHighlightChange: _propTypes.default.func,
98
111
  /**
99
112
  * The array of series to display.
100
113
  * Each type of series has its own specificity.
@@ -11,6 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _useScale = require("../hooks/useScale");
12
12
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
13
13
  var _InteractionProvider = require("../context/InteractionProvider");
14
+ var _context = require("../context");
14
15
  var _jsxRuntime = require("react/jsx-runtime");
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -34,16 +35,15 @@ function Scatter(props) {
34
35
  markerSize,
35
36
  onItemClick
36
37
  } = props;
37
- const highlightScope = React.useMemo(() => (0, _extends2.default)({
38
- highlighted: 'item',
39
- faded: 'global'
40
- }, series.highlightScope), [series.highlightScope]);
41
38
  const {
42
- item,
43
39
  useVoronoiInteraction
44
40
  } = React.useContext(_InteractionProvider.InteractionContext);
45
41
  const skipInteractionHandlers = useVoronoiInteraction || series.disableHover;
46
- const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope, skipInteractionHandlers);
42
+ const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(skipInteractionHandlers);
43
+ const {
44
+ isFaded,
45
+ isHighlighted
46
+ } = (0, _context.useHighlighted)();
47
47
  const cleanData = React.useMemo(() => {
48
48
  const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
49
49
  const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
@@ -65,12 +65,16 @@ function Scatter(props) {
65
65
  dataIndex: i
66
66
  };
67
67
  if (isInRange) {
68
- const isHighlighted = (0, _useInteractionItemProps.getIsHighlighted)(item, pointCtx, highlightScope);
68
+ const currentItem = {
69
+ seriesId: pointCtx.seriesId,
70
+ dataIndex: pointCtx.dataIndex
71
+ };
72
+ const isItemHighlighted = isHighlighted(currentItem);
69
73
  temp.push({
70
74
  x,
71
75
  y,
72
- isHighlighted,
73
- isFaded: !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, pointCtx, highlightScope),
76
+ isHighlighted: isItemHighlighted,
77
+ isFaded: !isItemHighlighted && isFaded(currentItem),
74
78
  interactionProps: getInteractionItemProps(pointCtx),
75
79
  id: scatterPoint.id,
76
80
  dataIndex: i,
@@ -79,7 +83,7 @@ function Scatter(props) {
79
83
  }
80
84
  }
81
85
  return temp;
82
- }, [xScale, yScale, series.data, series.id, item, highlightScope, getInteractionItemProps, color, colorGetter]);
86
+ }, [xScale, yScale, series.data, series.id, getInteractionItemProps, color, colorGetter, isFaded, isHighlighted]);
83
87
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
84
88
  children: cleanData.map(dataPoint => /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({
85
89
  cx: 0,
@@ -100,7 +104,7 @@ function Scatter(props) {
100
104
  process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
101
105
  // ----------------------------- Warning --------------------------------
102
106
  // | These PropTypes are generated from the TypeScript type definitions |
103
- // | To update them edit the TypeScript types and run "yarn proptypes" |
107
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
104
108
  // ----------------------------------------------------------------------
105
109
  color: _propTypes.default.string.isRequired,
106
110
  colorGetter: _propTypes.default.func,