@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
@@ -6,17 +6,18 @@ import { getSVGPoint, selectorChartAxisZoomOptionsLookup, selectorChartDrawingAr
6
6
  import { styled } from '@mui/material/styles';
7
7
  import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
8
8
  import { rafThrottle } from '@mui/x-internals/rafThrottle';
9
+ import { ChartsTooltipZoomSliderValue } from "./ChartsTooltipZoomSliderValue.js";
9
10
  import { selectorChartAxisZoomData } from "../../internals/plugins/useChartProZoom/index.js";
10
- import { ChartAxisZoomSliderHandle } from "./ChartAxisZoomSliderHandle.js";
11
+ import { ChartAxisZoomSliderThumb } from "./ChartAxisZoomSliderThumb.js";
11
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
- const BackgroundRect = styled('rect')(({
13
+ const ZoomSliderTrack = styled('rect')(({
13
14
  theme
14
15
  }) => ({
15
16
  '&': {
16
17
  fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[800] : (theme.vars || theme).palette.grey[300]
17
18
  }
18
19
  }));
19
- const ZoomRangePreviewRect = styled('rect')(({
20
+ const ZoomSliderActiveTrackRect = styled('rect')(({
20
21
  theme
21
22
  }) => ({
22
23
  '&': {
@@ -24,11 +25,11 @@ const ZoomRangePreviewRect = styled('rect')(({
24
25
  cursor: 'grab'
25
26
  }
26
27
  }));
27
- const ZOOM_SLIDER_BACKGROUND_SIZE = 8;
28
- const ZOOM_SLIDER_FOREGROUND_SIZE = 10;
29
- const ZOOM_SLIDER_HANDLE_HEIGHT = 20;
30
- const ZOOM_SLIDER_HANDLE_WIDTH = 10;
31
- const ZOOM_SLIDER_SIZE = Math.max(ZOOM_SLIDER_BACKGROUND_SIZE, ZOOM_SLIDER_FOREGROUND_SIZE, ZOOM_SLIDER_HANDLE_HEIGHT, ZOOM_SLIDER_HANDLE_WIDTH);
28
+ const ZOOM_SLIDER_TRACK_SIZE = 8;
29
+ const ZOOM_SLIDER_ACTIVE_TRACK_SIZE = 10;
30
+ const ZOOM_SLIDER_THUMB_HEIGHT = 20;
31
+ const ZOOM_SLIDER_THUMB_WIDTH = 10;
32
+ const ZOOM_SLIDER_SIZE = Math.max(ZOOM_SLIDER_TRACK_SIZE, ZOOM_SLIDER_ACTIVE_TRACK_SIZE, ZOOM_SLIDER_THUMB_HEIGHT, ZOOM_SLIDER_THUMB_WIDTH);
32
33
 
33
34
  /**
34
35
  * Renders the zoom slider for a specific axis.
@@ -53,48 +54,58 @@ export function ChartAxisZoomSlider({
53
54
  let x;
54
55
  let y;
55
56
  let reverse;
57
+ let axisPosition;
56
58
  if (axisDirection === 'x') {
57
59
  const axis = xAxis[axisId];
58
- if (!axis) {
60
+ if (!axis || axis.position === 'none') {
59
61
  return null;
60
62
  }
61
63
  const axisSize = axis.height;
62
64
  x = drawingArea.left;
63
65
  y = axis.position === 'bottom' ? drawingArea.top + drawingArea.height + axis.offset + axisSize + ZOOM_SLIDER_MARGIN : drawingArea.top - axis.offset - axisSize - ZOOM_SLIDER_SIZE - ZOOM_SLIDER_MARGIN;
64
66
  reverse = axis.reverse ?? false;
67
+ axisPosition = axis.position ?? 'bottom';
65
68
  } else {
66
69
  const axis = yAxis[axisId];
67
- if (!axis) {
70
+ if (!axis || axis.position === 'none') {
68
71
  return null;
69
72
  }
70
73
  const axisSize = axis.width;
71
74
  x = axis.position === 'right' ? drawingArea.left + drawingArea.width + axis.offset + axisSize + ZOOM_SLIDER_MARGIN : drawingArea.left - axis.offset - axisSize - ZOOM_SLIDER_SIZE - ZOOM_SLIDER_MARGIN;
72
75
  y = drawingArea.top;
73
76
  reverse = axis.reverse ?? false;
77
+ axisPosition = axis.position ?? 'left';
74
78
  }
75
- const backgroundRectOffset = (ZOOM_SLIDER_SIZE - ZOOM_SLIDER_BACKGROUND_SIZE) / 2;
79
+ const backgroundRectOffset = (ZOOM_SLIDER_SIZE - ZOOM_SLIDER_TRACK_SIZE) / 2;
76
80
  return /*#__PURE__*/_jsxs("g", {
77
81
  transform: `translate(${x} ${y})`,
78
- children: [/*#__PURE__*/_jsx(BackgroundRect, {
82
+ children: [/*#__PURE__*/_jsx(ZoomSliderTrack, {
79
83
  x: axisDirection === 'x' ? 0 : backgroundRectOffset,
80
84
  y: axisDirection === 'x' ? backgroundRectOffset : 0,
81
- height: axisDirection === 'x' ? ZOOM_SLIDER_BACKGROUND_SIZE : drawingArea.height,
82
- width: axisDirection === 'x' ? drawingArea.width : ZOOM_SLIDER_BACKGROUND_SIZE,
83
- rx: ZOOM_SLIDER_BACKGROUND_SIZE / 2,
84
- ry: ZOOM_SLIDER_BACKGROUND_SIZE / 2
85
- }), /*#__PURE__*/_jsx(ChartAxisZoomSliderSpan, {
85
+ height: axisDirection === 'x' ? ZOOM_SLIDER_TRACK_SIZE : drawingArea.height,
86
+ width: axisDirection === 'x' ? drawingArea.width : ZOOM_SLIDER_TRACK_SIZE,
87
+ rx: ZOOM_SLIDER_TRACK_SIZE / 2,
88
+ ry: ZOOM_SLIDER_TRACK_SIZE / 2
89
+ }), /*#__PURE__*/_jsx(ChartAxisZoomSliderActiveTrack, {
86
90
  zoomData: zoomData,
87
91
  axisId: axisId,
92
+ axisPosition: axisPosition,
88
93
  axisDirection: axisDirection,
89
94
  reverse: reverse
90
95
  })]
91
96
  });
92
97
  }
93
- function ChartAxisZoomSliderSpan({
98
+ const formatter = Intl.NumberFormat(undefined, {
99
+ maximumFractionDigits: 0
100
+ });
101
+ const zoomValueFormatter = value => formatter.format(value);
102
+ function ChartAxisZoomSliderActiveTrack({
94
103
  axisId,
95
104
  axisDirection,
105
+ axisPosition,
96
106
  zoomData,
97
- reverse
107
+ reverse,
108
+ valueFormatter = zoomValueFormatter
98
109
  }) {
99
110
  const {
100
111
  instance,
@@ -103,8 +114,11 @@ function ChartAxisZoomSliderSpan({
103
114
  const store = useStore();
104
115
  const drawingArea = useDrawingArea();
105
116
  const activePreviewRectRef = React.useRef(null);
106
- const previewHandleWidth = axisDirection === 'x' ? ZOOM_SLIDER_HANDLE_WIDTH : ZOOM_SLIDER_HANDLE_HEIGHT;
107
- const previewHandleHeight = axisDirection === 'x' ? ZOOM_SLIDER_HANDLE_HEIGHT : ZOOM_SLIDER_HANDLE_WIDTH;
117
+ const [startThumbEl, setStartThumbEl] = React.useState(null);
118
+ const [endThumbEl, setEndThumbEl] = React.useState(null);
119
+ const [showTooltip, setShowTooltip] = React.useState(null);
120
+ const previewThumbWidth = axisDirection === 'x' ? ZOOM_SLIDER_THUMB_WIDTH : ZOOM_SLIDER_THUMB_HEIGHT;
121
+ const previewThumbHeight = axisDirection === 'x' ? ZOOM_SLIDER_THUMB_HEIGHT : ZOOM_SLIDER_THUMB_WIDTH;
108
122
  React.useEffect(() => {
109
123
  const activePreviewRect = activePreviewRectRef.current;
110
124
  if (!activePreviewRect) {
@@ -145,6 +159,7 @@ function ChartAxisZoomSliderSpan({
145
159
  const onPointerUp = () => {
146
160
  activePreviewRect.removeEventListener('pointermove', onPointerMove);
147
161
  activePreviewRect.removeEventListener('pointerup', onPointerUp);
162
+ setShowTooltip(null);
148
163
  };
149
164
  const onPointerDown = event => {
150
165
  // Prevent text selection when dragging
@@ -176,6 +191,7 @@ function ChartAxisZoomSliderSpan({
176
191
  prevPointerZoom = pointerDownZoom;
177
192
  pointerZoomMin = pointerDownZoom - axisZoomData.start;
178
193
  pointerZoomMax = 100 - (axisZoomData.end - pointerDownZoom);
194
+ setShowTooltip('both');
179
195
  activePreviewRect.addEventListener('pointerup', onPointerUp);
180
196
  activePreviewRect.addEventListener('pointermove', onPointerMove);
181
197
  };
@@ -187,7 +203,7 @@ function ChartAxisZoomSliderSpan({
187
203
  onPointerMove.clear();
188
204
  };
189
205
  }, [axisDirection, axisId, instance, reverse, store, svgRef]);
190
- const onResizeStart = event => {
206
+ const onStartThumbMove = event => {
191
207
  const element = svgRef.current;
192
208
  if (!element) {
193
209
  return;
@@ -220,7 +236,7 @@ function ChartAxisZoomSliderSpan({
220
236
  });
221
237
  });
222
238
  };
223
- const onResizeEnd = event => {
239
+ const onEndThumbMove = event => {
224
240
  const element = svgRef.current;
225
241
  if (!element) {
226
242
  return;
@@ -257,67 +273,85 @@ function ChartAxisZoomSliderSpan({
257
273
  let previewY;
258
274
  let previewWidth;
259
275
  let previewHeight;
260
- let startHandleX;
261
- let startHandleY;
262
- let endHandleX;
263
- let endHandleY;
276
+ let startThumbX;
277
+ let startThumbY;
278
+ let endThumbX;
279
+ let endThumbY;
264
280
  if (axisDirection === 'x') {
265
281
  previewX = zoomData.start / 100 * drawingArea.width;
266
282
  previewY = 0;
267
283
  previewWidth = drawingArea.width * (zoomData.end - zoomData.start) / 100;
268
- previewHeight = ZOOM_SLIDER_FOREGROUND_SIZE;
269
- startHandleX = zoomData.start / 100 * drawingArea.width;
270
- startHandleY = 0;
271
- endHandleX = zoomData.end / 100 * drawingArea.width;
272
- endHandleY = 0;
284
+ previewHeight = ZOOM_SLIDER_ACTIVE_TRACK_SIZE;
285
+ startThumbX = zoomData.start / 100 * drawingArea.width;
286
+ startThumbY = 0;
287
+ endThumbX = zoomData.end / 100 * drawingArea.width;
288
+ endThumbY = 0;
273
289
  if (reverse) {
274
290
  previewX = drawingArea.width - previewX - previewWidth;
275
- startHandleX = drawingArea.width - startHandleX;
276
- endHandleX = drawingArea.width - endHandleX;
291
+ startThumbX = drawingArea.width - startThumbX;
292
+ endThumbX = drawingArea.width - endThumbX;
277
293
  }
278
- startHandleX -= previewHandleWidth / 2;
279
- endHandleX -= previewHandleWidth / 2;
294
+ startThumbX -= previewThumbWidth / 2;
295
+ endThumbX -= previewThumbWidth / 2;
280
296
  } else {
281
297
  previewX = 0;
282
298
  previewY = drawingArea.height - zoomData.end / 100 * drawingArea.height;
283
- previewWidth = ZOOM_SLIDER_FOREGROUND_SIZE;
299
+ previewWidth = ZOOM_SLIDER_ACTIVE_TRACK_SIZE;
284
300
  previewHeight = drawingArea.height * (zoomData.end - zoomData.start) / 100;
285
- startHandleX = 0;
286
- startHandleY = drawingArea.height - zoomData.start / 100 * drawingArea.height;
287
- endHandleX = 0;
288
- endHandleY = drawingArea.height - zoomData.end / 100 * drawingArea.height;
301
+ startThumbX = 0;
302
+ startThumbY = drawingArea.height - zoomData.start / 100 * drawingArea.height;
303
+ endThumbX = 0;
304
+ endThumbY = drawingArea.height - zoomData.end / 100 * drawingArea.height;
289
305
  if (reverse) {
290
306
  previewY = drawingArea.height - previewY - previewHeight;
291
- startHandleY = drawingArea.height - startHandleY;
292
- endHandleY = drawingArea.height - endHandleY;
307
+ startThumbY = drawingArea.height - startThumbY;
308
+ endThumbY = drawingArea.height - endThumbY;
293
309
  }
294
- startHandleY -= previewHandleHeight / 2;
295
- endHandleY -= previewHandleHeight / 2;
310
+ startThumbY -= previewThumbHeight / 2;
311
+ endThumbY -= previewThumbHeight / 2;
296
312
  }
297
- const previewOffset = (ZOOM_SLIDER_HANDLE_HEIGHT - ZOOM_SLIDER_FOREGROUND_SIZE) / 2;
313
+ const previewOffset = (ZOOM_SLIDER_THUMB_HEIGHT - ZOOM_SLIDER_ACTIVE_TRACK_SIZE) / 2;
298
314
  return /*#__PURE__*/_jsxs(React.Fragment, {
299
- children: [/*#__PURE__*/_jsx(ZoomRangePreviewRect, {
315
+ children: [/*#__PURE__*/_jsx(ZoomSliderActiveTrackRect, {
300
316
  ref: activePreviewRectRef,
301
317
  x: previewX + (axisDirection === 'x' ? 0 : previewOffset),
302
318
  y: previewY + (axisDirection === 'x' ? previewOffset : 0),
303
319
  width: previewWidth,
304
- height: previewHeight
305
- }), /*#__PURE__*/_jsx(ChartAxisZoomSliderHandle, {
306
- x: startHandleX,
307
- y: startHandleY,
308
- width: previewHandleWidth,
309
- height: previewHandleHeight,
320
+ height: previewHeight,
321
+ onPointerEnter: () => setShowTooltip('both'),
322
+ onPointerLeave: () => setShowTooltip(null)
323
+ }), /*#__PURE__*/_jsx(ChartAxisZoomSliderThumb, {
324
+ ref: setStartThumbEl,
325
+ x: startThumbX,
326
+ y: startThumbY,
327
+ width: previewThumbWidth,
328
+ height: previewThumbHeight,
310
329
  orientation: axisDirection === 'x' ? 'horizontal' : 'vertical',
311
- onResize: onResizeStart,
330
+ onMove: onStartThumbMove,
331
+ onPointerEnter: () => setShowTooltip('start'),
332
+ onPointerLeave: () => setShowTooltip(null),
312
333
  placement: "start"
313
- }), /*#__PURE__*/_jsx(ChartAxisZoomSliderHandle, {
314
- x: endHandleX,
315
- y: endHandleY,
316
- width: previewHandleWidth,
317
- height: previewHandleHeight,
334
+ }), /*#__PURE__*/_jsx(ChartAxisZoomSliderThumb, {
335
+ ref: setEndThumbEl,
336
+ x: endThumbX,
337
+ y: endThumbY,
338
+ width: previewThumbWidth,
339
+ height: previewThumbHeight,
318
340
  orientation: axisDirection === 'x' ? 'horizontal' : 'vertical',
319
- onResize: onResizeEnd,
341
+ onMove: onEndThumbMove,
342
+ onPointerEnter: () => setShowTooltip('end'),
343
+ onPointerLeave: () => setShowTooltip(null),
320
344
  placement: "end"
345
+ }), /*#__PURE__*/_jsx(ChartsTooltipZoomSliderValue, {
346
+ anchorEl: startThumbEl,
347
+ open: showTooltip === 'start' || showTooltip === 'both',
348
+ placement: axisPosition,
349
+ children: valueFormatter(zoomData.start)
350
+ }), /*#__PURE__*/_jsx(ChartsTooltipZoomSliderValue, {
351
+ anchorEl: endThumbEl,
352
+ open: showTooltip === 'end' || showTooltip === 'both',
353
+ placement: axisPosition,
354
+ children: valueFormatter(zoomData.end)
321
355
  })]
322
356
  });
323
357
  }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ export interface ChartZoomSliderThumbOwnerState {
3
+ onMove: (event: PointerEvent) => void;
4
+ orientation: 'horizontal' | 'vertical';
5
+ placement: 'start' | 'end';
6
+ }
7
+ export interface ChartZoomSliderThumbProps extends Omit<React.ComponentProps<'rect'>, 'orientation'>, ChartZoomSliderThumbOwnerState {}
8
+ /**
9
+ * Renders the zoom slider thumb, which is responsible for resizing the zoom range.
10
+ * @internal
11
+ */
12
+ export declare const ChartAxisZoomSliderThumb: React.ForwardRefExoticComponent<Omit<ChartZoomSliderThumbProps, "ref"> & React.RefAttributes<SVGRectElement>>;
@@ -0,0 +1,85 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry"];
6
+ import * as React from 'react';
7
+ import { styled } from '@mui/material/styles';
8
+ import useForkRef from '@mui/utils/useForkRef';
9
+ import useEventCallback from '@mui/utils/useEventCallback';
10
+ import { rafThrottle } from '@mui/x-internals/rafThrottle';
11
+ import clsx from 'clsx';
12
+ import { chartAxisZoomSliderThumbClasses, useUtilityClasses } from "./chartAxisZoomSliderThumbClasses.js";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const Rect = styled('rect')(({
15
+ theme
16
+ }) => ({
17
+ [`&.${chartAxisZoomSliderThumbClasses.root}`]: {
18
+ fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[300] : (theme.vars || theme).palette.common.white,
19
+ stroke: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[600] : (theme.vars || theme).palette.grey[500]
20
+ },
21
+ [`&.${chartAxisZoomSliderThumbClasses.horizontal}`]: {
22
+ cursor: 'ew-resize'
23
+ },
24
+ [`&.${chartAxisZoomSliderThumbClasses.vertical}`]: {
25
+ cursor: 'ns-resize'
26
+ }
27
+ }));
28
+ /**
29
+ * Renders the zoom slider thumb, which is responsible for resizing the zoom range.
30
+ * @internal
31
+ */
32
+ export const ChartAxisZoomSliderThumb = /*#__PURE__*/React.forwardRef(function ChartAxisZoomSliderThumb(_ref, forwardedRef) {
33
+ let {
34
+ className,
35
+ onMove,
36
+ orientation,
37
+ placement,
38
+ rx = 4,
39
+ ry = 4
40
+ } = _ref,
41
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
42
+ const classes = useUtilityClasses({
43
+ onMove,
44
+ orientation,
45
+ placement
46
+ });
47
+ const thumbRef = React.useRef(null);
48
+ const ref = useForkRef(thumbRef, forwardedRef);
49
+ const onMoveEvent = useEventCallback(onMove);
50
+ React.useEffect(() => {
51
+ const thumb = thumbRef.current;
52
+ if (!thumb) {
53
+ return;
54
+ }
55
+ const onPointerMove = rafThrottle(event => {
56
+ onMoveEvent(event);
57
+ });
58
+ const onPointerUp = () => {
59
+ thumb.removeEventListener('pointermove', onPointerMove);
60
+ thumb.removeEventListener('pointerup', onPointerUp);
61
+ };
62
+ const onPointerDown = event => {
63
+ // Prevent text selection when dragging the thumb
64
+ event.preventDefault();
65
+ event.stopPropagation();
66
+ thumb.setPointerCapture(event.pointerId);
67
+ thumb.addEventListener('pointerup', onPointerUp);
68
+ thumb.addEventListener('pointermove', onPointerMove);
69
+ };
70
+ thumb.addEventListener('pointerdown', onPointerDown);
71
+
72
+ // eslint-disable-next-line consistent-return
73
+ return () => {
74
+ thumb.removeEventListener('pointerdown', onPointerDown);
75
+ onPointerMove.clear();
76
+ };
77
+ }, [onMoveEvent, orientation]);
78
+ return /*#__PURE__*/_jsx(Rect, _extends({
79
+ className: clsx(classes.root, className),
80
+ ref: ref,
81
+ rx: rx,
82
+ ry: ry
83
+ }, rest));
84
+ });
85
+ 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,52 @@
1
+ import * as React from 'react';
2
+ import NoSsr from '@mui/material/NoSsr';
3
+ import Popper from '@mui/material/Popper';
4
+ import { ChartsTooltipPaper } from '@mui/x-charts/ChartsTooltip';
5
+ import Typography from '@mui/material/Typography';
6
+ import { styled } from '@mui/material/styles';
7
+
8
+ /**
9
+ * The root component of the zoom slider tooltip.
10
+ * @ignore - internal component.
11
+ */
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const ChartsZoomSliderTooltipRoot = styled(Popper, {
14
+ name: 'MuiChartsZoomSliderTooltip',
15
+ slot: 'Root'
16
+ })(({
17
+ theme
18
+ }) => ({
19
+ pointerEvents: 'none',
20
+ zIndex: theme.zIndex.modal
21
+ }));
22
+ const MODIFIERS = [{
23
+ name: 'offset',
24
+ options: {
25
+ offset: [0, 4]
26
+ }
27
+ }];
28
+ export function ChartsTooltipZoomSliderValue({
29
+ anchorEl,
30
+ open,
31
+ placement,
32
+ modifiers = MODIFIERS,
33
+ children
34
+ }) {
35
+ return /*#__PURE__*/_jsx(NoSsr, {
36
+ children: open ? /*#__PURE__*/_jsx(ChartsZoomSliderTooltipRoot, {
37
+ open: open,
38
+ anchorEl: anchorEl,
39
+ placement: placement,
40
+ modifiers: modifiers,
41
+ children: /*#__PURE__*/_jsx(ChartsTooltipPaper, {
42
+ sx: {
43
+ paddingX: 0.5
44
+ },
45
+ children: /*#__PURE__*/_jsx(Typography, {
46
+ variant: "caption",
47
+ children: children
48
+ })
49
+ })
50
+ }) : null
51
+ });
52
+ }
@@ -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>;
@@ -1,9 +1,9 @@
1
1
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
2
2
  import composeClasses from '@mui/utils/composeClasses';
3
3
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
4
- export const chartAxisZoomSliderHandleClasses = generateUtilityClasses('MuiChartAxisZoomSliderHandle', ['root', 'horizontal', 'vertical', 'start', 'end']);
5
- export function getAxisZoomSliderHandleUtilityClass(slot) {
6
- return generateUtilityClass('MuiChartAxisZoomSliderHandle', slot);
4
+ export const chartAxisZoomSliderThumbClasses = generateUtilityClasses('MuiChartAxisZoomSliderThumb', ['root', 'horizontal', 'vertical', 'start', 'end']);
5
+ export function getAxisZoomSliderThumbUtilityClass(slot) {
6
+ return generateUtilityClass('MuiChartAxisZoomSliderThumb', slot);
7
7
  }
8
8
  export const useUtilityClasses = ownerState => {
9
9
  const {
@@ -13,5 +13,5 @@ export const useUtilityClasses = ownerState => {
13
13
  const slots = {
14
14
  root: ['root', orientation === 'horizontal' ? 'horizontal' : 'vertical', placement === 'start' ? 'start' : 'end']
15
15
  };
16
- return composeClasses(slots, getAxisZoomSliderHandleUtilityClass);
16
+ return composeClasses(slots, getAxisZoomSliderThumbUtilityClass);
17
17
  };
@@ -44,13 +44,14 @@ const FunnelChart = /*#__PURE__*/React.forwardRef(function FunnelChart(props, re
44
44
  seriesConfig: seriesConfig,
45
45
  children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
46
46
  children: [!themedProps.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
47
- children: [/*#__PURE__*/_jsx(FunnelPlot, _extends({}, funnelPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !themedProps.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, themedProps.slotProps?.tooltip, {
48
- trigger: "item"
49
- })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), children]
47
+ children: [/*#__PURE__*/_jsx(FunnelPlot, _extends({}, funnelPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), children]
48
+ })), !themedProps.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, themedProps.slotProps?.tooltip, {
49
+ trigger: "item"
50
50
  }))]
51
51
  }))
52
52
  }));
53
53
  });
54
+ if (process.env.NODE_ENV !== "production") FunnelChart.displayName = "FunnelChart";
54
55
  process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
55
56
  // ----------------------------- Warning --------------------------------
56
57
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -78,12 +78,14 @@ const useAggregatedData = gap => {
78
78
  seriesId,
79
79
  value: currentSeries.data[dataIndex].value
80
80
  }) : currentSeries.sectionLabel;
81
+ const isIncreasing = currentSeries.dataDirection === 'increasing';
81
82
  const curve = getFunnelCurve(currentSeries.curve, {
82
83
  isHorizontal,
83
84
  gap,
84
85
  position: dataIndex,
85
86
  sections: currentSeries.dataPoints.length,
86
87
  borderRadius: currentSeries.borderRadius,
88
+ isIncreasing,
87
89
  min: minPoint,
88
90
  max: maxPoint
89
91
  });
@@ -58,4 +58,5 @@ const FunnelSection = consumeSlots('MuiFunnelSection', 'funnelSection', {
58
58
  ref: ref
59
59
  }));
60
60
  }));
61
+ if (process.env.NODE_ENV !== "production") FunnelSection.displayName = "FunnelSection";
61
62
  export { 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;
@@ -17,12 +17,14 @@ export class Pyramid {
17
17
  sections,
18
18
  borderRadius,
19
19
  min,
20
- max
20
+ max,
21
+ isIncreasing
21
22
  }) {
22
23
  this.context = void 0;
23
24
  this.position = 0;
24
25
  this.sections = 0;
25
26
  this.isHorizontal = false;
27
+ this.isIncreasing = false;
26
28
  this.gap = 0;
27
29
  this.borderRadius = 0;
28
30
  this.min = {
@@ -40,6 +42,7 @@ export class Pyramid {
40
42
  this.position = position ?? 0;
41
43
  this.sections = sections ?? 1;
42
44
  this.borderRadius = borderRadius ?? 0;
45
+ this.isIncreasing = isIncreasing ?? false;
43
46
  this.min = min ?? {
44
47
  x: 0,
45
48
  y: 0
@@ -48,6 +51,12 @@ export class Pyramid {
48
51
  x: 0,
49
52
  y: 0
50
53
  };
54
+ if (isIncreasing) {
55
+ const currentMin = this.min;
56
+ const currentMax = this.max;
57
+ this.min = currentMax;
58
+ this.max = currentMin;
59
+ }
51
60
  }
52
61
  areaStart() {}
53
62
  areaEnd() {}
@@ -57,14 +66,25 @@ export class Pyramid {
57
66
  if (this.gap > 0) {
58
67
  return this.borderRadius;
59
68
  }
60
- if (this.position === 0) {
61
- return [0, 0, this.borderRadius, this.borderRadius];
62
- }
63
- if (this.position === this.sections - 1 && this.gap <= 0) {
64
- return [this.borderRadius];
69
+ if (this.isIncreasing) {
70
+ // Is largest section
71
+ if (this.position === this.sections - 1) {
72
+ return [this.borderRadius, this.borderRadius];
73
+ }
74
+ // Is smallest section and shaped like a triangle
75
+ if (this.position === 0) {
76
+ return [0, 0, this.borderRadius];
77
+ }
65
78
  }
66
- if (this.position === this.sections - 1) {
67
- return [this.borderRadius, this.borderRadius];
79
+ if (!this.isIncreasing) {
80
+ // Is largest section
81
+ if (this.position === 0) {
82
+ return [0, 0, this.borderRadius, this.borderRadius];
83
+ }
84
+ // Is smallest section and shaped like a triangle
85
+ if (this.position === this.sections - 1) {
86
+ return [this.borderRadius];
87
+ }
68
88
  }
69
89
  return 0;
70
90
  }
@@ -113,8 +133,15 @@ export class Pyramid {
113
133
 
114
134
  // In the last section, to form a triangle we need 3 points instead of 4
115
135
  // Else the algorithm will break.
116
- if (this.position === this.sections - 1 && this.gap <= 0) {
117
- this.points = [this.points[0], this.points[1], this.points[3]];
136
+ const isLastSection = this.position === this.sections - 1;
137
+ const isFirstSection = this.position === 0;
138
+ if (this.gap <= 0) {
139
+ if (isFirstSection && this.isIncreasing) {
140
+ this.points = [this.points[0], this.points[1], this.points[2]];
141
+ }
142
+ if (isLastSection && !this.isIncreasing) {
143
+ this.points = [this.points[0], this.points[1], this.points[3]];
144
+ }
118
145
  }
119
146
  borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
120
147
  }