@mui/x-charts-pro 8.7.0 → 8.8.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 (84) hide show
  1. package/BarChartPro/BarChartPro.d.ts +1 -1
  2. package/BarChartPro/BarChartPro.js +32 -0
  3. package/CHANGELOG.md +98 -0
  4. package/ChartDataProviderPro/ChartDataProviderPro.js +7 -1
  5. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +31 -16
  6. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.d.ts +4 -0
  7. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +27 -12
  8. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.d.ts +18 -0
  9. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.js +102 -0
  10. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.d.ts +11 -0
  11. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.js +62 -0
  12. package/ChartZoomSlider/internals/previews/AreaPreviewPlot.d.ts +14 -0
  13. package/ChartZoomSlider/internals/previews/AreaPreviewPlot.js +61 -0
  14. package/ChartZoomSlider/internals/previews/BarPreviewPlot.d.ts +10 -0
  15. package/ChartZoomSlider/internals/previews/BarPreviewPlot.js +62 -0
  16. package/ChartZoomSlider/internals/previews/LinePreviewPlot.d.ts +14 -0
  17. package/ChartZoomSlider/internals/previews/LinePreviewPlot.js +59 -0
  18. package/ChartZoomSlider/internals/previews/PreviewPlot.types.d.ts +4 -0
  19. package/ChartZoomSlider/internals/previews/PreviewPlot.types.js +5 -0
  20. package/ChartZoomSlider/internals/previews/ScatterPreviewPlot.d.ts +16 -0
  21. package/ChartZoomSlider/internals/previews/ScatterPreviewPlot.js +93 -0
  22. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +2 -0
  23. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +3 -1
  24. package/ChartsToolbarPro/ChartsToolbarPro.js +2 -0
  25. package/FunnelChart/FunnelChart.d.ts +1 -1
  26. package/FunnelChart/FunnelPlot.js +1 -1
  27. package/FunnelChart/funnel.types.d.ts +14 -9
  28. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +1 -1
  29. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
  30. package/FunnelChart/seriesConfig/seriesProcessor.js +24 -48
  31. package/Heatmap/Heatmap.d.ts +1 -1
  32. package/LineChartPro/LineChartPro.js +38 -0
  33. package/PieChartPro/PieChartPro.d.ts +1 -1
  34. package/RadarChartPro/RadarChartPro.d.ts +1 -1
  35. package/ScatterChartPro/ScatterChartPro.d.ts +1 -1
  36. package/ScatterChartPro/ScatterChartPro.js +16 -0
  37. package/esm/BarChartPro/BarChartPro.d.ts +1 -1
  38. package/esm/BarChartPro/BarChartPro.js +32 -0
  39. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +7 -1
  40. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +33 -18
  41. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.d.ts +4 -0
  42. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +28 -13
  43. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.d.ts +18 -0
  44. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.js +94 -0
  45. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.d.ts +11 -0
  46. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.js +54 -0
  47. package/esm/ChartZoomSlider/internals/previews/AreaPreviewPlot.d.ts +14 -0
  48. package/esm/ChartZoomSlider/internals/previews/AreaPreviewPlot.js +53 -0
  49. package/esm/ChartZoomSlider/internals/previews/BarPreviewPlot.d.ts +10 -0
  50. package/esm/ChartZoomSlider/internals/previews/BarPreviewPlot.js +55 -0
  51. package/esm/ChartZoomSlider/internals/previews/LinePreviewPlot.d.ts +14 -0
  52. package/esm/ChartZoomSlider/internals/previews/LinePreviewPlot.js +51 -0
  53. package/esm/ChartZoomSlider/internals/previews/PreviewPlot.types.d.ts +4 -0
  54. package/esm/ChartZoomSlider/internals/previews/PreviewPlot.types.js +1 -0
  55. package/esm/ChartZoomSlider/internals/previews/ScatterPreviewPlot.d.ts +16 -0
  56. package/esm/ChartZoomSlider/internals/previews/ScatterPreviewPlot.js +86 -0
  57. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +2 -0
  58. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +3 -1
  59. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +2 -0
  60. package/esm/FunnelChart/FunnelChart.d.ts +1 -1
  61. package/esm/FunnelChart/FunnelPlot.js +1 -1
  62. package/esm/FunnelChart/funnel.types.d.ts +14 -9
  63. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +1 -1
  64. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
  65. package/esm/FunnelChart/seriesConfig/seriesProcessor.js +24 -48
  66. package/esm/Heatmap/Heatmap.d.ts +1 -1
  67. package/esm/LineChartPro/LineChartPro.js +38 -0
  68. package/esm/PieChartPro/PieChartPro.d.ts +1 -1
  69. package/esm/RadarChartPro/RadarChartPro.d.ts +1 -1
  70. package/esm/ScatterChartPro/ScatterChartPro.d.ts +1 -1
  71. package/esm/ScatterChartPro/ScatterChartPro.js +16 -0
  72. package/esm/index.js +1 -1
  73. package/esm/internals/plugins/useChartProExport/exportImage.js +9 -3
  74. package/esm/internals/plugins/useChartProExport/print.d.ts +3 -1
  75. package/esm/internals/plugins/useChartProExport/print.js +7 -2
  76. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +22 -12
  77. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +4 -4
  78. package/index.js +1 -1
  79. package/internals/plugins/useChartProExport/exportImage.js +9 -3
  80. package/internals/plugins/useChartProExport/print.d.ts +3 -1
  81. package/internals/plugins/useChartProExport/print.js +7 -2
  82. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +22 -12
  83. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +4 -4
  84. package/package.json +6 -6
