@mui/x-charts 7.0.0-alpha.2 → 7.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/BarChart/BarElement.d.ts +5 -1
  2. package/BarChart/BarElement.js +24 -1
  3. package/BarChart/index.d.ts +2 -1
  4. package/BarChart/index.js +15 -4
  5. package/CHANGELOG.md +364 -0
  6. package/ChartsLegend/index.d.ts +1 -0
  7. package/ChartsLegend/index.js +11 -0
  8. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
  9. package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
  10. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
  11. package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
  12. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
  13. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
  14. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
  15. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
  16. package/ChartsTooltip/index.d.ts +4 -0
  17. package/ChartsTooltip/index.js +44 -0
  18. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +14 -0
  19. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +174 -0
  20. package/ChartsVoronoiHandler/index.d.ts +1 -0
  21. package/ChartsVoronoiHandler/index.js +16 -0
  22. package/ChartsVoronoiHandler/package.json +6 -0
  23. package/ChartsYAxis/ChartsYAxis.js +6 -4
  24. package/LineChart/extremums.js +25 -8
  25. package/LineChart/index.d.ts +1 -1
  26. package/LineChart/index.js +11 -11
  27. package/PieChart/PieArc.d.ts +5 -2
  28. package/PieChart/PieArc.js +17 -2
  29. package/PieChart/PieArcLabel.d.ts +1 -1
  30. package/PieChart/PieArcLabel.js +5 -10
  31. package/PieChart/PieArcLabelPlot.d.ts +5 -1
  32. package/PieChart/PieArcLabelPlot.js +91 -3
  33. package/PieChart/PieArcPlot.d.ts +5 -1
  34. package/PieChart/PieArcPlot.js +90 -3
  35. package/PieChart/index.d.ts +3 -1
  36. package/PieChart/index.js +26 -4
  37. package/README.md +0 -1
  38. package/ScatterChart/Scatter.js +15 -6
  39. package/ScatterChart/ScatterChart.d.ts +7 -1
  40. package/ScatterChart/ScatterChart.js +18 -1
  41. package/ScatterChart/index.d.ts +1 -1
  42. package/ScatterChart/index.js +8 -8
  43. package/SparkLineChart/SparkLineChart.js +1 -0
  44. package/context/InteractionProvider.d.ts +10 -0
  45. package/context/InteractionProvider.js +21 -1
  46. package/esm/BarChart/BarElement.js +26 -2
  47. package/esm/BarChart/index.js +2 -1
  48. package/esm/ChartsLegend/index.js +2 -1
  49. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
  50. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  51. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
  52. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  53. package/esm/ChartsTooltip/index.js +5 -1
  54. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +168 -0
  55. package/esm/ChartsVoronoiHandler/index.js +1 -0
  56. package/esm/ChartsYAxis/ChartsYAxis.js +6 -4
  57. package/esm/LineChart/extremums.js +25 -8
  58. package/esm/LineChart/index.js +1 -1
  59. package/esm/PieChart/PieArc.js +18 -2
  60. package/esm/PieChart/PieArcLabel.js +7 -11
  61. package/esm/PieChart/PieArcLabelPlot.js +92 -3
  62. package/esm/PieChart/PieArcPlot.js +91 -3
  63. package/esm/PieChart/index.js +3 -1
  64. package/esm/ScatterChart/Scatter.js +15 -6
  65. package/esm/ScatterChart/ScatterChart.js +18 -1
  66. package/esm/ScatterChart/index.js +1 -1
  67. package/esm/SparkLineChart/SparkLineChart.js +1 -0
  68. package/esm/context/InteractionProvider.js +21 -1
  69. package/esm/hooks/useAxisEvents.js +20 -27
  70. package/esm/hooks/useInteractionItemProps.js +4 -1
  71. package/esm/index.js +1 -0
  72. package/esm/internals/defaultizeValueFormatter.js +4 -3
  73. package/esm/internals/utils.js +11 -0
  74. package/hooks/useAxisEvents.js +20 -27
  75. package/hooks/useInteractionItemProps.d.ts +2 -2
  76. package/hooks/useInteractionItemProps.js +4 -1
  77. package/index.d.ts +1 -0
  78. package/index.js +12 -1
  79. package/internals/defaultizeColor.d.ts +1 -0
  80. package/internals/defaultizeValueFormatter.d.ts +3 -1
  81. package/internals/defaultizeValueFormatter.js +3 -3
  82. package/internals/utils.d.ts +6 -0
  83. package/internals/utils.js +12 -0
  84. package/legacy/BarChart/BarElement.js +26 -2
  85. package/legacy/BarChart/index.js +2 -1
  86. package/legacy/ChartsLegend/index.js +2 -1
  87. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  88. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
  89. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  90. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
  91. package/legacy/ChartsTooltip/index.js +5 -1
  92. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +162 -0
  93. package/legacy/ChartsVoronoiHandler/index.js +1 -0
  94. package/legacy/ChartsYAxis/ChartsYAxis.js +6 -4
  95. package/legacy/LineChart/extremums.js +29 -14
  96. package/legacy/LineChart/index.js +1 -1
  97. package/legacy/PieChart/PieArc.js +18 -2
  98. package/legacy/PieChart/PieArcLabel.js +7 -11
  99. package/legacy/PieChart/PieArcLabelPlot.js +92 -3
  100. package/legacy/PieChart/PieArcPlot.js +91 -3
  101. package/legacy/PieChart/index.js +3 -1
  102. package/legacy/ScatterChart/Scatter.js +18 -7
  103. package/legacy/ScatterChart/ScatterChart.js +18 -1
  104. package/legacy/ScatterChart/index.js +1 -1
  105. package/legacy/SparkLineChart/SparkLineChart.js +1 -0
  106. package/legacy/context/InteractionProvider.js +21 -1
  107. package/legacy/hooks/useAxisEvents.js +20 -27
  108. package/legacy/hooks/useInteractionItemProps.js +6 -1
  109. package/legacy/index.js +2 -1
  110. package/legacy/internals/defaultizeValueFormatter.js +4 -3
  111. package/legacy/internals/utils.js +11 -0
  112. package/models/seriesType/config.d.ts +5 -1
  113. package/models/seriesType/scatter.d.ts +6 -1
  114. package/modern/BarChart/BarElement.js +26 -2
  115. package/modern/BarChart/index.js +2 -1
  116. package/modern/ChartsLegend/index.js +2 -1
  117. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  118. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  119. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  120. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  121. package/modern/ChartsTooltip/index.js +5 -1
  122. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +166 -0
  123. package/modern/ChartsVoronoiHandler/index.js +1 -0
  124. package/modern/ChartsYAxis/ChartsYAxis.js +6 -4
  125. package/modern/LineChart/extremums.js +25 -8
  126. package/modern/LineChart/index.js +1 -1
  127. package/modern/PieChart/PieArc.js +18 -2
  128. package/modern/PieChart/PieArcLabel.js +7 -11
  129. package/modern/PieChart/PieArcLabelPlot.js +92 -3
  130. package/modern/PieChart/PieArcPlot.js +91 -3
  131. package/modern/PieChart/index.js +3 -1
  132. package/modern/ScatterChart/Scatter.js +15 -6
  133. package/modern/ScatterChart/ScatterChart.js +18 -1
  134. package/modern/ScatterChart/index.js +1 -1
  135. package/modern/SparkLineChart/SparkLineChart.js +1 -0
  136. package/modern/context/InteractionProvider.js +21 -1
  137. package/modern/hooks/useAxisEvents.js +20 -27
  138. package/modern/hooks/useInteractionItemProps.js +4 -1
  139. package/modern/index.js +2 -1
  140. package/modern/internals/defaultizeValueFormatter.js +3 -3
  141. package/modern/internals/utils.js +11 -0
  142. package/package.json +6 -4
