@mui/x-charts 7.0.0-beta.0 → 7.0.0-beta.1

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 (185) hide show
  1. package/BarChart/BarChart.d.ts +2 -1
  2. package/BarChart/BarChart.js +23 -4
  3. package/BarChart/BarElement.d.ts +1 -1
  4. package/BarChart/BarElement.js +6 -3
  5. package/BarChart/BarPlot.d.ts +8 -1
  6. package/BarChart/BarPlot.js +19 -5
  7. package/BarChart/formatter.js +1 -1
  8. package/CHANGELOG.md +247 -0
  9. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +20 -0
  10. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +83 -0
  11. package/ChartsOnAxisClickHandler/index.d.ts +1 -0
  12. package/ChartsOnAxisClickHandler/index.js +16 -0
  13. package/ChartsOnAxisClickHandler/package.json +6 -0
  14. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  15. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  16. package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
  17. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -4
  18. package/ChartsTooltip/utils.d.ts +3 -1
  19. package/ChartsTooltip/utils.js +8 -0
  20. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
  21. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
  22. package/LineChart/AnimatedArea.d.ts +1361 -0
  23. package/LineChart/AnimatedArea.js +111 -0
  24. package/LineChart/AnimatedLine.d.ts +1361 -0
  25. package/LineChart/AnimatedLine.js +113 -0
  26. package/LineChart/AreaElement.d.ts +17 -17
  27. package/LineChart/AreaElement.js +17 -34
  28. package/LineChart/AreaPlot.d.ts +12 -7
  29. package/LineChart/AreaPlot.js +91 -58
  30. package/LineChart/LineChart.d.ts +13 -4
  31. package/LineChart/LineChart.js +35 -6
  32. package/LineChart/LineElement.d.ts +17 -17
  33. package/LineChart/LineElement.js +16 -36
  34. package/LineChart/LineHighlightElement.js +3 -2
  35. package/LineChart/LinePlot.d.ts +12 -7
  36. package/LineChart/LinePlot.js +89 -56
  37. package/LineChart/MarkElement.d.ts +5 -2
  38. package/LineChart/MarkElement.js +26 -13
  39. package/LineChart/MarkPlot.d.ts +8 -1
  40. package/LineChart/MarkPlot.js +80 -51
  41. package/LineChart/formatter.js +1 -1
  42. package/LineChart/index.d.ts +2 -0
  43. package/LineChart/index.js +22 -0
  44. package/PieChart/PieArcLabelPlot.d.ts +1 -1
  45. package/PieChart/PieArcLabelPlot.js +1 -1
  46. package/PieChart/PieArcPlot.d.ts +2 -2
  47. package/PieChart/PieArcPlot.js +6 -6
  48. package/PieChart/PieChart.d.ts +1 -1
  49. package/PieChart/PieChart.js +4 -4
  50. package/PieChart/PiePlot.d.ts +1 -1
  51. package/PieChart/PiePlot.js +4 -4
  52. package/ScatterChart/Scatter.d.ts +7 -1
  53. package/ScatterChart/Scatter.js +17 -3
  54. package/ScatterChart/ScatterChart.d.ts +8 -2
  55. package/ScatterChart/ScatterChart.js +11 -2
  56. package/ScatterChart/ScatterPlot.d.ts +1 -1
  57. package/ScatterChart/ScatterPlot.js +10 -2
  58. package/SparkLineChart/SparkLineChart.js +2 -0
  59. package/context/DrawingProvider.d.ts +6 -1
  60. package/context/DrawingProvider.js +9 -2
  61. package/context/InteractionProvider.d.ts +3 -3
  62. package/esm/BarChart/BarChart.js +23 -4
  63. package/esm/BarChart/BarElement.js +6 -3
  64. package/esm/BarChart/BarPlot.js +19 -5
  65. package/esm/BarChart/formatter.js +1 -1
  66. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
  67. package/esm/ChartsOnAxisClickHandler/index.js +1 -0
  68. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  69. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  70. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
  71. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -4
  72. package/esm/ChartsTooltip/utils.js +6 -0
  73. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
  74. package/esm/LineChart/AnimatedArea.js +103 -0
  75. package/esm/LineChart/AnimatedLine.js +105 -0
  76. package/esm/LineChart/AreaElement.js +16 -33
  77. package/esm/LineChart/AreaPlot.js +92 -59
  78. package/esm/LineChart/LineChart.js +35 -6
  79. package/esm/LineChart/LineElement.js +16 -35
  80. package/esm/LineChart/LineHighlightElement.js +3 -2
  81. package/esm/LineChart/LinePlot.js +90 -57
  82. package/esm/LineChart/MarkElement.js +26 -13
  83. package/esm/LineChart/MarkPlot.js +80 -51
  84. package/esm/LineChart/formatter.js +1 -1
  85. package/esm/LineChart/index.js +2 -0
  86. package/esm/PieChart/PieArcLabelPlot.js +1 -1
  87. package/esm/PieChart/PieArcPlot.js +6 -6
  88. package/esm/PieChart/PieChart.js +4 -4
  89. package/esm/PieChart/PiePlot.js +4 -4
  90. package/esm/ScatterChart/Scatter.js +17 -3
  91. package/esm/ScatterChart/ScatterChart.js +11 -2
  92. package/esm/ScatterChart/ScatterPlot.js +10 -2
  93. package/esm/SparkLineChart/SparkLineChart.js +2 -0
  94. package/esm/context/DrawingProvider.js +9 -2
  95. package/esm/hooks/useDrawingArea.js +7 -3
  96. package/esm/index.js +1 -0
  97. package/esm/internals/geometry.js +1 -1
  98. package/esm/internals/useAnimatedPath.js +29 -0
  99. package/esm/internals/utils.js +7 -0
  100. package/hooks/useDrawingArea.d.ts +2 -0
  101. package/hooks/useDrawingArea.js +7 -3
  102. package/index.d.ts +1 -0
  103. package/index.js +12 -1
  104. package/internals/geometry.js +1 -1
  105. package/internals/useAnimatedPath.d.ts +1 -0
  106. package/internals/useAnimatedPath.js +38 -0
  107. package/internals/utils.d.ts +4 -0
  108. package/internals/utils.js +8 -0
  109. package/legacy/BarChart/BarChart.js +23 -4
  110. package/legacy/BarChart/BarElement.js +5 -2
  111. package/legacy/BarChart/BarPlot.js +18 -4
  112. package/legacy/BarChart/formatter.js +1 -1
  113. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
  114. package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
  115. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  116. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  117. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +6 -7
  118. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -4
  119. package/legacy/ChartsTooltip/utils.js +6 -0
  120. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
  121. package/legacy/LineChart/AnimatedArea.js +102 -0
  122. package/legacy/LineChart/AnimatedLine.js +104 -0
  123. package/legacy/LineChart/AreaElement.js +15 -35
  124. package/legacy/LineChart/AreaPlot.js +102 -66
  125. package/legacy/LineChart/LineChart.js +35 -6
  126. package/legacy/LineChart/LineElement.js +15 -37
  127. package/legacy/LineChart/LineHighlightElement.js +3 -2
  128. package/legacy/LineChart/LinePlot.js +97 -63
  129. package/legacy/LineChart/MarkElement.js +29 -12
  130. package/legacy/LineChart/MarkPlot.js +83 -53
  131. package/legacy/LineChart/formatter.js +1 -1
  132. package/legacy/LineChart/index.js +2 -0
  133. package/legacy/PieChart/PieArcLabelPlot.js +1 -1
  134. package/legacy/PieChart/PieArcPlot.js +6 -6
  135. package/legacy/PieChart/PieChart.js +4 -4
  136. package/legacy/PieChart/PiePlot.js +4 -4
  137. package/legacy/ScatterChart/Scatter.js +19 -3
  138. package/legacy/ScatterChart/ScatterChart.js +11 -2
  139. package/legacy/ScatterChart/ScatterPlot.js +10 -2
  140. package/legacy/SparkLineChart/SparkLineChart.js +2 -0
  141. package/legacy/context/DrawingProvider.js +11 -2
  142. package/legacy/hooks/useDrawingArea.js +7 -3
  143. package/legacy/index.js +2 -1
  144. package/legacy/internals/geometry.js +1 -1
  145. package/legacy/internals/useAnimatedPath.js +32 -0
  146. package/legacy/internals/utils.js +7 -0
  147. package/modern/BarChart/BarChart.js +23 -4
  148. package/modern/BarChart/BarElement.js +6 -3
  149. package/modern/BarChart/BarPlot.js +19 -5
  150. package/modern/BarChart/formatter.js +1 -1
  151. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
  152. package/modern/ChartsOnAxisClickHandler/index.js +1 -0
  153. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  154. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  155. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
  156. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -4
  157. package/modern/ChartsTooltip/utils.js +6 -0
  158. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
  159. package/modern/LineChart/AnimatedArea.js +103 -0
  160. package/modern/LineChart/AnimatedLine.js +105 -0
  161. package/modern/LineChart/AreaElement.js +16 -33
  162. package/modern/LineChart/AreaPlot.js +91 -58
  163. package/modern/LineChart/LineChart.js +35 -6
  164. package/modern/LineChart/LineElement.js +16 -35
  165. package/modern/LineChart/LineHighlightElement.js +3 -2
  166. package/modern/LineChart/LinePlot.js +89 -56
  167. package/modern/LineChart/MarkElement.js +26 -13
  168. package/modern/LineChart/MarkPlot.js +80 -51
  169. package/modern/LineChart/formatter.js +1 -1
  170. package/modern/LineChart/index.js +2 -0
  171. package/modern/PieChart/PieArcLabelPlot.js +1 -1
  172. package/modern/PieChart/PieArcPlot.js +6 -6
  173. package/modern/PieChart/PieChart.js +4 -4
  174. package/modern/PieChart/PiePlot.js +4 -4
  175. package/modern/ScatterChart/Scatter.js +17 -3
  176. package/modern/ScatterChart/ScatterChart.js +11 -2
  177. package/modern/ScatterChart/ScatterPlot.js +10 -2
  178. package/modern/SparkLineChart/SparkLineChart.js +2 -0
  179. package/modern/context/DrawingProvider.js +9 -2
  180. package/modern/hooks/useDrawingArea.js +7 -3
  181. package/modern/index.js +2 -1
  182. package/modern/internals/geometry.js +1 -1
  183. package/modern/internals/useAnimatedPath.js +29 -0
  184. package/modern/internals/utils.js +7 -0
  185. package/package.json +6 -5
