@mui/x-charts 7.0.0-beta.3 → 7.0.0-beta.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 (218) hide show
  1. package/BarChart/BarChart.js +0 -2
  2. package/CHANGELOG.md +226 -15
  3. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  4. package/ChartsTooltip/utils.js +1 -1
  5. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
  6. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
  7. package/ChartsXAxis/ChartsXAxis.js +1 -1
  8. package/ChartsYAxis/ChartsYAxis.js +1 -1
  9. package/Gauge/Gauge.js +0 -2
  10. package/Gauge/GaugeContainer.d.ts +0 -2
  11. package/Gauge/GaugeContainer.js +0 -2
  12. package/Gauge/GaugeProvider.js +3 -0
  13. package/Gauge/GaugeValueText.js +1 -1
  14. package/LineChart/LineChart.js +0 -2
  15. package/PieChart/PieChart.js +0 -2
  16. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
  17. package/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  18. package/ScatterChart/ScatterChart.js +0 -3
  19. package/SparkLineChart/SparkLineChart.js +0 -2
  20. package/context/CartesianContextProvider.d.ts +0 -8
  21. package/context/CartesianContextProvider.js +4 -89
  22. package/context/DrawingProvider.d.ts +2 -11
  23. package/context/DrawingProvider.js +10 -35
  24. package/context/HighlightProvider.js +3 -0
  25. package/context/InteractionProvider.js +3 -0
  26. package/context/SeriesContextProvider.js +3 -0
  27. package/context/index.d.ts +0 -2
  28. package/context/index.js +1 -15
  29. package/esm/BarChart/BarChart.js +0 -2
  30. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  31. package/esm/ChartsTooltip/utils.js +2 -2
  32. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  33. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  34. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  35. package/esm/Gauge/Gauge.js +0 -2
  36. package/esm/Gauge/GaugeContainer.js +0 -2
  37. package/esm/Gauge/GaugeProvider.js +3 -0
  38. package/esm/Gauge/GaugeValueText.js +1 -1
  39. package/esm/LineChart/LineChart.js +0 -2
  40. package/esm/PieChart/PieChart.js +0 -2
  41. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  42. package/esm/ScatterChart/ScatterChart.js +0 -3
  43. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  44. package/esm/context/CartesianContextProvider.js +3 -88
  45. package/esm/context/DrawingProvider.js +10 -36
  46. package/esm/context/HighlightProvider.js +3 -0
  47. package/esm/context/InteractionProvider.js +3 -0
  48. package/esm/context/SeriesContextProvider.js +3 -0
  49. package/esm/context/index.js +1 -2
  50. package/esm/hooks/useAxisEvents.js +2 -2
  51. package/hooks/useAxisEvents.js +1 -1
  52. package/hooks/useTicks.d.ts +1 -1
  53. package/index.js +1 -1
  54. package/modern/BarChart/BarChart.js +0 -2
  55. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  56. package/modern/ChartsTooltip/utils.js +2 -2
  57. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  58. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  59. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  60. package/modern/Gauge/Gauge.js +0 -2
  61. package/modern/Gauge/GaugeContainer.js +0 -2
  62. package/modern/Gauge/GaugeProvider.js +3 -0
  63. package/modern/Gauge/GaugeValueText.js +1 -1
  64. package/modern/LineChart/LineChart.js +0 -2
  65. package/modern/PieChart/PieChart.js +0 -2
  66. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  67. package/modern/ScatterChart/ScatterChart.js +0 -3
  68. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  69. package/modern/context/CartesianContextProvider.js +3 -88
  70. package/modern/context/DrawingProvider.js +10 -36
  71. package/modern/context/HighlightProvider.js +3 -0
  72. package/modern/context/InteractionProvider.js +3 -0
  73. package/modern/context/SeriesContextProvider.js +3 -0
  74. package/modern/context/index.js +1 -2
  75. package/modern/hooks/useAxisEvents.js +2 -2
  76. package/modern/index.js +1 -1
  77. package/package.json +1 -1
  78. package/legacy/BarChart/BarChart.js +0 -440
  79. package/legacy/BarChart/BarElement.js +0 -119
  80. package/legacy/BarChart/BarPlot.js +0 -232
  81. package/legacy/BarChart/extremums.js +0 -45
  82. package/legacy/BarChart/formatter.js +0 -78
  83. package/legacy/BarChart/index.js +0 -3
  84. package/legacy/BarChart/legend.js +0 -15
  85. package/legacy/ChartContainer/ChartContainer.js +0 -189
  86. package/legacy/ChartContainer/index.js +0 -1
  87. package/legacy/ChartsAxis/ChartsAxis.js +0 -215
  88. package/legacy/ChartsAxis/axisClasses.js +0 -5
  89. package/legacy/ChartsAxis/index.js +0 -2
  90. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
  91. package/legacy/ChartsAxisHighlight/index.js +0 -1
  92. package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
  93. package/legacy/ChartsClipPath/index.js +0 -1
  94. package/legacy/ChartsGrid/ChartsGrid.js +0 -119
  95. package/legacy/ChartsGrid/chartsGridClasses.js +0 -6
  96. package/legacy/ChartsGrid/index.js +0 -2
  97. package/legacy/ChartsLegend/ChartsLegend.js +0 -100
  98. package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
  99. package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
  100. package/legacy/ChartsLegend/index.js +0 -4
  101. package/legacy/ChartsLegend/utils.js +0 -15
  102. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
  103. package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
  104. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
  105. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
  106. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
  107. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
  108. package/legacy/ChartsReferenceLine/common.js +0 -19
  109. package/legacy/ChartsReferenceLine/index.js +0 -2
  110. package/legacy/ChartsSurface.js +0 -78
  111. package/legacy/ChartsText/ChartsText.js +0 -95
  112. package/legacy/ChartsText/index.js +0 -1
  113. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
  114. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
  115. package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
  116. package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
  117. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
  118. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
  119. package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
  120. package/legacy/ChartsTooltip/index.js +0 -6
  121. package/legacy/ChartsTooltip/utils.js +0 -103
  122. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
  123. package/legacy/ChartsVoronoiHandler/index.js +0 -1
  124. package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
  125. package/legacy/ChartsXAxis/index.js +0 -1
  126. package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
  127. package/legacy/ChartsYAxis/index.js +0 -1
  128. package/legacy/Gauge/Gauge.js +0 -146
  129. package/legacy/Gauge/GaugeContainer.js +0 -215
  130. package/legacy/Gauge/GaugeProvider.js +0 -87
  131. package/legacy/Gauge/GaugeReferenceArc.js +0 -37
  132. package/legacy/Gauge/GaugeValueArc.js +0 -44
  133. package/legacy/Gauge/GaugeValueText.js +0 -66
  134. package/legacy/Gauge/gaugeClasses.js +0 -7
  135. package/legacy/Gauge/index.js +0 -7
  136. package/legacy/Gauge/utils.js +0 -84
  137. package/legacy/LineChart/AnimatedArea.js +0 -102
  138. package/legacy/LineChart/AnimatedLine.js +0 -104
  139. package/legacy/LineChart/AreaElement.js +0 -112
  140. package/legacy/LineChart/AreaPlot.js +0 -149
  141. package/legacy/LineChart/LineChart.js +0 -452
  142. package/legacy/LineChart/LineElement.js +0 -112
  143. package/legacy/LineChart/LineHighlightElement.js +0 -79
  144. package/legacy/LineChart/LineHighlightPlot.js +0 -97
  145. package/legacy/LineChart/LinePlot.js +0 -144
  146. package/legacy/LineChart/MarkElement.js +0 -153
  147. package/legacy/LineChart/MarkPlot.js +0 -178
  148. package/legacy/LineChart/extremums.js +0 -54
  149. package/legacy/LineChart/formatter.js +0 -82
  150. package/legacy/LineChart/index.js +0 -11
  151. package/legacy/LineChart/legend.js +0 -15
  152. package/legacy/PieChart/PieArc.js +0 -103
  153. package/legacy/PieChart/PieArcLabel.js +0 -112
  154. package/legacy/PieChart/PieArcLabelPlot.js +0 -193
  155. package/legacy/PieChart/PieArcPlot.js +0 -180
  156. package/legacy/PieChart/PieChart.js +0 -404
  157. package/legacy/PieChart/PiePlot.js +0 -137
  158. package/legacy/PieChart/dataTransform/transition.js +0 -149
  159. package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
  160. package/legacy/PieChart/formatter.js +0 -55
  161. package/legacy/PieChart/index.js +0 -6
  162. package/legacy/PieChart/legend.js +0 -16
  163. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -185
  164. package/legacy/ResponsiveChartContainer/index.js +0 -1
  165. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +0 -73
  166. package/legacy/ScatterChart/Scatter.js +0 -110
  167. package/legacy/ScatterChart/ScatterChart.js +0 -395
  168. package/legacy/ScatterChart/ScatterPlot.js +0 -80
  169. package/legacy/ScatterChart/extremums.js +0 -39
  170. package/legacy/ScatterChart/formatter.js +0 -12
  171. package/legacy/ScatterChart/index.js +0 -3
  172. package/legacy/ScatterChart/legend.js +0 -15
  173. package/legacy/SparkLineChart/SparkLineChart.js +0 -266
  174. package/legacy/SparkLineChart/index.js +0 -1
  175. package/legacy/colorPalettes/colorPalettes.js +0 -15
  176. package/legacy/colorPalettes/index.js +0 -1
  177. package/legacy/constants.js +0 -8
  178. package/legacy/context/CartesianContextProvider.js +0 -327
  179. package/legacy/context/DrawingProvider.js +0 -74
  180. package/legacy/context/HighlightProvider.js +0 -56
  181. package/legacy/context/InteractionProvider.js +0 -81
  182. package/legacy/context/SeriesContextProvider.js +0 -74
  183. package/legacy/context/index.js +0 -2
  184. package/legacy/hooks/index.js +0 -2
  185. package/legacy/hooks/useAxisEvents.js +0 -120
  186. package/legacy/hooks/useChartDimensions.js +0 -18
  187. package/legacy/hooks/useDrawingArea.js +0 -21
  188. package/legacy/hooks/useInteractionItemProps.js +0 -71
  189. package/legacy/hooks/useMounted.js +0 -21
  190. package/legacy/hooks/useReducedMotion.js +0 -27
  191. package/legacy/hooks/useScale.js +0 -33
  192. package/legacy/hooks/useTicks.js +0 -65
  193. package/legacy/index.js +0 -33
  194. package/legacy/internals/components/AxisSharedComponents.js +0 -25
  195. package/legacy/internals/defaultizeColor.js +0 -17
  196. package/legacy/internals/defaultizeValueFormatter.js +0 -12
  197. package/legacy/internals/domUtils.js +0 -121
  198. package/legacy/internals/geometry.js +0 -37
  199. package/legacy/internals/getCurve.js +0 -39
  200. package/legacy/internals/getScale.js +0 -17
  201. package/legacy/internals/getWordsByLines.js +0 -15
  202. package/legacy/internals/isBandScale.js +0 -3
  203. package/legacy/internals/stackSeries.js +0 -92
  204. package/legacy/internals/useAnimatedPath.js +0 -32
  205. package/legacy/internals/utils.js +0 -52
  206. package/legacy/models/axis.js +0 -6
  207. package/legacy/models/helpers.js +0 -1
  208. package/legacy/models/index.js +0 -4
  209. package/legacy/models/layout.js +0 -1
  210. package/legacy/models/seriesType/bar.js +0 -1
  211. package/legacy/models/seriesType/common.js +0 -1
  212. package/legacy/models/seriesType/config.js +0 -1
  213. package/legacy/models/seriesType/index.js +0 -5
  214. package/legacy/models/seriesType/line.js +0 -1
  215. package/legacy/models/seriesType/pie.js +0 -1
  216. package/legacy/models/seriesType/scatter.js +0 -1
  217. package/legacy/models/stacking.js +0 -1
  218. package/legacy/themeAugmentation/index.js +0 -3
