@mui/x-charts 7.7.0 → 7.8.0

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 (167) hide show
  1. package/BarChart/BarChart.js +21 -104
  2. package/BarChart/BarElement.d.ts +225 -228
  3. package/BarChart/BarLabel/BarLabel.d.ts +225 -228
  4. package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
  5. package/BarChart/BarLabel/BarLabelPlot.js +1 -24
  6. package/BarChart/BarLabel/getBarLabel.d.ts +1 -1
  7. package/BarChart/BarPlot.js +2 -2
  8. package/BarChart/checkScaleErrors.d.ts +5 -9
  9. package/BarChart/types.d.ts +2 -2
  10. package/BarChart/useBarChartProps.d.ts +34 -0
  11. package/BarChart/useBarChartProps.js +143 -0
  12. package/CHANGELOG.md +181 -0
  13. package/ChartContainer/ChartContainer.d.ts +2 -2
  14. package/ChartContainer/ChartContainer.js +6 -10
  15. package/ChartContainer/useChartContainerHooks.d.ts +11 -0
  16. package/ChartContainer/useChartContainerHooks.js +34 -0
  17. package/ChartContainer/usePluginsMerge.d.ts +1 -2
  18. package/ChartsAxis/ChartsAxis.js +2 -2
  19. package/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  20. package/ChartsGrid/ChartsGrid.js +2 -2
  21. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  22. package/ChartsReferenceLine/common.d.ts +0 -1
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  24. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  25. package/ChartsTooltip/ChartsTooltipTable.d.ts +0 -1
  26. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -4
  27. package/ChartsXAxis/ChartsXAxis.js +2 -2
  28. package/ChartsYAxis/ChartsYAxis.js +5 -3
  29. package/Gauge/GaugeProvider.d.ts +1 -1
  30. package/LineChart/AnimatedArea.d.ts +225 -228
  31. package/LineChart/AnimatedLine.d.ts +225 -228
  32. package/LineChart/AreaPlot.js +2 -2
  33. package/LineChart/LineChart.js +24 -106
  34. package/LineChart/LineHighlightPlot.js +2 -2
  35. package/LineChart/LinePlot.js +2 -2
  36. package/LineChart/MarkPlot.js +2 -2
  37. package/LineChart/useLineChartProps.d.ts +40 -0
  38. package/LineChart/useLineChartProps.js +152 -0
  39. package/PieChart/PieArc.d.ts +0 -1
  40. package/PieChart/PieArcLabel.d.ts +0 -1
  41. package/PieChart/dataTransform/transition.d.ts +0 -1
  42. package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -2
  43. package/ScatterChart/ScatterChart.js +20 -75
  44. package/ScatterChart/ScatterPlot.js +2 -2
  45. package/ScatterChart/useScatterChartProps.d.ts +31 -0
  46. package/ScatterChart/useScatterChartProps.js +116 -0
  47. package/context/CartesianProvider/CartesianContext.d.ts +25 -0
  48. package/context/CartesianProvider/CartesianContext.js +21 -0
  49. package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
  50. package/context/CartesianProvider/CartesianProvider.js +44 -0
  51. package/context/CartesianProvider/computeValue.d.ts +19 -0
  52. package/context/CartesianProvider/computeValue.js +104 -0
  53. package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
  54. package/context/CartesianProvider/getAxisExtremum.js +28 -0
  55. package/context/CartesianProvider/index.d.ts +9 -0
  56. package/context/CartesianProvider/index.js +51 -0
  57. package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
  58. package/context/CartesianProvider/normalizeAxis.js +23 -0
  59. package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
  60. package/context/CartesianProvider/useCartesianContext.js +17 -0
  61. package/context/ColorProvider.d.ts +2 -2
  62. package/esm/BarChart/BarChart.js +21 -104
  63. package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
  64. package/esm/BarChart/BarPlot.js +2 -2
  65. package/esm/BarChart/useBarChartProps.js +135 -0
  66. package/esm/ChartContainer/ChartContainer.js +5 -9
  67. package/esm/ChartContainer/useChartContainerHooks.js +24 -0
  68. package/esm/ChartsAxis/ChartsAxis.js +2 -2
  69. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  70. package/esm/ChartsGrid/ChartsGrid.js +2 -2
  71. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  72. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  73. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  74. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  75. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  76. package/esm/ChartsYAxis/ChartsYAxis.js +5 -3
  77. package/esm/LineChart/AreaPlot.js +2 -2
  78. package/esm/LineChart/LineChart.js +24 -106
  79. package/esm/LineChart/LineHighlightPlot.js +2 -2
  80. package/esm/LineChart/LinePlot.js +2 -2
  81. package/esm/LineChart/MarkPlot.js +2 -2
  82. package/esm/LineChart/useLineChartProps.js +144 -0
  83. package/esm/ScatterChart/ScatterChart.js +20 -75
  84. package/esm/ScatterChart/ScatterPlot.js +2 -2
  85. package/esm/ScatterChart/useScatterChartProps.js +108 -0
  86. package/esm/context/CartesianProvider/CartesianContext.js +13 -0
  87. package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
  88. package/esm/context/CartesianProvider/computeValue.js +97 -0
  89. package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
  90. package/esm/context/CartesianProvider/index.js +10 -0
  91. package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
  92. package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
  93. package/esm/hooks/useAxisEvents.js +7 -10
  94. package/esm/hooks/useColorScale.js +3 -3
  95. package/esm/hooks/useScale.js +4 -5
  96. package/esm/hooks/useTicks.js +2 -1
  97. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  98. package/esm/internals/getSVGPoint.js +11 -0
  99. package/esm/internals/index.js +8 -2
  100. package/esm/internals/utils.js +0 -12
  101. package/hooks/useAxisEvents.js +8 -11
  102. package/hooks/useChartDimensions.d.ts +1 -1
  103. package/hooks/useColor.d.ts +1 -1
  104. package/hooks/useColorScale.js +3 -3
  105. package/hooks/useDrawingArea.d.ts +2 -8
  106. package/hooks/useScale.js +4 -7
  107. package/hooks/useTicks.js +2 -1
  108. package/index.js +1 -1
  109. package/internals/components/AxisSharedComponents.d.ts +0 -1
  110. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
  111. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  112. package/internals/defaultizeColor.d.ts +68 -68
  113. package/internals/getSVGPoint.d.ts +6 -0
  114. package/internals/getSVGPoint.js +17 -0
  115. package/internals/getWordsByLines.d.ts +0 -1
  116. package/internals/index.d.ts +9 -1
  117. package/internals/index.js +69 -5
  118. package/internals/useAnimatedPath.d.ts +0 -1
  119. package/internals/utils.d.ts +0 -6
  120. package/internals/utils.js +0 -13
  121. package/models/axis.d.ts +1 -2
  122. package/models/plugin.d.ts +4 -1
  123. package/modern/BarChart/BarChart.js +21 -104
  124. package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
  125. package/modern/BarChart/BarPlot.js +2 -2
  126. package/modern/BarChart/useBarChartProps.js +135 -0
  127. package/modern/ChartContainer/ChartContainer.js +5 -9
  128. package/modern/ChartContainer/useChartContainerHooks.js +24 -0
  129. package/modern/ChartsAxis/ChartsAxis.js +2 -2
  130. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
  131. package/modern/ChartsGrid/ChartsGrid.js +2 -2
  132. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  133. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  134. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  135. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  136. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  137. package/modern/ChartsYAxis/ChartsYAxis.js +5 -3
  138. package/modern/LineChart/AreaPlot.js +2 -2
  139. package/modern/LineChart/LineChart.js +24 -106
  140. package/modern/LineChart/LineHighlightPlot.js +2 -2
  141. package/modern/LineChart/LinePlot.js +2 -2
  142. package/modern/LineChart/MarkPlot.js +2 -2
  143. package/modern/LineChart/useLineChartProps.js +144 -0
  144. package/modern/ScatterChart/ScatterChart.js +20 -75
  145. package/modern/ScatterChart/ScatterPlot.js +2 -2
  146. package/modern/ScatterChart/useScatterChartProps.js +108 -0
  147. package/modern/context/CartesianProvider/CartesianContext.js +13 -0
  148. package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
  149. package/modern/context/CartesianProvider/computeValue.js +97 -0
  150. package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
  151. package/modern/context/CartesianProvider/index.js +10 -0
  152. package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
  153. package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
  154. package/modern/hooks/useAxisEvents.js +7 -10
  155. package/modern/hooks/useColorScale.js +3 -3
  156. package/modern/hooks/useScale.js +4 -5
  157. package/modern/hooks/useTicks.js +2 -1
  158. package/modern/index.js +1 -1
  159. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  160. package/modern/internals/getSVGPoint.js +11 -0
  161. package/modern/internals/index.js +8 -2
  162. package/modern/internals/utils.js +0 -12
  163. package/package.json +3 -3
  164. package/context/CartesianContextProvider.d.ts +0 -61
  165. package/context/CartesianContextProvider.js +0 -220
  166. package/esm/context/CartesianContextProvider.js +0 -211
  167. package/modern/context/CartesianContextProvider.js +0 -211
