@mui/x-charts-pro 8.5.1 → 8.5.2

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 (78) hide show
  1. package/BarChartPro/BarChartPro.d.ts +3 -2
  2. package/CHANGELOG.md +92 -0
  3. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  4. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +2 -1
  5. package/ChartsToolbarPro/ChartsToolbarPro.d.ts +2 -1
  6. package/ChartsToolbarPro/Toolbar.types.d.ts +15 -0
  7. package/ChartsToolbarPro/Toolbar.types.js +5 -0
  8. package/FunnelChart/FunnelChart.js +4 -11
  9. package/FunnelChart/FunnelChart.plugins.d.ts +3 -2
  10. package/FunnelChart/FunnelChart.plugins.js +2 -1
  11. package/FunnelChart/FunnelPlot.d.ts +0 -5
  12. package/FunnelChart/FunnelPlot.js +30 -28
  13. package/FunnelChart/categoryAxis.types.d.ts +2 -1
  14. package/FunnelChart/curves/bump.d.ts +0 -2
  15. package/FunnelChart/curves/bump.js +10 -13
  16. package/FunnelChart/curves/linear.d.ts +1 -1
  17. package/FunnelChart/curves/linear.js +26 -23
  18. package/FunnelChart/curves/pyramid.js +10 -14
  19. package/FunnelChart/curves/step-pyramid.js +4 -6
  20. package/FunnelChart/curves/step.js +1 -15
  21. package/FunnelChart/funnelAxisPlugin/computeAxisValue.d.ts +25 -0
  22. package/FunnelChart/funnelAxisPlugin/computeAxisValue.js +124 -0
  23. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.d.ts +3 -0
  24. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +173 -0
  25. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +27 -0
  26. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.js +5 -0
  27. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +1482 -0
  28. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.js +27 -0
  29. package/FunnelChart/labelUtils.d.ts +3 -2
  30. package/FunnelChart/labelUtils.js +15 -15
  31. package/FunnelChart/positionGetter.d.ts +1 -0
  32. package/FunnelChart/positionGetter.js +5 -0
  33. package/FunnelChart/useFunnelChartProps.js +1 -3
  34. package/Heatmap/Heatmap.d.ts +3 -3
  35. package/LineChartPro/LineChartPro.d.ts +3 -2
  36. package/PieChartPro/PieChartPro.d.ts +3 -2
  37. package/RadarChartPro/RadarChartPro.d.ts +17 -2
  38. package/ScatterChartPro/ScatterChartPro.d.ts +3 -2
  39. package/esm/BarChartPro/BarChartPro.d.ts +3 -2
  40. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  41. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +2 -1
  42. package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +2 -1
  43. package/esm/ChartsToolbarPro/Toolbar.types.d.ts +15 -0
  44. package/esm/ChartsToolbarPro/Toolbar.types.js +1 -0
  45. package/esm/FunnelChart/FunnelChart.js +4 -11
  46. package/esm/FunnelChart/FunnelChart.plugins.d.ts +3 -2
  47. package/esm/FunnelChart/FunnelChart.plugins.js +3 -2
  48. package/esm/FunnelChart/FunnelPlot.d.ts +0 -5
  49. package/esm/FunnelChart/FunnelPlot.js +31 -29
  50. package/esm/FunnelChart/categoryAxis.types.d.ts +2 -1
  51. package/esm/FunnelChart/curves/bump.d.ts +0 -2
  52. package/esm/FunnelChart/curves/bump.js +10 -13
  53. package/esm/FunnelChart/curves/linear.d.ts +1 -1
  54. package/esm/FunnelChart/curves/linear.js +26 -23
  55. package/esm/FunnelChart/curves/pyramid.js +10 -14
  56. package/esm/FunnelChart/curves/step-pyramid.js +4 -6
  57. package/esm/FunnelChart/curves/step.js +1 -15
  58. package/esm/FunnelChart/funnelAxisPlugin/computeAxisValue.d.ts +25 -0
  59. package/esm/FunnelChart/funnelAxisPlugin/computeAxisValue.js +114 -0
  60. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.d.ts +3 -0
  61. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +165 -0
  62. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +27 -0
  63. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.js +1 -0
  64. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +1482 -0
  65. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.js +20 -0
  66. package/esm/FunnelChart/labelUtils.d.ts +3 -2
  67. package/esm/FunnelChart/labelUtils.js +15 -15
  68. package/esm/FunnelChart/positionGetter.d.ts +1 -0
  69. package/esm/FunnelChart/positionGetter.js +1 -0
  70. package/esm/FunnelChart/useFunnelChartProps.js +1 -3
  71. package/esm/Heatmap/Heatmap.d.ts +3 -3
  72. package/esm/LineChartPro/LineChartPro.d.ts +3 -2
  73. package/esm/PieChartPro/PieChartPro.d.ts +3 -2
  74. package/esm/RadarChartPro/RadarChartPro.d.ts +17 -2
  75. package/esm/ScatterChartPro/ScatterChartPro.d.ts +3 -2
  76. package/esm/index.js +1 -1
  77. package/index.js +1 -1
  78. package/package.json +6 -6
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { BarChartProps, BarChartSlotProps, BarChartSlots } from '@mui/x-charts/BarChart';
3
+ import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
3
4
  import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
