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