@@ -0,0 +1,168 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Delaunay } from 'd3-delaunay';
4
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
+ import { InteractionContext } from '../context/InteractionProvider';
6
+ import { CartesianContext } from '../context/CartesianContextProvider';
7
+ import { SVGContext, DrawingContext } from '../context/DrawingProvider';
8
+ import { SeriesContext } from '../context/SeriesContextProvider';
9
+ import { getValueToPositionMapper } from '../hooks/useScale';
10
+ import { getSVGPoint } from '../internals/utils';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ function ChartsVoronoiHandler(props) {
13
+ var _React$useContext$sca;
14
+ const {
15
+ voronoiMaxRadius
16
+ } = props;
17
+ const svgRef = React.useContext(SVGContext);
18
+ const {
19
+ width,
20
+ height,
21
+ top,
22
+ left
23
+ } = React.useContext(DrawingContext);
24
+ const {
25
+ xAxis,
26
+ yAxis,
27
+ xAxisIds,
28
+ yAxisIds
29
+ } = React.useContext(CartesianContext);
30
+ const {
31
+ dispatch
32
+ } = React.useContext(InteractionContext);
33
+ const {
34
+ series,
35
+ seriesOrder
36
+ } = (_React$useContext$sca = React.useContext(SeriesContext).scatter) != null ? _React$useContext$sca : {};
37
+ const voronoiRef = React.useRef({});
38
+ const defaultXAxisId = xAxisIds[0];
39
+ const defaultYAxisId = yAxisIds[0];
40
+ useEnhancedEffect(() => {
41
+ dispatch({
42
+ type: 'updateVoronoiUsage',
43
+ useVoronoiInteraction: true
44
+ });
45
+ return () => {
46
+ dispatch({
47
+ type: 'updateVoronoiUsage',
48
+ useVoronoiInteraction: false
49
+ });
50
+ };
51
+ }, [dispatch]);
52
+ useEnhancedEffect(() => {
53
+ if (seriesOrder === undefined || series === undefined) {
54
+ // If there is no scatter chart series
55
+ return;
56
+ }
57
+ voronoiRef.current = {};
58
+ let points = [];
59
+ seriesOrder.forEach(seriesId => {
60
+ const {
61
+ data,
62
+ xAxisKey,
63
+ yAxisKey
64
+ } = series[seriesId];
65
+ const xScale = xAxis[xAxisKey != null ? xAxisKey : defaultXAxisId].scale;
66
+ const yScale = yAxis[yAxisKey != null ? yAxisKey : defaultYAxisId].scale;
67
+ const getXPosition = getValueToPositionMapper(xScale);
68
+ const getYPosition = getValueToPositionMapper(yScale);
69
+ const seriesPoints = data.flatMap(({
70
+ x,
71
+ y
72
+ }) => [getXPosition(x), getYPosition(y)]);
73
+ voronoiRef.current[seriesId] = {
74
+ startIndex: points.length,
75
+ endIndex: points.length + seriesPoints.length
76
+ };
77
+ points = points.concat(seriesPoints);
78
+ });
79
+ voronoiRef.current.delauney = new Delaunay(points);
80
+ }, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
81
+ React.useEffect(() => {
82
+ const element = svgRef.current;
83
+ if (element === null) {
84
+ return undefined;
85
+ }
86
+ const handleMouseOut = () => {
87
+ dispatch({
88
+ type: 'exitChart'
89
+ });
90
+ };
91
+
92
+ // TODO: A perf optimisation of voronoi could be to use the last point as the intial point for the next search.
93
+ const handleMouseMove = event => {
94
+ var _voronoiRef$current$d;
95
+ // Get mouse coordinate in global SVG space
96
+ const svgPoint = getSVGPoint(svgRef.current, event);
97
+ const outsideX = svgPoint.x < left || svgPoint.x > left + width;
98
+ const outsideY = svgPoint.y < top || svgPoint.y > top + height;
99
+ if (outsideX || outsideY) {
100
+ dispatch({
101
+ type: 'exitChart'
102
+ });
103
+ return;
104
+ }
105
+ if (!voronoiRef.current.delauney) {
106
+ return;
107
+ }
108
+ const closestPointIndex = (_voronoiRef$current$d = voronoiRef.current.delauney) == null ? void 0 : _voronoiRef$current$d.find(svgPoint.x, svgPoint.y);
109
+ if (closestPointIndex !== undefined) {
110
+ const seriesId = Object.keys(voronoiRef.current).find(id => {
111
+ if (id === 'delauney') {
112
+ return false;
113
+ }
114
+ return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
115
+ });
116
+ if (seriesId === undefined) {
117
+ return;
118
+ }
119
+ const dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
120
+ if (voronoiMaxRadius !== undefined) {
121
+ const pointX = voronoiRef.current.delauney.points[2 * closestPointIndex];
122
+ const pointY = voronoiRef.current.delauney.points[2 * closestPointIndex + 1];
123
+ const dist2 = (pointX - svgPoint.x) ** 2 + (pointY - svgPoint.y) ** 2;
124
+ if (dist2 > voronoiMaxRadius ** 2) {
125
+ // The closest point is too far to be considered.
126
+ dispatch({
127
+ type: 'leaveItem',
128
+ data: {
129
+ type: 'scatter',
130
+ seriesId,
131
+ dataIndex
132
+ }
133
+ });
134
+ return;
135
+ }
136
+ }
137
+ dispatch({
138
+ type: 'enterItem',
139
+ data: {
140
+ type: 'scatter',
141
+ seriesId,
142
+ dataIndex
143
+ }
144
+ });
145
+ }
146
+ };
147
+ element.addEventListener('mouseout', handleMouseOut);
148
+ element.addEventListener('mousemove', handleMouseMove);
149
+ return () => {
150
+ element.removeEventListener('mouseout', handleMouseOut);
151
+ element.removeEventListener('mousemove', handleMouseMove);
152
+ };
153
+ }, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius]);
154
+ return /*#__PURE__*/_jsx("g", {}); // Workaround to fix docs scripts
155
+ }
156
+ process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
157
+ // ----------------------------- Warning --------------------------------
158
+ // | These PropTypes are generated from the TypeScript type definitions |
159
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
160
+ // ----------------------------------------------------------------------
161
+ /**
162
+ * Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
163
+ * If `undefined`, the radius is assumed to be infinite.
164
+ * @default undefined
165
+ */
166
+ voronoiMaxRadius: PropTypes.number
167
+ } : void 0;
168
+ export { ChartsVoronoiHandler };
@@ -0,0 +1 @@
1
+ export * from './ChartsVoronoiHandler';
@@ -75,6 +75,8 @@ function ChartsYAxis(inProps) {
75
75
  tickFontSize,
76
76
  label,
77
77
  labelFontSize,
78
+ labelStyle,
79
+ tickLabelStyle,
78
80
  tickSize: tickSizeProp,
79
81
  valueFormatter,
80
82
  slots,
@@ -109,11 +111,11 @@ function ChartsYAxis(inProps) {
109
111
  elementType: TickLabel,
110
112
  externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
111
113
  additionalProps: {
112
- style: {
114
+ style: _extends({
113
115
  fontSize: tickFontSize,
114
116
  textAnchor: position === 'right' ? 'start' : 'end',
115
117
  dominantBaseline: 'central'
116
- },
118
+ }, tickLabelStyle),
117
119
  className: classes.tickLabel
118
120
  },
119
121
  ownerState: {}
@@ -122,12 +124,12 @@ function ChartsYAxis(inProps) {
122
124
  elementType: Label,
123
125
  externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
124
126
  additionalProps: {
125
- style: {
127
+ style: _extends({
126
128
  fontSize: labelFontSize,
127
129
  angle: positionSign * 90,
128
130
  textAnchor: 'middle',
129
131
  dominantBaseline: 'auto'
130
- }
132
+ }, labelStyle)
131
133
  },
132
134
  ownerState: {}
133
135
  });
@@ -7,6 +7,18 @@ export const getExtremumX = params => {
7
7
  const maxX = Math.max(...((_axis$data2 = axis.data) != null ? _axis$data2 : []));
8
8
  return [minX, maxX];
9
9
  };
10
+ function getSeriesExtremums(getValues, stackedData) {
11
+ if (stackedData.length === 0) {
12
+ return [null, null];
13
+ }
14
+ return stackedData.reduce((seriesAcc, stackedValue) => {
15
+ const [base, value] = getValues(stackedValue);
16
+ if (seriesAcc[0] === null) {
17
+ return [Math.min(base, value), Math.max(base, value)];
18
+ }
19
+ return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
20
+ }, getValues(stackedData[0]));
21
+ }
10
22
  export const getExtremumY = params => {
11
23
  const {
12
24
  series,
@@ -14,16 +26,21 @@ export const getExtremumY = params => {
14
26
  isDefaultAxis
15
27
  } = params;
16
28
  return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
17
- const isArea = series[seriesId].area !== undefined;
18
- const getValues = isArea ? d => d : d => [d[1], d[1]]; // Id area should go from bottom to top, without area should only consider the top
29
+ const {
30
+ area,
31
+ stackedData
32
+ } = series[seriesId];
33
+ const isArea = area !== undefined;
34
+ const getValues = isArea ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
19
35
 
20
- const [seriesMin, seriesMax] = series[seriesId].stackedData.reduce((seriesAcc, stackedValue) => {
21
- const [base, value] = getValues(stackedValue);
22
- return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
23
- }, getValues(series[seriesId].stackedData[0]));
24
- if (acc[0] === null || acc[1] === null) {
25
- return [seriesMin, seriesMax];
36
+ const seriesExtremums = getSeriesExtremums(getValues, stackedData);
37
+ if (acc[0] === null) {
38
+ return seriesExtremums;
39
+ }
40
+ if (seriesExtremums[0] === null) {
41
+ return acc;
26
42
  }
43
+ const [seriesMin, seriesMax] = seriesExtremums;
27
44
  return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
28
45
  }, [null, null]);
29
46
  };
@@ -1,8 +1,8 @@
1
+ export * from './LineChart';
1
2
  export * from './LinePlot';
2
3
  export * from './AreaPlot';
3
4
  export * from './MarkPlot';
4
5
  export * from './LineHighlightPlot';
5
- export * from './LineChart';
6
6
  export * from './AreaElement';
7
7
  export * from './LineElement';
8
8
  export * from './MarkElement';
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "onClick", "isFaded", "isHighlighted", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
4
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
5
6
  import { arc as d3Arc } from 'd3-shape';
6
7
  import { animated, to } from '@react-spring/web';
7
8
  import composeClasses from '@mui/utils/composeClasses';
@@ -37,7 +38,7 @@ const PieArcRoot = styled(animated.path, {
37
38
  strokeWidth: 1,
38
39
  strokeLinejoin: 'round'
39
40
  }));