@@ -1,84 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- function deg2rad(angle) {
4
- return Math.PI * angle / 180;
5
- }
6
- function getPoint(angle) {
7
- var radAngle = deg2rad(angle);
8
- return [Math.sin(radAngle), -Math.cos(radAngle)];
9
- }
10
-
11
- /**
12
- * Retruns the ratio of the arc bounding box and its center.
13
- * @param startAngle The start angle (in deg)
14
- * @param endAngle The end angle (in deg)
15
- */
16
- export function getArcRatios(startAngle, endAngle) {
17
- // Set the start, end and center point.
18
- var points = [[0, 0], getPoint(startAngle), getPoint(endAngle)];
19
-
20
- // Add cardinal points included in the arc
21
- var minAngle = Math.min(startAngle, endAngle);
22
- var maxAngle = Math.max(startAngle, endAngle);
23
- var initialAngle = Math.floor(minAngle / 90) * 90;
24
- for (var step = 1; step <= 4; step += 1) {
25
- var cartinalAngle = initialAngle + step * 90;
26
- if (cartinalAngle < maxAngle) {
27
- points.push(getPoint(cartinalAngle));
28
- }
29
- }
30
- var minX = Math.min.apply(Math, _toConsumableArray(points.map(function (_ref) {
31
- var _ref2 = _slicedToArray(_ref, 1),
32
- x = _ref2[0];
33
- return x;
34
- })));
35
- var maxX = Math.max.apply(Math, _toConsumableArray(points.map(function (_ref3) {
36
- var _ref4 = _slicedToArray(_ref3, 1),
37
- x = _ref4[0];
38
- return x;
39
- })));
40
- var minY = Math.min.apply(Math, _toConsumableArray(points.map(function (_ref5) {
41
- var _ref6 = _slicedToArray(_ref5, 2),
42
- y = _ref6[1];
43
- return y;
44
- })));
45
- var maxY = Math.max.apply(Math, _toConsumableArray(points.map(function (_ref7) {
46
- var _ref8 = _slicedToArray(_ref7, 2),
47
- y = _ref8[1];
48
- return y;
49
- })));
50
- return {
51
- cx: -minX / (maxX - minX),
52
- cy: -minY / (maxY - minY),
53
- minX: minX,
54
- maxX: maxX,
55
- minY: minY,
56
- maxY: maxY
57
- };
58
- }
59
- export function getAvailableRadius(cx, cy, width, height, _ref9) {
60
- var minX = _ref9.minX,
61
- maxX = _ref9.maxX,
62
- minY = _ref9.minY,
63
- maxY = _ref9.maxY;
64
- return Math.min.apply(Math, _toConsumableArray([{
65
- ratio: Math.abs(minX),
66
- space: cx
67
- }, {
68
- ratio: Math.abs(maxX),
69
- space: width - cx
70
- }, {
71
- ratio: Math.abs(minY),
72
- space: cy
73
- }, {
74
- ratio: Math.abs(maxY),
75
- space: height - cy
76
- }].map(function (_ref10) {
77
- var ratio = _ref10.ratio,
78
- space = _ref10.space;
79
- if (ratio < 0.00001) {
80
- return Infinity;
81
- }
82
- return space / ratio;
83
- })));
84
- }
@@ -1,102 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["d", "skipAnimation", "ownerState"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import { styled } from '@mui/material/styles';
7
- import { color as d3Color } from 'd3-color';
8
- import { animated, useSpring } from '@react-spring/web';
9
- import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
- import { cleanId } from '../internals/utils';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
14
- export var AreaElementPath = styled(animated.path, {
15
- name: 'MuiAreaElement',
16
- slot: 'Root',
17
- overridesResolver: function overridesResolver(_, styles) {
18
- return styles.root;
19
- }
20
- })(function (_ref) {
21
- var ownerState = _ref.ownerState;
22
- return {
23
- stroke: 'none',
24
- fill: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(1).formatHex() : d3Color(ownerState.color).brighter(0.5).formatHex(),
25
- transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
26
- opacity: ownerState.isFaded ? 0.3 : 1
27
- };
28
- });
29
- /**
30
- * Demos:
31
- *
32
- * - [Lines](https://mui.com/x/react-charts/lines/)
33
- * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
34
- *
35
- * API:
36
- *
37
- * - [AreaElement API](https://mui.com/x/api/charts/animated-area/)
38
- */
39
- function AnimatedArea(props) {
40
- var d = props.d,
41
- skipAnimation = props.skipAnimation,
42
- ownerState = props.ownerState,
43
- other = _objectWithoutProperties(props, _excluded);
44
- var _React$useContext = React.useContext(DrawingContext),
45
- left = _React$useContext.left,
46
- top = _React$useContext.top,
47
- right = _React$useContext.right,
48
- bottom = _React$useContext.bottom,
49
- width = _React$useContext.width,
50
- height = _React$useContext.height,
51
- chartId = _React$useContext.chartId;
52
- var path = useAnimatedPath(d, skipAnimation);
53
- var _useSpring = useSpring({
54
- from: {
55
- animatedWidth: left
56
- },
57
- to: {
58
- animatedWidth: width + left + right
59
- },
60
- reset: false,
61
- immediate: skipAnimation
62
- }),
63
- animatedWidth = _useSpring.animatedWidth;
64
- var clipId = cleanId("".concat(chartId, "-").concat(ownerState.id, "-area-clip"));
65
- return /*#__PURE__*/_jsxs(React.Fragment, {
66
- children: [/*#__PURE__*/_jsx("clipPath", {
67
- id: clipId,
68
- children: /*#__PURE__*/_jsx(animated.rect, {
69
- x: 0,
70
- y: 0,
71
- width: animatedWidth,
72
- height: top + height + bottom
73
- })
74
- }), /*#__PURE__*/_jsx("g", {
75
- clipPath: "url(#".concat(clipId, ")"),
76
- children: /*#__PURE__*/_jsx(AreaElementPath, _extends({}, other, {
77
- ownerState: ownerState,
78
- d: path
79
- }))
80
- })]
81
- });
82
- }
83
- process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
84
- // ----------------------------- Warning --------------------------------
85
- // | These PropTypes are generated from the TypeScript type definitions |
86
- // | To update them edit the TypeScript types and run "yarn proptypes" |
87
- // ----------------------------------------------------------------------
88
- d: PropTypes.string.isRequired,
89
- ownerState: PropTypes.shape({
90
- classes: PropTypes.object,
91
- color: PropTypes.string.isRequired,
92
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
93
- isFaded: PropTypes.bool.isRequired,
94
- isHighlighted: PropTypes.bool.isRequired
95
- }).isRequired,
96
- /**
97
- * If `true`, animations are skipped.
98
- * @default false
99
- */
100
- skipAnimation: PropTypes.bool
101
- } : void 0;
102
- export { AnimatedArea };
@@ -1,104 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["d", "skipAnimation", "ownerState"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import { animated, useSpring } from '@react-spring/web';
7
- import { color as d3Color } from 'd3-color';
8
- import { styled } from '@mui/material/styles';
9
- import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
- import { cleanId } from '../internals/utils';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
14
- export var LineElementPath = styled(animated.path, {
15
- name: 'MuiLineElement',
16
- slot: 'Root',
17
- overridesResolver: function overridesResolver(_, styles) {
18
- return styles.root;
19
- }
20
- })(function (_ref) {
21
- var ownerState = _ref.ownerState;
22
- return {
23
- strokeWidth: 2,
24
- strokeLinejoin: 'round',
25
- fill: 'none',
26
- stroke: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
27
- transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
28
- opacity: ownerState.isFaded ? 0.3 : 1
29
- };
30
- });
31
- /**
32
- * Demos:
33
- *
34
- * - [Lines](https://mui.com/x/react-charts/lines/)
35
- * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
36
- *
37
- * API:
38
- *
39
- * - [AnimatedLine API](https://mui.com/x/api/charts/animated-line/)
40
- */
41
- function AnimatedLine(props) {
42
- var d = props.d,
43
- skipAnimation = props.skipAnimation,
44
- ownerState = props.ownerState,
45
- other = _objectWithoutProperties(props, _excluded);
46
- var _React$useContext = React.useContext(DrawingContext),
47
- left = _React$useContext.left,
48
- top = _React$useContext.top,
49
- bottom = _React$useContext.bottom,
50
- width = _React$useContext.width,
51
- height = _React$useContext.height,
52
- right = _React$useContext.right,
53
- chartId = _React$useContext.chartId;
54
- var path = useAnimatedPath(d, skipAnimation);
55
- var _useSpring = useSpring({
56
- from: {
57
- animatedWidth: left
58
- },
59
- to: {
60
- animatedWidth: width + left + right
61
- },
62
- reset: false,
63
- immediate: skipAnimation
64
- }),
65
- animatedWidth = _useSpring.animatedWidth;
66
- var clipId = cleanId("".concat(chartId, "-").concat(ownerState.id, "-line-clip"));
67
- return /*#__PURE__*/_jsxs(React.Fragment, {
68
- children: [/*#__PURE__*/_jsx("clipPath", {
69
- id: clipId,
70
- children: /*#__PURE__*/_jsx(animated.rect, {
71
- x: 0,
72
- y: 0,
73
- width: animatedWidth,
74
- height: top + height + bottom
75
- })
76
- }), /*#__PURE__*/_jsx("g", {
77
- clipPath: "url(#".concat(clipId, ")"),
78
- children: /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
79
- ownerState: ownerState,
80
- d: path
81
- }))
82
- })]
83
- });
84
- }
85
- process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
86
- // ----------------------------- Warning --------------------------------
87
- // | These PropTypes are generated from the TypeScript type definitions |
88
- // | To update them edit the TypeScript types and run "yarn proptypes" |
89
- // ----------------------------------------------------------------------
90
- d: PropTypes.string.isRequired,
91
- ownerState: PropTypes.shape({
92
- classes: PropTypes.object,
93
- color: PropTypes.string.isRequired,
94
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
95
- isFaded: PropTypes.bool.isRequired,
96
- isHighlighted: PropTypes.bool.isRequired
97
- }).isRequired,
98
- /**
99
- * If `true`, animations are skipped.
100
- * @default false
101
- */
102
- skipAnimation: PropTypes.bool
103
- } : void 0;
104
- export { AnimatedLine };
@@ -1,112 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import composeClasses from '@mui/utils/composeClasses';
7
- import { useSlotProps } from '@mui/base/utils';
8
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
9
- import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
- import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
11
- import { InteractionContext } from '../context/InteractionProvider';
12
- import { AnimatedArea } from './AnimatedArea';
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- export function getAreaElementUtilityClass(slot) {
15
- return generateUtilityClass('MuiAreaElement', slot);
16
- }
17
- export var areaElementClasses = generateUtilityClasses('MuiAreaElement', ['root', 'highlighted', 'faded']);
18
- var useUtilityClasses = function useUtilityClasses(ownerState) {
19
- var classes = ownerState.classes,
20
- id = ownerState.id,
21
- isFaded = ownerState.isFaded,
22
- isHighlighted = ownerState.isHighlighted;
23
- var slots = {
24
- root: ['root', "series-".concat(id), isHighlighted && 'highlighted', isFaded && 'faded']
25
- };
26
- return composeClasses(slots, getAreaElementUtilityClass, classes);
27
- };
28
- /**
29
- * Demos:
30
- *
31
- * - [Lines](https://mui.com/x/react-charts/lines/)
32
- * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
33
- *
34
- * API:
35
- *
36
- * - [AreaElement API](https://mui.com/x/api/charts/area-element/)
37
- */
38
- function AreaElement(props) {
39
- var _slots$area;
40
- var id = props.id,
41
- innerClasses = props.classes,
42
- color = props.color,
43
- highlightScope = props.highlightScope,
44
- slots = props.slots,
45
- slotProps = props.slotProps,
46
- onClick = props.onClick,
47
- other = _objectWithoutProperties(props, _excluded);
48
- var getInteractionItemProps = useInteractionItemProps(highlightScope);
49
- var _React$useContext = React.useContext(InteractionContext),
50
- item = _React$useContext.item;
51
- var isHighlighted = getIsHighlighted(item, {
52
- type: 'line',
53
- seriesId: id
54
- }, highlightScope);
55
- var isFaded = !isHighlighted && getIsFaded(item, {
56
- type: 'line',
57
- seriesId: id
58
- }, highlightScope);
59
- var ownerState = {
60
- id: id,
61
- classes: innerClasses,
62
- color: color,
63
- isFaded: isFaded,
64
- isHighlighted: isHighlighted
65
- };
66
- var classes = useUtilityClasses(ownerState);
67
- var Area = (_slots$area = slots == null ? void 0 : slots.area) != null ? _slots$area : AnimatedArea;
68
- var areaProps = useSlotProps({
69
- elementType: Area,
70
- externalSlotProps: slotProps == null ? void 0 : slotProps.area,
71
- additionalProps: _extends({}, other, getInteractionItemProps({
72
- type: 'line',
73
- seriesId: id
74
- }), {
75
- className: classes.root,
76
- onClick: onClick,
77
- cursor: onClick ? 'pointer' : 'unset'
78
- }),
79
- ownerState: ownerState
80
- });
81
- return /*#__PURE__*/_jsx(Area, _extends({}, areaProps));
82
- }
83
- process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
84
- // ----------------------------- Warning --------------------------------
85
- // | These PropTypes are generated from the TypeScript type definitions |
86
- // | To update them edit the TypeScript types and run "yarn proptypes" |
87
- // ----------------------------------------------------------------------
88
- classes: PropTypes.object,
89
- color: PropTypes.string.isRequired,
90
- d: PropTypes.string.isRequired,
91
- highlightScope: PropTypes.shape({
92
- faded: PropTypes.oneOf(['global', 'none', 'series']),
93
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
94
- }),
95
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
96
- /**
97
- * If `true`, animations are skipped.
98
- * @default false
99
- */
100
- skipAnimation: PropTypes.bool,
101
- /**
102
- * The props used for each component slot.
103
- * @default {}
104
- */
105
- slotProps: PropTypes.object,
106
- /**
107
- * Overridable component slots.
108
- * @default {}
109
- */
110
- slots: PropTypes.object
111
- } : void 0;
112
- export { AreaElement };
@@ -1,149 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
- var _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import { area as d3Area } from 'd3-shape';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
- import { CartesianContext } from '../context/CartesianContextProvider';
9
- import { AreaElement } from './AreaElement';
10
- import { getValueToPositionMapper } from '../hooks/useScale';
11
- import getCurveFactory from '../internals/getCurve';
12
- import { DEFAULT_X_AXIS_KEY } from '../constants';
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- var useAggregatedData = function useAggregatedData() {
15
- var seriesData = React.useContext(SeriesContext).line;
16
- var axisData = React.useContext(CartesianContext);
17
- if (seriesData === undefined) {
18
- return [];
19
- }
20
- var series = seriesData.series,
21
- stackingGroups = seriesData.stackingGroups;
22
- var xAxis = axisData.xAxis,
23
- yAxis = axisData.yAxis,
24
- xAxisIds = axisData.xAxisIds,
25
- yAxisIds = axisData.yAxisIds;
26
- var defaultXAxisId = xAxisIds[0];
27
- var defaultYAxisId = yAxisIds[0];
28
- return stackingGroups.flatMap(function (_ref) {
29
- var groupIds = _ref.ids;
30
- return groupIds.flatMap(function (seriesId) {
31
- var _xData$map;
32
- var _series$seriesId = series[seriesId],
33
- _series$seriesId$xAxi = _series$seriesId.xAxisKey,
34
- xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
35
- _series$seriesId$yAxi = _series$seriesId.yAxisKey,
36
- yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
37
- stackedData = _series$seriesId.stackedData,
38
- data = _series$seriesId.data,
39
- connectNulls = _series$seriesId.connectNulls;
40
- var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
41
- var yScale = yAxis[yAxisKey].scale;
42
- var xData = xAxis[xAxisKey].data;
43
- if (process.env.NODE_ENV !== 'production') {
44
- if (xData === undefined) {
45
- throw new Error("MUI X Charts: ".concat(xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : "The x-axis with id \"".concat(xAxisKey, "\""), " should have data property to be able to display a line plot."));
46
- }
47
- if (xData.length < stackedData.length) {
48
- throw new Error("MUI X Charts: The data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)."));
49
- }
50
- }
51
- var areaPath = d3Area().x(function (d) {
52
- return xScale(d.x);
53
- }).defined(function (_, i) {
54
- return connectNulls || data[i] != null;
55
- }).y0(function (d) {
56
- return d.y && yScale(d.y[0]);
57
- }).y1(function (d) {
58
- return d.y && yScale(d.y[1]);
59
- });
60
- var curve = getCurveFactory(series[seriesId].curve);
61
- var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
62
- return {
63
- x: x,
64
- y: stackedData[index]
65
- };
66
- })) != null ? _xData$map : [];
67
- var d3Data = connectNulls ? formattedData.filter(function (_, i) {
68
- return data[i] != null;
69
- }) : formattedData;
70
- var d = areaPath.curve(curve)(d3Data) || '';
71
- return _extends({}, series[seriesId], {
72
- d: d,
73
- seriesId: seriesId
74
- });
75
- });
76
- });
77
- };
78
-
79
- /**
80
- * Demos:
81
- *
82
- * - [Lines](https://mui.com/x/react-charts/lines/)
83
- * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
84
- * - [Stacking](https://mui.com/x/react-charts/stacking/)
85
- *
86
- * API:
87
- *
88
- * - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
89
- */
90
- function AreaPlot(props) {
91
- var slots = props.slots,
92
- slotProps = props.slotProps,
93
- onItemClick = props.onItemClick,
94
- skipAnimation = props.skipAnimation,
95
- other = _objectWithoutProperties(props, _excluded);
96
- var completedData = useAggregatedData();
97
- return /*#__PURE__*/_jsx("g", _extends({}, other, {
98
- children: completedData.reverse().map(function (_ref2) {
99
- var d = _ref2.d,
100
- seriesId = _ref2.seriesId,
101
- color = _ref2.color,
102
- highlightScope = _ref2.highlightScope,
103
- area = _ref2.area;
104
- return !!area && /*#__PURE__*/_jsx(AreaElement, {
105
- id: seriesId,
106
- d: d,
107
- color: color,
108
- highlightScope: highlightScope,
109
- slots: slots,
110
- slotProps: slotProps,
111
- onClick: onItemClick && function (event) {
112
- return onItemClick(event, {
113
- type: 'line',
114
- seriesId: seriesId
115
- });
116
- },
117
- skipAnimation: skipAnimation
118
- }, seriesId);
119
- })
120
- }));
121
- }
122
- process.env.NODE_ENV !== "production" ? AreaPlot.propTypes = {
123
- // ----------------------------- Warning --------------------------------
124
- // | These PropTypes are generated from the TypeScript type definitions |
125
- // | To update them edit the TypeScript types and run "yarn proptypes" |
126
- // ----------------------------------------------------------------------
127
- /**
128
- * Callback fired when a line area item is clicked.
129
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
130
- * @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
131
- */
132
- onItemClick: PropTypes.func,
133
- /**
134
- * If `true`, animations are skipped.
135
- * @default false
136
- */
137
- skipAnimation: PropTypes.bool,
138
- /**
139
- * The props used for each component slot.
140
- * @default {}
141
- */
142
- slotProps: PropTypes.object,
143
- /**
144
- * Overridable component slots.
145
- * @default {}
146
- */
147
- slots: PropTypes.object
148
- } : void 0;
149
- export { AreaPlot };