@mui/x-charts-pro 8.3.1 → 8.4.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 (90) hide show
  1. package/BarChartPro/BarChartPro.js +37 -20
  2. package/CHANGELOG.md +110 -0
  3. package/ChartContainerPro/ChartContainerPro.js +1 -0
  4. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  5. package/ChartZoomSlider/index.d.ts +1 -1
  6. package/ChartZoomSlider/index.js +4 -4
  7. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +94 -60
  8. package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.d.ts +12 -0
  9. package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +92 -0
  10. package/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.d.ts +11 -0
  11. package/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.js +58 -0
  12. package/ChartZoomSlider/internals/chartAxisZoomSliderThumbClasses.d.ts +17 -0
  13. package/ChartZoomSlider/internals/{chartAxisZoomSliderHandleClasses.js → chartAxisZoomSliderThumbClasses.js} +6 -6
  14. package/FunnelChart/FunnelChart.js +4 -3
  15. package/FunnelChart/FunnelPlot.js +2 -0
  16. package/FunnelChart/FunnelSection.js +2 -1
  17. package/FunnelChart/curves/curve.types.d.ts +4 -0
  18. package/FunnelChart/curves/pyramid.d.ts +3 -1
  19. package/FunnelChart/curves/pyramid.js +37 -10
  20. package/FunnelChart/curves/step-pyramid.d.ts +10 -2
  21. package/FunnelChart/curves/step-pyramid.js +96 -20
  22. package/FunnelChart/curves/step.d.ts +5 -1
  23. package/FunnelChart/curves/step.js +20 -2
  24. package/FunnelChart/funnel.types.d.ts +7 -0
  25. package/FunnelChart/seriesConfig/seriesProcessor.js +47 -1
  26. package/Heatmap/Heatmap.d.ts +1 -1
  27. package/Heatmap/Heatmap.js +25 -21
  28. package/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.d.ts +2 -0
  29. package/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.js +27 -0
  30. package/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +1 -10
  31. package/Heatmap/HeatmapTooltip/HeatmapTooltip.js +4 -102
  32. package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +10 -0
  33. package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.js +5 -0
  34. package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.d.ts +7 -0
  35. package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +96 -0
  36. package/Heatmap/HeatmapTooltip/index.d.ts +3 -1
  37. package/Heatmap/HeatmapTooltip/index.js +11 -0
  38. package/LineChartPro/LineChartPro.js +37 -20
  39. package/ScatterChartPro/ScatterChartPro.js +38 -21
  40. package/esm/BarChartPro/BarChartPro.js +35 -18
  41. package/esm/ChartContainerPro/ChartContainerPro.js +1 -0
  42. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  43. package/esm/ChartZoomSlider/index.d.ts +1 -1
  44. package/esm/ChartZoomSlider/index.js +1 -1
  45. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +94 -60
  46. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.d.ts +12 -0
  47. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +85 -0
  48. package/esm/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.d.ts +11 -0
  49. package/esm/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.js +52 -0
  50. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderThumbClasses.d.ts +17 -0
  51. package/esm/ChartZoomSlider/internals/{chartAxisZoomSliderHandleClasses.js → chartAxisZoomSliderThumbClasses.js} +4 -4
  52. package/esm/FunnelChart/FunnelChart.js +4 -3
  53. package/esm/FunnelChart/FunnelPlot.js +2 -0
  54. package/esm/FunnelChart/FunnelSection.js +1 -0
  55. package/esm/FunnelChart/curves/curve.types.d.ts +4 -0
  56. package/esm/FunnelChart/curves/pyramid.d.ts +3 -1
  57. package/esm/FunnelChart/curves/pyramid.js +37 -10
  58. package/esm/FunnelChart/curves/step-pyramid.d.ts +10 -2
  59. package/esm/FunnelChart/curves/step-pyramid.js +96 -20
  60. package/esm/FunnelChart/curves/step.d.ts +5 -1
  61. package/esm/FunnelChart/curves/step.js +20 -2
  62. package/esm/FunnelChart/funnel.types.d.ts +7 -0
  63. package/esm/FunnelChart/seriesConfig/seriesProcessor.js +47 -1
  64. package/esm/Heatmap/Heatmap.d.ts +1 -1
  65. package/esm/Heatmap/Heatmap.js +23 -19
  66. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.d.ts +2 -0
  67. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.js +19 -0
  68. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +1 -10
  69. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.js +5 -103
  70. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +10 -0
  71. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.js +1 -0
  72. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipContent.d.ts +7 -0
  73. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +89 -0
  74. package/esm/Heatmap/HeatmapTooltip/index.d.ts +3 -1
  75. package/esm/Heatmap/HeatmapTooltip/index.js +3 -1
  76. package/esm/LineChartPro/LineChartPro.js +35 -18
  77. package/esm/ScatterChartPro/ScatterChartPro.js +36 -19
  78. package/esm/index.js +1 -1
  79. package/esm/internals/plugins/useChartProExport/exportImage.js +1 -1
  80. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +2 -2
  81. package/index.js +1 -1
  82. package/internals/plugins/useChartProExport/exportImage.js +1 -1
  83. package/internals/plugins/useChartProZoom/useChartProZoom.js +2 -2
  84. package/package.json +5 -5
  85. package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +0 -12
  86. package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +0 -92
  87. package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +0 -17
  88. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +0 -12
  89. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +0 -85
  90. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +0 -17
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartAxisZoomSliderThumb = void 0;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ var _styles = require("@mui/material/styles");
14
+ var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
15
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
16
+ var _rafThrottle = require("@mui/x-internals/rafThrottle");
17
+ var _clsx = _interopRequireDefault(require("clsx"));
18
+ var _chartAxisZoomSliderThumbClasses = require("./chartAxisZoomSliderThumbClasses");
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry"];
21
+ const Rect = (0, _styles.styled)('rect')(({
22
+ theme
23
+ }) => ({
24
+ [`&.${_chartAxisZoomSliderThumbClasses.chartAxisZoomSliderThumbClasses.root}`]: {
25
+ fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[300] : (theme.vars || theme).palette.common.white,
26
+ stroke: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[600] : (theme.vars || theme).palette.grey[500]
27
+ },
28
+ [`&.${_chartAxisZoomSliderThumbClasses.chartAxisZoomSliderThumbClasses.horizontal}`]: {
29
+ cursor: 'ew-resize'
30
+ },
31
+ [`&.${_chartAxisZoomSliderThumbClasses.chartAxisZoomSliderThumbClasses.vertical}`]: {
32
+ cursor: 'ns-resize'
33
+ }
34
+ }));
35
+ /**
36
+ * Renders the zoom slider thumb, which is responsible for resizing the zoom range.
37
+ * @internal
38
+ */
39
+ const ChartAxisZoomSliderThumb = exports.ChartAxisZoomSliderThumb = /*#__PURE__*/React.forwardRef(function ChartAxisZoomSliderThumb(_ref, forwardedRef) {
40
+ let {
41
+ className,
42
+ onMove,
43
+ orientation,
44
+ placement,
45
+ rx = 4,
46
+ ry = 4
47
+ } = _ref,
48
+ rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
49
+ const classes = (0, _chartAxisZoomSliderThumbClasses.useUtilityClasses)({
50
+ onMove,
51
+ orientation,
52
+ placement
53
+ });
54
+ const thumbRef = React.useRef(null);
55
+ const ref = (0, _useForkRef.default)(thumbRef, forwardedRef);
56
+ const onMoveEvent = (0, _useEventCallback.default)(onMove);
57
+ React.useEffect(() => {
58
+ const thumb = thumbRef.current;
59
+ if (!thumb) {
60
+ return;
61
+ }
62
+ const onPointerMove = (0, _rafThrottle.rafThrottle)(event => {
63
+ onMoveEvent(event);
64
+ });
65
+ const onPointerUp = () => {
66
+ thumb.removeEventListener('pointermove', onPointerMove);
67
+ thumb.removeEventListener('pointerup', onPointerUp);
68
+ };
69
+ const onPointerDown = event => {
70
+ // Prevent text selection when dragging the thumb
71
+ event.preventDefault();
72
+ event.stopPropagation();
73
+ thumb.setPointerCapture(event.pointerId);
74
+ thumb.addEventListener('pointerup', onPointerUp);
75
+ thumb.addEventListener('pointermove', onPointerMove);
76
+ };
77
+ thumb.addEventListener('pointerdown', onPointerDown);
78
+
79
+ // eslint-disable-next-line consistent-return
80
+ return () => {
81
+ thumb.removeEventListener('pointerdown', onPointerDown);
82
+ onPointerMove.clear();
83
+ };
84
+ }, [onMoveEvent, orientation]);
85
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Rect, (0, _extends2.default)({
86
+ className: (0, _clsx.default)(classes.root, className),
87
+ ref: ref,
88
+ rx: rx,
89
+ ry: ry
90
+ }, rest));
91
+ });
92
+ if (process.env.NODE_ENV !== "production") ChartAxisZoomSliderThumb.displayName = "ChartAxisZoomSliderThumb";
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { PopperProps } from '@mui/material/Popper';
3
+ interface ChartsTooltipZoomSliderValueProps extends Pick<PopperProps, 'anchorEl' | 'open' | 'modifiers' | 'placement'>, React.PropsWithChildren {}
4
+ export declare function ChartsTooltipZoomSliderValue({
5
+ anchorEl,
6
+ open,
7
+ placement,
8
+ modifiers,
9
+ children
10
+ }: ChartsTooltipZoomSliderValueProps): React.JSX.Element;
11
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ChartsTooltipZoomSliderValue = ChartsTooltipZoomSliderValue;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _NoSsr = _interopRequireDefault(require("@mui/material/NoSsr"));
11
+ var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
12
+ var _ChartsTooltip = require("@mui/x-charts/ChartsTooltip");
13
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ /**
17
+ * The root component of the zoom slider tooltip.
18
+ * @ignore - internal component.
19
+ */const ChartsZoomSliderTooltipRoot = (0, _styles.styled)(_Popper.default, {
20
+ name: 'MuiChartsZoomSliderTooltip',
21
+ slot: 'Root'
22
+ })(({
23
+ theme
24
+ }) => ({
25
+ pointerEvents: 'none',
26
+ zIndex: theme.zIndex.modal
27
+ }));
28
+ const MODIFIERS = [{
29
+ name: 'offset',
30
+ options: {
31
+ offset: [0, 4]
32
+ }
33
+ }];
34
+ function ChartsTooltipZoomSliderValue({
35
+ anchorEl,
36
+ open,
37
+ placement,
38
+ modifiers = MODIFIERS,
39
+ children
40
+ }) {
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoSsr.default, {
42
+ children: open ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsZoomSliderTooltipRoot, {
43
+ open: open,
44
+ anchorEl: anchorEl,
45
+ placement: placement,
46
+ modifiers: modifiers,
47
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltipPaper, {
48
+ sx: {
49
+ paddingX: 0.5
50
+ },
51
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
52
+ variant: "caption",
53
+ children: children
54
+ })
55
+ })
56
+ }) : null
57
+ });
58
+ }
@@ -0,0 +1,17 @@
1
+ import type { ChartZoomSliderThumbOwnerState } from "./ChartAxisZoomSliderThumb.js";
2
+ export interface ChartAxisZoomSliderThumbClasses {
3
+ /** Styles applied to the root element. */
4
+ root: string;
5
+ /** Styles applied to the root element when it is horizontal. */
6
+ horizontal: string;
7
+ /** Styles applied to the root element when it is vertical. */
8
+ vertical: string;
9
+ /** Styles applied to the root element when it is a start thumb. */
10
+ start: string;
11
+ /** Styles applied to the root element when it is an end thumb. */
12
+ end: string;
13
+ }
14
+ export type ChartAxisZoomSliderThumbClassKey = keyof ChartAxisZoomSliderThumbClasses;
15
+ export declare const chartAxisZoomSliderThumbClasses: ChartAxisZoomSliderThumbClasses;
16
+ export declare function getAxisZoomSliderThumbUtilityClass(slot: string): string;
17
+ export declare const useUtilityClasses: (ownerState: ChartZoomSliderThumbOwnerState) => Record<"root", string>;
@@ -4,15 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.chartAxisZoomSliderHandleClasses = void 0;
8
- exports.getAxisZoomSliderHandleUtilityClass = getAxisZoomSliderHandleUtilityClass;
7
+ exports.chartAxisZoomSliderThumbClasses = void 0;
8
+ exports.getAxisZoomSliderThumbUtilityClass = getAxisZoomSliderThumbUtilityClass;
9
9
  exports.useUtilityClasses = void 0;
