@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
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorFunnelGap = exports.selectorFunnel = exports.selectorChartYAxis = exports.selectorChartXAxis = void 0;
7
+ var _internals = require("@mui/x-charts/internals");
8
+ var _computeAxisValue = require("./computeAxisValue");
9
+ const selectorFunnel = state => state.funnel;
10
+ exports.selectorFunnel = selectorFunnel;
11
+ const selectorFunnelGap = exports.selectorFunnelGap = (0, _internals.createSelector)([selectorFunnel], funnel => funnel?.gap ?? 0);
12
+ const selectorChartXAxis = exports.selectorChartXAxis = (0, _internals.createSelector)([_internals.selectorChartRawXAxis, _internals.selectorChartDrawingArea, _internals.selectorChartSeriesProcessed, _internals.selectorChartSeriesConfig, selectorFunnelGap], (axis, drawingArea, formattedSeries, seriesConfig, gap) => (0, _computeAxisValue.computeAxisValue)({
13
+ drawingArea,
14
+ formattedSeries,
15
+ axis,
16
+ seriesConfig,
17
+ axisDirection: 'x',
18
+ gap
19
+ }));
20
+ const selectorChartYAxis = exports.selectorChartYAxis = (0, _internals.createSelector)([_internals.selectorChartRawYAxis, _internals.selectorChartDrawingArea, _internals.selectorChartSeriesProcessed, _internals.selectorChartSeriesConfig, selectorFunnelGap], (axis, drawingArea, formattedSeries, seriesConfig, gap) => (0, _computeAxisValue.computeAxisValue)({
21
+ drawingArea,
22
+ formattedSeries,
23
+ axis,
24
+ seriesConfig,
25
+ axisDirection: 'y',
26
+ gap
27
+ }));
@@ -1,4 +1,5 @@
1
1
  import { FunnelDataPoints, FunnelLabelOptions } from "./funnel.types.js";