40
- export default function PieArc(props) {
41
+ function PieArc(props) {
41
42
  const {
42
43
  id,
43
44
  dataIndex,
@@ -82,4 +83,19 @@ export default function PieArc(props) {
82
83
  seriesId: id,
83
84
  dataIndex
84
85
  })));
85
- }
86
+ }
87
+ process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
88
+ // ----------------------------- Warning --------------------------------
89
+ // | These PropTypes are generated from the TypeScript type definitions |
90
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
91
+ // ----------------------------------------------------------------------
92
+ classes: PropTypes.object,
93
+ dataIndex: PropTypes.number.isRequired,
94
+ highlightScope: PropTypes.shape({
95
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
96
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
97
+ }),
98
+ isFaded: PropTypes.bool.isRequired,
99
+ isHighlighted: PropTypes.bool.isRequired
100
+ } : void 0;
101
+ export { PieArc };
@@ -2,9 +2,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
4
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
5
6
  import { animated, to } from '@react-spring/web';
6
7
  import { arc as d3Arc } from 'd3-shape';
7
- import PropTypes from 'prop-types';
8
8
  import composeClasses from '@mui/utils/composeClasses';
9
9
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
10
10
  import { styled } from '@mui/material/styles';
@@ -57,7 +57,7 @@ const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle,
57
57
  }