@@ -10,7 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _d3Shape = require("d3-shape");
13
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
13
+ var _CartesianProvider = require("../context/CartesianProvider");
14
14
  var _AreaElement = require("./AreaElement");
15
15
  var _useScale = require("../hooks/useScale");
16
16
  var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
@@ -23,7 +23,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
23
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
24
  const useAggregatedData = () => {
25
25
  const seriesData = (0, _useSeries.useLineSeries)();
26
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
26
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
27
27
  if (seriesData === undefined) {
28
28
  return [];
29
29
  }
@@ -7,14 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.LineChart = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
- var _useId = _interopRequireDefault(require("@mui/utils/useId"));
11
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
11
  var _AreaPlot = require("./AreaPlot");
13
12
  var _LinePlot = require("./LinePlot");
14
13
  var _ResponsiveChartContainer = require("../ResponsiveChartContainer");
15
14
  var _MarkPlot = require("./MarkPlot");
16
15
  var _ChartsAxis = require("../ChartsAxis/ChartsAxis");
17
- var _constants = require("../constants");
18
16
  var _ChartsTooltip = require("../ChartsTooltip");
19
17
  var _ChartsLegend = require("../ChartsLegend");
20
18
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
@@ -23,6 +21,7 @@ var _LineHighlightPlot = require("./LineHighlightPlot");
23
21
  var _ChartsGrid = require("../ChartsGrid");
24
22
  var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
25
23
  var _ChartsOverlay = require("../ChartsOverlay");
24
+ var _useLineChartProps = require("./useLineChartProps");
26
25
  var _jsxRuntime = require("react/jsx-runtime");
27
26
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
28
27
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -38,110 +37,29 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
38
37
  */
39
38
  const LineChart = exports.LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
40
39
  const {
41
- xAxis,
42
- yAxis,
43
- series,
44
- width,
45
- height,
46
- margin,
47
- colors,
48
- dataset,
49
- sx,
50
- tooltip,
51
- onAxisClick,
52
- onAreaClick,
53
- onLineClick,
54
- onMarkClick,
55
- axisHighlight = {
56
- x: 'line'
57
- },
58
- disableLineItemHighlight,
59
- legend,
60
- grid,
61
- topAxis,
62
- leftAxis,
63
- rightAxis,
64
- bottomAxis,
65
- children,
66
- slots,
67
- slotProps,
68
- skipAnimation,
69
- loading,
70
- highlightedItem,
71
- onHighlightChange
72
- } = props;
73
- const id = (0, _useId.default)();
74
- const clipPathId = `${id}-clip-path`;
75
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, {
76
- ref: ref,
77
- series: series.map(s => (0, _extends2.default)({
78
- disableHighlight: !!disableLineItemHighlight,
79
- type: 'line'
80
- }, s)),
81
- width: width,
82
- height: height,
83
- margin: margin,
84
- xAxis: xAxis ?? [{
85
- id: _constants.DEFAULT_X_AXIS_KEY,
86
- scaleType: 'point',
87
- data: Array.from({
88
- length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
89
- }, (_, index) => index)
90
- }],
91
- yAxis: yAxis,
92
- colors: colors,
93
- dataset: dataset,
94
- sx: sx,
95
- disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
96
- highlightedItem: highlightedItem,
97
- onHighlightChange: onHighlightChange,
98
- children: [onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, {
99
- onAxisClick: onAxisClick
100
- }), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
101
- vertical: grid.vertical,
102
- horizontal: grid.horizontal
103
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
104
- clipPath: `url(#${clipPathId})`,
105
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaPlot.AreaPlot, {
106
- slots: slots,
107
- slotProps: slotProps,
108
- onItemClick: onAreaClick,
109
- skipAnimation: skipAnimation
110
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinePlot.LinePlot, {
111
- slots: slots,
112
- slotProps: slotProps,
113
- onItemClick: onLineClick,
114
- skipAnimation: skipAnimation
115
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
116
- loading: loading,
117
- slots: slots,
118
- slotProps: slotProps
119
- })]
120
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
121
- topAxis: topAxis,
122
- leftAxis: leftAxis,
123
- rightAxis: rightAxis,
124
- bottomAxis: bottomAxis,
125
- slots: slots,
126
- slotProps: slotProps
127
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlight)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MarkPlot.MarkPlot, {
128
- slots: slots,
129
- slotProps: slotProps,
130
- onItemClick: onMarkClick,
131
- skipAnimation: skipAnimation
132
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineHighlightPlot.LineHighlightPlot, {
133
- slots: slots,
134
- slotProps: slotProps
135
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
136
- slots: slots,
137
- slotProps: slotProps
138
- })), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltip, {
139
- slots: slots,
140
- slotProps: slotProps
141
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, {
142
- id: clipPathId
143
- }), children]
144
- });
40
+ chartContainerProps,
41
+ axisClickHandlerProps,
42
+ gridProps,
43
+ clipPathProps,
44
+ clipPathGroupProps,
45
+ areaPlotProps,
46
+ linePlotProps,
47
+ markPlotProps,
48
+ overlayProps,
49
+ chartsAxisProps,
50
+ axisHighlightProps,
51
+ lineHighlightPlotProps,
52
+ legendProps,
53
+ tooltipProps,
54
+ children
55
+ } = (0, _useLineChartProps.useLineChartProps)(props);
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, (0, _extends2.default)({
57
+ ref: ref
58
+ }, chartContainerProps, {
59
+ children: [props.onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, (0, _extends2.default)({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaPlot.AreaPlot, (0, _extends2.default)({}, areaPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinePlot.LinePlot, (0, _extends2.default)({}, linePlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps))]
61
+ })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MarkPlot.MarkPlot, (0, _extends2.default)({}, markPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineHighlightPlot.LineHighlightPlot, (0, _extends2.default)({}, lineHighlightPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, (0, _extends2.default)({}, clipPathProps)), children]
62
+ }));
145
63
  });
