@mui/x-charts-pro 8.1.0 → 8.3.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 (198) hide show
  1. package/BarChartPro/BarChartPro.d.ts +7 -1
  2. package/BarChartPro/BarChartPro.js +62 -5
  3. package/CHANGELOG.md +233 -7
  4. package/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  5. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  6. package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -2
  7. package/ChartZoomSlider/ChartZoomSlider.d.ts +5 -0
  8. package/ChartZoomSlider/ChartZoomSlider.js +47 -0
  9. package/ChartZoomSlider/index.d.ts +2 -0
  10. package/ChartZoomSlider/index.js +27 -0
  11. package/ChartZoomSlider/internals/ChartAxisZoomSlider.d.ts +23 -0
  12. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +348 -0
  13. package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +12 -0
  14. package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +92 -0
  15. package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +17 -0
  16. package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.js +27 -0
  17. package/ChartsToolbarPro/ChartsToolbarPro.d.ts +2 -0
  18. package/ChartsToolbarPro/ChartsToolbarPro.js +31 -0
  19. package/ChartsToolbarPro/index.d.ts +1 -0
  20. package/ChartsToolbarPro/index.js +16 -0
  21. package/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.d.ts +13 -0
  22. package/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.js +36 -0
  23. package/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.d.ts +13 -0
  24. package/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.js +36 -0
  25. package/FunnelChart/FunnelChart.js +9 -8
  26. package/FunnelChart/FunnelPlot.d.ts +5 -0
  27. package/FunnelChart/FunnelPlot.js +36 -18
  28. package/FunnelChart/FunnelSection.d.ts +1 -0
  29. package/FunnelChart/FunnelSection.js +12 -7
  30. package/FunnelChart/curves/borderRadiusPolygon.d.ts +8 -0
  31. package/FunnelChart/curves/borderRadiusPolygon.js +42 -0
  32. package/FunnelChart/curves/bump.d.ts +27 -0
  33. package/FunnelChart/curves/bump.js +81 -0
  34. package/FunnelChart/curves/curve.types.d.ts +38 -0
  35. package/FunnelChart/curves/curve.types.js +5 -0
  36. package/FunnelChart/curves/getFunnelCurve.d.ts +3 -0
  37. package/FunnelChart/curves/getFunnelCurve.js +30 -0
  38. package/FunnelChart/curves/index.d.ts +2 -0
  39. package/FunnelChart/curves/index.js +27 -0
  40. package/FunnelChart/curves/linear.d.ts +32 -0
  41. package/FunnelChart/curves/linear.js +88 -0
  42. package/FunnelChart/curves/pyramid.d.ts +34 -0
  43. package/FunnelChart/curves/pyramid.js +127 -0
  44. package/FunnelChart/curves/step-pyramid.d.ts +31 -0
  45. package/FunnelChart/curves/step-pyramid.js +107 -0
  46. package/FunnelChart/curves/step.d.ts +32 -0
  47. package/FunnelChart/curves/step.js +88 -0
  48. package/FunnelChart/curves/utils.d.ts +4 -0
  49. package/FunnelChart/curves/utils.js +29 -0
  50. package/FunnelChart/funnel.types.d.ts +25 -4
  51. package/FunnelChart/funnelPlotSlots.types.d.ts +1 -1
  52. package/FunnelChart/funnelSectionClasses.d.ts +6 -2
  53. package/FunnelChart/funnelSectionClasses.js +5 -2
  54. package/FunnelChart/index.d.ts +3 -2
  55. package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +1 -0
  56. package/FunnelChart/useFunnelChartProps.d.ts +1 -6
  57. package/FunnelChart/useFunnelChartProps.js +7 -15
  58. package/Heatmap/Heatmap.d.ts +3 -3
  59. package/Heatmap/Heatmap.js +3 -21
  60. package/LineChartPro/LineChartPro.d.ts +7 -1
  61. package/LineChartPro/LineChartPro.js +62 -5
  62. package/ScatterChartPro/ScatterChartPro.d.ts +7 -1
  63. package/ScatterChartPro/ScatterChartPro.js +62 -5
  64. package/esm/BarChartPro/BarChartPro.d.ts +7 -1
  65. package/esm/BarChartPro/BarChartPro.js +62 -5
  66. package/esm/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  67. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  68. package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -2
  69. package/esm/ChartZoomSlider/ChartZoomSlider.d.ts +5 -0
  70. package/esm/ChartZoomSlider/ChartZoomSlider.js +41 -0
  71. package/esm/ChartZoomSlider/index.d.ts +2 -0
  72. package/esm/ChartZoomSlider/index.js +2 -0
  73. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.d.ts +23 -0
  74. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +339 -0
  75. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +12 -0
  76. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +85 -0
  77. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +17 -0
  78. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.js +17 -0
  79. package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +2 -0
  80. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +24 -0
  81. package/esm/ChartsToolbarPro/index.d.ts +1 -0
  82. package/esm/ChartsToolbarPro/index.js +1 -0
  83. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.d.ts +13 -0
  84. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.js +29 -0
  85. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.d.ts +13 -0
  86. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.js +29 -0
  87. package/esm/FunnelChart/FunnelChart.js +9 -8
  88. package/esm/FunnelChart/FunnelPlot.d.ts +5 -0
  89. package/esm/FunnelChart/FunnelPlot.js +37 -19
  90. package/esm/FunnelChart/FunnelSection.d.ts +1 -0
  91. package/esm/FunnelChart/FunnelSection.js +12 -7
  92. package/esm/FunnelChart/curves/borderRadiusPolygon.d.ts +8 -0
  93. package/esm/FunnelChart/curves/borderRadiusPolygon.js +36 -0
  94. package/esm/FunnelChart/curves/bump.d.ts +27 -0
  95. package/esm/FunnelChart/curves/bump.js +74 -0
  96. package/esm/FunnelChart/curves/curve.types.d.ts +38 -0
  97. package/esm/FunnelChart/curves/curve.types.js +1 -0
  98. package/esm/FunnelChart/curves/getFunnelCurve.d.ts +3 -0
  99. package/esm/FunnelChart/curves/getFunnelCurve.js +23 -0
  100. package/esm/FunnelChart/curves/index.d.ts +2 -0
  101. package/esm/FunnelChart/curves/index.js +2 -0
  102. package/esm/FunnelChart/curves/linear.d.ts +32 -0
  103. package/esm/FunnelChart/curves/linear.js +82 -0
  104. package/esm/FunnelChart/curves/pyramid.d.ts +34 -0
  105. package/esm/FunnelChart/curves/pyramid.js +121 -0
  106. package/esm/FunnelChart/curves/step-pyramid.d.ts +31 -0
  107. package/esm/FunnelChart/curves/step-pyramid.js +101 -0
  108. package/esm/FunnelChart/curves/step.d.ts +32 -0
  109. package/esm/FunnelChart/curves/step.js +82 -0
  110. package/esm/FunnelChart/curves/utils.d.ts +4 -0
  111. package/esm/FunnelChart/curves/utils.js +19 -0
  112. package/esm/FunnelChart/funnel.types.d.ts +25 -4
  113. package/esm/FunnelChart/funnelPlotSlots.types.d.ts +1 -1
  114. package/esm/FunnelChart/funnelSectionClasses.d.ts +6 -2
  115. package/esm/FunnelChart/funnelSectionClasses.js +5 -2
  116. package/esm/FunnelChart/index.d.ts +3 -2
  117. package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +1 -0
  118. package/esm/FunnelChart/useFunnelChartProps.d.ts +1 -6
  119. package/esm/FunnelChart/useFunnelChartProps.js +7 -15
  120. package/esm/Heatmap/Heatmap.d.ts +3 -3
  121. package/esm/Heatmap/Heatmap.js +3 -21
  122. package/esm/LineChartPro/LineChartPro.d.ts +7 -1
  123. package/esm/LineChartPro/LineChartPro.js +62 -5
  124. package/esm/ScatterChartPro/ScatterChartPro.d.ts +7 -1
  125. package/esm/ScatterChartPro/ScatterChartPro.js +62 -5
  126. package/esm/index.d.ts +4 -1
  127. package/esm/index.js +5 -2
  128. package/esm/internals/material/icons.d.ts +3 -0
  129. package/esm/internals/material/icons.js +13 -0
  130. package/esm/internals/material/index.d.ts +4 -0
  131. package/esm/internals/material/index.js +12 -0
  132. package/esm/internals/plugins/useChartProExport/common.d.ts +1 -0
  133. package/esm/internals/plugins/useChartProExport/common.js +8 -0
  134. package/esm/internals/plugins/useChartProExport/exportImage.d.ts +3 -0
  135. package/esm/internals/plugins/useChartProExport/exportImage.js +85 -0
  136. package/esm/internals/plugins/useChartProExport/print.js +6 -50
  137. package/esm/internals/plugins/useChartProExport/useChartProExport.js +22 -2
  138. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +32 -0
  139. package/esm/internals/plugins/useChartProZoom/calculateZoom.d.ts +23 -0
  140. package/esm/internals/plugins/useChartProZoom/calculateZoom.js +32 -0
  141. package/esm/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -1
  142. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +46 -4
  143. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +84 -32
  144. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +3 -2
  145. package/esm/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +17 -2
  146. package/esm/internals/slots/chartBaseSlotProps.d.ts +10 -0
  147. package/esm/internals/slots/chartBaseSlotProps.js +1 -0
  148. package/esm/internals/slots/chartsBaseSlots.d.ts +6 -0
  149. package/esm/internals/slots/chartsBaseSlots.js +1 -0
  150. package/esm/internals/slots/chartsIconSlots.d.ts +14 -0
  151. package/esm/internals/slots/chartsIconSlots.js +1 -0
  152. package/esm/themeAugmentation/components.d.ts +0 -4
  153. package/esm/themeAugmentation/components.js +1 -0
  154. package/esm/themeAugmentation/index.d.ts +3 -3
  155. package/esm/themeAugmentation/overrides.d.ts +0 -3
  156. package/esm/themeAugmentation/overrides.js +2 -0
  157. package/esm/themeAugmentation/props.d.ts +0 -6
  158. package/esm/themeAugmentation/props.js +2 -0
  159. package/esm/typeOverloads/modules.d.ts +1 -1
  160. package/index.d.ts +4 -1
  161. package/index.js +90 -1
  162. package/internals/material/icons.d.ts +3 -0
  163. package/internals/material/icons.js +20 -0
  164. package/internals/material/index.d.ts +4 -0
  165. package/internals/material/index.js +19 -0
  166. package/internals/plugins/useChartProExport/common.d.ts +1 -0
  167. package/internals/plugins/useChartProExport/common.js +14 -0
  168. package/internals/plugins/useChartProExport/exportImage.d.ts +3 -0
  169. package/internals/plugins/useChartProExport/exportImage.js +95 -0
  170. package/internals/plugins/useChartProExport/print.js +6 -50
  171. package/internals/plugins/useChartProExport/useChartProExport.js +22 -2
  172. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +32 -0
  173. package/internals/plugins/useChartProZoom/calculateZoom.d.ts +23 -0
  174. package/internals/plugins/useChartProZoom/calculateZoom.js +39 -0
  175. package/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -1
  176. package/internals/plugins/useChartProZoom/useChartProZoom.js +45 -3
  177. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +84 -32
  178. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +3 -2
  179. package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +17 -2
  180. package/internals/slots/chartBaseSlotProps.d.ts +10 -0
  181. package/internals/slots/chartBaseSlotProps.js +5 -0
  182. package/internals/slots/chartsBaseSlots.d.ts +6 -0
  183. package/internals/slots/chartsBaseSlots.js +5 -0
  184. package/internals/slots/chartsIconSlots.d.ts +14 -0
  185. package/internals/slots/chartsIconSlots.js +5 -0
  186. package/package.json +10 -7
  187. package/themeAugmentation/components.d.ts +0 -4
  188. package/themeAugmentation/components.js +5 -0
  189. package/themeAugmentation/index.d.ts +3 -3
  190. package/themeAugmentation/overrides.d.ts +0 -3
  191. package/themeAugmentation/overrides.js +5 -0
  192. package/themeAugmentation/props.d.ts +0 -6
  193. package/themeAugmentation/props.js +5 -0
  194. package/typeOverloads/modules.d.ts +1 -1
  195. package/FunnelChart/funnelStepCurve.d.ts +0 -4
  196. package/FunnelChart/funnelStepCurve.js +0 -74
  197. package/esm/FunnelChart/funnelStepCurve.d.ts +0 -4
  198. package/esm/FunnelChart/funnelStepCurve.js +0 -67
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsToolbarZoomOutButton = ChartsToolbarZoomOutButton;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _Toolbar = require("@mui/x-charts/Toolbar");
13
+ var _internals = require("@mui/x-charts/internals");
14
+ var _hooks = require("@mui/x-charts/hooks");
15
+ var _material = require("../../internals/material");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function ChartsToolbarZoomOutButton({
18
+ slots,
19
+ slotProps
20
+ }) {
21
+ const {
22
+ instance
23
+ } = (0, _internals.useChartContext)();
24
+ const ZoomOutIcon = slots?.zoomOutIcon ?? _material.defaultSlotsMaterial.zoomOutIcon;
25
+ const Tooltip = slots?.baseTooltip ?? _material.defaultSlotsMaterial.baseTooltip;
26
+ const {
27
+ localeText
28
+ } = (0, _hooks.useChartsLocalization)();
29
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, {
30
+ title: localeText.zoomOut,
31
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Toolbar.ToolbarButton, {
32
+ onClick: () => instance.zoomOut(),
33
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ZoomOutIcon, (0, _extends2.default)({}, slotProps?.zoomOutIcon))
34
+ })
35
+ });
36
+ }
@@ -15,7 +15,6 @@ var _ChartsOverlay = require("@mui/x-charts/ChartsOverlay");
15
15
  var _ChartsTooltip = require("@mui/x-charts/ChartsTooltip");