2
+ import { PositionGetter } from "./positionGetter.js";
2
3
  /**
3
4
  * It tries to keep the label inside the bounds of the section based on the position.
4
5
  *
@@ -30,8 +31,8 @@ export declare const positionLabel: ({
30
31
  dataIndex,
31
32
  baseScaleData
32
33
  }: Omit<FunnelLabelOptions, "textAnchor" | "dominantBaseline"> & {
33
- xPosition: (value: number, bandIndex: number, stackOffset?: number, useBand?: boolean) => number | undefined;
34
- yPosition: (value: number, bandIndex: number, stackOffset?: number, useBand?: boolean) => number | undefined;
34
+ xPosition: PositionGetter;
35
+ yPosition: PositionGetter;
35
36
  isHorizontal: boolean;
36
37
  values: readonly FunnelDataPoints[];
37
38
  dataIndex: number;
@@ -80,28 +80,28 @@ const positionLabel = ({
80
80
  minBottom = yPosition(values[2].y, baseScaleData[dataIndex], stackOffset) + mv;
81
81
  maxBottom = yPosition(values[3].y, baseScaleData[dataIndex], stackOffset) + mv;
82
82
  minRight = 0;
83
- maxRight = xPosition(Math.min(...values.map(v => v.x)), baseScaleData[dataIndex], stackOffset, true) + mh;
83
+ maxRight = xPosition(Math.min(...values.map(v => v.x)), dataIndex, baseScaleData[dataIndex], stackOffset, true) + mh;
84
84
  minLeft = 0;
85
- maxLeft = xPosition(Math.max(...values.map(v => v.x)), baseScaleData[dataIndex], stackOffset) + mh;
85
+ maxLeft = xPosition(Math.max(...values.map(v => v.x)), dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
86
86
  center = maxRight - (maxRight - maxLeft) / 2;
87
87
  leftCenter = 0;
88
88
  rightCenter = 0;
89
- middle = yPosition(0, baseScaleData[dataIndex], stackOffset) - mv;
90
- topMiddle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, baseScaleData[dataIndex], stackOffset) - mv;
91
- bottomMiddle = yPosition(values[3].y - (values[3].y - values[2].y) / 2, baseScaleData[dataIndex], stackOffset) + mv;
89
+ middle = yPosition(0, dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
90
+ topMiddle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
91
+ bottomMiddle = yPosition(values[3].y - (values[3].y - values[2].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) + mv;
92
92
  } else {
93
93
  minTop = 0;
94
- maxTop = yPosition(Math.max(...values.map(v => v.y)), baseScaleData[dataIndex], stackOffset) - mv;
94
+ maxTop = yPosition(Math.max(...values.map(v => v.y)), dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
95
95
  minBottom = 0;
96
- maxBottom = yPosition(Math.min(...values.map(v => v.y)), baseScaleData[dataIndex], stackOffset, true) - mv;
97
- maxRight = xPosition(values[0].x, baseScaleData[dataIndex], stackOffset) + mh;
98
- minRight = xPosition(values[1].x, baseScaleData[dataIndex], stackOffset) + mh;
99
- minLeft = xPosition(values[2].x, baseScaleData[dataIndex], stackOffset) - mh;
100
- maxLeft = xPosition(values[3].x, baseScaleData[dataIndex], stackOffset) - mh;
101
- center = xPosition(0, baseScaleData[dataIndex], stackOffset) - mh;
102
- rightCenter = xPosition(values[0].x - (values[0].x - values[1].x) / 2, baseScaleData[dataIndex], stackOffset) + mh;
103
- leftCenter = xPosition(values[3].x - (values[3].x - values[2].x) / 2, baseScaleData[dataIndex], stackOffset) - mh;
104
- middle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, baseScaleData[dataIndex], stackOffset);
96
+ maxBottom = yPosition(Math.min(...values.map(v => v.y)), dataIndex, baseScaleData[dataIndex], stackOffset, true) - mv;
97
+ maxRight = xPosition(values[0].x, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
98
+ minRight = xPosition(values[1].x, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
99
+ minLeft = xPosition(values[2].x, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
100
+ maxLeft = xPosition(values[3].x, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
101
+ center = xPosition(0, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
102
+ rightCenter = xPosition(values[0].x - (values[0].x - values[1].x) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
103
+ leftCenter = xPosition(values[3].x - (values[3].x - values[2].x) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
104
+ middle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset);
105
105
  middle = maxTop - (maxTop - maxBottom) / 2;
106
106
  topMiddle = 0;
107
107
  bottomMiddle = 0;
@@ -0,0 +1 @@
1
+ export type PositionGetter = (value: number, bandIndex: number, bandIdentifier: string | number, stackOffset?: number, useBand?: boolean) => number;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -91,8 +91,7 @@ const useFunnelChartProps = props => {
91
91
  onHighlightChange,
92
92
  className,
93
93
  axisHighlight,
94
- apiRef,
95
- gap
94
+ apiRef
96
95
  } = props,
97
96
  rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
98
97
  const margin = (0, _internals.defaultizeMargin)(marginProps, _constants.DEFAULT_MARGINS);
@@ -124,7 +123,6 @@ const useFunnelChartProps = props => {
124
123
  plugins: _FunnelChart.FUNNEL_CHART_PLUGINS
125
124
  });
126
125
  const funnelPlotProps = {
127
- gap,
128
126
  onItemClick,
129
127
  slots,
130
128
  slotProps
@@ -5,14 +5,14 @@ import { ChartsTooltipProps } from '@mui/x-charts/ChartsTooltip';
5
5
  import { ChartsAxisSlots, ChartsAxisSlotProps, XAxis, YAxis } from '@mui/x-charts/internals';
6
6
  import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
7
7
  import { ChartsLegendSlotProps, ChartsLegendSlots } from '@mui/x-charts/ChartsLegend';
8
- import { ChartsToolbarSlotProps, ChartsToolbarSlots } from '@mui/x-charts/Toolbar';
9
8
  import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
10
9
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
11
10
  import { HeatmapSeriesType } from "../models/seriesType/heatmap.js";
12
11
  import { HeatmapTooltipProps } from "./HeatmapTooltip/index.js";
13
12
  import { HeatmapItemSlotProps, HeatmapItemSlots } from "./HeatmapItem.js";
14
13
  import { HeatmapPluginsSignatures } from "./Heatmap.plugins.js";
15
- export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots, ChartsToolbarSlots, Partial<ChartsSlotsPro> {
14
+ import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
15
+ export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {
16
16
  /**
17
17
  * Custom component for the tooltip.
18
18
  * @default ChartsTooltipRoot
@@ -24,7 +24,7 @@ export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, Heatm
24
24
  */
25
25
  legend?: ChartsLegendSlots['legend'];
26
26
  }