58
58
  return y;
59
59
  };
60
- export default function PieArcLabel(props) {
60
+ function PieArcLabel(props) {
61
61
  const {
62
62
  id,
63
63
  classes: innerClasses,
@@ -98,12 +98,8 @@ process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
98
98
  // | To update them edit the TypeScript types and run "yarn proptypes" |
99
99
  // ----------------------------------------------------------------------
100
100
  classes: PropTypes.object,
101
- cornerRadius: PropTypes.number,
102
- dataIndex: PropTypes.number.isRequired,
103
- highlightScope: PropTypes.shape({
104
- faded: PropTypes.oneOf(['global', 'none', 'series']),
105
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
106
- }),
107
- innerRadius: PropTypes.number,
108
- outerRadius: PropTypes.number.isRequired
109
- } : void 0;
101
+ formattedArcLabel: PropTypes.string,
102
+ isFaded: PropTypes.bool.isRequired,
103
+ isHighlighted: PropTypes.bool.isRequired
104
+ } : void 0;
105
+ export { PieArcLabel };
@@ -3,10 +3,11 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
4
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useTransition } from '@react-spring/web';
7
8
  import { defaultLabelTransitionConfig } from './dataTransform/transition';
8
9
  import { useTransformData } from './dataTransform/useTransformData';