10
10
  var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
11
11
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
12
12
  var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
13
- const chartAxisZoomSliderHandleClasses = exports.chartAxisZoomSliderHandleClasses = (0, _generateUtilityClasses.default)('MuiChartAxisZoomSliderHandle', ['root', 'horizontal', 'vertical', 'start', 'end']);
14
- function getAxisZoomSliderHandleUtilityClass(slot) {
15
- return (0, _generateUtilityClass.default)('MuiChartAxisZoomSliderHandle', slot);
13
+ const chartAxisZoomSliderThumbClasses = exports.chartAxisZoomSliderThumbClasses = (0, _generateUtilityClasses.default)('MuiChartAxisZoomSliderThumb', ['root', 'horizontal', 'vertical', 'start', 'end']);
14
+ function getAxisZoomSliderThumbUtilityClass(slot) {
15
+ return (0, _generateUtilityClass.default)('MuiChartAxisZoomSliderThumb', slot);
16
16
  }
17
17
  const useUtilityClasses = ownerState => {
18
18
  const {
@@ -22,6 +22,6 @@ const useUtilityClasses = ownerState => {
22
22
  const slots = {
23
23
  root: ['root', orientation === 'horizontal' ? 'horizontal' : 'vertical', placement === 'start' ? 'start' : 'end']
24
24
  };
25
- return (0, _composeClasses.default)(slots, getAxisZoomSliderHandleUtilityClass);
25
+ return (0, _composeClasses.default)(slots, getAxisZoomSliderThumbUtilityClass);
26
26
  };
27
27
  exports.useUtilityClasses = useUtilityClasses;
@@ -51,13 +51,14 @@ const FunnelChart = exports.FunnelChart = /*#__PURE__*/React.forwardRef(function
51
51
  seriesConfig: seriesConfig,
52
52
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_internals.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
53
53
  children: [!themedProps.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
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, {
55
- trigger: "item"
56
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), children]
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)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), children]
55
+ })), !themedProps.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, themedProps.slotProps?.tooltip, {
56
+ trigger: "item"
57
57
  }))]