@@ -14,8 +14,10 @@ var _CartesianContextProvider = require("../context/CartesianContextProvider");
14
14
  var _MarkElement = require("./MarkElement");
15
15
  var _useScale = require("../hooks/useScale");
16
16
  var _constants = require("../constants");
17
+ var _DrawingProvider = require("../context/DrawingProvider");
18
+ var _utils = require("../internals/utils");
17
19
  var _jsxRuntime = require("react/jsx-runtime");
18
- const _excluded = ["slots", "slotProps"];
20
+ const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
19
21
  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
22
  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 && Object.prototype.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; }
21
23
  /**
@@ -31,11 +33,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
31
33
  function MarkPlot(props) {
32
34
  const {
33
35
  slots,
34
- slotProps
36
+ slotProps,
37
+ skipAnimation,
38
+ onItemClick
35
39
  } = props,
36
40
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
37
41
  const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).line;
38
42
  const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
43
+ const {
44
+ chartId
45
+ } = React.useContext(_DrawingProvider.DrawingContext);
39
46
  const Mark = slots?.mark ?? _MarkElement.MarkElement;
40
47
  if (seriesData === undefined) {
41
48
  return null;
@@ -56,7 +63,7 @@ function MarkPlot(props) {
56
63
  children: stackingGroups.flatMap(({
57
64
  ids: groupIds
58
65
  }) => {
59
- return groupIds.flatMap(seriesId => {
66
+ return groupIds.map(seriesId => {
60
67
  const {
61
68
  xAxisKey = defaultXAxisId,
62
69
  yAxisKey = defaultYAxisId,
@@ -87,59 +94,70 @@ function MarkPlot(props) {
87
94
  if (xData === undefined) {
88
95
  throw new Error(`MUI X Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
89
96
  }
90
- return xData?.map((x, index) => {
91
- const value = data[index] == null ? null : stackedData[index][1];
92
- return {
93
- x: xScale(x),
94
- y: value === null ? null : yScale(value),
95
- position: x,
96
- value,
97
- index
98
- };
99
- }).filter(({
100
- x,
101
- y,
102
- index,
103
- position,
104
- value
105
- }) => {
106
- if (value === null || y === null) {
107
- // Remove missing data point
108
- return false;
109
- }
110
- if (!isInRange({
111
- x,
112
- y
113
- })) {
114
- // Remove out of range
115
- return false;
116
- }
117
- if (showMark === true) {
118
- return true;
119
- }
120
- return showMark({
97
+ const clipId = (0, _utils.cleanId)(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
98
+
99
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
100
+ clipPath: `url(#${clipId})`,
101
+ children: xData?.map((x, index) => {
102
+ const value = data[index] == null ? null : stackedData[index][1];
103
+ return {
104
+ x: xScale(x),
105
+ y: value === null ? null : yScale(value),
106
+ position: x,
107
+ value,
108
+ index
109
+ };
110
+ }).filter(({
121
111
  x,
122
112
  y,
123
113
  index,
124
114
  position,
125
115
  value
126
- });
127
- }).map(({
128
- x,
129
- y,
130
- index
131
- }) => {
132
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Mark, (0, _extends2.default)({
133
- id: seriesId,
134
- dataIndex: index,
135
- shape: "circle",
136
- color: series[seriesId].color,
137
- x: x,
138
- y: y // Don't knwo why TS don't get from the filter that y can't be null
139
- ,
140
- highlightScope: series[seriesId].highlightScope
141
- }, slotProps?.mark), `${seriesId}-${index}`);
142
- });
116
+ }) => {
117
+ if (value === null || y === null) {
118
+ // Remove missing data point
119
+ return false;
120
+ }
121
+ if (!isInRange({
122
+ x,
123
+ y
124
+ })) {
125
+ // Remove out of range
126
+ return false;
127
+ }
128
+ if (showMark === true) {
129
+ return true;
130
+ }
131
+ return showMark({
132
+ x,
133
+ y,
134
+ index,
135
+ position,
136
+ value
137
+ });
138
+ }).map(({
139
+ x,
140
+ y,
141
+ index
142
+ }) => {
143
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Mark, (0, _extends2.default)({
144
+ id: seriesId,
145
+ dataIndex: index,
146
+ shape: "circle",
147
+ color: series[seriesId].color,
148
+ x: x,
149
+ y: y // Don't know why TS doesn't get from the filter that y can't be null
150
+ ,
151
+ highlightScope: series[seriesId].highlightScope,
152
+ skipAnimation: skipAnimation,
153
+ onClick: onItemClick && (event => onItemClick(event, {
154
+ type: 'line',
155
+ seriesId,
156
+ dataIndex: index
157
+ }))
158
+ }, slotProps?.mark), `${seriesId}-${index}`);
159
+ })
160
+ }, seriesId);
143
161
  });
144
162
  })
145
163
  }));
@@ -149,6 +167,17 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
149
167
  // | These PropTypes are generated from the TypeScript type definitions |
150
168
  // | To update them edit the TypeScript types and run "yarn proptypes" |
151
169
  // ----------------------------------------------------------------------
170
+ /**
171
+ * Callback fired when a line mark item is clicked.
172
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
173
+ * @param {LineItemIdentifier} lineItemIdentifier The line mark item identifier.
174
+ */
175
+ onItemClick: _propTypes.default.func,
176
+ /**
177
+ * If `true`, animations are skipped.
178
+ * @default false
179
+ */
180
+ skipAnimation: _propTypes.default.bool,
152
181
  /**
153
182
  * The props used for each component slot.
154
183
  * @default {}
@@ -76,7 +76,7 @@ const formatter = (params, dataset) => {
76
76
  return {
77
77
  seriesOrder,
78
78
  stackingGroups,
79
- series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v === null ? '' : v.toLocaleString())
79
+ series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v == null ? '' : v.toLocaleString())
80
80
  };
81
81
  };
82
82
  var _default = exports.default = formatter;
@@ -4,6 +4,8 @@ export * from './AreaPlot';
4
4
  export * from './MarkPlot';
5
5
  export * from './LineHighlightPlot';
6
6
  export * from './AreaElement';
7
+ export * from './AnimatedArea';
7
8
  export * from './LineElement';
9
+ export * from './AnimatedLine';
8
10
  export * from './MarkElement';
9
11
  export * from './LineHighlightElement';
@@ -69,6 +69,17 @@ Object.keys(_AreaElement).forEach(function (key) {
69
69
  }
70
70
  });
71
71
  });
72
+ var _AnimatedArea = require("./AnimatedArea");
73
+ Object.keys(_AnimatedArea).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _AnimatedArea[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _AnimatedArea[key];
80
+ }
81
+ });
82
+ });
72
83
  var _LineElement = require("./LineElement");
73
84
  Object.keys(_LineElement).forEach(function (key) {
74
85
  if (key === "default" || key === "__esModule") return;
@@ -80,6 +91,17 @@ Object.keys(_LineElement).forEach(function (key) {
80
91
  }
81
92
  });
82
93
  });
94
+ var _AnimatedLine = require("./AnimatedLine");
95
+ Object.keys(_AnimatedLine).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _AnimatedLine[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _AnimatedLine[key];
102
+ }
103
+ });
104
+ });
83
105
  var _MarkElement = require("./MarkElement");
84
106
  Object.keys(_MarkElement).forEach(function (key) {
85
107
  if (key === "default" || key === "__esModule") return;
@@ -24,7 +24,7 @@ export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'da
24
24
  */