146
64
  process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
147
65
  // ----------------------------- Warning --------------------------------
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
12
+ var _CartesianProvider = require("../context/CartesianProvider");
13
13
  var _LineHighlightElement = require("./LineHighlightElement");
14
14
  var _useScale = require("../hooks/useScale");
15
15
  var _InteractionProvider = require("../context/InteractionProvider");
@@ -37,7 +37,7 @@ function LineHighlightPlot(props) {
37
37
  } = props,
38
38
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
39
39
  const seriesData = (0, _useSeries.useLineSeries)();
40
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
40
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
41
41
  const {
42
42
  axis
43
43
  } = React.useContext(_InteractionProvider.InteractionContext);
@@ -10,7 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _d3Shape = require("d3-shape");
13
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
13
+ var _CartesianProvider = require("../context/CartesianProvider");
14
14
  var _LineElement = require("./LineElement");
15
15
  var _useScale = require("../hooks/useScale");
16
16
  var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
@@ -23,7 +23,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
23
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
24
  const useAggregatedData = () => {
25
25
  const seriesData = (0, _useSeries.useLineSeries)();
26
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
26
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
27
27
  if (seriesData === undefined) {
28
28
  return [];
29
29
  }
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
12
+ var _CartesianProvider = require("../context/CartesianProvider");
13
13
  var _MarkElement = require("./MarkElement");
14
14
  var _useScale = require("../hooks/useScale");
15
15
  var _useChartId = require("../hooks/useChartId");
@@ -40,7 +40,7 @@ function MarkPlot(props) {
40
40
  } = props,
41
41
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
42
42
  const seriesData = (0, _useSeries.useLineSeries)();
43
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
43
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
44
44
  const chartId = (0, _useChartId.useChartId)();
45
45
  const Mark = slots?.mark ?? _MarkElement.MarkElement;
46
46
  if (seriesData === undefined) {
@@ -0,0 +1,40 @@
1
+ import type { LineChartProps } from './LineChart';
2
+ import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
3
+ import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
4
+ import { ChartsGridProps } from '../ChartsGrid';
5
+ import { ChartsClipPathProps } from '../ChartsClipPath';
6
+ import { AreaPlotProps } from './AreaPlot';
7
+ import { LinePlotProps } from './LinePlot';
8
+ import { MarkPlotProps } from './MarkPlot';
9
+ import { ChartsOverlayProps } from '../ChartsOverlay';
10
+ import { ChartsAxisProps } from '../ChartsAxis';
11
+ import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
12
+ import { LineHighlightPlotProps } from './LineHighlightPlot';
13
+ import { ChartsLegendProps } from '../ChartsLegend';
14
+ import { ChartsTooltipProps } from '../ChartsTooltip';
15
+ /**
16
+ * A helper function that extracts LineChartProps from the input props
17
+ * and returns an object with props for the children components of LineChart.
18
+ *
19
+ * @param props The input props for LineChart
20
+ * @returns An object with props for the children components of LineChart
21
+ */
22
+ export declare const useLineChartProps: (props: LineChartProps) => {
23
+ chartContainerProps: ResponsiveChartContainerProps;
24
+ axisClickHandlerProps: ChartsOnAxisClickHandlerProps;
25
+ gridProps: ChartsGridProps;
26
+ clipPathProps: ChartsClipPathProps;
27
+ clipPathGroupProps: {
28
+ clipPath: string;
29
+ };
30
+ areaPlotProps: AreaPlotProps;
31
+ linePlotProps: LinePlotProps;
32
+ markPlotProps: MarkPlotProps;
33
+ overlayProps: ChartsOverlayProps;
34
+ chartsAxisProps: ChartsAxisProps;
35
+ axisHighlightProps: ChartsAxisHighlightProps;
36
+ lineHighlightPlotProps: LineHighlightPlotProps;
37
+ legendProps: ChartsLegendProps;
38
+ tooltipProps: ChartsTooltipProps;
39
+ children: import("react").ReactNode;
40
+ };
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useLineChartProps = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
10
+ var _constants = require("../constants");
11
+ /**
12
+ * A helper function that extracts LineChartProps from the input props
13
+ * and returns an object with props for the children components of LineChart.
14
+ *
15
+ * @param props The input props for LineChart
16
+ * @returns An object with props for the children components of LineChart
17
+ */
18
+ const useLineChartProps = props => {
19
+ const {
20
+ xAxis,
21
+ yAxis,
22
+ series,
23
+ width,
24
+ height,
25
+ margin,
26
+ colors,
27
+ dataset,
28
+ sx,
29
+ tooltip,
30
+ onAxisClick,
31
+ onAreaClick,
32
+ onLineClick,
33
+ onMarkClick,
34
+ axisHighlight,
35
+ disableLineItemHighlight,
36
+ legend,
37
+ grid,
38
+ topAxis,
39
+ leftAxis,
40
+ rightAxis,
41
+ bottomAxis,
42
+ children,
43
+ slots,
44
+ slotProps,
45
+ skipAnimation,
46
+ loading,
47
+ highlightedItem,
48
+ onHighlightChange
49
+ } = props;
50
+ const id = (0, _useId.default)();
51
+ const clipPathId = `${id}-clip-path`;
52
+ const chartContainerProps = {
53
+ series: series.map(s => (0, _extends2.default)({
54
+ disableHighlight: !!disableLineItemHighlight,
55
+ type: 'line'
56
+ }, s)),
57
+ width,
58
+ height,
59
+ margin,
60
+ colors,
61
+ dataset,
62
+ xAxis: xAxis ?? [{
63
+ id: _constants.DEFAULT_X_AXIS_KEY,
64
+ scaleType: 'point',
65
+ data: Array.from({
66
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
67
+ }, (_, index) => index)
68
+ }],
69
+ yAxis,
70
+ sx,
71
+ highlightedItem,
72
+ onHighlightChange,
73
+ disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
74
+ };
75
+ const axisClickHandlerProps = {
76
+ onAxisClick
77
+ };
78
+ const gridProps = {
79
+ vertical: grid?.vertical,
80
+ horizontal: grid?.horizontal
81
+ };
82
+ const clipPathGroupProps = {
83
+ clipPath: `url(#${clipPathId})`
84
+ };
85
+ const clipPathProps = {
86
+ id: clipPathId
87
+ };
88
+ const areaPlotProps = {
89
+ slots,
90
+ slotProps,
91
+ onItemClick: onAreaClick,
92
+ skipAnimation
93
+ };
94
+ const linePlotProps = {
95
+ slots,
96
+ slotProps,
97
+ onItemClick: onLineClick,
98
+ skipAnimation
99
+ };
100
+ const markPlotProps = {
101
+ slots,
102
+ slotProps,
103
+ onItemClick: onMarkClick,
104
+ skipAnimation
105
+ };
106
+ const overlayProps = {
107
+ slots,
108
+ slotProps,
109
+ loading
110
+ };
111
+ const chartsAxisProps = {
112
+ topAxis,
113
+ leftAxis,
114
+ rightAxis,
115
+ bottomAxis,
116
+ slots,
117
+ slotProps
118
+ };
119
+ const axisHighlightProps = (0, _extends2.default)({
120
+ x: 'line'
121
+ }, axisHighlight);
122
+ const lineHighlightPlotProps = {
123
+ slots,
124
+ slotProps
125
+ };
126
+ const legendProps = (0, _extends2.default)({}, legend, {
127
+ slots,
128
+ slotProps
129
+ });
130
+ const tooltipProps = (0, _extends2.default)({}, tooltip, {
131
+ slots,
132
+ slotProps
133
+ });
134
+ return {
135
+ chartContainerProps,
136
+ axisClickHandlerProps,
137
+ gridProps,
138
+ clipPathProps,
139
+ clipPathGroupProps,
140
+ areaPlotProps,
141
+ linePlotProps,
142
+ markPlotProps,
143
+ overlayProps,
144
+ chartsAxisProps,
145
+ axisHighlightProps,
146
+ lineHighlightPlotProps,
147
+ legendProps,
148
+ tooltipProps,
149
+ children
150
+ };
151
+ };
152
+ exports.useLineChartProps = useLineChartProps;
@@ -1,4 +1,3 @@
1
- /// <reference types="@react-spring/core" />
2
1
  import * as React from 'react';
3
2
  import { SpringValue } from '@react-spring/web';
4
3
  import { PieItemId } from '../models';
@@ -1,4 +1,3 @@
1
- /// <reference types="@react-spring/core" />
2
1
  import * as React from 'react';
3
2
  import { SpringValue } from '@react-spring/web';
4
3
  import { PieItemId } from '../models/seriesType/pie';
@@ -1,4 +1,3 @@
1
- /// <reference types="@react-spring/core" />
2
1
  import { UseTransitionProps } from '@react-spring/web';
3
2
  import { ValueWithHighlight } from './useTransformData';
4
3
  export declare const defaultTransitionConfig: UseTransitionProps<ValueWithHighlight>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ResponsiveChartContainerProps } from './ResponsiveChartContainer';
3
2
  /**
4
3
  * Wrapping div that take the shape of its parent.
@@ -6,5 +5,5 @@ import type { ResponsiveChartContainerProps } from './ResponsiveChartContainer';
6
5
  * @ignore - do not document.
7
6
  */
8
7
  export declare const ResizableContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
9
- ownerState: Pick<ResponsiveChartContainerProps, 'width' | 'height'>;
8
+ ownerState: Pick<ResponsiveChartContainerProps, "width" | "height">;
10
9
  }, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement>>, {}>;