58
58
  }))
59
59
  }));
60
60
  });
61
+ if (process.env.NODE_ENV !== "production") FunnelChart.displayName = "FunnelChart";
61
62
  process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
62
63
  // ----------------------------- Warning --------------------------------
63
64
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -86,12 +86,14 @@ const useAggregatedData = gap => {
86
86
  seriesId,
87
87
  value: currentSeries.data[dataIndex].value
88
88
  }) : currentSeries.sectionLabel;
89
+ const isIncreasing = currentSeries.dataDirection === 'increasing';
89
90
  const curve = (0, _curves.getFunnelCurve)(currentSeries.curve, {
90
91
  isHorizontal,
91
92
  gap,
92
93
  position: dataIndex,
93
94
  sections: currentSeries.dataPoints.length,
94
95
  borderRadius: currentSeries.borderRadius,
96
+ isIncreasing,
95
97
  min: minPoint,
96
98
  max: maxPoint
97
99
  });
@@ -64,4 +64,5 @@ const FunnelSection = exports.FunnelSection = (0, _internals.consumeSlots)('MuiF
64
64
  }, other, {
65
65
  ref: ref
66
66
  }));
67
- }));
67
+ }));
68
+ if (process.env.NODE_ENV !== "production") FunnelSection.displayName = "FunnelSection";
@@ -8,6 +8,10 @@ export type CurveOptions = {
8
8
  * Indicates if the main axis of the visualization.
9
9
  */
10
10
  isHorizontal?: boolean;
11
+ /**
12
+ * Indicates if the segments values are increasing or decreasing.
13
+ */
14
+ isIncreasing?: boolean;
11
15
  /**
12
16
  * The order position of the segment.
13
17
  */
@@ -11,6 +11,7 @@ export declare class Pyramid implements CurveGenerator {
11
11
  private position;
12
12
  private sections;
13
13
  private isHorizontal;
14
+ private isIncreasing;
14
15
  private gap;
15
16
  private borderRadius;
16
17
  private min;
@@ -23,7 +24,8 @@ export declare class Pyramid implements CurveGenerator {
23
24
  sections,
24
25
  borderRadius,
25
26
  min,
26
- max
27
+ max,
28
+ isIncreasing
27
29
  }: CurveOptions);
28
30
  areaStart(): void;
29
31
  areaEnd(): void;
@@ -22,12 +22,14 @@ class Pyramid {
22
22
  sections,
23
23
  borderRadius,
24
24
  min,
25
- max
25
+ max,
26
+ isIncreasing
26
27
  }) {
27
28
  this.context = void 0;
28
29
  this.position = 0;
29
30
  this.sections = 0;
30
31
  this.isHorizontal = false;
32
+ this.isIncreasing = false;
31
33
  this.gap = 0;
32
34
  this.borderRadius = 0;
33
35
  this.min = {
@@ -45,6 +47,7 @@ class Pyramid {
45
47
  this.position = position ?? 0;
46
48
  this.sections = sections ?? 1;
47
49
  this.borderRadius = borderRadius ?? 0;
50
+ this.isIncreasing = isIncreasing ?? false;
48
51
  this.min = min ?? {
49
52
  x: 0,
50
53
  y: 0
@@ -53,6 +56,12 @@ class Pyramid {
53
56
  x: 0,
54
57
  y: 0
55
58
  };
59
+ if (isIncreasing) {
60
+ const currentMin = this.min;
61
+ const currentMax = this.max;
62
+ this.min = currentMax;
63
+ this.max = currentMin;
64
+ }
56
65
  }
57
66
  areaStart() {}
58
67
  areaEnd() {}
@@ -62,14 +71,25 @@ class Pyramid {
62
71
  if (this.gap > 0) {
63
72
  return this.borderRadius;
64
73
  }
65
- if (this.position === 0) {
66
- return [0, 0, this.borderRadius, this.borderRadius];
67
- }
68
- if (this.position === this.sections - 1 && this.gap <= 0) {
69
- return [this.borderRadius];
74
+ if (this.isIncreasing) {
75
+ // Is largest section
76
+ if (this.position === this.sections - 1) {
77
+ return [this.borderRadius, this.borderRadius];
78
+ }
79
+ // Is smallest section and shaped like a triangle
80
+ if (this.position === 0) {
81
+ return [0, 0, this.borderRadius];
82
+ }
70
83
  }
71
- if (this.position === this.sections - 1) {
72
- return [this.borderRadius, this.borderRadius];
84
+ if (!this.isIncreasing) {
85
+ // Is largest section
86
+ if (this.position === 0) {
87
+ return [0, 0, this.borderRadius, this.borderRadius];
88
+ }
89
+ // Is smallest section and shaped like a triangle
90
+ if (this.position === this.sections - 1) {
91
+ return [this.borderRadius];
92
+ }
73
93
  }
74
94
  return 0;
75
95
  }
@@ -118,8 +138,15 @@ class Pyramid {
118
138
 
119
139
  // In the last section, to form a triangle we need 3 points instead of 4
120
140
  // Else the algorithm will break.
121
- if (this.position === this.sections - 1 && this.gap <= 0) {
122
- this.points = [this.points[0], this.points[1], this.points[3]];
141
+ const isLastSection = this.position === this.sections - 1;
142
+ const isFirstSection = this.position === 0;
143
+ if (this.gap <= 0) {
144
+ if (isFirstSection && this.isIncreasing) {
145
+ this.points = [this.points[0], this.points[1], this.points[2]];
146
+ }
147
+ if (isLastSection && !this.isIncreasing) {
148
+ this.points = [this.points[0], this.points[1], this.points[3]];
149
+ }
123
150
  }
124
151
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());
125
152
  }
@@ -1,5 +1,5 @@
1
1
  import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
2
- import { CurveOptions } from "./curve.types.js";
2
+ import { CurveOptions, Point } from "./curve.types.js";
3
3
  /**
4
4
  * This is a custom "step-pyramid" curve generator.
5
5
  * It creates a step pyramid, which is a step-like shape with static lengths.
@@ -8,7 +8,9 @@ import { CurveOptions } from "./curve.types.js";
8
8
  export declare class StepPyramid implements CurveGenerator {
9
9
  private context;
10
10
  private position;
11
+ private sections;
11
12
  private isHorizontal;
13
+ private isIncreasing;
12
14
  private gap;
13
15
  private borderRadius;
14
16
  private min;
@@ -18,14 +20,20 @@ export declare class StepPyramid implements CurveGenerator {
18
20
  isHorizontal,
19
21
  gap,
20
22
  position,
23
+ sections,
21
24
  borderRadius,
22
25
  min,
23
- max
26
+ max,
27
+ isIncreasing
24
28
  }: CurveOptions);
25
29
  areaStart(): void;
26
30
  areaEnd(): void;
27
31
  lineStart(): void;
28
32
  lineEnd(): void;
29
33
  protected getBorderRadius(): number | number[];
34
+ slopeStart(index: number): Point;
35
+ slopeEnd(index: number): Point;
36
+ initialX(index: number): number;
37
+ initialY(index: number): number;
30
38
  point(xIn: number, yIn: number): void;
31
39
  }
@@ -18,13 +18,17 @@ class StepPyramid {
18
18
  isHorizontal,
19
19
  gap,
20
20
  position,
21
+ sections,
21
22
  borderRadius,
22
23
  min,
23
- max
24
+ max,
25
+ isIncreasing
24
26
  }) {
25
27
  this.context = void 0;
26
28
  this.position = 0;
29
+ this.sections = 0;
27
30
  this.isHorizontal = false;
31
+ this.isIncreasing = false;
28
32
  this.gap = 0;
29
33
  this.borderRadius = 0;
30
34
  this.min = {
@@ -40,7 +44,9 @@ class StepPyramid {
40
44
  this.isHorizontal = isHorizontal ?? false;
41
45
  this.gap = (gap ?? 0) / 2;
42
46
  this.position = position ?? 0;
47
+ this.sections = sections ?? 1;
43
48
  this.borderRadius = borderRadius ?? 0;
49
+ this.isIncreasing = isIncreasing ?? false;
44
50
  this.min = min ?? {
45
51
  x: 0,
46
52
  y: 0
@@ -55,7 +61,91 @@ class StepPyramid {
55
61
  lineStart() {}
56
62
  lineEnd() {}
57
63
  getBorderRadius() {
58
- return this.gap > 0 || this.position === 0 ? this.borderRadius : [this.borderRadius, this.borderRadius];
64
+ if (this.gap > 0) {
65
+ return this.borderRadius;
66
+ }
67
+ if (this.isIncreasing) {
68
+ if (this.position === this.sections - 1) {
69
+ return this.borderRadius;
70
+ }
71
+ return [0, 0, this.borderRadius, this.borderRadius];
72
+ }
73
+ if (this.position === 0) {
74
+ return this.borderRadius;
75
+ }
76
+ return [this.borderRadius, this.borderRadius];
77
+ }
78
+ slopeStart(index) {
79
+ if (this.isIncreasing) {
80
+ if (this.isHorizontal) {
81
+ return {
82
+ x: this.min.x,
83
+ y: (this.min.y + this.max.y) / 2
84
+ };
85
+ }
86
+ return {
87
+ x: (this.min.x + this.max.x) / 2,
88
+ y: this.min.y
89
+ };
90
+ }
91
+ if (this.isHorizontal) {
92
+ if (index <= 1) {
93
+ return this.min;
94
+ }
95
+ return {
96
+ x: this.min.x,
97
+ y: this.max.y
98
+ };
99
+ }
100
+ if (index <= 1) {
101
+ return {
102
+ x: this.max.x,
103
+ y: this.min.y
104
+ };
105
+ }
106
+ return this.min;
107
+ }
108
+ slopeEnd(index) {
109
+ if (this.isIncreasing) {
110
+ if (this.isHorizontal) {
111
+ if (index <= 1) {
112
+ return {
113
+ x: this.max.x,
114
+ y: this.min.y
115
+ };
116
+ }
117
+ return this.max;
118
+ }
119
+ if (index <= 1) {
120
+ return this.max;
121
+ }
122
+ return {
123
+ x: this.min.x,
124
+ y: this.max.y
125
+ };
126
+ }
127
+ if (this.isHorizontal) {
128
+ return {
129
+ x: this.max.x,
130
+ y: (this.max.y + this.min.y) / 2
131
+ };
132
+ }
133
+ return {
134
+ x: (this.max.x + this.min.x) / 2,
135
+ y: this.max.y
136
+ };
137
+ }
138
+ initialX(index) {
139
+ if (this.isIncreasing) {
140
+ return index === 0 || index === 1 ? this.points.at(1).x : this.points.at(2).x;
141
+ }
142
+ return index === 0 || index === 1 ? this.points.at(0).x : this.points.at(3).x;
143
+ }
144
+ initialY(index) {
145
+ if (this.isIncreasing) {
146
+ return index === 0 || index === 1 ? this.points.at(1).y : this.points.at(2).y;
147
+ }
148
+ return index === 0 || index === 1 ? this.points.at(0).y : this.points.at(3).y;
59
149
  }
60
150
  point(xIn, yIn) {
61
151
  this.points.push({
@@ -68,34 +158,20 @@ class StepPyramid {
68
158
 
69
159
  // Add gaps where they are needed.
70
160
  this.points = this.points.map((point, index) => {
161
+ const slopeStart = this.slopeStart(index);
162
+ const slopeEnd = this.slopeEnd(index);
71
163
  if (this.isHorizontal) {
72
- const slopeEnd = {
73
- x: this.max.x,
74
- y: (this.max.y + this.min.y) / 2
75
- };
76
- const slopeStart = index <= 1 ? this.min : {
77
- x: this.min.x,
78
- y: this.max.y
79
- };
80
164
  const yGetter = (0, _utils.lerpY)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
81
165
  const xGap = point.x + (index === 0 || index === 3 ? this.gap : -this.gap);
82
- const xInitial = index === 0 || index === 1 ? this.points.at(0).x : this.points.at(3).x;
166
+ const xInitial = this.initialX(index);
83
167
  return {
84
168
  x: xGap,
85
169
  y: yGetter(xInitial)
86
170
  };
87
171
  }
88
- const slopeEnd = {
89
- x: (this.max.x + this.min.x) / 2,
90
- y: this.max.y
91
- };
92
- const slopeStart = index <= 1 ? {
93
- x: this.max.x,
94
- y: this.min.y
95
- } : this.min;
96
172
  const xGetter = (0, _utils.lerpX)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
97
173
  const yGap = point.y + (index === 0 || index === 3 ? this.gap : -this.gap);
98
- const yInitial = index === 0 || index === 1 ? this.points.at(0).y : this.points.at(3).y;
174
+ const yInitial = this.initialY(index);
99
175
  return {
100
176
  x: xGetter(yInitial),
101
177
  y: yGap
@@ -13,15 +13,19 @@ import { CurveOptions } from "./curve.types.js";
13
13
  export declare class Step implements CurveGenerator {
14
14
  private context;
15
15
  private isHorizontal;
16
+ private isIncreasing;
16
17
  private gap;
17
18
  private borderRadius;
18
19
  private position;
20
+ private sections;
19
21
  private points;
20
22
  constructor(context: CanvasRenderingContext2D, {
21
23
  isHorizontal,
22
24
  gap,
23
25
  position,
24
- borderRadius
26
+ borderRadius,
27
+ isIncreasing,
28
+ sections
25
29
  }: CurveOptions);
26
30
  areaStart(): void;
27
31
  areaEnd(): void;
@@ -23,26 +23,44 @@ class Step {
23
23
  isHorizontal,
24
24
  gap,
25
25
  position,
26
- borderRadius
26
+ borderRadius,
27
+ isIncreasing,
28
+ sections
27
29
  }) {
28
30
  this.context = void 0;
29
31
  this.isHorizontal = false;
32
+ this.isIncreasing = false;
30
33
  this.gap = 0;
31
34
  this.borderRadius = 0;
32
35
  this.position = 0;
36
+ this.sections = 0;
33
37
  this.points = [];
34
38
  this.context = context;
35
39
  this.isHorizontal = isHorizontal ?? false;
36
40
  this.gap = (gap ?? 0) / 2;
37
41
  this.position = position ?? 0;
42
+ this.sections = sections ?? 1;
38
43
  this.borderRadius = borderRadius ?? 0;
44
+ this.isIncreasing = isIncreasing ?? false;
39
45
  }
40
46
  areaStart() {}
41
47
  areaEnd() {}
42
48
  lineStart() {}
43
49
  lineEnd() {}
44
50
  getBorderRadius() {
45
- return this.gap > 0 || this.position === 0 ? this.borderRadius : [this.borderRadius, this.borderRadius];
51
+ if (this.gap > 0) {
52
+ return this.borderRadius;
53
+ }
54
+ if (this.isIncreasing) {
55
+ if (this.position === this.sections - 1) {
56
+ return this.borderRadius;
57
+ }
58
+ return [0, 0, this.borderRadius, this.borderRadius];
59
+ }
60
+ if (this.position === 0) {
61
+ return this.borderRadius;
62
+ }
63
+ return [this.borderRadius, this.borderRadius];
46
64
  }
47
65
  point(xIn, yIn) {
48
66
  this.points.push({
@@ -110,6 +110,13 @@ export type FunnelItem = {
110
110
  export interface DefaultizedFunnelSeriesType extends DefaultizedProps<FunnelSeriesType, CommonDefaultizedProps | 'layout'> {
111
111
  dataPoints: FunnelDataPoints[][];
112
112
  data: Readonly<MakeRequired<FunnelValueType, 'id' | 'color'>[]>;
113
+ /**
114
+ * Denotes if the data is increasing, first data point is less than the last data point.
115
+ * While the data is decreasing if the first data point is greater than the last data point.
116
+ *
117
+ * This is used to determine the direction of the funnel.
118
+ */
119
+ dataDirection: 'increasing' | 'decreasing';
113
120
  }
114
121
  export type FunnelDataPoints = Record<'x' | 'y', number> & {
115
122
  useBandWidth: boolean;