4
5
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
5
6
  import { BarChartProPluginsSignatures } from "./BarChartPro.plugins.js";
6
- export interface BarChartProSlots extends BarChartSlots, Partial<ChartsSlotsPro> {}
7
- export interface BarChartProSlotProps extends BarChartSlotProps, Partial<ChartsSlotPropsPro> {}
7
+ export interface BarChartProSlots extends Omit<BarChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
8
+ export interface BarChartProSlotProps extends Omit<BarChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
8
9
  export interface BarChartProProps extends Omit<BarChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<ChartContainerProProps<'bar', BarChartProPluginsSignatures>, 'series' | 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {
9
10
  /**
10
11
  * Overridable component slots.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,98 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.5.2
9
+
10
+ _Jun 12, 2025_
11
+
12
+ We'd like to extend a big thank you to the 15 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 📊 Improve Data Grid selectors performance
15
+ - 🐞 Fix `useSyncExternalStore` import error in React 17
16
+
17
+ Special thanks go out to the community members for their valuable contributions:
18
+ @alisasanib, @noobyogi0010.
19
+
20
+ The following are all team members who have contributed to this release:
21
+ @alexfauquette, @arminmeh, @bernardobelchior, @cherniavskii, @JCQuintas, @KenanYusuf, @LukasTy, @mapache-salvaje, @michelengelen, @noraleonte, @oliviertassinari, @prakhargupta1, @romgrk.
22
+
23
+ ### Data Grid
24
+
25
+ #### `@mui/x-data-grid@8.5.2`
26
+
27
+ - [DataGrid] Improve selectors performance (#18234) @romgrk
28
+ - [DataGrid] Fix data grid palette when using CSS vars (#18310) @KenanYusuf
29
+ - [DataGrid] Ignore data source request if the grid got unmounted (#18268) @arminmeh
30
+
31
+ #### `@mui/x-data-grid-pro@8.5.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
32
+
33
+ Same changes as in `@mui/x-data-grid@8.5.2`, plus:
34
+
35
+ - [DataGridPro] Fix flex column width if it is a pinned column (#18293) @alisasanib
36
+ - [DataGridPro] Fix inconsistent filtering results with aggregation (#17954) @cherniavskii
37
+
38
+ #### `@mui/x-data-grid-premium@8.5.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
39
+
40
+ Same changes as in `@mui/x-data-grid-pro@8.5.2`.
41
+
42
+ ### Date and Time Pickers
43
+
44
+ #### `@mui/x-date-pickers@8.5.2`
45
+
46
+ - [pickers] Add `PickerDay2` and `DateRangePickerDay2` components (#15921) @noraleonte
47
+ - [pickers] Fix `hiddenLabel` prop propagation (#18195) @noobyogi0010
48
+
49
+ #### `@mui/x-date-pickers-pro@8.5.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
+
51
+ Same changes as in `@mui/x-date-pickers@8.5.2`.
52
+
53
+ ### Charts
54
+
55
+ #### `@mui/x-charts@8.5.2`
56
+
57
+ - [charts] Add a default value formatter for continuous scales (#18178) @bernardobelchior
58
+ - [charts] Add margin-bottom to charts toolbar (#18326) @bernardobelchior
59
+ - [charts] Fix grid with band scale (#18295) @alexfauquette
60
+ - [charts] Remove unnecessary style changes in tests (#18317) @JCQuintas
61
+ - [charts] Remove `sx` prop merging from `useComponentRenderer` (#18235) @bernardobelchior
62
+ - [charts] Fix `useSyncExternalStore` import error in React 17 (#18314) @bernardobelchior
63
+
64
+ #### `@mui/x-charts-pro@8.5.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
65
+
66
+ Same changes as in `@mui/x-charts@8.5.2`, plus:
67
+
68
+ - [charts-pro] Document zoom slider tooltip value formatting (#18261) @bernardobelchior
69
+ - [charts-pro] Funnel `gap` prop does not impact the drawing area (#18233) @JCQuintas
70
+ - [charts-pro] Use `ChartsToolbarPro` types in pro charts (#18243) @bernardobelchior
71
+
72
+ ### Tree View
73
+
74
+ #### `@mui/x-tree-view@8.5.2`
75
+
76
+ - [tree-view] Fix `useSyncExternalStore` import error in React 17 (#18314) @bernardobelchior
77
+
78
+ #### `@mui/x-tree-view-pro@8.5.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
79
+
80
+ Same changes as in `@mui/x-tree-view@8.5.2`.
81
+
82
+ ### Docs
83
+
84
+ - [docs] Add toolbar custom trigger and panel recipe (#18297) @KenanYusuf
85
+ - [docs] Copyedit the Priority support page (#18311) @mapache-salvaje
86
+ - [docs] Remove confusing opt-out mention in telemetry docs (#18257) @prakhargupta1
87
+ - [docs] Revise the Master Detail doc (#17927) @mapache-salvaje
88
+ - [docs] Revise the list view doc (#17928) @mapache-salvaje
89
+ - [docs] Audit and revise the Pro column docs (#17844) @mapache-salvaje
90
+ - [docs] Add some more context on Heatmap (#18256) @oliviertassinari
91
+ - [x-telemetry] Reduce Telemetry overhead (#18292) @oliviertassinari
92
+ - [code-infra] Align Node version used in CI to v22 (#18319) @LukasTy
93
+ - [code-infra] Fix pkg.pr.new publishing (#18316) @bernardobelchior
94
+ - [code-infra] Revert `React` to `19.0.0` (#18265) @LukasTy
95
+ - [code-infra] Use `catalog` for reused dependencies (#18302) @LukasTy
96
+ - [infra] Remove unused karma/mocha deps and files (#18340) @JCQuintas
97
+ - [infra] Update github label references to use 'scope' instead of 'component' (#18260) @michelengelen
98
+ - [infra] Use a single browser server in CI (#18230) @JCQuintas
99
+
8
100
  ## 8.5.1
9
101
 
10
102
  <!-- generated comparing v8.5.0..master -->
@@ -18,7 +18,7 @@ var _material = require("../internals/material");
18
18
  var _allPlugins = require("../internals/plugins/allPlugins");
19
19
  var _useChartDataProviderProProps = require("./useChartDataProviderProProps");
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
- const releaseInfo = "MTc0OTA3MDgwMDAwMA==";
21
+ const releaseInfo = "MTc0OTY3OTIwMDAwMA==";
22
22
  const packageIdentifier = 'x-charts-pro';
23
23
  /**
24
24
  * Orchestrates the data providers for the chart components and hooks.
@@ -257,7 +257,8 @@ function getZoomSliderTooltipsText(axis, drawingArea) {
257
257
  const formatValue = value => {
258
258
  if (axis.valueFormatter) {
259
259
  return axis.valueFormatter(value, {
260
- location: 'zoom-slider-tooltip'
260
+ location: 'zoom-slider-tooltip',
261
+ scale: axis.scale
261
262
  });
262
263
  }
263
264
  return `${value}`;
@@ -1,6 +1,7 @@
1
1
  import { ChartsToolbarProps } from '@mui/x-charts/Toolbar';
2
2
  import * as React from 'react';
3
+ export interface ChartsToolbarProProps extends ChartsToolbarProps {}
3
4
  /**
4
5
  * The chart toolbar component for the pro package.
5
6
  */
6
- export declare function ChartsToolbarPro(props: ChartsToolbarProps): React.JSX.Element | null;
7
+ export declare function ChartsToolbarPro(props: ChartsToolbarProProps): React.JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { ChartsToolbarProProps } from "./ChartsToolbarPro.js";
3
+ export interface ChartsToolbarProSlots {
4
+ /**
5
+ * Custom component for the toolbar.
6
+ * @default ChartsToolbar
7
+ */
8
+ toolbar?: React.ElementType<ChartsToolbarProProps>;
9
+ }
10
+ export interface ChartsToolbarProSlotProps {
11
+ /**
12
+ * Props for the toolbar component.
13
+ */
14
+ toolbar?: Partial<ChartsToolbarProProps>;
15
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -23,6 +23,7 @@ var _useFunnelChartProps = require("./useFunnelChartProps");
23
23
  var _seriesConfig = require("./seriesConfig");
24
24
  var _useChartContainerProProps = require("../ChartContainerPro/useChartContainerProProps");
25
25
  var _ChartDataProviderPro = require("../ChartDataProviderPro");
26
+ var _FunnelChart2 = require("./FunnelChart.plugins");
26
27
  var _jsxRuntime = require("react/jsx-runtime");
27
28
  const seriesConfig = {
28
29
  funnel: _seriesConfig.seriesConfig
@@ -48,7 +49,9 @@ const FunnelChart = exports.FunnelChart = /*#__PURE__*/React.forwardRef(function
48
49
  } = (0, _useChartContainerProProps.useChartContainerProProps)(chartContainerProps, ref);
49
50
  const Tooltip = themedProps.slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
50
51
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartDataProviderPro.ChartDataProviderPro, (0, _extends2.default)({}, chartDataProviderProProps, {
52
+ gap: themedProps.gap,
51
53
  seriesConfig: seriesConfig,
54
+ plugins: _FunnelChart2.FUNNEL_CHART_PLUGINS,
52
55
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_internals.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
53
56
  children: [!themedProps.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
54
57
  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]
@@ -95,16 +98,6 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
95
98
  size: _propTypes.default.number,
96
99
  tickLabelStyle: _propTypes.default.object,
97
100
  tickSize: _propTypes.default.number
98
- }), _propTypes.default.shape({
99
- categories: _propTypes.default.arrayOf(_propTypes.default.string),
100
- disableLine: _propTypes.default.bool,
101
- disableTicks: _propTypes.default.bool,
102
- id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
103
- position: _propTypes.default.oneOf(['bottom', 'left', 'none', 'right', 'top']),
104
- scaleType: _propTypes.default.oneOf(['point']),
105
- size: _propTypes.default.number,
106
- tickLabelStyle: _propTypes.default.object,
107
- tickSize: _propTypes.default.number
108
101
  }), _propTypes.default.shape({
109
102
  categories: _propTypes.default.arrayOf(_propTypes.default.string),
110
103
  disableLine: _propTypes.default.bool,
@@ -229,7 +222,7 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
229
222
  })]),
230
223
  /**
231
224
  * The function called for onClick events.
232
- * The second argument contains information about all line/bar elements at the current mouse position.
225
+ * The second argument contains information about all funnel elements at the current position.
233
226
  * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
234
227
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
235
228
  */
@@ -1,4 +1,5 @@
1
- import { ConvertSignaturesIntoPlugins, UseChartCartesianAxisSignature, UseChartHighlightSignature, UseChartInteractionSignature } from '@mui/x-charts/internals';
1
+ import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
- export type FunnelChartPluginsSignatures = [UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
3
+ import { UseChartFunnelAxisSignature } from "./funnelAxisPlugin/useChartFunnelAxis.types.js";
4
+ export type FunnelChartPluginsSignatures = [UseChartFunnelAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
4
5
  export declare const FUNNEL_CHART_PLUGINS: ConvertSignaturesIntoPlugins<FunnelChartPluginsSignatures>;
@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.FUNNEL_CHART_PLUGINS = void 0;
7
7
  var _internals = require("@mui/x-charts/internals");
8
8
  var _useChartProExport = require("../internals/plugins/useChartProExport");
9
- const FUNNEL_CHART_PLUGINS = exports.FUNNEL_CHART_PLUGINS = [_internals.useChartCartesianAxis, _internals.useChartInteraction, _internals.useChartHighlight, _useChartProExport.useChartProExport];
9
+ var _useChartFunnelAxis = require("./funnelAxisPlugin/useChartFunnelAxis");
10
+ const FUNNEL_CHART_PLUGINS = exports.FUNNEL_CHART_PLUGINS = [_useChartFunnelAxis.useChartFunnelAxis, _internals.useChartInteraction, _internals.useChartHighlight, _useChartProExport.useChartProExport];
@@ -2,11 +2,6 @@ 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;
10
5
  /**
11
6
  * Callback fired when a funnel item is clicked.
12
7
  * @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
@@ -13,25 +13,27 @@ var React = _react;
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
15
15
  var _internals = require("@mui/x-charts/internals");
16
- var _hooks = require("@mui/x-charts/hooks");
17
16
  var _FunnelSection = require("./FunnelSection");
18
17
  var _labelUtils = require("./labelUtils");
19
18
  var _useFunnelSeries = require("../hooks/useFunnelSeries");
20
19
  var _curves = require("./curves");
21
20
  var _FunnelSectionLabel = require("./FunnelSectionLabel");
21
+ var _useChartFunnelAxisRendering = require("./funnelAxisPlugin/useChartFunnelAxisRendering.selectors");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
- const _excluded = ["onItemClick", "gap"];
23
+ const _excluded = ["onItemClick"];
24
24
  _internals.cartesianSeriesTypes.addType('funnel');
25
- const useAggregatedData = gap => {
25
+ const useAggregatedData = () => {
26
26
  const seriesData = (0, _useFunnelSeries.useFunnelSeriesContext)();
27
+ const store = (0, _internals.useStore)();
27
28
  const {
28
- xAxis,
29
- xAxisIds
30
- } = (0, _hooks.useXAxes)();
29
+ axis: xAxis,
30
+ axisIds: xAxisIds
31
+ } = (0, _internals.useSelector)(store, _useChartFunnelAxisRendering.selectorChartXAxis);
31
32
  const {
32
- yAxis,
33
- yAxisIds
34
- } = (0, _hooks.useYAxes)();
33
+ axis: yAxis,
34
+ axisIds: yAxisIds
35
+ } = (0, _internals.useSelector)(store, _useChartFunnelAxisRendering.selectorChartYAxis);
36
+ const gap = (0, _internals.useSelector)(store, _useChartFunnelAxisRendering.selectorFunnelGap);
35
37
  const allData = React.useMemo(() => {
36
38
  if (seriesData === undefined) {
37
39
  return [];
@@ -54,22 +56,28 @@ const useAggregatedData = gap => {
54
56
  const bandWidth = (isXAxisBand || isYAxisBand) && baseScaleConfig.scale?.bandwidth() || 0;
55
57
  const xScale = xAxis[xAxisId].scale;
56
58
  const yScale = yAxis[yAxisId].scale;
57
- const xPosition = (value, bandIndex, stackOffset, useBand) => {
58
- if (isXAxisBand) {
59
- const position = xScale(bandIndex);
59
+ const xPosition = (value, bandIndex, bandIdentifier, stackOffset, useBand) => {
60
+ if ((0, _internals.isBandScale)(xScale)) {
61
+ const position = xScale(bandIdentifier);
60
62
  return useBand ? position + bandWidth : position;
61
63
  }
62
- return xScale(isHorizontal ? value + (stackOffset || 0) : value);
64
+ if (isHorizontal) {
65
+ return xScale(value + (stackOffset || 0)) + bandIndex * gap;
66
+ }
67
+ return xScale(value);
63
68
  };
64
- const yPosition = (value, bandIndex, stackOffset, useBand) => {
65
- if (isYAxisBand) {
66
- const position = yScale(bandIndex);
69
+ const yPosition = (value, bandIndex, bandIdentifier, stackOffset, useBand) => {
70
+ if ((0, _internals.isBandScale)(yScale)) {
71
+ const position = yScale(bandIdentifier);
67
72
  return useBand ? position + bandWidth : position;
68
73
  }
69
- return yScale(isHorizontal ? value : value + (stackOffset || 0));
74
+ if (isHorizontal) {
75
+ return yScale(value);
76
+ }
77
+ return yScale(value + (stackOffset || 0)) + bandIndex * gap;
70
78
  };
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)));
79
+ const allY = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => yPosition(v.y, dataIndex, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
80
+ const allX = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => xPosition(v.x, dataIndex, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
73
81
  const minPoint = {
74
82
  x: Math.min(...allX),
75
83
  y: Math.min(...allY)
@@ -97,7 +105,7 @@ const useAggregatedData = gap => {
97
105
  min: minPoint,
98
106
  max: maxPoint
99
107
  });
100
- 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);
108
+ const line = (0, _d3Shape.line)().x(d => xPosition(d.x, dataIndex, baseScaleConfig.data?.[dataIndex], d.stackOffset, d.useBandWidth)).y(d => yPosition(d.y, dataIndex, baseScaleConfig.data?.[dataIndex], d.stackOffset, d.useBandWidth)).curve(curve);
101
109
  return {
102
110
  d: line(values),
103
111
  color,
@@ -126,11 +134,10 @@ const useAggregatedData = gap => {
126
134
  };
127
135
  function FunnelPlot(props) {
128
136
  const {
129
- onItemClick,
130
- gap
137
+ onItemClick
131
138
  } = props,
132
139
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
133
- const data = useAggregatedData(gap);
140
+ const data = useAggregatedData();
134
141
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
135
142
  children: [data.map(({
136
143
  d,
@@ -175,11 +182,6 @@ process.env.NODE_ENV !== "production" ? FunnelPlot.propTypes = {
175
182
  // | These PropTypes are generated from the TypeScript type definitions |
176
183
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
177
184
  // ----------------------------------------------------------------------
178
- /**
179
- * The gap, in pixels, between funnel sections.
180
- * @default 0
181
- */
182
- gap: _propTypes.default.number,
183
185
  /**
184
186
  * Callback fired when a funnel item is clicked.
185
187
  * @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
@@ -1,6 +1,7 @@
1
1
  import { AxisConfig, ScaleName } from '@mui/x-charts/models';
2
2
  import { MakeOptional } from '@mui/x-internals/types';
3
- export type CategoryAxis<S extends ScaleName = ScaleName> = S extends ScaleName ? {
3
+ export type FunnelScaleName = Exclude<ScaleName, 'point'>;
4
+ export type CategoryAxis<S extends FunnelScaleName = FunnelScaleName> = S extends FunnelScaleName ? {
4
5
  /**
5
6
  * The categories to be displayed on the axis.
6
7
  * The order of the categories is the order in which they are displayed.
@@ -11,13 +11,11 @@ import { CurveOptions } from "./curve.types.js";
11
11
  export declare class Bump implements CurveGenerator {
12
12
  private context;
13
13
  private isHorizontal;
14
- private gap;
15
14
  private min;
16
15
  private max;
17
16
  private points;
18
17
  constructor(context: CanvasRenderingContext2D, {
19
18
  isHorizontal,
20
- gap,
21
19
  min,
22
20
  max,
23
21
  isIncreasing
@@ -17,14 +17,12 @@ exports.Bump = void 0;
17
17
  class Bump {
18
18
  constructor(context, {
19
19
  isHorizontal,
20
- gap,
21
20
  min,
22
21
  max,
23
22
  isIncreasing
24
23
  }) {
25
24
  this.context = void 0;
26
25
  this.isHorizontal = false;
27
- this.gap = 0;
28
26
  this.min = {
29
27
  x: 0,
30
28
  y: 0
@@ -36,7 +34,6 @@ class Bump {
36
34
  this.points = [];
37
35
  this.context = context;
38
36
  this.isHorizontal = isHorizontal ?? false;
39
- this.gap = (gap ?? 0) / 2;
40
37
  this.min = min ?? {
41
38
  x: 0,
42
39
  y: 0
@@ -79,34 +76,34 @@ class Bump {
79
76
  const [p0, p1, p2, p3] = this.points;
80
77
 
81
78
  // 0 is the top-left corner
82
- this.context.moveTo(p0.x + this.gap, p0.y);
83
- this.context.lineTo(p0.x + this.gap, p0.y);
79
+ this.context.moveTo(p0.x, p0.y);
80
+ this.context.lineTo(p0.x, p0.y);
84
81
 
85
82
  // Bezier curve to point 1
86
- this.context.bezierCurveTo((p0.x + p1.x) / 2, p0.y, (p0.x + p1.x) / 2, p1.y, p1.x - this.gap, p1.y);
83
+ this.context.bezierCurveTo((p0.x + p1.x) / 2, p0.y, (p0.x + p1.x) / 2, p1.y, p1.x, p1.y);
87
84
 
88
85
  // Line to point 2
89
- this.context.lineTo(p2.x - this.gap, p2.y);
86
+ this.context.lineTo(p2.x, p2.y);
90
87
 
91
88
  // Bezier curve back to point 3
92
- this.context.bezierCurveTo((p2.x + p3.x) / 2, p2.y, (p2.x + p3.x) / 2, p3.y, p3.x + this.gap, p3.y);
89
+ this.context.bezierCurveTo((p2.x + p3.x) / 2, p2.y, (p2.x + p3.x) / 2, p3.y, p3.x, p3.y);
93
90
  this.context.closePath();
94
91
  }
95
92
  drawVerticalPath() {
96
93
  const [p0, p1, p2, p3] = this.points;
97
94
 
98
95
  // 0 is the top-right corner
99
- this.context.moveTo(p0.x, p0.y + this.gap);
100
- this.context.lineTo(p0.x, p0.y + this.gap);
96
+ this.context.moveTo(p0.x, p0.y);
97
+ this.context.lineTo(p0.x, p0.y);
101
98
 
102
99
  // Bezier curve to point 1
103
- this.context.bezierCurveTo(p0.x, (p0.y + p1.y) / 2, p1.x, (p0.y + p1.y) / 2, p1.x, p1.y - this.gap);
100
+ this.context.bezierCurveTo(p0.x, (p0.y + p1.y) / 2, p1.x, (p0.y + p1.y) / 2, p1.x, p1.y);
104
101
 
105
102
  // Line to point 2
106
- this.context.lineTo(p2.x, p2.y - this.gap);
103
+ this.context.lineTo(p2.x, p2.y);
107
104
 
108
105
  // Bezier curve back to point 3
109
- this.context.bezierCurveTo(p2.x, (p2.y + p3.y) / 2, p3.x, (p2.y + p3.y) / 2, p3.x, p3.y + this.gap);
106
+ this.context.bezierCurveTo(p2.x, (p2.y + p3.y) / 2, p3.x, (p2.y + p3.y) / 2, p3.x, p3.y);
110
107
  this.context.closePath();
111
108
  }
112
109
  }
@@ -3,7 +3,7 @@ import { CurveOptions } from "./curve.types.js";
3
3
  /**
4
4
  * This is a custom "linear" curve generator.
5
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.
6
+ * with the option to properly handling the border radius.
7
7
  *
8
8
  * The implementation is based on the d3-shape linear curve generator.
9
9
  * https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/linear.js
@@ -11,7 +11,7 @@ var _utils = require("./utils");
11
11
  /**
12
12
  * This is a custom "linear" curve generator.
13
13
  * It draws straight lines for the 4 provided points,
14
- * with the option to add a gap between sections while also properly handling the border radius.
14
+ * with the option to properly handling the border radius.
15
15
  *
16
16
  * The implementation is based on the d3-shape linear curve generator.
17
17
  * https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/linear.js
@@ -47,7 +47,7 @@ class Linear {
47
47
  this.pointShape = 'square';
48
48
  this.context = context;
49
49
  this.isHorizontal = isHorizontal ?? false;
50
- this.gap = (gap ?? 0) / 2;
50
+ this.gap = gap ?? 0;
51
51
  this.position = position ?? 0;
52
52
  this.sections = sections ?? 1;
53
53
  this.borderRadius = borderRadius ?? 0;
@@ -118,21 +118,19 @@ class Linear {
118
118
 
119
119
  // Add gaps where they are needed.
120
120
  this.points = this.points.map((point, index) => {
121
- const slopeStart = this.points.at(index <= 1 ? 0 : 2);
122
- const slopeEnd = this.points.at(index <= 1 ? 1 : 3);
121
+ const slopeStart = this.points.at(index <= 1 ? 0 : 3);
122
+ const slopeEnd = this.points.at(index <= 1 ? 1 : 2);
123
123
  if (this.isHorizontal) {
124
- const yGetter = (0, _utils.lerpY)(slopeStart.x - this.gap, slopeStart.y, slopeEnd.x - this.gap, slopeEnd.y);
125
- const xGap = point.x + (index === 0 || index === 3 ? this.gap : -this.gap);
124
+ const yGetter = (0, _utils.lerpY)(slopeStart.x - this.gap, slopeStart.y, slopeEnd.x, slopeEnd.y);
126
125
  return {
127
- x: xGap,
128
- y: yGetter(xGap)
126
+ x: point.x,
127
+ y: yGetter(point.x)
129
128
  };
130
129
  }
131
- const xGetter = (0, _utils.lerpX)(slopeStart.x, slopeStart.y - this.gap, slopeEnd.x, slopeEnd.y - this.gap);
132
- const yGap = point.y + (index === 0 || index === 3 ? this.gap : -this.gap);
130
+ const xGetter = (0, _utils.lerpX)(slopeStart.x, slopeStart.y - this.gap, slopeEnd.x, slopeEnd.y);
133
131
  return {
134
- x: xGetter(yGap),
135
- y: yGap
132
+ x: xGetter(point.y),
133
+ y: point.y
136
134
  };
137
135
  });
138
136
  if (this.pointShape === 'sharp') {
@@ -140,23 +138,28 @@ class Linear {
140
138
  // Else the algorithm will break.
141
139
  const isLastSection = this.position === this.sections - 1;
142
140
  const isFirstSection = this.position === 0;
141
+ let firstPoint = null;
142
+ let secondPoint = null;
143
143
  if (isFirstSection && this.isIncreasing) {
144
- this.points = [this.isHorizontal ? {
145
- x: this.max.x + this.gap,
146
- y: (this.max.y + this.min.y) / 2
147
- } : {
148
- x: (this.max.x + this.min.x) / 2,
149
- y: this.max.y + this.gap
150
- }, this.points[1], this.points[2]];
144
+ firstPoint = this.points[1];
145
+ secondPoint = this.points[2];
151
146
  }
152
147
  if (isLastSection && !this.isIncreasing) {
153
- this.points = [this.points[0], this.isHorizontal ? {
154
- x: this.max.x - this.gap,
148
+ firstPoint = this.points[3];
149
+ secondPoint = this.points[0];
150
+ }
151
+ if (firstPoint && secondPoint) {
152
+ this.points = [
153
+ // Sharp point at the start
154
+ this.isHorizontal ? {
155
+ x: this.max.x,
155
156
  y: (this.max.y + this.min.y) / 2
156
157
  } : {
157
158
  x: (this.max.x + this.min.x) / 2,
158
- y: this.max.y - this.gap
159
- }, this.points[3]];
159
+ y: this.max.y
160
+ },
161
+ // Then other points
162
+ firstPoint, secondPoint];
160
163
  }
161
164
  }
162
165
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());
@@ -102,7 +102,7 @@ class Pyramid {
102
102
  return;
103
103
  }
104
104
 
105
- // Add gaps where they are needed.
105
+ // Replace funnel points by pyramids ones.
106
106
  this.points = this.points.map((point, index) => {
107
107
  if (this.isHorizontal) {
108
108
  const slopeEnd = {
@@ -114,10 +114,9 @@ class Pyramid {
114
114
  y: this.max.y
115
115
  };
116
116
  const yGetter = (0, _utils.lerpY)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
117
- const xGap = point.x + (index === 0 || index === 3 ? this.gap : -this.gap);
118
117
  return {
119
- x: xGap,
120
- y: yGetter(xGap)
118
+ x: point.x,
119
+ y: yGetter(point.x)
121
120
  };
122
121
  }
123
122
  const slopeEnd = {
@@ -129,10 +128,9 @@ class Pyramid {
129
128
  y: this.min.y
130
129
  } : this.min;
131
130
  const xGetter = (0, _utils.lerpX)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
132
- const yGap = point.y + (index === 0 || index === 3 ? this.gap : -this.gap);
133
131
  return {
134
- x: xGetter(yGap),
135
- y: yGap
132
+ x: xGetter(point.y),
133
+ y: point.y
136
134
  };
137
135
  });
138
136
 
@@ -140,13 +138,11 @@ class Pyramid {
140
138
  // Else the algorithm will break.
141
139
  const isLastSection = this.position === this.sections - 1;
142
140
  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
- }
141
+ if (isFirstSection && this.isIncreasing) {
142
+ this.points = [this.points[0], this.points[1], this.points[2]];
143
+ }
144
+ if (isLastSection && !this.isIncreasing) {
145
+ this.points = [this.points[0], this.points[1], this.points[3]];
150
146
  }
151
147
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());
152
148
  }
@@ -42,7 +42,7 @@ class StepPyramid {
42
42
  this.points = [];
43
43
  this.context = context;
44
44
  this.isHorizontal = isHorizontal ?? false;
45
- this.gap = (gap ?? 0) / 2;
45
+ this.gap = gap ?? 0;
46
46
  this.position = position ?? 0;
47
47
  this.sections = sections ?? 1;
48
48
  this.borderRadius = borderRadius ?? 0;
@@ -156,25 +156,23 @@ class StepPyramid {
156
156
  return;
157
157
  }
158
158
 
159
- // Add gaps where they are needed.
159
+ // Replace funnel points by pyramids ones.
160
160
  this.points = this.points.map((point, index) => {
161
161
  const slopeStart = this.slopeStart(index);
162
162
  const slopeEnd = this.slopeEnd(index);
163
163
  if (this.isHorizontal) {
164
164
  const yGetter = (0, _utils.lerpY)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
165
- const xGap = point.x + (index === 0 || index === 3 ? this.gap : -this.gap);
166
165
  const xInitial = this.initialX(index);
167
166
  return {
168
- x: xGap,
167
+ x: point.x,
169
168
  y: yGetter(xInitial)
170
169
  };
171
170
  }
172
171
  const xGetter = (0, _utils.lerpX)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
173
- const yGap = point.y + (index === 0 || index === 3 ? this.gap : -this.gap);
174
172
  const yInitial = this.initialY(index);
175
173
  return {
176
174
  x: xGetter(yInitial),
177
- y: yGap
175
+ y: point.y
178
176
  };
179
177
  });
180
178
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());