16
16
  var _internals = require("@mui/x-charts/internals");
17
17
  var _ChartsLegend = require("@mui/x-charts/ChartsLegend");
18
- var _ChartsClipPath = require("@mui/x-charts/ChartsClipPath");
19
18
  var _ChartsSurface = require("@mui/x-charts/ChartsSurface");
20
19
  var _ChartsAxisHighlight = require("@mui/x-charts/ChartsAxisHighlight");
21
20
  var _ChartsAxis = require("@mui/x-charts/ChartsAxis");
@@ -38,9 +37,7 @@ const FunnelChart = exports.FunnelChart = /*#__PURE__*/React.forwardRef(function
38
37
  funnelPlotProps,
39
38
  overlayProps,
40
39
  legendProps,
41
- clipPathGroupProps,
42
40
  chartsAxisProps,
43
- clipPathProps,
44
41
  chartsWrapperProps,
45
42
  axisHighlightProps,
46
43
  children
@@ -54,11 +51,9 @@ const FunnelChart = exports.FunnelChart = /*#__PURE__*/React.forwardRef(function
54
51
  seriesConfig: seriesConfig,
55
52
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_internals.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
56
53
  children: [!themedProps.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
57
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
58
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FunnelPlot.FunnelPlot, (0, _extends2.default)({}, funnelPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps))]
59
- })), !themedProps.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, themedProps.slotProps?.tooltip, {
54
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FunnelPlot.FunnelPlot, (0, _extends2.default)({}, funnelPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !themedProps.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, themedProps.slotProps?.tooltip, {
60
55
  trigger: "item"
61
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, (0, _extends2.default)({}, clipPathProps)), children]
56
+ })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), children]
62
57
  }))]