@@ -1,9 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP, useDrawingArea, useSelector, useStore, ZOOM_SLIDER_MARGIN } from '@mui/x-charts/internals';
4
+ import { DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP, selectorChartAxisZoomOptionsLookup, useDrawingArea, useSelector, useStore, ZOOM_SLIDER_MARGIN, ZOOM_SLIDER_PREVIEW_SIZE } from '@mui/x-charts/internals';
5
5
  import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
6
- import { ZOOM_SLIDER_SIZE, ZOOM_SLIDER_TRACK_SIZE } from "./constants.js";
6
+ import { ChartAxisZoomSliderPreview } from "./ChartAxisZoomSliderPreview.js";
7
+ import { ZOOM_SLIDER_ACTIVE_TRACK_SIZE, ZOOM_SLIDER_SIZE, ZOOM_SLIDER_TRACK_SIZE } from "./constants.js";
7
8
  import { selectorChartAxisZoomData } from "../../internals/plugins/useChartProZoom/index.js";
8
9
  import { ChartAxisZoomSliderTrack } from "./ChartAxisZoomSliderTrack.js";
9
10
  import { ChartAxisZoomSliderActiveTrack } from "./ChartAxisZoomSliderActiveTrack.js";
@@ -19,6 +20,7 @@ export function ChartAxisZoomSlider({
19
20
  const store = useStore();
20
21
  const drawingArea = useDrawingArea();
21
22
  const zoomData = useSelector(store, selectorChartAxisZoomData, [axisId]);
23
+ const zoomOptions = useSelector(store, selectorChartAxisZoomOptionsLookup, [axisId]);
22
24
  const [showTooltip, setShowTooltip] = React.useState(false);
23
25
  const {
24
26
  xAxis
@@ -26,6 +28,7 @@ export function ChartAxisZoomSlider({
26
28
  const {
27
29
  yAxis
28
30
  } = useYAxes();
31
+ const showPreview = zoomOptions.slider.preview;
29
32
  if (!zoomData) {
30
33
  return null;
31
34
  }
@@ -34,6 +37,7 @@ export function ChartAxisZoomSlider({
34
37
  let reverse;
35
38
  let axisPosition;
36
39
  let tooltipConditions;
40
+ const sliderSize = showPreview ? ZOOM_SLIDER_PREVIEW_SIZE : ZOOM_SLIDER_SIZE;
37
41
  if (axisDirection === 'x') {
38
42
  const axis = xAxis[axisId];
39
43
  if (!axis || axis.position === 'none') {
@@ -41,7 +45,7 @@ export function ChartAxisZoomSlider({
41
45
  }
42
46
  const axisSize = axis.height;
43
47
  x = drawingArea.left;
44
- 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;
48
+ y = axis.position === 'bottom' ? drawingArea.top + drawingArea.height + axis.offset + axisSize + ZOOM_SLIDER_MARGIN : drawingArea.top - axis.offset - axisSize - sliderSize - ZOOM_SLIDER_MARGIN;
45
49
  reverse = axis.reverse ?? false;
46
50
  axisPosition = axis.position ?? 'bottom';
47
51
  tooltipConditions = axis.zoom?.slider?.showTooltip ?? DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP;
@@ -51,38 +55,49 @@ export function ChartAxisZoomSlider({
51
55
  return null;
52
56
  }
53
57
  const axisSize = axis.width;
54
- 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;
58
+ x = axis.position === 'right' ? drawingArea.left + drawingArea.width + axis.offset + axisSize + ZOOM_SLIDER_MARGIN : drawingArea.left - axis.offset - axisSize - sliderSize - ZOOM_SLIDER_MARGIN;
55
59
  y = drawingArea.top;
56
60
  reverse = axis.reverse ?? false;
57
61
  axisPosition = axis.position ?? 'left';
58
62
  tooltipConditions = axis.zoom?.slider?.showTooltip ?? DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP;
59
63
  }
60
- const backgroundRectOffset = (ZOOM_SLIDER_SIZE - ZOOM_SLIDER_TRACK_SIZE) / 2;
64
+ const backgroundRectOffset = (sliderSize - ZOOM_SLIDER_TRACK_SIZE) / 2;
65
+ const track = showPreview ? /*#__PURE__*/_jsx(ChartAxisZoomSliderPreview, {
66
+ axisId: axisId,
67
+ axisDirection: axisDirection,
68
+ reverse: reverse,
69
+ x: 0,
70
+ y: 0,
71
+ height: axisDirection === 'x' ? ZOOM_SLIDER_PREVIEW_SIZE : drawingArea.height,
72
+ width: axisDirection === 'x' ? drawingArea.width : ZOOM_SLIDER_PREVIEW_SIZE
73
+ }) : /*#__PURE__*/_jsx(ChartAxisZoomSliderTrack, {
74
+ x: axisDirection === 'x' ? 0 : backgroundRectOffset,
75
+ y: axisDirection === 'x' ? backgroundRectOffset : 0,
76
+ height: axisDirection === 'x' ? ZOOM_SLIDER_TRACK_SIZE : drawingArea.height,
77
+ width: axisDirection === 'x' ? drawingArea.width : ZOOM_SLIDER_TRACK_SIZE,
78
+ rx: ZOOM_SLIDER_TRACK_SIZE / 2,
79
+ ry: ZOOM_SLIDER_TRACK_SIZE / 2,
80
+ axisId: axisId,
81
+ axisDirection: axisDirection,
82
+ reverse: reverse,
83
+ onSelectStart: tooltipConditions === 'hover' ? () => setShowTooltip(true) : undefined,
84
+ onSelectEnd: tooltipConditions === 'hover' ? () => setShowTooltip(false) : undefined
85
+ });
61
86
  return /*#__PURE__*/_jsxs("g", {
62
87
  "data-charts-zoom-slider": true,
63
88
  transform: `translate(${x} ${y})`,
64
89
  style: {
65
90
  touchAction: 'none'
66
91
  },
67
- children: [/*#__PURE__*/_jsx(ChartAxisZoomSliderTrack, {
68
- x: axisDirection === 'x' ? 0 : backgroundRectOffset,
69
- y: axisDirection === 'x' ? backgroundRectOffset : 0,
70
- height: axisDirection === 'x' ? ZOOM_SLIDER_TRACK_SIZE : drawingArea.height,
71
- width: axisDirection === 'x' ? drawingArea.width : ZOOM_SLIDER_TRACK_SIZE,
72
- rx: ZOOM_SLIDER_TRACK_SIZE / 2,
73
- ry: ZOOM_SLIDER_TRACK_SIZE / 2,
74
- axisId: axisId,
75
- axisDirection: axisDirection,
76
- reverse: reverse,
77
- onSelectStart: tooltipConditions === 'hover' ? () => setShowTooltip(true) : undefined,
78
- onSelectEnd: tooltipConditions === 'hover' ? () => setShowTooltip(false) : undefined
79
- }), /*#__PURE__*/_jsx(ChartAxisZoomSliderActiveTrack, {
92
+ children: [track, /*#__PURE__*/_jsx(ChartAxisZoomSliderActiveTrack, {
80
93
  zoomData: zoomData,
81
94
  axisId: axisId,
82
95
  axisPosition: axisPosition,
83
96
  axisDirection: axisDirection,
84
97
  reverse: reverse,
85
98
  showTooltip: showTooltip && tooltipConditions !== 'never' || tooltipConditions === 'always',
99
+ size: showPreview ? ZOOM_SLIDER_PREVIEW_SIZE : ZOOM_SLIDER_ACTIVE_TRACK_SIZE,
100
+ preview: showPreview,
86
101
  onPointerEnter: tooltipConditions === 'hover' ? () => setShowTooltip(true) : undefined,
87
102
  onPointerLeave: tooltipConditions === 'hover' ? () => setShowTooltip(false) : undefined
88
103
  })]
@@ -4,6 +4,8 @@ export interface ChartAxisZoomSliderActiveTrackProps {
4
4
  axisId: AxisId;
5
5
  axisDirection: 'x' | 'y';
6
6
  axisPosition: 'top' | 'bottom' | 'left' | 'right';
7
+ size: number;
8
+ preview: boolean;
7
9
  zoomData: ZoomData;
8
10
  reverse?: boolean;
9
11
  showTooltip: boolean;
@@ -14,6 +16,8 @@ export declare function ChartAxisZoomSliderActiveTrack({
14
16
  axisId,
15
17
  axisDirection,
16
18
  axisPosition,
19
+ size,
20
+ preview,
17
21
  zoomData,
18
22
  reverse,
19
23
  showTooltip,
@@ -5,25 +5,39 @@ import { styled } from '@mui/material/styles';
5
5
  import { getSVGPoint, invertScale, selectorChartAxis, selectorChartAxisZoomOptionsLookup, useChartContext, useDrawingArea, useSelector, useStore } from '@mui/x-charts/internals';
6
6
  import * as React from 'react';
7
7
  import { rafThrottle } from '@mui/x-internals/rafThrottle';
8
+ import { shouldForwardProp } from '@mui/system';
8
9
  import { selectorChartAxisZoomData } from "../../internals/plugins/useChartProZoom/index.js";
9
10
  import { ChartAxisZoomSliderThumb } from "./ChartAxisZoomSliderThumb.js";
10
11
  import { ChartsTooltipZoomSliderValue } from "./ChartsTooltipZoomSliderValue.js";
11
12
  import { calculateZoomEnd, calculateZoomFromPoint, calculateZoomStart } from "./zoom-utils.js";
12
- import { ZOOM_SLIDER_ACTIVE_TRACK_SIZE, ZOOM_SLIDER_THUMB_HEIGHT, ZOOM_SLIDER_THUMB_WIDTH } from "./constants.js";
13
+ import { ZOOM_SLIDER_THUMB_HEIGHT, ZOOM_SLIDER_THUMB_WIDTH } from "./constants.js";
13
14
  import { useUtilityClasses } from "./chartAxisZoomSliderTrackClasses.js";
14
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- const ZoomSliderActiveTrackRect = styled('rect')(({
16
+ const ZoomSliderActiveTrackRect = styled('rect', {
17
+ shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'preview'
18
+ })(({
16
19
  theme
17
20
  }) => ({
18
- '&': {
19
- fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[500] : (theme.vars || theme).palette.grey[600],
20
- cursor: 'grab'
21
- }
21
+ fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[500] : (theme.vars || theme).palette.grey[600],
22
+ cursor: 'grab',
23
+ variants: [{
24
+ props: {
25
+ preview: true
26
+ },
27
+ style: {
28
+ fill: 'transparent',
29
+ rx: 4,
30
+ ry: 4,
31
+ stroke: theme.palette.grey[500]
32
+ }
33
+ }]
22
34
  }));
23
35
  export function ChartAxisZoomSliderActiveTrack({
24
36
  axisId,
25
37
  axisDirection,
26
38
  axisPosition,
39
+ size,
40
+ preview,
27
41
  zoomData,
28
42
  reverse,
29
43
  showTooltip,
@@ -162,11 +176,11 @@ export function ChartAxisZoomSliderActiveTrack({
162
176
  previewX = (zoomStart - minStart) / range * drawingArea.width;
163
177
  previewY = 0;
164
178
  previewWidth = drawingArea.width * (zoomEnd - zoomStart) / range;
165
- previewHeight = ZOOM_SLIDER_ACTIVE_TRACK_SIZE;
179
+ previewHeight = size;
166
180
  startThumbX = (zoomStart - minStart) / range * drawingArea.width;
167
- startThumbY = 0;
181
+ startThumbY = ZOOM_SLIDER_THUMB_HEIGHT < size ? (size - ZOOM_SLIDER_THUMB_HEIGHT) / 2 : 0;
168
182
  endThumbX = (zoomEnd - minStart) / range * drawingArea.width;
169
- endThumbY = 0;
183
+ endThumbY = ZOOM_SLIDER_THUMB_HEIGHT < size ? (size - ZOOM_SLIDER_THUMB_HEIGHT) / 2 : 0;
170
184
  if (reverse) {
171
185
  previewX = drawingArea.width - previewX - previewWidth;
172
186
  startThumbX = drawingArea.width - startThumbX;
@@ -177,11 +191,11 @@ export function ChartAxisZoomSliderActiveTrack({
177
191
  } else {
178
192
  previewX = 0;
179
193
  previewY = drawingArea.height - (zoomEnd - minStart) / range * drawingArea.height;
180
- previewWidth = ZOOM_SLIDER_ACTIVE_TRACK_SIZE;
194
+ previewWidth = size;
181
195
  previewHeight = drawingArea.height * (zoomEnd - zoomStart) / range;
182
- startThumbX = 0;
196
+ startThumbX = ZOOM_SLIDER_THUMB_HEIGHT < size ? (size - ZOOM_SLIDER_THUMB_HEIGHT) / 2 : 0;
183
197
  startThumbY = drawingArea.height - (zoomStart - minStart) / range * drawingArea.height;
184
- endThumbX = 0;
198
+ endThumbX = ZOOM_SLIDER_THUMB_HEIGHT < size ? (size - ZOOM_SLIDER_THUMB_HEIGHT) / 2 : 0;
185
199
  endThumbY = drawingArea.height - (zoomEnd - minStart) / range * drawingArea.height;
186
200
  if (reverse) {
187
201
  previewY = drawingArea.height - previewY - previewHeight;
@@ -191,12 +205,13 @@ export function ChartAxisZoomSliderActiveTrack({
191
205
  startThumbY -= previewThumbHeight / 2;
192
206
  endThumbY -= previewThumbHeight / 2;
193
207
  }
194
- const previewOffset = (ZOOM_SLIDER_THUMB_HEIGHT - ZOOM_SLIDER_ACTIVE_TRACK_SIZE) / 2;
208
+ const previewOffset = ZOOM_SLIDER_THUMB_HEIGHT > size ? (ZOOM_SLIDER_THUMB_HEIGHT - size) / 2 : 0;
195
209
  return /*#__PURE__*/_jsxs(React.Fragment, {
196
210
  children: [/*#__PURE__*/_jsx(ZoomSliderActiveTrackRect, {
197
211
  ref: activePreviewRectRef,
198
212
  x: previewX + (axisDirection === 'x' ? 0 : previewOffset),
199
213
  y: previewY + (axisDirection === 'x' ? previewOffset : 0),
214
+ preview: preview,
200
215
  width: previewWidth,
201
216
  height: previewHeight,
202
217
  onPointerEnter: onPointerEnter,
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { AxisId } from '@mui/x-charts/internals';
3
+ interface ChartAxisZoomSliderPreviewProps {
4
+ axisId: AxisId;
5
+ axisDirection: 'x' | 'y';
6
+ reverse: boolean;
7
+ x: number;
8
+ y: number;
9
+ height: number;
10
+ width: number;
11
+ }
12
+ export declare function ChartAxisZoomSliderPreview({
13
+ axisId,
14
+ axisDirection,
15
+ reverse,
16
+ ...props
17
+ }: ChartAxisZoomSliderPreviewProps): React.JSX.Element;
18
+ export {};
@@ -0,0 +1,94 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["axisId", "axisDirection", "reverse"];
4
+ import * as React from 'react';
5
+ import { styled } from '@mui/material/styles';
6
+ import { selectorChartAxisZoomOptionsLookup, useSelector, useStore } from '@mui/x-charts/internals';
7
+ import { alpha } from '@mui/system';
8
+ import useId from '@mui/utils/useId';
9
+ import { selectorChartAxisZoomData } from "../../internals/plugins/useChartProZoom/index.js";
10
+ import { ChartAxisZoomSliderPreviewContent } from "./ChartAxisZoomSliderPreviewContent.js";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const PreviewBackgroundRect = styled('rect')(({
13
+ theme
14
+ }) => ({
15
+ rx: 4,
16
+ ry: 4,
17
+ stroke: theme.palette.grey[700],
18
+ fill: alpha(theme.palette.grey[700], 0.4)
19
+ }));
20
+ export function ChartAxisZoomSliderPreview(_ref) {
21
+ let {
22
+ axisId,
23
+ axisDirection
24
+ } = _ref,
25
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
26
+ return /*#__PURE__*/_jsxs("g", _extends({}, props, {
27
+ children: [/*#__PURE__*/_jsx(PreviewRectangles, _extends({}, props, {
28
+ axisId: axisId,
29
+ axisDirection: axisDirection
30
+ })), /*#__PURE__*/_jsx("rect", _extends({}, props, {
31
+ fill: "transparent",
32
+ rx: 4,
33
+ ry: 4
34
+ })), /*#__PURE__*/_jsx(ChartAxisZoomSliderPreviewContent, _extends({
35
+ axisId: axisId
36
+ }, props))]
37
+ }));
38
+ }
39
+ function PreviewRectangles(props) {
40
+ const {
41
+ axisId,
42
+ axisDirection
43
+ } = props;
44
+ const store = useStore();
45
+ const zoomData = useSelector(store, selectorChartAxisZoomData, [axisId]);
46
+ const zoomOptions = useSelector(store, selectorChartAxisZoomOptionsLookup, [axisId]);
47
+ const id = useId();
48
+ if (!zoomData) {
49
+ return null;
50
+ }
51
+ const maskId = `zoom-preview-mask-${axisId}-${id}`;
52
+ let x;
53
+ let y;
54
+ let width;
55
+ let height;
56
+ const range = zoomOptions.maxEnd - zoomOptions.minStart;
57
+ if (axisDirection === 'x') {
58
+ x = props.x + (zoomData.start - zoomOptions.minStart) / range * props.width;
59
+ y = props.y;
60
+ width = (zoomData.end - zoomData.start) / range * props.width;
61
+ height = props.height;
62
+ } else {
63
+ x = props.x;
64
+ y = props.y + (1 - zoomData.end / range) * props.height;
65
+ width = props.width;
66
+ height = (zoomData.end - zoomData.start) / range * props.height;
67
+ }
68
+ return /*#__PURE__*/_jsxs(React.Fragment, {
69
+ children: [/*#__PURE__*/_jsxs("mask", {
70
+ id: maskId,
71
+ children: [/*#__PURE__*/_jsx("rect", {
72
+ x: props.x,
73
+ y: props.y,
74
+ width: props.width,
75
+ height: props.height,
76
+ fill: "white"
77
+ }), /*#__PURE__*/_jsx("rect", {
78
+ x: x,
79
+ y: y,
80
+ width: width,
81
+ height: height,
82
+ fill: "black",
83
+ rx: 4,
84
+ ry: 4
85
+ })]
86
+ }), /*#__PURE__*/_jsx(PreviewBackgroundRect, {
87
+ x: props.x,
88
+ y: props.y,
89
+ width: props.width,
90
+ height: props.height,
91
+ mask: `url(#${maskId})`
92
+ })]
93
+ });
94
+ }
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { AxisId } from '@mui/x-charts/internals';
3
+ interface ChartAxisZoomSliderPreviewContentProps {
4
+ axisId: AxisId;
5
+ x: number;
6
+ y: number;
7
+ height: number;
8
+ width: number;
9
+ }
10
+ export declare function ChartAxisZoomSliderPreviewContent(props: ChartAxisZoomSliderPreviewContentProps): React.JSX.Element;
11
+ export {};
@@ -0,0 +1,54 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { selectorChartSeriesProcessed, useSelector, useStore } from '@mui/x-charts/internals';
4
+ import { LinePreviewPlot } from "./previews/LinePreviewPlot.js";
5
+ import { AreaPreviewPlot } from "./previews/AreaPreviewPlot.js";
6
+ import { BarPreviewPlot } from "./previews/BarPreviewPlot.js";
7
+ import { ScatterPreviewPlot } from "./previews/ScatterPreviewPlot.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export function ChartAxisZoomSliderPreviewContent(props) {
10
+ const {
11
+ axisId,
12
+ x,
13
+ y,
14
+ width,
15
+ height
16
+ } = props;
17
+ const store = useStore();
18
+ const processedSeries = useSelector(store, selectorChartSeriesProcessed);
19
+ const children = [];
20
+ const clipId = `zoom-preview-mask-${axisId}`;
21
+ const hasLineSeries = (processedSeries.line?.seriesOrder?.length ?? 0) > 0;
22
+ const hasBarSeries = (processedSeries.bar?.seriesOrder?.length ?? 0) > 0;
23
+ const hasScatterSeries = (processedSeries.scatter?.seriesOrder?.length ?? 0) > 0;
24
+ if (hasLineSeries) {
25
+ children.push(/*#__PURE__*/_jsx(AreaPreviewPlot, {
26
+ axisId: axisId
27
+ }, "area"));
28
+ }
29
+ if (hasBarSeries) {
30
+ children.push(/*#__PURE__*/_jsx(BarPreviewPlot, _extends({}, props), "bar"));
31
+ }
32
+ if (hasLineSeries) {
33
+ children.push(/*#__PURE__*/_jsx(LinePreviewPlot, {
34
+ axisId: axisId
35
+ }, "line"));
36
+ }
37
+ if (hasScatterSeries) {
38
+ children.push(/*#__PURE__*/_jsx(ScatterPreviewPlot, _extends({}, props), "scatter"));
39
+ }
40
+ return /*#__PURE__*/_jsxs(React.Fragment, {
41
+ children: [/*#__PURE__*/_jsx("clipPath", {
42
+ id: clipId,
43
+ children: /*#__PURE__*/_jsx("rect", {
44
+ x: x,
45
+ y: y,
46
+ width: width,
47
+ height: height
48
+ })
49
+ }), /*#__PURE__*/_jsx("g", {
50
+ clipPath: `url(#${clipId})`,
51
+ children: children
52
+ })]
53
+ });
54
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import { SeriesId } from '@mui/x-charts/internals';
3
+ import { PreviewPlotProps } from "./PreviewPlot.types.js";
4
+ interface AreaPreviewPlotProps extends PreviewPlotProps {}
5
+ export declare function AreaPreviewPlot({
6
+ axisId
7
+ }: AreaPreviewPlotProps): React.JSX.Element;
8
+ export interface PreviewAreaElementProps extends Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color' | 'id'> {
9
+ id: SeriesId;
10
+ gradientId?: string;
11
+ color: string;
12
+ d: string;
13
+ }
14
+ export {};
@@ -0,0 +1,53 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["id", "color", "gradientId", "onClick"];
4
+ import * as React from 'react';
5
+ import { styled } from '@mui/material/styles';
6
+ import { useSelector, useStore, useAreaPlotData, selectorChartPreviewComputedXAxis, selectorChartPreviewComputedYAxis } from '@mui/x-charts/internals';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const AreaPlotRoot = styled('g', {
9
+ name: 'MuiAreaPlot',
10
+ slot: 'Root'
11
+ })();
12
+ export function AreaPreviewPlot({
13
+ axisId
14
+ }) {
15
+ const completedData = useAreaPreviewData(axisId);
16
+ return /*#__PURE__*/_jsx(AreaPlotRoot, {
17
+ children: completedData.map(({
18
+ d,
19
+ seriesId,
20
+ color,
21
+ area,
22
+ gradientId
23
+ }) => !!area && /*#__PURE__*/_jsx(PreviewAreaElement, {
24
+ id: seriesId,
25
+ d: d,
26
+ color: color,
27
+ gradientId: gradientId
28
+ }, seriesId))
29
+ });
30
+ }
31
+ /**
32
+ * Preview of the area element for the zoom preview.
33
+ * Based on AreaElement and AnimatedArea.
34
+ */
35
+ function PreviewAreaElement(_ref) {
36
+ let {
37
+ id,
38
+ color,
39
+ gradientId
40
+ } = _ref,
41
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
42
+ return /*#__PURE__*/_jsx("path", _extends({
43
+ fill: gradientId ? `url(#${gradientId})` : color,
44
+ stroke: "none",
45
+ "data-series": id
46
+ }, other));
47
+ }
48
+ function useAreaPreviewData(axisId) {
49
+ const store = useStore();
50
+ const xAxes = useSelector(store, selectorChartPreviewComputedXAxis, [axisId]);
51
+ const yAxes = useSelector(store, selectorChartPreviewComputedYAxis, [axisId]);
52
+ return useAreaPlotData(xAxes, yAxes);
53
+ }
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { PreviewPlotProps } from "./PreviewPlot.types.js";
3
+ interface BarPreviewPlotProps extends PreviewPlotProps {
4
+ x: number;
5
+ y: number;
6
+ height: number;
7
+ width: number;
8
+ }
9
+ export declare function BarPreviewPlot(props: BarPreviewPlotProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ import { selectorChartPreviewComputedXAxis, selectorChartPreviewComputedYAxis, useBarPlotData, useSelector, useStore } from '@mui/x-charts/internals';
3
+ import { BarElement } from '@mui/x-charts/BarChart';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export function BarPreviewPlot(props) {
6
+ const drawingArea = {
7
+ left: props.x,
8
+ top: props.y,
9
+ width: props.width,
10
+ height: props.height,
11
+ right: props.x + props.width,
12
+ bottom: props.y + props.height
13
+ };
14
+ const {
15
+ completedData
16
+ } = useBarPreviewData(props.axisId, drawingArea);
17
+ return /*#__PURE__*/_jsx("g", {
18
+ children: completedData.map(({
19
+ seriesId,
20
+ data
21
+ }) => /*#__PURE__*/_jsx("g", {
22
+ children: data.map(({
23
+ dataIndex,
24
+ color,
25
+ layout,
26
+ x,
27
+ xOrigin,
28
+ y,
29
+ yOrigin,
30
+ width,
31
+ height
32
+ }) => {
33
+ return /*#__PURE__*/_jsx(BarElement, {
34
+ id: seriesId,
35
+ dataIndex: dataIndex,
36
+ color: color,
37
+ skipAnimation: true,
38
+ layout: layout ?? 'vertical',
39
+ x: x,
40
+ xOrigin: xOrigin,
41
+ y: y,
42
+ yOrigin: yOrigin,
43
+ width: width,
44
+ height: height
45
+ }, dataIndex);
46
+ })
47
+ }, seriesId))
48
+ });
49
+ }
50
+ function useBarPreviewData(axisId, drawingArea) {
51
+ const store = useStore();
52
+ const xAxes = useSelector(store, selectorChartPreviewComputedXAxis, [axisId]);
53
+ const yAxes = useSelector(store, selectorChartPreviewComputedYAxis, [axisId]);
54
+ return useBarPlotData(drawingArea, xAxes, yAxes);
55
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import { SeriesId } from '@mui/x-charts/internals';
3
+ import { PreviewPlotProps } from "./PreviewPlot.types.js";
4
+ interface LinePreviewPlotProps extends PreviewPlotProps {}
5
+ export declare function LinePreviewPlot({
6
+ axisId
7
+ }: LinePreviewPlotProps): React.JSX.Element;
8
+ export interface PreviewLineElementProps extends Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color' | 'id'> {
9
+ id: SeriesId;
10
+ gradientId?: string;
11
+ color: string;
12
+ d: string;
13
+ }
14
+ export {};
@@ -0,0 +1,51 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["id", "color", "gradientId", "onClick"];
4
+ import * as React from 'react';
5
+ import { useSelector, useStore, useLinePlotData, selectorChartPreviewComputedXAxis, selectorChartPreviewComputedYAxis } from '@mui/x-charts/internals';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function LinePreviewPlot({
8
+ axisId
9
+ }) {
10
+ const completedData = useLinePreviewData(axisId);
11
+ return /*#__PURE__*/_jsx("g", {
12
+ children: completedData.map(({
13
+ d,
14
+ seriesId,
15
+ color,
16
+ gradientId
17
+ }) => {
18
+ return /*#__PURE__*/_jsx(PreviewLineElement, {
19
+ id: seriesId,
20
+ d: d,
21
+ color: color,
22
+ gradientId: gradientId
23
+ }, seriesId);
24
+ })
25
+ });
26
+ }
27
+ /**
28
+ * Preview of the line element for the zoom preview.
29
+ * Based on LineElement and AnimatedLine.
30
+ */
31
+ function PreviewLineElement(_ref) {
32
+ let {
33
+ id,
34
+ color,
35
+ gradientId
36
+ } = _ref,
37
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
38
+ return /*#__PURE__*/_jsx("path", _extends({
39
+ stroke: gradientId ? `url(#${gradientId})` : color,
40
+ strokeWidth: 2,
41
+ strokeLinejoin: "round",
42
+ fill: "none",
43
+ "data-series": id
44
+ }, other));
45
+ }
46
+ function useLinePreviewData(axisId) {
47
+ const store = useStore();
48
+ const xAxes = useSelector(store, selectorChartPreviewComputedXAxis, [axisId]);
49
+ const yAxes = useSelector(store, selectorChartPreviewComputedYAxis, [axisId]);
50
+ return useLinePlotData(xAxes, yAxes);
51
+ }
@@ -0,0 +1,4 @@
1
+ import { AxisId } from '@mui/x-charts/internals';
2
+ export interface PreviewPlotProps {
3
+ axisId: AxisId;
4
+ }
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { PreviewPlotProps } from "./PreviewPlot.types.js";
3
+ interface ScatterPreviewPlotProps extends PreviewPlotProps {
4
+ x: number;
5
+ y: number;
6
+ height: number;
7
+ width: number;
8
+ }
9
+ export declare function ScatterPreviewPlot({
10
+ axisId,
11
+ x,
12
+ y,
13
+ height,
14
+ width
15
+ }: ScatterPreviewPlotProps): React.JSX.Element | null;
16
+ export {};