@@ -18,6 +18,7 @@ var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
18
18
  var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler");
19
19
  var _ChartsGrid = require("../ChartsGrid");
20
20
  var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
21
+ var _useScatterChartProps = require("./useScatterChartProps");
21
22
  var _jsxRuntime = require("react/jsx-runtime");
22
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -33,81 +34,25 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
33
34
  */
34
35
  const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props, ref) {
35
36
  const {
36
- xAxis,
37
- yAxis,
38
- zAxis,
39
- series,
40
- tooltip,
41
- axisHighlight,
42
- voronoiMaxRadius,
43
- disableVoronoi,
44
- legend,
45
- width,
46
- height,
47
- margin,
48
- colors,
49
- sx,
50
- grid,
51
- topAxis,
52
- leftAxis,
53
- rightAxis,
54
- bottomAxis,
55
- onItemClick,
56
- children,
57
- slots,
58
- slotProps,
59
- loading,
60
- highlightedItem,
61
- onHighlightChange
62
- } = props;
63
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveChartContainer.ResponsiveChartContainer, {
64
- ref: ref,
65
- series: series.map(s => (0, _extends2.default)({
66
- type: 'scatter'
67
- }, s)),
68
- width: width,
69
- height: height,
70
- margin: margin,
71
- colors: colors,
72
- xAxis: xAxis,
73
- yAxis: yAxis,
74
- sx: sx,
75
- highlightedItem: highlightedItem,
76
- onHighlightChange: onHighlightChange,
77
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, {
78
- zAxis: zAxis,
79
- children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, {
80
- voronoiMaxRadius: voronoiMaxRadius,
81
- onItemClick: onItemClick
82
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
83
- topAxis: topAxis,
84
- leftAxis: leftAxis,
85
- rightAxis: rightAxis,
86
- bottomAxis: bottomAxis,
87
- slots: slots,
88
- slotProps: slotProps
89
- }), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
90
- vertical: grid.vertical,
91
- horizontal: grid.horizontal
92
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, {
93
- slots: slots,
94
- slotProps: slotProps,
95
- onItemClick: disableVoronoi ? onItemClick : undefined
96
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
97
- loading: loading,
98
- slots: slots,
99
- slotProps: slotProps
100
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
101
- slots: slots,
102
- slotProps: slotProps
103
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({
104
- x: "none",
105
- y: "none"
106
- }, axisHighlight)), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({
107
- trigger: "item"
108
- }, tooltip)), children]
109
- })
110
- });
37
+ chartContainerProps,
38
+ zAxisProps,
39
+ voronoiHandlerProps,
40
+ chartsAxisProps,
41
+ gridProps,
42
+ scatterPlotProps,
43
+ overlayProps,
44
+ legendProps,
45
+ axisHighlightProps,
46
+ tooltipProps,
47
+ children
48
+ } = (0, _useScatterChartProps.useScatterChartProps)(props);
49
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveChartContainer.ResponsiveChartContainer, (0, _extends2.default)({
50
+ ref: ref
51
+ }, chartContainerProps, {
52
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, (0, _extends2.default)({}, zAxisProps, {
53
+ children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
54
+ }))
55
+ }));
111
56
  });