27
- export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps, ChartsLegendSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotPropsPro> {
27
+ export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps, ChartsLegendSlotProps, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {
28
28
  tooltip?: Partial<HeatmapTooltipProps>;
29
29
  }
30
30
  export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginsSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation' | 'slots' | 'slotProps'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { LineChartProps, LineChartSlots, LineChartSlotProps } from '@mui/x-charts/LineChart';
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 { LineChartProPluginsSignatures } from "./LineChartPro.plugins.js";
6
- export interface LineChartProSlots extends LineChartSlots, Partial<ChartsSlotsPro> {}
7
- export interface LineChartProSlotProps extends LineChartSlotProps, Partial<ChartsSlotPropsPro> {}
7
+ export interface LineChartProSlots extends Omit<LineChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
8
+ export interface LineChartProSlotProps extends Omit<LineChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
8
9
  export interface LineChartProProps extends Omit<LineChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<ChartContainerProProps<'line', LineChartProPluginsSignatures>, 'series' | 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {
9
10
  /**
10
11
  * Overridable component slots.
@@ -3,8 +3,9 @@ import { PieChartProps, PieChartSlotProps, PieChartSlots } from '@mui/x-charts/P
3
3
  import { ChartsSlotsPro, ChartsSlotPropsPro } from "../internals/material/index.js";
4
4
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
5
5
  import { PieChartProPluginSignatures } from "./PieChartPro.plugins.js";
6
- export interface PieChartProSlots extends PieChartSlots, Partial<ChartsSlotsPro> {}
7
- export interface PieChartProSlotProps extends PieChartSlotProps, Partial<ChartsSlotPropsPro> {}
6
+ import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
7
+ export interface PieChartProSlots extends Omit<PieChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
8
+ export interface PieChartProSlotProps extends Omit<PieChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
8
9
  export interface PieChartProProps extends Omit<PieChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<ChartContainerProProps<'pie', PieChartProPluginSignatures>, 'series' | 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {
9
10
  /**
10
11
  * Overridable component slots.
@@ -1,7 +1,22 @@
1
1
  import * as React from 'react';
2
- import { RadarChartProps, RadarDataProviderProps } from '@mui/x-charts/RadarChart';
2
+ import { RadarChartProps, RadarDataProviderProps, RadarChartSlotProps, RadarChartSlots } from '@mui/x-charts/RadarChart';
3
3
  import { RadarChartProPluginsSignatures } from "./RadarChartPro.plugins.js";
4
- export interface RadarChartProProps extends Omit<RadarChartProps, 'apiRef'>, Omit<RadarDataProviderProps<RadarChartProPluginsSignatures>, 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {}
4
+ import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
5
+ import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
6
+ export interface RadarChartProSlots extends Omit<RadarChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
7
+ export interface RadarChartProSlotProps extends Omit<RadarChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
8
+ export interface RadarChartProProps extends Omit<RadarChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<RadarDataProviderProps<RadarChartProPluginsSignatures>, 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {
9
+ /**
10
+ * Overridable component slots.
11
+ * @default {}
12
+ */
13
+ slots?: RadarChartProSlots;
14
+ /**
15
+ * The props used for each component slot.
16
+ * @default {}
17
+ */
18
+ slotProps?: RadarChartProSlotProps;
19
+ }
5
20
  /**
6
21
  * Demos:
7
22
  *
@@ -3,8 +3,9 @@ import { ScatterChartProps, ScatterChartSlotProps, ScatterChartSlots } from '@mu
3
3
  import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
4
4
  import { ChartContainerProProps } from "../ChartContainerPro/ChartContainerPro.js";
5
5
  import { ScatterChartProPluginsSignatures } from "./ScatterChartPro.plugins.js";
6
- export interface ScatterChartProSlots extends ScatterChartSlots, Partial<ChartsSlotsPro> {}
7
- export interface ScatterChartProSlotProps extends ScatterChartSlotProps, Partial<ChartsSlotPropsPro> {}
6
+ import { ChartsToolbarProSlots, ChartsToolbarProSlotProps } from "../ChartsToolbarPro/Toolbar.types.js";
7
+ export interface ScatterChartProSlots extends Omit<ScatterChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
8
+ export interface ScatterChartProSlotProps extends Omit<ScatterChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
8
9
  export interface ScatterChartProProps extends Omit<ScatterChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<ChartContainerProProps<'scatter', ScatterChartProPluginsSignatures>, 'series' | 'plugins' | 'seriesConfig' | 'onItemClick' | 'slots' | 'slotProps'> {
9
10
  /**
10
11
  * Overridable component slots.
@@ -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.
@@ -11,7 +11,7 @@ import { defaultSlotsMaterial } from "../internals/material/index.js";
11
11
  import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
12
12
  import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const releaseInfo = "MTc0OTA3MDgwMDAwMA==";
14
+ const releaseInfo = "MTc0OTY3OTIwMDAwMA==";
15
15
  const packageIdentifier = 'x-charts-pro';
16
16
  /**
17
17
  * Orchestrates the data providers for the chart components and hooks.
@@ -249,7 +249,8 @@ function getZoomSliderTooltipsText(axis, drawingArea) {
249
249
  const formatValue = value => {
250
250
  if (axis.valueFormatter) {
251
251
  return axis.valueFormatter(value, {
252
- location: 'zoom-slider-tooltip'
252
+ location: 'zoom-slider-tooltip',
253
+ scale: axis.scale
253
254
  });
254
255
  }
255
256
  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 @@
1
+ export {};
@@ -16,6 +16,7 @@ import { useFunnelChartProps } from "./useFunnelChartProps.js";
16
16
  import { seriesConfig as funnelSeriesConfig } from "./seriesConfig/index.js";
17
17
  import { useChartContainerProProps } from "../ChartContainerPro/useChartContainerProProps.js";
18
18
  import { ChartDataProviderPro } from "../ChartDataProviderPro/index.js";
19
+ import { FUNNEL_CHART_PLUGINS } from "./FunnelChart.plugins.js";
19
20
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
21
  const seriesConfig = {
21
22
  funnel: funnelSeriesConfig
@@ -41,7 +42,9 @@ const FunnelChart = /*#__PURE__*/React.forwardRef(function FunnelChart(props, re
41
42
  } = useChartContainerProProps(chartContainerProps, ref);
42
43
  const Tooltip = themedProps.slots?.tooltip ?? ChartsTooltip;
43
44
  return /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
45
+ gap: themedProps.gap,
44
46
  seriesConfig: seriesConfig,
47
+ plugins: FUNNEL_CHART_PLUGINS,
45
48
  children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
46
49
  children: [!themedProps.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
47
50
  children: [/*#__PURE__*/_jsx(FunnelPlot, _extends({}, funnelPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), children]
@@ -88,16 +91,6 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
88
91
  size: PropTypes.number,
89
92
  tickLabelStyle: PropTypes.object,
90
93
  tickSize: PropTypes.number
91
- }), PropTypes.shape({
92
- categories: PropTypes.arrayOf(PropTypes.string),
93
- disableLine: PropTypes.bool,
94
- disableTicks: PropTypes.bool,
95
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
96
- position: PropTypes.oneOf(['bottom', 'left', 'none', 'right', 'top']),
97
- scaleType: PropTypes.oneOf(['point']),
98
- size: PropTypes.number,
99
- tickLabelStyle: PropTypes.object,
100
- tickSize: PropTypes.number
101
94
  }), PropTypes.shape({
102
95
  categories: PropTypes.arrayOf(PropTypes.string),
103
96
  disableLine: PropTypes.bool,
@@ -222,7 +215,7 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
222
215
  })]),