9
- import PieArcLabel from './PieArcLabel';
10
+ import { PieArcLabel } from './PieArcLabel';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  const RATIO = 180 / Math.PI;
12
13
  function getItemLabel(arcLabel, arcLabelMinAngle, item) {
@@ -23,7 +24,7 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
23
24
  }
24
25
  return arcLabel(item);
25
26
  }
26
- export function PieArcLabelPlot(props) {
27
+ function PieArcLabelPlot(props) {
27
28
  var _slots$pieArcLabel;
28
29
  const {
29
30
  slots,
@@ -89,4 +90,92 @@ export function PieArcLabelPlot(props) {
89
90
  }, slotProps == null ? void 0 : slotProps.pieArcLabel));
90
91
  })
91
92
  }));
92
- }
93
+ }
94
+ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
95
+ // ----------------------------- Warning --------------------------------
96
+ // | These PropTypes are generated from the TypeScript type definitions |
97
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
98
+ // ----------------------------------------------------------------------
99
+ /**
100
+ * The label displayed into the arc.
101
+ */
102
+ arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
103
+ /**
104
+ * The minimal angle required to display the arc label.
105
+ */
106
+ arcLabelMinAngle: PropTypes.number,
107
+ /**
108
+ * The radius applied to arc corners (similar to border radius).
109
+ * @default 0
110
+ */
111
+ cornerRadius: PropTypes.number,
112
+ data: PropTypes.arrayOf(PropTypes.shape({
113
+ color: PropTypes.string.isRequired,
114
+ endAngle: PropTypes.number.isRequired,
115
+ formattedValue: PropTypes.string.isRequired,
116
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
117
+ index: PropTypes.number.isRequired,
118
+ label: PropTypes.string,
119
+ padAngle: PropTypes.number.isRequired,
120
+ startAngle: PropTypes.number.isRequired,
121
+ value: PropTypes.number.isRequired
122
+ })).isRequired,
123
+ /**
124
+ * Override the arc attibutes when it is faded.
125
+ */
126
+ faded: PropTypes.shape({
127
+ additionalRadius: PropTypes.number,
128
+ color: PropTypes.string,
129
+ cornerRadius: PropTypes.number,
130
+ innerRadius: PropTypes.number,
131
+ outerRadius: PropTypes.number,
132
+ paddingAngle: PropTypes.number
133
+ }),
134
+ /**
135
+ * Override the arc attibutes when it is highlighted.
136
+ */
137
+ highlighted: PropTypes.shape({
138
+ additionalRadius: PropTypes.number,
139
+ color: PropTypes.string,
140
+ cornerRadius: PropTypes.number,
141
+ innerRadius: PropTypes.number,
142
+ outerRadius: PropTypes.number,
143
+ paddingAngle: PropTypes.number
144
+ }),
145
+ highlightScope: PropTypes.shape({
146
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
147
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
148
+ }),
149
+ id: PropTypes.string.isRequired,
150
+ /**
151
+ * The radius between circle center and the begining of the arc.
152
+ * @default 0
153
+ */
154
+ innerRadius: PropTypes.number,
155
+ /**
156
+ * The radius between circle center and the end of the arc.
157
+ * @default R_max The maximal radius that fit into the drawing area.
158
+ */
159
+ outerRadius: PropTypes.number.isRequired,
160
+ /**
161
+ * The padding angle (deg) between two arcs.
162
+ * @default 0
163
+ */
164
+ paddingAngle: PropTypes.number,
165
+ /**
166
+ * If `true`, animations are skiped.
167
+ * @default false
168
+ */
169
+ skipAnimation: PropTypes.bool,
170
+ /**
171
+ * The props used for each component slot.
172
+ * @default {}
173
+ */
174
+ slotProps: PropTypes.object,
175
+ /**
176
+ * Overridable component slots.
177
+ * @default {}
178
+ */
179
+ slots: PropTypes.object
180
+ } : void 0;
181
+ export { PieArcLabelPlot };
@@ -3,12 +3,13 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
4
4
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useTransition } from '@react-spring/web';
7
- import PieArc from './PieArc';
8
+ import { PieArc } from './PieArc';
8
9
  import { defaultTransitionConfig } from './dataTransform/transition';