25
25
  slotProps?: PieArcLabelPlotSlotProps;
26
26
  /**
27
- * If `true`, animations are skiped.
27
+ * If `true`, animations are skipped.
28
28
  * @default false
29
29
  */
30
30
  skipAnimation?: boolean;
@@ -182,7 +182,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
182
182
  */
183
183
  paddingAngle: _propTypes.default.number,
184
184
  /**
185
- * If `true`, animations are skiped.
185
+ * If `true`, animations are skipped.
186
186
  * @default false
187
187
  */
188
188
  skipAnimation: _propTypes.default.bool,
@@ -29,9 +29,9 @@ export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' |
29
29
  * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
30
30
  * @param {DefaultizedPieValueType} item The pie item.
31
31
  */
32
- onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
32
+ onItemClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
33
33
  /**
34
- * If `true`, animations are skiped.
34
+ * If `true`, animations are skipped.
35
35
  * @default false
36
36
  */
37
37
  skipAnimation?: boolean;
@@ -14,7 +14,7 @@ var _PieArc = require("./PieArc");
14
14
  var _transition = require("./dataTransform/transition");
15
15
  var _useTransformData = require("./dataTransform/useTransformData");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
17
+ const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
18
18
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
19
19
  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
20
  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 && Object.prototype.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; }