223
216
  /**
224
217
  * The function called for onClick events.
225
- * The second argument contains information about all line/bar elements at the current mouse position.
218
+ * The second argument contains information about all funnel elements at the current position.
226
219
  * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
227
220
  * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
228
221
  */
@@ -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>;
@@ -1,3 +1,4 @@
1
- import { useChartCartesianAxis, useChartHighlight, useChartInteraction } from '@mui/x-charts/internals';
1
+ import { useChartHighlight, useChartInteraction } from '@mui/x-charts/internals';
2
2
  import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
3
- export const FUNNEL_CHART_PLUGINS = [useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartProExport];
3
+ import { useChartFunnelAxis } from "./funnelAxisPlugin/useChartFunnelAxis.js";
4
+ export const FUNNEL_CHART_PLUGINS = [useChartFunnelAxis, useChartInteraction, useChartHighlight, 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.
@@ -1,29 +1,31 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["onItemClick", "gap"];
3
+ const _excluded = ["onItemClick"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
7
- import { cartesianSeriesTypes } from '@mui/x-charts/internals';
8
- import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
7
+ import { cartesianSeriesTypes, useSelector, useStore, isBandScale } from '@mui/x-charts/internals';
9
8
  import { FunnelSection } from "./FunnelSection.js";
10
9
  import { alignLabel, positionLabel } from "./labelUtils.js";
11
10
  import { useFunnelSeriesContext } from "../hooks/useFunnelSeries.js";
12
11
  import { getFunnelCurve } from "./curves/index.js";
13
12
  import { FunnelSectionLabel } from "./FunnelSectionLabel.js";
13
+ import { selectorChartXAxis, selectorChartYAxis, selectorFunnelGap } from "./funnelAxisPlugin/useChartFunnelAxisRendering.selectors.js";
14
14
  import { createElement as _createElement } from "react";
15
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  cartesianSeriesTypes.addType('funnel');
17
- const useAggregatedData = gap => {
17
+ const useAggregatedData = () => {
18
18
  const seriesData = useFunnelSeriesContext();
19
+ const store = useStore();
19
20
  const {
20
- xAxis,
21
- xAxisIds
22
- } = useXAxes();
21
+ axis: xAxis,
22
+ axisIds: xAxisIds
23
+ } = useSelector(store, selectorChartXAxis);
23
24
  const {
24
- yAxis,
25
- yAxisIds
26
- } = useYAxes();
25
+ axis: yAxis,
26
+ axisIds: yAxisIds
27
+ } = useSelector(store, selectorChartYAxis);
28
+ const gap = useSelector(store, selectorFunnelGap);
27
29
  const allData = React.useMemo(() => {
28
30
  if (seriesData === undefined) {
29
31
  return [];
@@ -46,22 +48,28 @@ const useAggregatedData = gap => {
46
48
  const bandWidth = (isXAxisBand || isYAxisBand) && baseScaleConfig.scale?.bandwidth() || 0;
47
49
  const xScale = xAxis[xAxisId].scale;
48
50
  const yScale = yAxis[yAxisId].scale;
49
- const xPosition = (value, bandIndex, stackOffset, useBand) => {
50
- if (isXAxisBand) {
51
- const position = xScale(bandIndex);
51
+ const xPosition = (value, bandIndex, bandIdentifier, stackOffset, useBand) => {
52
+ if (isBandScale(xScale)) {
53
+ const position = xScale(bandIdentifier);
52
54
  return useBand ? position + bandWidth : position;
53
55
  }
54
- return xScale(isHorizontal ? value + (stackOffset || 0) : value);
56
+ if (isHorizontal) {
57
+ return xScale(value + (stackOffset || 0)) + bandIndex * gap;
58
+ }
59
+ return xScale(value);
55
60
  };
56
- const yPosition = (value, bandIndex, stackOffset, useBand) => {
57
- if (isYAxisBand) {
58
- const position = yScale(bandIndex);
61
+ const yPosition = (value, bandIndex, bandIdentifier, stackOffset, useBand) => {
62
+ if (isBandScale(yScale)) {
63
+ const position = yScale(bandIdentifier);
59
64
  return useBand ? position + bandWidth : position;
60
65
  }
61
- return yScale(isHorizontal ? value : value + (stackOffset || 0));
66
+ if (isHorizontal) {
67
+ return yScale(value);
68
+ }
69
+ return yScale(value + (stackOffset || 0)) + bandIndex * gap;
62
70
  };
63
- const allY = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => yPosition(v.y, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
64
- const allX = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => xPosition(v.x, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
71
+ const allY = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => yPosition(v.y, dataIndex, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
72
+ const allX = currentSeries.dataPoints.flatMap((d, dataIndex) => d.flatMap(v => xPosition(v.x, dataIndex, baseScaleConfig.data?.[dataIndex], v.stackOffset, v.useBandWidth)));
65
73
  const minPoint = {
66
74
  x: Math.min(...allX),
67
75
  y: Math.min(...allY)
@@ -89,7 +97,7 @@ const useAggregatedData = gap => {
89
97
  min: minPoint,
90
98
  max: maxPoint
91
99
  });
92
- const line = d3Line().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);
100
+ const line = d3Line().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);
93
101
  return {
94
102
  d: line(values),
95
103
  color,
@@ -118,11 +126,10 @@ const useAggregatedData = gap => {
118
126
  };
119
127
  function FunnelPlot(props) {
120
128
  const {
121
- onItemClick,
122
- gap
129
+ onItemClick
123
130
  } = props,
124
131
  other = _objectWithoutPropertiesLoose(props, _excluded);
125
- const data = useAggregatedData(gap);
132
+ const data = useAggregatedData();
126
133
  return /*#__PURE__*/_jsxs(React.Fragment, {
127
134
  children: [data.map(({
128
135
  d,
@@ -167,11 +174,6 @@ process.env.NODE_ENV !== "production" ? FunnelPlot.propTypes = {
167
174
  // | These PropTypes are generated from the TypeScript type definitions |
168
175
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
169
176
  // ----------------------------------------------------------------------
170
- /**
171
- * The gap, in pixels, between funnel sections.
172
- * @default 0
173
- */
174
- gap: PropTypes.number,
175
177
  /**
176
178
  * Callback fired when a funnel item is clicked.
177
179
  * @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
@@ -11,14 +11,12 @@
11
11
  export class Bump {
12
12
  constructor(context, {
13
13
  isHorizontal,
14
- gap,
15
14
  min,
16
15
  max,
17
16
  isIncreasing
18
17
  }) {
19
18
  this.context = void 0;
20
19
  this.isHorizontal = false;
21
- this.gap = 0;
22
20
  this.min = {
23
21
  x: 0,
24
22
  y: 0
@@ -30,7 +28,6 @@ export class Bump {
30
28
  this.points = [];
31
29
  this.context = context;
32
30
  this.isHorizontal = isHorizontal ?? false;
33
- this.gap = (gap ?? 0) / 2;
34
31
  this.min = min ?? {
35
32
  x: 0,
36
33
  y: 0
@@ -73,34 +70,34 @@ export class Bump {
73
70
  const [p0, p1, p2, p3] = this.points;
74
71
 
75
72
  // 0 is the top-left corner
76
- this.context.moveTo(p0.x + this.gap, p0.y);
77
- this.context.lineTo(p0.x + this.gap, p0.y);
73
+ this.context.moveTo(p0.x, p0.y);
74
+ this.context.lineTo(p0.x, p0.y);
78
75
 
79
76
  // Bezier curve to point 1
80
- this.context.bezierCurveTo((p0.x + p1.x) / 2, p0.y, (p0.x + p1.x) / 2, p1.y, p1.x - this.gap, p1.y);
77
+ this.context.bezierCurveTo((p0.x + p1.x) / 2, p0.y, (p0.x + p1.x) / 2, p1.y, p1.x, p1.y);
81
78
 
82
79
  // Line to point 2
83
- this.context.lineTo(p2.x - this.gap, p2.y);
80
+ this.context.lineTo(p2.x, p2.y);
84
81
 
85
82
  // Bezier curve back to point 3
86
- this.context.bezierCurveTo((p2.x + p3.x) / 2, p2.y, (p2.x + p3.x) / 2, p3.y, p3.x + this.gap, p3.y);
83
+ this.context.bezierCurveTo((p2.x + p3.x) / 2, p2.y, (p2.x + p3.x) / 2, p3.y, p3.x, p3.y);
87
84
  this.context.closePath();
88
85
  }
89
86
  drawVerticalPath() {
90
87
  const [p0, p1, p2, p3] = this.points;
91
88
 
92
89
  // 0 is the top-right corner
93
- this.context.moveTo(p0.x, p0.y + this.gap);
94
- this.context.lineTo(p0.x, p0.y + this.gap);
90
+ this.context.moveTo(p0.x, p0.y);
91
+ this.context.lineTo(p0.x, p0.y);
95
92
 
96
93
  // Bezier curve to point 1
97
- this.context.bezierCurveTo(p0.x, (p0.y + p1.y) / 2, p1.x, (p0.y + p1.y) / 2, p1.x, p1.y - this.gap);
94
+ this.context.bezierCurveTo(p0.x, (p0.y + p1.y) / 2, p1.x, (p0.y + p1.y) / 2, p1.x, p1.y);
98
95
 
99
96
  // Line to point 2
100
- this.context.lineTo(p2.x, p2.y - this.gap);
97
+ this.context.lineTo(p2.x, p2.y);
101
98
 
102
99
  // Bezier curve back to point 3
103
- this.context.bezierCurveTo(p2.x, (p2.y + p3.y) / 2, p3.x, (p2.y + p3.y) / 2, p3.x, p3.y + this.gap);
100
+ this.context.bezierCurveTo(p2.x, (p2.y + p3.y) / 2, p3.x, (p2.y + p3.y) / 2, p3.x, p3.y);
104
101
  this.context.closePath();
105
102
  }
106
103
  }
@@ -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