9
10
  import { useTransformData } from './dataTransform/useTransformData';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
- export function PieArcPlot(props) {
12
+ function PieArcPlot(props) {
12
13
  var _slots$pieArc;
13
14
  const {
14
15
  slots,
@@ -81,4 +82,91 @@ export function PieArcPlot(props) {
81
82
  }, slotProps == null ? void 0 : slotProps.pieArc));
82
83
  })
83
84
  }));
84
- }
85
+ }
86
+ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
87
+ // ----------------------------- Warning --------------------------------
88
+ // | These PropTypes are generated from the TypeScript type definitions |
89
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
90
+ // ----------------------------------------------------------------------
91
+ /**
92
+ * The radius applied to arc corners (similar to border radius).
93
+ * @default 0
94
+ */
95
+ cornerRadius: PropTypes.number,
96
+ data: PropTypes.arrayOf(PropTypes.shape({
97
+ color: PropTypes.string.isRequired,
98
+ endAngle: PropTypes.number.isRequired,
99
+ formattedValue: PropTypes.string.isRequired,
100
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
101
+ index: PropTypes.number.isRequired,
102
+ label: PropTypes.string,
103
+ padAngle: PropTypes.number.isRequired,
104
+ startAngle: PropTypes.number.isRequired,
105
+ value: PropTypes.number.isRequired
106
+ })).isRequired,
107
+ /**
108
+ * Override the arc attibutes when it is faded.
109
+ */
110
+ faded: PropTypes.shape({
111
+ additionalRadius: PropTypes.number,
112
+ color: PropTypes.string,
113
+ cornerRadius: PropTypes.number,
114
+ innerRadius: PropTypes.number,
115
+ outerRadius: PropTypes.number,
116
+ paddingAngle: PropTypes.number
117
+ }),
118
+ /**
119
+ * Override the arc attibutes when it is highlighted.
120
+ */
121
+ highlighted: PropTypes.shape({
122
+ additionalRadius: PropTypes.number,
123
+ color: PropTypes.string,
124
+ cornerRadius: PropTypes.number,
125
+ innerRadius: PropTypes.number,
126
+ outerRadius: PropTypes.number,
127
+ paddingAngle: PropTypes.number
128
+ }),
129
+ highlightScope: PropTypes.shape({
130
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
131
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
132
+ }),
133
+ id: PropTypes.string.isRequired,
134
+ /**
135
+ * The radius between circle center and the begining of the arc.
136
+ * @default 0
137
+ */
138
+ innerRadius: PropTypes.number,
139
+ /**
140
+ * Callback fired when a pie item is clicked.
141
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
142
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
143
+ * @param {DefaultizedPieValueType} item The pie item.
144
+ */
145
+ onClick: PropTypes.func,
146
+ /**
147
+ * The radius between circle center and the end of the arc.
148
+ * @default R_max The maximal radius that fit into the drawing area.
149
+ */
150
+ outerRadius: PropTypes.number.isRequired,
151
+ /**
152
+ * The padding angle (deg) between two arcs.
153
+ * @default 0
154
+ */
155
+ paddingAngle: PropTypes.number,
156
+ /**
157
+ * If `true`, animations are skiped.
158
+ * @default false
159
+ */
160
+ skipAnimation: PropTypes.bool,
161
+ /**
162
+ * The props used for each component slot.
163
+ * @default {}
164
+ */
165
+ slotProps: PropTypes.object,
166
+ /**
167
+ * Overridable component slots.
168
+ * @default {}
169
+ */
170
+ slots: PropTypes.object
171
+ } : void 0;
172
+ export { PieArcPlot };
@@ -1,4 +1,6 @@
1
- export * from './PiePlot';
2
1
  export * from './PieChart';