112
57
  process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
113
58
  // ----------------------------- Warning --------------------------------
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _Scatter = require("./Scatter");
12
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
12
+ var _CartesianProvider = require("../context/CartesianProvider");
13
13
  var _getColor = _interopRequireDefault(require("./getColor"));
14
14
  var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
15
15
  var _useSeries = require("../hooks/useSeries");
@@ -33,7 +33,7 @@ function ScatterPlot(props) {
33
33
  onItemClick
34
34
  } = props;
35
35
  const seriesData = (0, _useSeries.useScatterSeries)();
36
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
36
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
37
37
  const {
38
38
  zAxis,
39
39
  zAxisIds
@@ -0,0 +1,31 @@
1
+ import { ChartsAxisProps } from '../ChartsAxis';
2
+ import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
3
+ import { ChartsGridProps } from '../ChartsGrid';
4
+ import { ChartsLegendProps } from '../ChartsLegend';
5
+ import { ChartsOverlayProps } from '../ChartsOverlay';
6
+ import { ChartsTooltipProps } from '../ChartsTooltip';
7
+ import type { ChartsVoronoiHandlerProps } from '../ChartsVoronoiHandler';
8
+ import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
9
+ import { ZAxisContextProviderProps } from '../context';
10
+ import type { ScatterChartProps } from './ScatterChart';
11
+ import type { ScatterPlotProps } from './ScatterPlot';
12
+ /**
13
+ * A helper function that extracts ScatterChartProps from the input props
14
+ * and returns an object with props for the children components of ScatterChart.
15
+ *
16
+ * @param props The input props for ScatterChart
17
+ * @returns An object with props for the children components of ScatterChart
18
+ */
19
+ export declare const useScatterChartProps: (props: ScatterChartProps) => {
20
+ chartContainerProps: ResponsiveChartContainerProps;
21
+ zAxisProps: Omit<ZAxisContextProviderProps, "children">;
22
+ voronoiHandlerProps: ChartsVoronoiHandlerProps;
23
+ chartsAxisProps: ChartsAxisProps;
24
+ gridProps: ChartsGridProps;
25
+ scatterPlotProps: ScatterPlotProps;
26
+ overlayProps: ChartsOverlayProps;
27
+ legendProps: ChartsLegendProps;
28
+ axisHighlightProps: ChartsAxisHighlightProps;
29
+ tooltipProps: ChartsTooltipProps;
30
+ children: import("react").ReactNode;
31
+ };