63
58
  }))
64
59
  }));
@@ -70,6 +65,7 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
70
65
  // ----------------------------------------------------------------------
71
66
  apiRef: _propTypes.default.shape({
72
67
  current: _propTypes.default.shape({
68
+ exportAsImage: _propTypes.default.func.isRequired,
73
69
  exportAsPrint: _propTypes.default.func.isRequired,
74
70
  setZoomData: _propTypes.default.func.isRequired
75
71
  })
@@ -183,6 +179,11 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
183
179
  * @default false
184
180
  */
185
181
  disableAxisListener: _propTypes.default.bool,
182
+ /**
183
+ * The gap, in pixels, between funnel sections.
184
+ * @default 0
185
+ */
186
+ gap: _propTypes.default.number,
186
187
  /**
187
188
  * The height of the chart in px. If not defined, it takes the height of the parent element.
188
189
  */
@@ -239,7 +240,7 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
239
240
  * The function called for onClick events.
240
241
  * The second argument contains information about all line/bar elements at the current mouse position.
241
242
  * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
242
- * @param {null | AxisData} data The data about the clicked axis and items associated with it.
243
+ * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
243
244
  */
244
245
  onAxisClick: _propTypes.default.func,
245
246
  /**
@@ -2,6 +2,11 @@ import * as React from 'react';
2
2
  import { FunnelItemIdentifier } from "./funnel.types.js";
3
3
  import { FunnelPlotSlotExtension } from "./funnelPlotSlots.types.js";
4
4
  export interface FunnelPlotProps extends FunnelPlotSlotExtension {
5
+ /**
6
+ * The gap, in pixels, between funnel sections.
7
+ * @default 0
8
+ */
9
+ gap?: number;
5
10
  /**
6
11
  * Callback fired when a funnel item is clicked.
7
12
  * @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
@@ -17,21 +17,12 @@ var _hooks = require("@mui/x-charts/hooks");
17
17
  var _styles = require("@mui/material/styles");
18
18
  var _FunnelSection = require("./FunnelSection");
19
19
  var _labelUtils = require("./labelUtils");
20
- var _funnelStepCurve = require("./funnelStepCurve");
21
20
  var _useFunnelSeries = require("../hooks/useFunnelSeries");
21
+ var _curves = require("./curves");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
- const _excluded = ["onItemClick"];
23
+ const _excluded = ["onItemClick", "gap"];
24
24
  _internals.cartesianSeriesTypes.addType('funnel');
25
- const getFunnelCurve = (curve, isHorizontal) => {
26
- if (curve === 'step') {
27
- return isHorizontal ? _funnelStepCurve.funnelHorizontalStepCurve : _funnelStepCurve.funnelVerticalStepCurve;
28
- }
29
- if (curve === 'bump') {
30
- return isHorizontal ? (0, _internals.getCurveFactory)('bumpX') : (0, _internals.getCurveFactory)('bumpY');
31
- }
32
- return (0, _internals.getCurveFactory)(curve ?? 'linear');
33
- };
34
- const useAggregatedData = () => {
25
+ const useAggregatedData = gap => {
35
26
  const seriesData = (0, _useFunnelSeries.useFunnelSeriesContext)();
36
27
  const {
37
28
  xAxis,
@@ -63,7 +54,6 @@ const useAggregatedData = () => {
63
54
  const bandWidth = (isXAxisBand || isYAxisBand) && baseScaleConfig.scale?.bandwidth() || 0;
64
55
  const xScale = xAxis[xAxisId].scale;
65
56
  const yScale = yAxis[yAxisId].scale;
66
- const curve = getFunnelCurve(currentSeries.curve, isHorizontal);
67
57
  const xPosition = (value, bandIndex, stackOffset, useBand) => {
68
58
  if (isXAxisBand) {
69
59
  const position = xScale(bandIndex);
@@ -78,7 +68,17 @@ const useAggregatedData = () => {
78
68
  }
79
69
  return yScale(isHorizontal ? value : value + (stackOffset || 0));
80
70
  };
81
- return currentSeries.dataPoints.map((values, dataIndex) => {
71
+ const allY = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => yPosition(v.y, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
72
+ const allX = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => xPosition(v.x, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
73
+ const minPoint = {
74
+ x: Math.min(...allX),
75
+ y: Math.min(...allY)
76
+ };
77
+ const maxPoint = {
78
+ x: Math.max(...allX),
79
+ y: Math.max(...allY)
80
+ };
81
+ return currentSeries.dataPoints.flatMap((values, dataIndex) => {
82
82
  const color = currentSeries.data[dataIndex].color;
83
83
  const id = `${seriesId}-${dataIndex}`;
84
84
  const sectionLabel = typeof currentSeries.sectionLabel === 'function' ? currentSeries.sectionLabel({
@@ -86,6 +86,15 @@ const useAggregatedData = () => {
86
86
  seriesId,
87
87
  value: currentSeries.data[dataIndex].value
88
88
  }) : currentSeries.sectionLabel;
89
+ const curve = (0, _curves.getFunnelCurve)(currentSeries.curve, {
90
+ isHorizontal,
91
+ gap,
92
+ position: dataIndex,
93
+ sections: currentSeries.dataPoints.length,
94
+ borderRadius: currentSeries.borderRadius,
95
+ min: minPoint,
96
+ max: maxPoint
97
+ });
89
98
  const line = (0, _d3Shape.line)().x(d => xPosition(d.x, baseScaleConfig.data?.[dataIndex], d.stackOffset, d.useBandWidth)).y(d => yPosition(d.y, baseScaleConfig.data?.[dataIndex], d.stackOffset, d.useBandWidth)).curve(curve);
90
99
  return {
91
100
  d: line(values),
@@ -93,6 +102,7 @@ const useAggregatedData = () => {
93
102
  id,
94
103
  seriesId,
95
104
  dataIndex,
105
+ variant: currentSeries.variant,
96
106
  label: sectionLabel !== false && (0, _extends2.default)({}, (0, _labelUtils.positionLabel)((0, _extends2.default)({}, sectionLabel, {
97
107
  xPosition,
98
108
  yPosition,
@@ -109,29 +119,32 @@ const useAggregatedData = () => {
109
119
  });
110
120
  });
111
121
  return result.flat();
112
- }, [seriesData, xAxis, xAxisIds, yAxis, yAxisIds]);
122
+ }, [seriesData, xAxis, xAxisIds, yAxis, yAxisIds, gap]);
113
123
  return allData;
114
124
  };
115
125
  function FunnelPlot(props) {
116
126
  const {
117
- onItemClick
127
+ onItemClick,
128
+ gap
118
129
  } = props,
119
130
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
120
131
  const theme = (0, _styles.useTheme)();
121
- const data = useAggregatedData();
132
+ const data = useAggregatedData(gap);
122
133
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
123
134
  children: [data.map(({
124
135
  d,
125
136
  color,
126
137
  id,
127
138
  seriesId,
128
- dataIndex
139
+ dataIndex,
140
+ variant
129
141
  }) => /*#__PURE__*/(0, _react.createElement)(_FunnelSection.FunnelSection, (0, _extends2.default)({}, other, {
130
142
  d: d,
131
143
  color: color,
132
144
  key: id,
133
145
  dataIndex: dataIndex,
134
146
  seriesId: seriesId,
147
+ variant: variant,
135
148
  onClick: onItemClick && (event => {
136
149
  onItemClick(event, {
137
150
  type: 'funnel',
@@ -172,6 +185,11 @@ process.env.NODE_ENV !== "production" ? FunnelPlot.propTypes = {
172
185
  // | These PropTypes are generated from the TypeScript type definitions |
173
186
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
174
187
  // ----------------------------------------------------------------------
188
+ /**
189
+ * The gap, in pixels, between funnel sections.
190
+ * @default 0
191
+ */
192
+ gap: _propTypes.default.number,
175
193
  /**
176
194
  * Callback fired when a funnel item is clicked.
177
195
  * @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
@@ -6,6 +6,7 @@ export interface FunnelSectionProps extends Omit<React.SVGProps<SVGPathElement>,
6
6
  dataIndex: number;
7
7
  color: string;
8
8
  classes?: Partial<FunnelSectionClasses>;
9
+ variant?: 'filled' | 'outlined';
9
10
  }
10
11
  export declare const FunnelSectionPath: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, React.SVGProps<SVGPathElement>, {}>;
11
12
  /**
@@ -16,9 +16,9 @@ var _hooks = require("@mui/x-charts/hooks");
16
16
  var _clsx = _interopRequireDefault(require("clsx"));
17
17
  var _funnelSectionClasses = require("./funnelSectionClasses");
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
- const _excluded = ["seriesId", "dataIndex", "classes", "color", "onClick", "className"];
19
+ const _excluded = ["seriesId", "dataIndex", "classes", "color", "onClick", "className", "variant"];
20
20
  const FunnelSectionPath = exports.FunnelSectionPath = (0, _styles.styled)('path')(() => ({
21
- transition: 'opacity 0.2s ease-in, fill 0.2s ease-in'
21
+ transition: 'opacity 0.2s ease-in, fill 0.2s ease-in, fill-opacity 0.2s ease-in, filter 0.2s ease-in'
22
22
  }));
23
23
 
24
24
  /**
@@ -33,7 +33,8 @@ const FunnelSection = exports.FunnelSection = (0, _internals.consumeSlots)('MuiF
33
33
  classes,
34
34
  color,
35
35
  onClick,
36
- className
36
+ className,
37
+ variant = 'filled'
37
38
  } = props,
38
39
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
39
40
  const interactionProps = (0, _internals.useInteractionItemProps)({
@@ -48,14 +49,18 @@ const FunnelSection = exports.FunnelSection = (0, _internals.consumeSlots)('MuiF
48
49
  seriesId,
49
50
  dataIndex
50
51
  });
52
+ const isOutlined = variant === 'outlined';
51
53
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(FunnelSectionPath, (0, _extends2.default)({}, interactionProps, {
52
- filter: isHighlighted ? 'brightness(120%)' : undefined,
53
- opacity: isFaded ? 0.3 : 1,
54
+ filter: isHighlighted && !isOutlined ? 'brightness(120%)' : undefined,
55
+ opacity: isFaded && !isOutlined ? 0.3 : 1,
54
56
  fill: color,
55
- stroke: "none",
57
+ stroke: isOutlined ? color : 'none',
58
+ fillOpacity: isOutlined && !isHighlighted ? 0.4 : 1,
59
+ strokeOpacity: 1,
60
+ strokeWidth: isOutlined ? 1.5 : 0,
56
61
  cursor: onClick ? 'pointer' : 'unset',
57
62
  onClick: onClick,
58
- className: (0, _clsx.default)(classes?.root, className, isHighlighted && classes?.highlighted, isFaded && classes?.faded)
63
+ className: (0, _clsx.default)(classes?.root, className, isOutlined ? classes?.outlined : classes?.filled, isHighlighted && classes?.highlighted, isFaded && classes?.faded)
59
64
  }, other, {
60
65
  ref: ref
61
66
  }));
@@ -0,0 +1,8 @@
1
+ import { Point } from "./curve.types.js";
2
+ /**
3
+ * Draws a polygon with rounded corners
4
+ * @param {CanvasRenderingContext2D} ctx The canvas context
5
+ * @param {Array} points A list of `{x, y}` points
6
+ * @param {number} radius how much to round the corners
7
+ */
8
+ export declare function borderRadiusPolygon(ctx: CanvasRenderingContext2D, points: Point[], radius: number | number[]): void;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.borderRadiusPolygon = borderRadiusPolygon;
7
+ const distance = (p1, p2) => Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2);
8
+ const lerp = (a, b, x) => a + (b - a) * x;
9
+ const lerp2D = (p1, p2, t) => ({
10
+ x: lerp(p1.x, p2.x, t),
11
+ y: lerp(p1.y, p2.y, t)
12
+ });
13
+
14
+ /**
15
+ * Draws a polygon with rounded corners
16
+ * @param {CanvasRenderingContext2D} ctx The canvas context
17
+ * @param {Array} points A list of `{x, y}` points
18
+ * @param {number} radius how much to round the corners
19
+ */
20
+ function borderRadiusPolygon(ctx, points, radius) {
21
+ const numPoints = points.length;
22
+ radius = Array.isArray(radius) ? radius : Array(numPoints).fill(radius);
23
+ const corners = [];
24
+ for (let i = 0; i < numPoints; i += 1) {
25
+ const lastPoint = points[i];
26
+ const thisPoint = points[(i + 1) % numPoints];
27
+ const nextPoint = points[(i + 2) % numPoints];
28
+ const lastEdgeLength = distance(lastPoint, thisPoint);
29
+ const lastOffsetDistance = Math.min(lastEdgeLength / 2, radius[i] ?? 0);
30
+ const start = lerp2D(thisPoint, lastPoint, lastOffsetDistance / lastEdgeLength);
31
+ const nextEdgeLength = distance(nextPoint, thisPoint);
32
+ const nextOffsetDistance = Math.min(nextEdgeLength / 2, radius[i] ?? 0);
33
+ const end = lerp2D(thisPoint, nextPoint, nextOffsetDistance / nextEdgeLength);
34
+ corners.push([start, thisPoint, end]);
35
+ }
36
+ ctx.moveTo(corners[0][0].x, corners[0][0].y);
37
+ for (const [start, ctrl, end] of corners) {
38
+ ctx.lineTo(start.x, start.y);
39
+ ctx.quadraticCurveTo(ctrl.x, ctrl.y, end.x, end.y);
40
+ }
41
+ ctx.closePath();
42
+ }
@@ -0,0 +1,27 @@
1
+ import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
2
+ import { CurveOptions } from "./curve.types.js";
3
+ /**
4
+ * This is a custom "bump" curve generator.
5
+ * It draws smooth curves for the 4 provided points,
6
+ * with the option to add a gap between sections while also properly handling the border radius.
7
+ *
8
+ * The implementation is based on the d3-shape bump curve generator.
9
+ * https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/bump.js
10
+ */
11
+ export declare class Bump implements CurveGenerator {
12
+ private context;
13
+ private x;
14
+ private y;
15
+ private currentPoint;
16
+ private isHorizontal;
17
+ private gap;
18
+ constructor(context: CanvasRenderingContext2D, {
19
+ isHorizontal,
20
+ gap
21
+ }: CurveOptions);
22
+ areaStart(): void;
23
+ areaEnd(): void;
24
+ lineStart(): void;
25
+ lineEnd(): void;
26
+ point(x: number, y: number): void;
27
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Bump = void 0;
7
+ /* eslint-disable class-methods-use-this */
8
+
9
+ /**
10
+ * This is a custom "bump" curve generator.
11
+ * It draws smooth curves for the 4 provided points,
12
+ * with the option to add a gap between sections while also properly handling the border radius.
13
+ *
14
+ * The implementation is based on the d3-shape bump curve generator.
15
+ * https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/bump.js
16
+ */
17
+ class Bump {
18
+ constructor(context, {
19
+ isHorizontal,
20
+ gap
21
+ }) {
22
+ this.context = void 0;
23
+ this.x = NaN;
24
+ this.y = NaN;
25
+ this.currentPoint = 0;
26
+ this.isHorizontal = false;
27
+ this.gap = 0;
28
+ this.context = context;
29
+ this.isHorizontal = isHorizontal ?? false;
30
+ this.gap = (gap ?? 0) / 2;
31
+ }
32
+ areaStart() {}
33
+ areaEnd() {}
34
+ lineStart() {}
35
+ lineEnd() {}
36
+ point(x, y) {
37
+ x = +x;
38
+ y = +y;
39
+
40
+ // 0 is the top-left corner.
41
+ if (this.isHorizontal) {
42
+ if (this.currentPoint === 0) {
43
+ this.context.moveTo(x + this.gap, y);
44
+ this.context.lineTo(x + this.gap, y);
45
+ } else if (this.currentPoint === 1) {
46
+ this.context.bezierCurveTo((this.x + x) / 2, this.y, (this.x + x) / 2, y, x - this.gap, y);
47
+ } else if (this.currentPoint === 2) {
48
+ this.context.lineTo(x - this.gap, y);
49
+ } else {
50
+ this.context.bezierCurveTo((this.x + x) / 2, this.y, (this.x + x) / 2, y, x + this.gap, y);
51
+ }
52
+ if (this.currentPoint === 3) {
53
+ this.context.closePath();
54
+ }
55
+ this.currentPoint += 1;
56
+ this.x = x;
57
+ this.y = y;
58
+ return;
59
+ }
60
+
61
+ // 0 is the top-right corner.
62
+ if (this.currentPoint === 0) {
63
+ // X from Y
64
+ this.context.moveTo(x, y + this.gap);
65
+ this.context.lineTo(x, y + this.gap);
66
+ } else if (this.currentPoint === 1) {
67
+ this.context.bezierCurveTo(this.x, (this.y + y) / 2, x, (this.y + y) / 2, x, y - this.gap);
68
+ } else if (this.currentPoint === 2) {
69
+ this.context.lineTo(x, y - this.gap);
70
+ } else {
71
+ this.context.bezierCurveTo(this.x, (this.y + y) / 2, x, (this.y + y) / 2, x, y + this.gap);
72
+ }
73
+ if (this.currentPoint === 3) {
74
+ this.context.closePath();
75
+ }
76
+ this.currentPoint += 1;
77
+ this.x = x;
78
+ this.y = y;
79
+ }
80
+ }
81
+ exports.Bump = Bump;
@@ -0,0 +1,38 @@
1
+ export type CurveOptions = {
2
+ /**
3
+ * The gap between each segment.
4
+ * @default 0
5
+ */
6
+ gap?: number;
7
+ /**
8
+ * Indicates if the main axis of the visualization.
9
+ */
10
+ isHorizontal?: boolean;
11
+ /**
12
+ * The order position of the segment.
13
+ */
14
+ position?: number;
15
+ /**
16
+ * The total number of segments that will be drawn.
17
+ * @default 1
18
+ */
19
+ sections?: number;
20
+ /**
21
+ * The border radius of the segments.
22
+ * @default 0
23
+ */
24
+ borderRadius?: number;
25
+ /**
26
+ * The minimum point for all the segments.
27
+ */
28
+ min?: Point;
29
+ /**
30
+ * The maximum point for all the segments.
31
+ */
32
+ max?: Point;
33
+ };
34
+ export type FunnelCurveType = 'linear' | 'step' | 'bump' | 'pyramid' | 'step-pyramid';
35
+ export type Point = {
36
+ x: number;
37
+ y: number;
38
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,3 @@
1
+ import { CurveFactory } from '@mui/x-charts-vendor/d3-shape';
2
+ import { CurveOptions, FunnelCurveType } from "./curve.types.js";
3
+ export declare const getFunnelCurve: (curve: FunnelCurveType | undefined, options: CurveOptions) => CurveFactory;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFunnelCurve = void 0;
7
+ var _step = require("./step");
8
+ var _linear = require("./linear");
9
+ var _bump = require("./bump");
10
+ var _pyramid = require("./pyramid");
11
+ var _stepPyramid = require("./step-pyramid");
12
+ const curveConstructor = curve => {
13
+ if (curve === 'step') {
14
+ return _step.Step;
15
+ }
16
+ if (curve === 'bump') {
17
+ return _bump.Bump;
18
+ }
19
+ if (curve === 'pyramid') {
20
+ return _pyramid.Pyramid;
21
+ }
22
+ if (curve === 'step-pyramid') {
23
+ return _stepPyramid.StepPyramid;
24
+ }
25
+ return _linear.Linear;
26
+ };
27
+ const getFunnelCurve = (curve, options) => {
28
+ return context => new (curveConstructor(curve))(context, options);
29
+ };
30
+ exports.getFunnelCurve = getFunnelCurve;
@@ -0,0 +1,2 @@
1
+ export * from "./curve.types.js";
2
+ export * from "./getFunnelCurve.js";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _curve = require("./curve.types");
7
+ Object.keys(_curve).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _curve[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _curve[key];
14
+ }
15
+ });
16
+ });
17
+ var _getFunnelCurve = require("./getFunnelCurve");
18
+ Object.keys(_getFunnelCurve).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _getFunnelCurve[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _getFunnelCurve[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,32 @@
1
+ import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
2
+ import { CurveOptions } from "./curve.types.js";
3
+ /**
4
+ * This is a custom "linear" curve generator.
5
+ * It draws straight lines for the 4 provided points,
6
+ * with the option to add a gap between sections while also properly handling the border radius.
7
+ *
8
+ * The implementation is based on the d3-shape linear curve generator.
9
+ * https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/linear.js
10
+ */
11
+ export declare class Linear implements CurveGenerator {
12
+ private context;
13
+ private position;
14
+ private sections;
15
+ private isHorizontal;
16
+ private gap;
17
+ private borderRadius;
18
+ private points;
19
+ constructor(context: CanvasRenderingContext2D, {
20
+ isHorizontal,
21
+ gap,
22
+ position,
23
+ sections,
24
+ borderRadius
25
+ }: CurveOptions);
26
+ areaStart(): void;
27
+ areaEnd(): void;
28
+ lineStart(): void;
29
+ lineEnd(): void;
30
+ protected getBorderRadius(): number | number[];
31
+ point(xIn: number, yIn: number): void;
32
+ }