@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,97 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["slots", "slotProps"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import { SeriesContext } from '../context/SeriesContextProvider';
7
- import { CartesianContext } from '../context/CartesianContextProvider';
8
- import { LineHighlightElement } from './LineHighlightElement';
9
- import { getValueToPositionMapper } from '../hooks/useScale';
10
- import { InteractionContext } from '../context/InteractionProvider';
11
- import { DEFAULT_X_AXIS_KEY } from '../constants';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- /**
14
- * Demos:
15
- *
16
- * - [Lines](https://mui.com/x/react-charts/lines/)
17
- * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
18
- *
19
- * API:
20
- *
21
- * - [LineHighlightPlot API](https://mui.com/x/api/charts/line-highlight-plot/)
22
- */
23
- function LineHighlightPlot(props) {
24
- var _axis$x, _slots$lineHighlight;
25
- var slots = props.slots,
26
- slotProps = props.slotProps,
27
- other = _objectWithoutProperties(props, _excluded);
28
- var seriesData = React.useContext(SeriesContext).line;
29
- var axisData = React.useContext(CartesianContext);
30
- var _React$useContext = React.useContext(InteractionContext),
31
- axis = _React$useContext.axis;
32
- var highlightedIndex = (_axis$x = axis.x) == null ? void 0 : _axis$x.index;
33
- if (highlightedIndex === undefined) {
34
- return null;
35
- }
36
- if (seriesData === undefined) {
37
- return null;
38
- }
39
- var series = seriesData.series,
40
- stackingGroups = seriesData.stackingGroups;
41
- var xAxis = axisData.xAxis,
42
- yAxis = axisData.yAxis,
43
- xAxisIds = axisData.xAxisIds,
44
- yAxisIds = axisData.yAxisIds;
45
- var defaultXAxisId = xAxisIds[0];
46
- var defaultYAxisId = yAxisIds[0];
47
- var Element = (_slots$lineHighlight = slots == null ? void 0 : slots.lineHighlight) != null ? _slots$lineHighlight : LineHighlightElement;
48
- return /*#__PURE__*/_jsx("g", _extends({}, other, {
49
- children: stackingGroups.flatMap(function (_ref) {
50
- var groupIds = _ref.ids;
51
- return groupIds.flatMap(function (seriesId) {
52
- var _series$seriesId = series[seriesId],
53
- _series$seriesId$xAxi = _series$seriesId.xAxisKey,
54
- xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
55
- _series$seriesId$yAxi = _series$seriesId.yAxisKey,
56
- yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
57
- stackedData = _series$seriesId.stackedData,
58
- data = _series$seriesId.data,
59
- disableHighlight = _series$seriesId.disableHighlight;
60
- if (disableHighlight || data[highlightedIndex] == null) {
61
- return null;
62
- }
63
- var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
64
- var yScale = yAxis[yAxisKey].scale;
65
- var xData = xAxis[xAxisKey].data;
66
- if (xData === undefined) {
67
- 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."));
68
- }
69
- var x = xScale(xData[highlightedIndex]);
70
- var y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
71
- return /*#__PURE__*/_jsx(Element, _extends({
72
- id: seriesId,
73
- color: series[seriesId].color,
74
- x: x,
75
- y: y
76
- }, slotProps == null ? void 0 : slotProps.lineHighlight), "".concat(seriesId));
77
- });
78
- })
79
- }));
80
- }
81
- process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
82
- // ----------------------------- Warning --------------------------------
83
- // | These PropTypes are generated from the TypeScript type definitions |
84
- // | To update them edit the TypeScript types and run "yarn proptypes" |
85
- // ----------------------------------------------------------------------
86
- /**
87
- * The props used for each component slot.
88
- * @default {}
89
- */
90
- slotProps: PropTypes.object,
91
- /**
92
- * Overridable component slots.
93
- * @default {}
94
- */
95
- slots: PropTypes.object
96
- } : void 0;
97
- export { LineHighlightPlot };
@@ -1,144 +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", "skipAnimation", "onItemClick"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import { line as d3Line } from 'd3-shape';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
- import { CartesianContext } from '../context/CartesianContextProvider';
9
- import { LineElement } from './LineElement';
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 linePath = d3Line().x(function (d) {
52
- return xScale(d.x);
53
- }).defined(function (_, i) {
54
- return connectNulls || data[i] != null;
55
- }).y(function (d) {
56
- return yScale(d.y[1]);
57
- });
58
- var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
59
- return {
60
- x: x,
61
- y: stackedData[index]
62
- };
63
- })) != null ? _xData$map : [];
64
- var d3Data = connectNulls ? formattedData.filter(function (_, i) {
65
- return data[i] != null;
66
- }) : formattedData;
67
- var d = linePath.curve(getCurveFactory(series[seriesId].curve))(d3Data) || '';
68
- return _extends({}, series[seriesId], {
69
- d: d,
70
- seriesId: seriesId
71
- });
72
- });
73
- });
74
- };
75
-
76
- /**
77
- * Demos:
78
- *
79
- * - [Lines](https://mui.com/x/react-charts/lines/)
80
- * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
81
- *
82
- * API:
83
- *
84
- * - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
85
- */
86
- function LinePlot(props) {
87
- var slots = props.slots,
88
- slotProps = props.slotProps,
89
- skipAnimation = props.skipAnimation,
90
- onItemClick = props.onItemClick,
91
- other = _objectWithoutProperties(props, _excluded);
92
- var completedData = useAggregatedData();
93
- return /*#__PURE__*/_jsx("g", _extends({}, other, {
94
- children: completedData.map(function (_ref2) {
95
- var d = _ref2.d,
96
- seriesId = _ref2.seriesId,
97
- color = _ref2.color,
98
- highlightScope = _ref2.highlightScope;
99
- return /*#__PURE__*/_jsx(LineElement, {
100
- id: seriesId,
101
- d: d,
102
- color: color,
103
- highlightScope: highlightScope,
104
- skipAnimation: skipAnimation,
105
- slots: slots,
106
- slotProps: slotProps,
107
- onClick: onItemClick && function (event) {
108
- return onItemClick(event, {
109
- type: 'line',
110
- seriesId: seriesId
111
- });
112
- }
113
- }, seriesId);
114
- })
115
- }));
116
- }
117
- process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
118
- // ----------------------------- Warning --------------------------------
119
- // | These PropTypes are generated from the TypeScript type definitions |
120
- // | To update them edit the TypeScript types and run "yarn proptypes" |
121
- // ----------------------------------------------------------------------
122
- /**
123
- * Callback fired when a line item is clicked.
124
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
125
- * @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
126
- */
127
- onItemClick: PropTypes.func,
128
- /**
129
- * If `true`, animations are skipped.
130
- * @default false
131
- */
132
- skipAnimation: PropTypes.bool,
133
- /**
134
- * The props used for each component slot.
135
- * @default {}
136
- */
137
- slotProps: PropTypes.object,
138
- /**
139
- * Overridable component slots.
140
- * @default {}
141
- */
142
- slots: PropTypes.object
143
- } : void 0;
144
- export { LinePlot };
@@ -1,153 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "highlightScope", "onClick", "skipAnimation"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import composeClasses from '@mui/utils/composeClasses';
7
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
8
- import { styled } from '@mui/material/styles';
9
- import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
- import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
11
- import { animated, to, useSpring } from '@react-spring/web';
12
- import { getSymbol } from '../internals/utils';
13
- import { InteractionContext } from '../context/InteractionProvider';
14
- import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- export function getMarkElementUtilityClass(slot) {
17
- return generateUtilityClass('MuiMarkElement', slot);
18
- }
19
- export var markElementClasses = generateUtilityClasses('MuiMarkElement', ['root', 'highlighted', 'faded']);
20
- var useUtilityClasses = function useUtilityClasses(ownerState) {
21
- var classes = ownerState.classes,
22
- id = ownerState.id,
23
- isFaded = ownerState.isFaded,
24
- isHighlighted = ownerState.isHighlighted;
25
- var slots = {
26
- root: ['root', "series-".concat(id), isHighlighted && 'highlighted', isFaded && 'faded']
27
- };
28
- return composeClasses(slots, getMarkElementUtilityClass, classes);
29
- };
30
- var MarkElementPath = styled(animated.path, {
31
- name: 'MuiMarkElement',
32
- slot: 'Root',
33
- overridesResolver: function overridesResolver(_, styles) {
34
- return styles.root;
35
- }
36
- })(function (_ref) {
37
- var ownerState = _ref.ownerState,
38
- theme = _ref.theme;
39
- return {
40
- fill: (theme.vars || theme).palette.background.paper,
41
- stroke: ownerState.color,
42
- strokeWidth: 2
43
- };
44
- });
45
- MarkElementPath.propTypes = {
46
- // ----------------------------- Warning --------------------------------
47
- // | These PropTypes are generated from the TypeScript type definitions |
48
- // | To update them edit the TypeScript types and run "yarn proptypes" |
49
- // ----------------------------------------------------------------------
50
- as: PropTypes.elementType,
51
- ownerState: PropTypes.shape({
52
- classes: PropTypes.object,
53
- color: PropTypes.string.isRequired,
54
- id: PropTypes.string.isRequired,
55
- isFaded: PropTypes.bool.isRequired,
56
- isHighlighted: PropTypes.bool.isRequired
57
- }).isRequired,
58
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
59
- };
60
- /**
61
- * Demos:
62
- *
63
- * - [Lines](https://mui.com/x/react-charts/lines/)
64
- * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
65
- *
66
- * API:
67
- *
68
- * - [MarkElement API](https://mui.com/x/api/charts/mark-element/)
69
- */
70
- function MarkElement(props) {
71
- var _axis$x;
72
- var x = props.x,
73
- y = props.y,
74
- id = props.id,
75
- innerClasses = props.classes,
76
- color = props.color,
77
- shape = props.shape,
78
- dataIndex = props.dataIndex,
79
- highlightScope = props.highlightScope,
80
- onClick = props.onClick,
81
- skipAnimation = props.skipAnimation,
82
- other = _objectWithoutProperties(props, _excluded);
83
- var getInteractionItemProps = useInteractionItemProps(highlightScope);
84
- var _React$useContext = React.useContext(InteractionContext),
85
- item = _React$useContext.item,
86
- axis = _React$useContext.axis;
87
- var isHighlighted = ((_axis$x = axis.x) == null ? void 0 : _axis$x.index) === dataIndex || getIsHighlighted(item, {
88
- type: 'line',
89
- seriesId: id
90
- }, highlightScope);
91
- var isFaded = !isHighlighted && getIsFaded(item, {
92
- type: 'line',
93
- seriesId: id
94
- }, highlightScope);
95
- var position = useSpring({
96
- x: x,
97
- y: y,
98
- immediate: skipAnimation
99
- });
100
- var ownerState = {
101
- id: id,
102
- classes: innerClasses,
103
- isHighlighted: isHighlighted,
104
- isFaded: isFaded,
105
- color: color
106
- };
107
- var classes = useUtilityClasses(ownerState);
108
- return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, {
109
- style: {
110
- transform: to([position.x, position.y], function (pX, pY) {
111
- return "translate(".concat(pX, "px, ").concat(pY, "px)");
112
- }),
113
- transformOrigin: to([position.x, position.y], function (pX, pY) {
114
- return "".concat(pX, "px ").concat(pY, "px");
115
- })
116
- },
117
- ownerState: ownerState,
118
- className: classes.root,
119
- d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
120
- onClick: onClick,
121
- cursor: onClick ? 'pointer' : 'unset'
122
- }, getInteractionItemProps({
123
- type: 'line',
124
- seriesId: id,
125
- dataIndex: dataIndex
126
- })));
127
- }
128
- process.env.NODE_ENV !== "production" ? MarkElement.propTypes = {
129
- // ----------------------------- Warning --------------------------------
130
- // | These PropTypes are generated from the TypeScript type definitions |
131
- // | To update them edit the TypeScript types and run "yarn proptypes" |
132
- // ----------------------------------------------------------------------
133
- classes: PropTypes.object,
134
- /**
135
- * The index to the element in the series' data array.
136
- */
137
- dataIndex: PropTypes.number.isRequired,
138
- highlightScope: PropTypes.shape({
139
- faded: PropTypes.oneOf(['global', 'none', 'series']),
140
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
141
- }),
142
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
143
- /**
144
- * The shape of the marker.
145
- */
146
- shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired,
147
- /**
148
- * If `true`, animations are skipped.
149
- * @default false
150
- */
151
- skipAnimation: PropTypes.bool
152
- } : void 0;
153
- export { MarkElement };
@@ -1,178 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
5
- import * as React from 'react';
6
- import PropTypes from 'prop-types';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
- import { CartesianContext } from '../context/CartesianContextProvider';
9
- import { MarkElement } from './MarkElement';
10
- import { getValueToPositionMapper } from '../hooks/useScale';
11
- import { DEFAULT_X_AXIS_KEY } from '../constants';
12
- import { DrawingContext } from '../context/DrawingProvider';
13
- import { cleanId } from '../internals/utils';
14
- import { jsx as _jsx } from "react/jsx-runtime";
15
- /**
16
- * Demos:
17
- *
18
- * - [Lines](https://mui.com/x/react-charts/lines/)
19
- * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
20
- *
21
- * API:
22
- *
23
- * - [MarkPlot API](https://mui.com/x/api/charts/mark-plot/)
24
- */
25
- function MarkPlot(props) {
26
- var _slots$mark;
27
- var slots = props.slots,
28
- slotProps = props.slotProps,
29
- skipAnimation = props.skipAnimation,
30
- onItemClick = props.onItemClick,
31
- other = _objectWithoutProperties(props, _excluded);
32
- var seriesData = React.useContext(SeriesContext).line;
33
- var axisData = React.useContext(CartesianContext);
34
- var _React$useContext = React.useContext(DrawingContext),
35
- chartId = _React$useContext.chartId;
36
- var Mark = (_slots$mark = slots == null ? void 0 : slots.mark) != null ? _slots$mark : MarkElement;
37
- if (seriesData === undefined) {
38
- return null;
39
- }
40
- var series = seriesData.series,
41
- stackingGroups = seriesData.stackingGroups;
42
- var xAxis = axisData.xAxis,
43
- yAxis = axisData.yAxis,
44
- xAxisIds = axisData.xAxisIds,
45
- yAxisIds = axisData.yAxisIds;
46
- var defaultXAxisId = xAxisIds[0];
47
- var defaultYAxisId = yAxisIds[0];
48
- return /*#__PURE__*/_jsx("g", _extends({}, other, {
49
- children: stackingGroups.flatMap(function (_ref) {
50
- var groupIds = _ref.ids;
51
- return groupIds.map(function (seriesId) {
52
- var _series$seriesId = series[seriesId],
53
- _series$seriesId$xAxi = _series$seriesId.xAxisKey,
54
- xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
55
- _series$seriesId$yAxi = _series$seriesId.yAxisKey,
56
- yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
57
- stackedData = _series$seriesId.stackedData,
58
- data = _series$seriesId.data,
59
- _series$seriesId$show = _series$seriesId.showMark,
60
- showMark = _series$seriesId$show === void 0 ? true : _series$seriesId$show;
61
- if (showMark === false) {
62
- return null;
63
- }
64
- var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
65
- var yScale = yAxis[yAxisKey].scale;
66
- var xData = xAxis[xAxisKey].data;
67
- var xRange = xAxis[xAxisKey].scale.range();
68
- var yRange = yScale.range();
69
- var isInRange = function isInRange(_ref2) {
70
- var x = _ref2.x,
71
- y = _ref2.y;
72
- if (x < Math.min.apply(Math, _toConsumableArray(xRange)) || x > Math.max.apply(Math, _toConsumableArray(xRange))) {
73
- return false;
74
- }
75
- if (y < Math.min.apply(Math, _toConsumableArray(yRange)) || y > Math.max.apply(Math, _toConsumableArray(yRange))) {
76
- return false;
77
- }
78
- return true;
79
- };
80
- if (xData === undefined) {
81
- 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."));
82
- }
83
- var clipId = cleanId("".concat(chartId, "-").concat(seriesId, "-line-clip")); // We assume that if displaying line mark, the line will also be rendered
84
-
85
- return /*#__PURE__*/_jsx("g", {
86
- clipPath: "url(#".concat(clipId, ")"),
87
- children: xData == null ? void 0 : xData.map(function (x, index) {
88
- var value = data[index] == null ? null : stackedData[index][1];
89
- return {
90
- x: xScale(x),
91
- y: value === null ? null : yScale(value),
92
- position: x,
93
- value: value,
94
- index: index
95
- };
96
- }).filter(function (_ref3) {
97
- var x = _ref3.x,
98
- y = _ref3.y,
99
- index = _ref3.index,
100
- position = _ref3.position,
101
- value = _ref3.value;
102
- if (value === null || y === null) {
103
- // Remove missing data point
104
- return false;
105
- }
106
- if (!isInRange({
107
- x: x,
108
- y: y
109
- })) {
110
- // Remove out of range
111
- return false;
112
- }
113
- if (showMark === true) {
114
- return true;
115
- }
116
- return showMark({
117
- x: x,
118
- y: y,
119
- index: index,
120
- position: position,
121
- value: value
122
- });
123
- }).map(function (_ref4) {
124
- var x = _ref4.x,
125
- y = _ref4.y,
126
- index = _ref4.index;
127
- return /*#__PURE__*/_jsx(Mark, _extends({
128
- id: seriesId,
129
- dataIndex: index,
130
- shape: "circle",
131
- color: series[seriesId].color,
132
- x: x,
133
- y: y // Don't know why TS doesn't get from the filter that y can't be null
134
- ,
135
- highlightScope: series[seriesId].highlightScope,
136
- skipAnimation: skipAnimation,
137
- onClick: onItemClick && function (event) {
138
- return onItemClick(event, {
139
- type: 'line',
140
- seriesId: seriesId,
141
- dataIndex: index
142
- });
143
- }
144
- }, slotProps == null ? void 0 : slotProps.mark), "".concat(seriesId, "-").concat(index));
145
- })
146
- }, seriesId);
147
- });
148
- })
149
- }));
150
- }
151
- process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
152
- // ----------------------------- Warning --------------------------------
153
- // | These PropTypes are generated from the TypeScript type definitions |
154
- // | To update them edit the TypeScript types and run "yarn proptypes" |
155
- // ----------------------------------------------------------------------
156
- /**
157
- * Callback fired when a line mark item is clicked.
158
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
159
- * @param {LineItemIdentifier} lineItemIdentifier The line mark item identifier.
160
- */
161
- onItemClick: PropTypes.func,
162
- /**
163
- * If `true`, animations are skipped.
164
- * @default false
165
- */
166
- skipAnimation: PropTypes.bool,
167
- /**
168
- * The props used for each component slot.
169
- * @default {}
170
- */
171
- slotProps: PropTypes.object,
172
- /**
173
- * Overridable component slots.
174
- * @default {}
175
- */
176
- slots: PropTypes.object
177
- } : void 0;
178
- export { MarkPlot };
@@ -1,54 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- export var getExtremumX = function getExtremumX(params) {
4
- var _axis$data, _axis$data2;
5
- var axis = params.axis;
6
- var minX = Math.min.apply(Math, _toConsumableArray((_axis$data = axis.data) != null ? _axis$data : []));
7
- var maxX = Math.max.apply(Math, _toConsumableArray((_axis$data2 = axis.data) != null ? _axis$data2 : []));
8
- return [minX, maxX];
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
- }
25
- export var getExtremumY = function getExtremumY(params) {
26
- var series = params.series,
27
- axis = params.axis,
28
- isDefaultAxis = params.isDefaultAxis;
29
- return Object.keys(series).filter(function (seriesId) {
30
- return series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined;
31
- }).reduce(function (acc, seriesId) {
32
- var _series$seriesId = series[seriesId],
33
- area = _series$seriesId.area,
34
- stackedData = _series$seriesId.stackedData;
35
- var isArea = area !== undefined;
36
- var getValues = isArea ? function (d) {
37
- return d;
38
- } : function (d) {
39
- return [d[1], d[1]];
40
- }; // Since this series is not used to display an area, we do not consider the base (the d[0]).
41
-
42
- var seriesExtremums = getSeriesExtremums(getValues, stackedData);
43
- if (acc[0] === null) {
44
- return seriesExtremums;
45
- }
46
- if (seriesExtremums[0] === null) {
47
- return acc;
48
- }
49
- var _seriesExtremums = _slicedToArray(seriesExtremums, 2),
50
- seriesMin = _seriesExtremums[0],
51
- seriesMax = _seriesExtremums[1];
52
- return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
53
- }, [null, null]);
54
- };