@@ -33,7 +33,7 @@ function PieArcPlot(props) {
33
33
  additionalRadius: -5
34
34
  },
35
35
  data,
36
- onClick,
36
+ onItemClick,
37
37
  skipAnimation
38
38
  } = props,
39
39
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
@@ -80,8 +80,8 @@ function PieArcPlot(props) {
80
80
  highlightScope: highlightScope,
81
81
  isFaded: item.isFaded,
82
82
  isHighlighted: item.isHighlighted,
83
- onClick: onClick && (event => {
84
- onClick(event, {
83
+ onClick: onItemClick && (event => {
84
+ onItemClick(event, {
85
85
  type: 'pie',
86
86
  seriesId: id,
87
87
  dataIndex: index
@@ -158,7 +158,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
158
158
  * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
159
159
  * @param {DefaultizedPieValueType} item The pie item.
160
160
  */
161
- onClick: _propTypes.default.func,
161
+ onItemClick: _propTypes.default.func,
162
162
  /**
163
163
  * The radius between circle center and the end of the arc.
164
164
  */
@@ -169,7 +169,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
169
169
  */
170
170
  paddingAngle: _propTypes.default.number,
171
171
  /**
172
- * If `true`, animations are skiped.
172
+ * If `true`, animations are skipped.
173
173
  * @default false
174
174
  */
175
175
  skipAnimation: _propTypes.default.bool,
@@ -33,7 +33,7 @@ export interface PieChartProps extends Omit<ResponsiveChartContainerProps, 'seri
33
33
  * @deprecated Consider using `slotProps.legend` instead.
34
34
  */
35
35
  legend?: ChartsLegendProps;
36
- onClick?: PiePlotProps['onClick'];
36
+ onItemClick?: PiePlotProps['onItemClick'];
37
37
  slots?: PieChartSlots;
38
38
  /**
39
39
  * The props used for each component slot.
@@ -67,7 +67,7 @@ function PieChart(props) {
67
67
  children,
68
68
  slots,
69
69
  slotProps,
70
- onClick
70
+ onItemClick
71
71
  } = props;
72
72
  const margin = (0, _extends2.default)({}, defaultMargin, marginProps);
73
73
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, {
@@ -96,7 +96,7 @@ function PieChart(props) {
96
96
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PiePlot.PiePlot, {
97
97
  slots: slots,
98
98
  slotProps: slotProps,
99
- onClick: onClick,
99
+ onItemClick: onItemClick,
100
100
  skipAnimation: skipAnimation
101
101
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
102
102
  slots: slots,
@@ -216,7 +216,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
216
216
  right: _propTypes.default.number,
217
217
  top: _propTypes.default.number
218
218
  }),
219
- onClick: _propTypes.default.func,
219
+ onItemClick: _propTypes.default.func,
220
220
  /**
221
221
  * Indicate which axis to display the right of the charts.
222
222
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -246,7 +246,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
246
246
  }), _propTypes.default.string]),
247
247
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
248
248
  /**
249
- * If `true`, animations are skiped.
249
+ * If `true`, animations are skipped.
250
250
  * @default false
251
251
  */
252
252
  skipAnimation: _propTypes.default.bool,
@@ -5,7 +5,7 @@ export interface PiePlotSlots extends PieArcPlotSlots, PieArcLabelPlotSlots {
5
5
  }
6
6
  export interface PiePlotSlotProps extends PieArcPlotSlotProps, PieArcLabelPlotSlotProps {
7
7
  }
8
- export interface PiePlotProps extends Pick<PieArcPlotProps, 'skipAnimation' | 'onClick'> {
8
+ export interface PiePlotProps extends Pick<PieArcPlotProps, 'skipAnimation' | 'onItemClick'> {
9
9
  /**
10
10
  * Overridable component slots.
11
11
  * @default {}
@@ -30,7 +30,7 @@ function PiePlot(props) {
30
30
  skipAnimation,
31
31
  slots,
32
32
  slotProps,
33
- onClick
33
+ onItemClick
34
34
  } = props;
35
35
  const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).pie;
36
36
  const {
@@ -78,7 +78,7 @@ function PiePlot(props) {
78
78
  highlightScope: highlightScope,
79
79
  highlighted: highlighted,
80
80
  faded: faded,
81
- onClick: onClick,
81
+ onItemClick: onItemClick,
82
82
  slots: slots,
83
83
  slotProps: slotProps
84
84
  })
@@ -132,9 +132,9 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
132
132
  * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
133
133
  * @param {DefaultizedPieValueType} item The pie item.
134
134
  */
135
- onClick: _propTypes.default.func,
135
+ onItemClick: _propTypes.default.func,
136
136
  /**
137
- * If `true`, animations are skiped.
137
+ * If `true`, animations are skipped.
138
138
  * @default false
139
139
  */
140
140
  skipAnimation: _propTypes.default.bool,
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { DefaultizedScatterSeriesType } from '../models/seriesType/scatter';
2
+ import { DefaultizedScatterSeriesType, ScatterItemIdentifier } from '../models/seriesType/scatter';
3
3
  import { D3Scale } from '../models/axis';
4
4
  export interface ScatterProps {
5
5
  series: DefaultizedScatterSeriesType;
@@ -7,6 +7,12 @@ export interface ScatterProps {
7
7
  yScale: D3Scale;
8
8
  markerSize: number;
9
9
  color: string;
10
+ /**
11
+ * Callback fired when clicking on a scatter item.
12
+ * @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
13
+ * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
14
+ */
15
+ onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, scatterItemIdentifier: ScatterItemIdentifier) => void;
10
16
  }
11
17
  /**
12
18
  * Demos:
@@ -30,7 +30,8 @@ function Scatter(props) {
30
30
  xScale,
31
31
  yScale,
32
32
  color,
33
- markerSize
33
+ markerSize,
34
+ onItemClick
34
35
  } = props;
35
36
  const highlightScope = React.useMemo(() => (0, _extends2.default)({
36
37
  highlighted: 'item',
@@ -70,7 +71,8 @@ function Scatter(props) {
70
71
  isHighlighted,
71
72
  isFaded: !isHighlighted && (0, _useInteractionItemProps.getIsFaded)(item, pointCtx, highlightScope),
72
73
  interactionProps: getInteractionItemProps(pointCtx),
73
- id: scatterPoint.id
74
+ id: scatterPoint.id,
75
+ dataIndex: i
74
76
  });
75
77
  }
76
78
  }
@@ -83,7 +85,13 @@ function Scatter(props) {
83
85
  r: (dataPoint.isHighlighted ? 1.2 : 1) * markerSize,
84
86
  transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
85
87
  fill: color,
86
- opacity: dataPoint.isFaded && 0.3 || 1
88
+ opacity: dataPoint.isFaded && 0.3 || 1,
89
+ onClick: onItemClick && (event => onItemClick(event, {
90
+ type: 'scatter',
91
+ seriesId: series.id,
92
+ dataIndex: dataPoint.dataIndex
93
+ })),
94
+ cursor: onItemClick ? 'pointer' : 'unset'
87
95
  }, dataPoint.interactionProps), dataPoint.id))
88
96
  });
89
97
  }
@@ -94,6 +102,12 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
94
102
  // ----------------------------------------------------------------------
95
103
  color: _propTypes.default.string.isRequired,
96
104
  markerSize: _propTypes.default.number.isRequired,
105
+ /**
106
+ * Callback fired when clicking on a scatter item.
107
+ * @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
108
+ * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
109
+ */
110
+ onItemClick: _propTypes.default.func,
97
111
  series: _propTypes.default.object.isRequired,
98
112
  xScale: _propTypes.default.func.isRequired,
99
113
  yScale: _propTypes.default.func.isRequired
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ScatterPlotSlotProps, ScatterPlotSlots } from './ScatterPlot';
2
+ import { ScatterPlotProps, ScatterPlotSlotProps, ScatterPlotSlots } from './ScatterPlot';
3
3
  import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
4
4
  import { ChartsAxisProps } from '../ChartsAxis';
5
5
  import { ScatterSeriesType } from '../models/seriesType/scatter';
@@ -13,7 +13,7 @@ export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, Ch
13
13
  }
14
14
  export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps {
15
15
  }
16
- export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, ChartsVoronoiHandlerProps {
16
+ export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsVoronoiHandlerProps, 'onItemClick'> {
17
17
  series: MakeOptional<ScatterSeriesType, 'type'>[];
18
18
  tooltip?: ChartsTooltipProps;
19
19
  axisHighlight?: ChartsAxisHighlightProps;
@@ -36,6 +36,12 @@ export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, '
36
36
  * @default {}
37
37
  */
38
38
  slotProps?: ScatterChartSlotProps;
39
+ /**
40
+ * Callback fired when clicking on a scatter item.
41
+ * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element if using Voronoi cells. Or the Mouse event from the scatter element, when `disableVoronoi=true`.
42
+ * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
43
+ */
44
+ onItemClick?: ScatterPlotProps['onItemClick'] | ChartsVoronoiHandlerProps['onItemClick'];
39
45
  }
40
46
  /**
41
47
  * Demos:
@@ -47,6 +47,7 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
47
47
  leftAxis,
48
48
  rightAxis,
49
49
  bottomAxis,
50
+ onItemClick,
50
51
  children,
51
52
  slots,
52
53
  slotProps
@@ -64,7 +65,8 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
64
65
  yAxis: yAxis,
65
66
  sx: sx,
66
67
  children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, {
67
- voronoiMaxRadius: voronoiMaxRadius
68
+ voronoiMaxRadius: voronoiMaxRadius,
69
+ onItemClick: onItemClick
68
70
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
69
71
  topAxis: topAxis,
70
72
  leftAxis: leftAxis,
@@ -74,7 +76,8 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
74
76
  slotProps: slotProps
75
77
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, {
76
78
  slots: slots,
77
- slotProps: slotProps
79
+ slotProps: slotProps,
80
+ onItemClick: disableVoronoi ? onItemClick : undefined
78
81
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
79
82
  slots: slots,
80
83
  slotProps: slotProps
@@ -203,6 +206,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
203
206
  right: _propTypes.default.number,
204
207
  top: _propTypes.default.number
205
208
  }),
209
+ /**
210
+ * Callback fired when clicking on a scatter item.
211
+ * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element if using Voronoi cells. Or the Mouse event from the scatter element, when `disableVoronoi=true`.
212
+ * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
213
+ */
214
+ onItemClick: _propTypes.default.func,
206
215
  /**
207
216
  * Indicate which axis to display the right of the charts.
208
217
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -6,7 +6,7 @@ export interface ScatterPlotSlots {
6
6
  export interface ScatterPlotSlotProps {
7
7
  scatter?: Partial<ScatterProps>;
8
8
  }
9
- export interface ScatterPlotProps {
9
+ export interface ScatterPlotProps extends Pick<ScatterProps, 'onItemClick'> {
10
10
  /**
11
11
  * Overridable component slots.
12
12
  * @default {}
@@ -27,7 +27,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
27
27
  function ScatterPlot(props) {
28
28
  const {
29
29
  slots,
30
- slotProps
30
+ slotProps,
31
+ onItemClick
31
32
  } = props;
32
33
  const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).scatter;
33
34
  const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
@@ -63,7 +64,8 @@ function ScatterPlot(props) {
63
64
  yScale: yScale,
64
65
  color: color,
65
66
  markerSize: markerSize ?? 4,
66
- series: series[seriesId]
67
+ series: series[seriesId],
68
+ onItemClick: onItemClick
67
69
  }, slotProps?.scatter), id);
68
70
  })
69
71
  });
@@ -73,6 +75,12 @@ process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
73
75
  // | These PropTypes are generated from the TypeScript type definitions |
74
76
  // | To update them edit the TypeScript types and run "yarn proptypes" |
75
77
  // ----------------------------------------------------------------------
78
+ /**
79
+ * Callback fired when clicking on a scatter item.
80
+ * @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
81
+ * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
82
+ */
83
+ onItemClick: _propTypes.default.func,
76
84
  /**
77
85
  * The props used for each component slot.
78
86
  * @default {}
@@ -94,9 +94,11 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
94
94
  }
95
95
  }), plotType === 'line' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
96
96
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.AreaPlot, {
97
+ skipAnimation: true,
97
98
  slots: slots,
98
99
  slotProps: slotProps
99
100
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.LinePlot, {
101
+ skipAnimation: true,
100
102
  slots: slots,
101
103
  slotProps: slotProps
102
104
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.LineHighlightPlot, {
@@ -33,7 +33,12 @@ export type DrawingArea = {
33
33
  */
34
34
  height: number;
35
35
  };
36
- export declare const DrawingContext: React.Context<DrawingArea>;
36
+ export declare const DrawingContext: React.Context<DrawingArea & {
37
+ /**
38
+ * A random id used to distinguish each chart on the same page.
39
+ */
40
+ chartId: string;
41
+ }>;
37
42
  export declare const SVGContext: React.Context<React.RefObject<SVGSVGElement>>;
38
43
  /**
39
44
  * API:
@@ -7,8 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.DrawingContext = void 0;
8
8
  exports.DrawingProvider = DrawingProvider;
9
9
  exports.SVGContext = void 0;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var React = _interopRequireWildcard(require("react"));
11
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
+ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
12
14
  var _useChartDimensions = _interopRequireDefault(require("../hooks/useChartDimensions"));
13
15
  var _jsxRuntime = require("react/jsx-runtime");
14
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); }
@@ -23,7 +25,8 @@ const DrawingContext = exports.DrawingContext = /*#__PURE__*/React.createContext
23
25
  bottom: 0,
24
26
  right: 0,
25
27
  height: 300,
26
- width: 400
28
+ width: 400,
29
+ chartId: ''
27
30
  });
28
31
  const SVGContext = exports.SVGContext = /*#__PURE__*/React.createContext({
29
32
  current: null
@@ -43,10 +46,14 @@ function DrawingProvider(props) {
43
46
  children
44
47
  } = props;
45
48
  const drawingArea = (0, _useChartDimensions.default)(width, height, margin);
49
+ const chartId = (0, _useId.default)();
50
+ const value = React.useMemo(() => (0, _extends2.default)({
51
+ chartId: chartId ?? ''
52
+ }, drawingArea), [chartId, drawingArea]);
46
53
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(SVGContext.Provider, {
47
54
  value: svgRef,
48
55
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DrawingContext.Provider, {
49
- value: drawingArea,
56
+ value: value,
50
57
  children: children
51
58
  })
52
59
  });