2
+ export * from './PiePlot';
3
+ export * from './PieArcPlot';
4
+ export * from './PieArcLabelPlot';
3
5
  export * from './PieArc';
4
6
  export * from './PieArcLabel';
@@ -23,10 +23,16 @@ function Scatter(props) {
23
23
  color,
24
24
  markerSize
25
25
  } = props;
26
+ const highlightScope = React.useMemo(() => _extends({
27
+ highlighted: 'item',
28
+ faded: 'global'
29
+ }, series.highlightScope), [series.highlightScope]);
26
30
  const {
27
- item
31
+ item,
32
+ useVoronoiInteraction
28
33
  } = React.useContext(InteractionContext);
29
- const getInteractionItemProps = useInteractionItemProps(series.highlightScope);
34
+ const skipInteractionHandlers = useVoronoiInteraction || series.disableHover;
35
+ const getInteractionItemProps = useInteractionItemProps(highlightScope, skipInteractionHandlers);
30
36
  const cleanData = React.useMemo(() => {
31
37
  const getXPosition = getValueToPositionMapper(xScale);
32
38
  const getYPosition = getValueToPositionMapper(yScale);
@@ -48,22 +54,24 @@ function Scatter(props) {
48
54
  dataIndex: i
49
55
  };
50
56
  if (isInRange) {
57
+ const isHighlighted = getIsHighlighted(item, pointCtx, highlightScope);
51
58
  temp.push({
52
59
  x,
53
60
  y,
54
- isFaded: !getIsHighlighted(item, pointCtx, series.highlightScope) && getIsFaded(item, pointCtx, series.highlightScope),
61
+ isHighlighted,
62
+ isFaded: !isHighlighted && getIsFaded(item, pointCtx, highlightScope),
55
63
  interactionProps: getInteractionItemProps(pointCtx),
56
64
  id: scatterPoint.id
57
65
  });
58
66
  }
59
67
  }
60
68
  return temp;
61
- }, [yScale, xScale, getInteractionItemProps, item, series.data, series.highlightScope, series.id]);
69
+ }, [xScale, yScale, series.data, series.id, item, highlightScope, getInteractionItemProps]);
62
70
  return /*#__PURE__*/_jsx("g", {
63
71
  children: cleanData.map(dataPoint => /*#__PURE__*/_jsx("circle", _extends({
64
72
  cx: 0,
65
73
  cy: 0,
66
- r: markerSize,
74
+ r: (dataPoint.isHighlighted ? 1.2 : 1) * markerSize,
67
75
  transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
68
76
  fill: color,
69
77
  opacity: dataPoint.isFaded && 0.3 || 1
@@ -78,12 +86,13 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
78
86
  color: PropTypes.string.isRequired,
79
87
  markerSize: PropTypes.number.isRequired,
80
88
  series: PropTypes.shape({
81
- color: PropTypes.string,
89
+ color: PropTypes.string.isRequired,
82
90
  data: PropTypes.arrayOf(PropTypes.shape({
83
91
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
84
92
  x: PropTypes.number.isRequired,
85
93
  y: PropTypes.number.isRequired
86
94
  })).isRequired,
95
+ disableHover: PropTypes.bool,
87
96
  highlightScope: PropTypes.shape({
88
97
  faded: PropTypes.oneOf(['global', 'none', 'series']),
89
98
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])