@mui/x-charts-pro 8.2.0 → 8.3.1
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.
- package/BarChartPro/BarChartPro.d.ts +7 -1
- package/BarChartPro/BarChartPro.js +60 -4
- package/CHANGELOG.md +199 -6
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartZoomSlider/ChartZoomSlider.d.ts +5 -0
- package/ChartZoomSlider/ChartZoomSlider.js +47 -0
- package/ChartZoomSlider/index.d.ts +2 -0
- package/ChartZoomSlider/index.js +27 -0
- package/ChartZoomSlider/internals/ChartAxisZoomSlider.d.ts +23 -0
- package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +348 -0
- package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +12 -0
- package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +92 -0
- package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +17 -0
- package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.js +27 -0
- package/ChartsToolbarPro/ChartsToolbarPro.d.ts +2 -0
- package/ChartsToolbarPro/ChartsToolbarPro.js +31 -0
- package/ChartsToolbarPro/index.d.ts +1 -0
- package/ChartsToolbarPro/index.js +16 -0
- package/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.d.ts +13 -0
- package/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.js +36 -0
- package/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.d.ts +13 -0
- package/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.js +36 -0
- package/FunnelChart/FunnelChart.js +2 -7
- package/FunnelChart/FunnelPlot.js +24 -3
- package/FunnelChart/FunnelSection.d.ts +1 -0
- package/FunnelChart/FunnelSection.js +12 -7
- package/FunnelChart/curves/borderRadiusPolygon.d.ts +8 -0
- package/FunnelChart/curves/borderRadiusPolygon.js +42 -0
- package/FunnelChart/curves/bump.d.ts +8 -5
- package/FunnelChart/curves/bump.js +21 -22
- package/FunnelChart/curves/curve.types.d.ts +33 -3
- package/FunnelChart/curves/getFunnelCurve.d.ts +2 -2
- package/FunnelChart/curves/getFunnelCurve.js +12 -4
- package/FunnelChart/curves/linear.d.ts +17 -9
- package/FunnelChart/curves/linear.js +62 -87
- package/FunnelChart/curves/pyramid.d.ts +34 -0
- package/FunnelChart/curves/pyramid.js +127 -0
- package/FunnelChart/curves/step-pyramid.d.ts +31 -0
- package/FunnelChart/curves/step-pyramid.js +107 -0
- package/FunnelChart/curves/step.d.ts +32 -0
- package/FunnelChart/curves/step.js +88 -0
- package/FunnelChart/curves/utils.d.ts +4 -0
- package/FunnelChart/curves/utils.js +29 -0
- package/FunnelChart/funnel.types.d.ts +23 -2
- package/FunnelChart/funnelSectionClasses.d.ts +5 -1
- package/FunnelChart/funnelSectionClasses.js +5 -2
- package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +1 -0
- package/FunnelChart/useFunnelChartProps.d.ts +0 -5
- package/FunnelChart/useFunnelChartProps.js +0 -11
- package/Heatmap/Heatmap.d.ts +3 -3
- package/Heatmap/Heatmap.js +2 -20
- package/LineChartPro/LineChartPro.d.ts +7 -1
- package/LineChartPro/LineChartPro.js +60 -4
- package/ScatterChartPro/ScatterChartPro.d.ts +7 -1
- package/ScatterChartPro/ScatterChartPro.js +60 -4
- package/esm/BarChartPro/BarChartPro.d.ts +7 -1
- package/esm/BarChartPro/BarChartPro.js +60 -4
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartZoomSlider/ChartZoomSlider.d.ts +5 -0
- package/esm/ChartZoomSlider/ChartZoomSlider.js +41 -0
- package/esm/ChartZoomSlider/index.d.ts +2 -0
- package/esm/ChartZoomSlider/index.js +2 -0
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.d.ts +23 -0
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +339 -0
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +12 -0
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +85 -0
- package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +17 -0
- package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.js +17 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +2 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPro.js +24 -0
- package/esm/ChartsToolbarPro/index.d.ts +1 -0
- package/esm/ChartsToolbarPro/index.js +1 -0
- package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.d.ts +13 -0
- package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.js +29 -0
- package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.d.ts +13 -0
- package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.js +29 -0
- package/esm/FunnelChart/FunnelChart.js +2 -7
- package/esm/FunnelChart/FunnelPlot.js +24 -3
- package/esm/FunnelChart/FunnelSection.d.ts +1 -0
- package/esm/FunnelChart/FunnelSection.js +12 -7
- package/esm/FunnelChart/curves/borderRadiusPolygon.d.ts +8 -0
- package/esm/FunnelChart/curves/borderRadiusPolygon.js +36 -0
- package/esm/FunnelChart/curves/bump.d.ts +8 -5
- package/esm/FunnelChart/curves/bump.js +21 -22
- package/esm/FunnelChart/curves/curve.types.d.ts +33 -3
- package/esm/FunnelChart/curves/getFunnelCurve.d.ts +2 -2
- package/esm/FunnelChart/curves/getFunnelCurve.js +12 -4
- package/esm/FunnelChart/curves/linear.d.ts +17 -9
- package/esm/FunnelChart/curves/linear.js +62 -86
- package/esm/FunnelChart/curves/pyramid.d.ts +34 -0
- package/esm/FunnelChart/curves/pyramid.js +121 -0
- package/esm/FunnelChart/curves/step-pyramid.d.ts +31 -0
- package/esm/FunnelChart/curves/step-pyramid.js +101 -0
- package/esm/FunnelChart/curves/step.d.ts +32 -0
- package/esm/FunnelChart/curves/step.js +82 -0
- package/esm/FunnelChart/curves/utils.d.ts +4 -0
- package/esm/FunnelChart/curves/utils.js +19 -0
- package/esm/FunnelChart/funnel.types.d.ts +23 -2
- package/esm/FunnelChart/funnelSectionClasses.d.ts +5 -1
- package/esm/FunnelChart/funnelSectionClasses.js +5 -2
- package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +1 -0
- package/esm/FunnelChart/useFunnelChartProps.d.ts +0 -5
- package/esm/FunnelChart/useFunnelChartProps.js +0 -11
- package/esm/Heatmap/Heatmap.d.ts +3 -3
- package/esm/Heatmap/Heatmap.js +2 -20
- package/esm/LineChartPro/LineChartPro.d.ts +7 -1
- package/esm/LineChartPro/LineChartPro.js +60 -4
- package/esm/ScatterChartPro/ScatterChartPro.d.ts +7 -1
- package/esm/ScatterChartPro/ScatterChartPro.js +60 -4
- package/esm/index.d.ts +4 -1
- package/esm/index.js +4 -3
- package/esm/internals/material/icons.d.ts +3 -0
- package/esm/internals/material/icons.js +13 -0
- package/esm/internals/material/index.d.ts +4 -0
- package/esm/internals/material/index.js +12 -0
- package/esm/internals/plugins/useChartProZoom/calculateZoom.d.ts +23 -0
- package/esm/internals/plugins/useChartProZoom/calculateZoom.js +32 -0
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -1
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +45 -3
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +63 -11
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +3 -2
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +17 -2
- package/esm/internals/slots/chartBaseSlotProps.d.ts +10 -0
- package/esm/internals/slots/chartBaseSlotProps.js +1 -0
- package/esm/internals/slots/chartsBaseSlots.d.ts +6 -0
- package/esm/internals/slots/chartsBaseSlots.js +1 -0
- package/esm/internals/slots/chartsIconSlots.d.ts +14 -0
- package/esm/internals/slots/chartsIconSlots.js +1 -0
- package/esm/typeOverloads/modules.d.ts +1 -1
- package/index.d.ts +4 -1
- package/index.js +23 -1
- package/internals/material/icons.d.ts +3 -0
- package/internals/material/icons.js +20 -0
- package/internals/material/index.d.ts +4 -0
- package/internals/material/index.js +19 -0
- package/internals/plugins/useChartProZoom/calculateZoom.d.ts +23 -0
- package/internals/plugins/useChartProZoom/calculateZoom.js +39 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.js +44 -2
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +63 -11
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +3 -2
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +17 -2
- package/internals/slots/chartBaseSlotProps.d.ts +10 -0
- package/internals/slots/chartBaseSlotProps.js +5 -0
- package/internals/slots/chartsBaseSlots.d.ts +6 -0
- package/internals/slots/chartsBaseSlots.js +5 -0
- package/internals/slots/chartsIconSlots.d.ts +14 -0
- package/internals/slots/chartsIconSlots.js +5 -0
- package/package.json +7 -7
- package/typeOverloads/modules.d.ts +1 -1
- package/FunnelChart/curves/funnelStep.d.ts +0 -25
- package/FunnelChart/curves/funnelStep.js +0 -87
- package/esm/FunnelChart/curves/funnelStep.d.ts +0 -25
- package/esm/FunnelChart/curves/funnelStep.js +0 -80
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
|
|
3
|
+
import { ChartAxisZoomSlider } from "./internals/ChartAxisZoomSlider.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders the zoom slider for all x and y axes that have it enabled.
|
|
7
|
+
*/
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export function ChartZoomSlider() {
|
|
10
|
+
const {
|
|
11
|
+
xAxisIds,
|
|
12
|
+
xAxis: xAxes
|
|
13
|
+
} = useXAxes();
|
|
14
|
+
const {
|
|
15
|
+
yAxisIds,
|
|
16
|
+
yAxis: yAxes
|
|
17
|
+
} = useYAxes();
|
|
18
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
19
|
+
children: [xAxisIds.map(axisId => {
|
|
20
|
+
const xAxis = xAxes[axisId];
|
|
21
|
+
const slider = xAxis.zoom?.slider;
|
|
22
|
+
if (!slider?.enabled) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return /*#__PURE__*/_jsx(ChartAxisZoomSlider, {
|
|
26
|
+
axisId: axisId,
|
|
27
|
+
axisDirection: "x"
|
|
28
|
+
}, axisId);
|
|
29
|
+
}), yAxisIds.map(axisId => {
|
|
30
|
+
const yAxis = yAxes[axisId];
|
|
31
|
+
const slider = yAxis.zoom?.slider;
|
|
32
|
+
if (!slider?.enabled) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/_jsx(ChartAxisZoomSlider, {
|
|
36
|
+
axisId: axisId,
|
|
37
|
+
axisDirection: "y"
|
|
38
|
+
}, axisId);
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AxisId, DefaultizedZoomOptions, ZoomData } from '@mui/x-charts/internals';
|
|
3
|
+
interface ChartZoomSliderProps {
|
|
4
|
+
/**
|
|
5
|
+
* The ID of the axis this overview refers to.
|
|
6
|
+
*/
|
|
7
|
+
axisId: AxisId;
|
|
8
|
+
/**
|
|
9
|
+
* The direction of the axis.
|
|
10
|
+
*/
|
|
11
|
+
axisDirection: 'x' | 'y';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Renders the zoom slider for a specific axis.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function ChartAxisZoomSlider({
|
|
18
|
+
axisDirection,
|
|
19
|
+
axisId
|
|
20
|
+
}: ChartZoomSliderProps): React.JSX.Element | null;
|
|
21
|
+
export declare function calculateZoomStart(newStart: number, currentZoom: ZoomData, options: Pick<DefaultizedZoomOptions, 'minStart' | 'minSpan' | 'maxSpan'>): number;
|
|
22
|
+
export declare function calculateZoomEnd(newEnd: number, currentZoom: ZoomData, options: Pick<DefaultizedZoomOptions, 'maxEnd' | 'minSpan' | 'maxSpan'>): number;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { getSVGPoint, selectorChartAxisZoomOptionsLookup, selectorChartDrawingArea, useChartContext, useDrawingArea, useSelector, useStore, ZOOM_SLIDER_MARGIN } from '@mui/x-charts/internals';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
|
|
8
|
+
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
9
|
+
import { selectorChartAxisZoomData } from "../../internals/plugins/useChartProZoom/index.js";
|
|
10
|
+
import { ChartAxisZoomSliderHandle } from "./ChartAxisZoomSliderHandle.js";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const BackgroundRect = styled('rect')(({
|
|
13
|
+
theme
|
|
14
|
+
}) => ({
|
|
15
|
+
'&': {
|
|
16
|
+
fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[800] : (theme.vars || theme).palette.grey[300]
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
const ZoomRangePreviewRect = styled('rect')(({
|
|
20
|
+
theme
|
|
21
|
+
}) => ({
|
|
22
|
+
'&': {
|
|
23
|
+
fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[500] : (theme.vars || theme).palette.grey[600],
|
|
24
|
+
cursor: 'grab'
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
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);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Renders the zoom slider for a specific axis.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export function ChartAxisZoomSlider({
|
|
38
|
+
axisDirection,
|
|
39
|
+
axisId
|
|
40
|
+
}) {
|
|
41
|
+
const store = useStore();
|
|
42
|
+
const drawingArea = useDrawingArea();
|
|
43
|
+
const zoomData = useSelector(store, selectorChartAxisZoomData, axisId);
|
|
44
|
+
const {
|
|
45
|
+
xAxis
|
|
46
|
+
} = useXAxes();
|
|
47
|
+
const {
|
|
48
|
+
yAxis
|
|
49
|
+
} = useYAxes();
|
|
50
|
+
if (!zoomData) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
let x;
|
|
54
|
+
let y;
|
|
55
|
+
let reverse;
|
|
56
|
+
if (axisDirection === 'x') {
|
|
57
|
+
const axis = xAxis[axisId];
|
|
58
|
+
if (!axis) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const axisSize = axis.height;
|
|
62
|
+
x = drawingArea.left;
|
|
63
|
+
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
|
+
reverse = axis.reverse ?? false;
|
|
65
|
+
} else {
|
|
66
|
+
const axis = yAxis[axisId];
|
|
67
|
+
if (!axis) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const axisSize = axis.width;
|
|
71
|
+
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
|
+
y = drawingArea.top;
|
|
73
|
+
reverse = axis.reverse ?? false;
|
|
74
|
+
}
|
|
75
|
+
const backgroundRectOffset = (ZOOM_SLIDER_SIZE - ZOOM_SLIDER_BACKGROUND_SIZE) / 2;
|
|
76
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
77
|
+
transform: `translate(${x} ${y})`,
|
|
78
|
+
children: [/*#__PURE__*/_jsx(BackgroundRect, {
|
|
79
|
+
x: axisDirection === 'x' ? 0 : backgroundRectOffset,
|
|
80
|
+
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, {
|
|
86
|
+
zoomData: zoomData,
|
|
87
|
+
axisId: axisId,
|
|
88
|
+
axisDirection: axisDirection,
|
|
89
|
+
reverse: reverse
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function ChartAxisZoomSliderSpan({
|
|
94
|
+
axisId,
|
|
95
|
+
axisDirection,
|
|
96
|
+
zoomData,
|
|
97
|
+
reverse
|
|
98
|
+
}) {
|
|
99
|
+
const {
|
|
100
|
+
instance,
|
|
101
|
+
svgRef
|
|
102
|
+
} = useChartContext();
|
|
103
|
+
const store = useStore();
|
|
104
|
+
const drawingArea = useDrawingArea();
|
|
105
|
+
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;
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
const activePreviewRect = activePreviewRectRef.current;
|
|
110
|
+
if (!activePreviewRect) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* min and max values of zoom to ensure the pointer anchor in the slider is maintained */
|
|
115
|
+
let pointerZoomMin;
|
|
116
|
+
let pointerZoomMax;
|
|
117
|
+
let prevPointerZoom = 0;
|
|
118
|
+
const onPointerMove = rafThrottle(event => {
|
|
119
|
+
const {
|
|
120
|
+
left,
|
|
121
|
+
top,
|
|
122
|
+
height,
|
|
123
|
+
width
|
|
124
|
+
} = selectorChartDrawingArea(store.getSnapshot());
|
|
125
|
+
const axisZoomData = selectorChartAxisZoomData(store.getSnapshot(), axisId);
|
|
126
|
+
const element = svgRef.current;
|
|
127
|
+
if (!axisZoomData || !element) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const point = getSVGPoint(element, event);
|
|
131
|
+
let pointerZoom;
|
|
132
|
+
if (axisDirection === 'x') {
|
|
133
|
+
pointerZoom = (point.x - left) / width * 100;
|
|
134
|
+
} else {
|
|
135
|
+
pointerZoom = (top + height - point.y) / height * 100;
|
|
136
|
+
}
|
|
137
|
+
if (reverse) {
|
|
138
|
+
pointerZoom = 100 - pointerZoom;
|
|
139
|
+
}
|
|
140
|
+
pointerZoom = Math.max(pointerZoomMin, Math.min(pointerZoomMax, pointerZoom));
|
|
141
|
+
const deltaZoom = pointerZoom - prevPointerZoom;
|
|
142
|
+
prevPointerZoom = pointerZoom;
|
|
143
|
+
instance.moveZoomRange(axisId, deltaZoom);
|
|
144
|
+
});
|
|
145
|
+
const onPointerUp = () => {
|
|
146
|
+
activePreviewRect.removeEventListener('pointermove', onPointerMove);
|
|
147
|
+
activePreviewRect.removeEventListener('pointerup', onPointerUp);
|
|
148
|
+
};
|
|
149
|
+
const onPointerDown = event => {
|
|
150
|
+
// Prevent text selection when dragging
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
activePreviewRect.setPointerCapture(event.pointerId);
|
|
153
|
+
const {
|
|
154
|
+
left,
|
|
155
|
+
top,
|
|
156
|
+
height,
|
|
157
|
+
width
|
|
158
|
+
} = selectorChartDrawingArea(store.getSnapshot());
|
|
159
|
+
const axisZoomData = selectorChartAxisZoomData(store.getSnapshot(), axisId);
|
|
160
|
+
const element = svgRef.current;
|
|
161
|
+
if (!axisZoomData || !element) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const point = getSVGPoint(element, event);
|
|
165
|
+
|
|
166
|
+
// The corresponding value of zoom where the pointer was pressed
|
|
167
|
+
let pointerDownZoom;
|
|
168
|
+
if (axisDirection === 'x') {
|
|
169
|
+
pointerDownZoom = (point.x - left) / width * 100;
|
|
170
|
+
} else {
|
|
171
|
+
pointerDownZoom = (top + height - point.y) / height * 100;
|
|
172
|
+
}
|
|
173
|
+
if (reverse) {
|
|
174
|
+
pointerDownZoom = 100 - pointerDownZoom;
|
|
175
|
+
}
|
|
176
|
+
prevPointerZoom = pointerDownZoom;
|
|
177
|
+
pointerZoomMin = pointerDownZoom - axisZoomData.start;
|
|
178
|
+
pointerZoomMax = 100 - (axisZoomData.end - pointerDownZoom);
|
|
179
|
+
activePreviewRect.addEventListener('pointerup', onPointerUp);
|
|
180
|
+
activePreviewRect.addEventListener('pointermove', onPointerMove);
|
|
181
|
+
};
|
|
182
|
+
activePreviewRect.addEventListener('pointerdown', onPointerDown);
|
|
183
|
+
|
|
184
|
+
// eslint-disable-next-line consistent-return
|
|
185
|
+
return () => {
|
|
186
|
+
activePreviewRect.removeEventListener('pointerdown', onPointerDown);
|
|
187
|
+
onPointerMove.clear();
|
|
188
|
+
};
|
|
189
|
+
}, [axisDirection, axisId, instance, reverse, store, svgRef]);
|
|
190
|
+
const onResizeStart = event => {
|
|
191
|
+
const element = svgRef.current;
|
|
192
|
+
if (!element) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const point = getSVGPoint(element, event);
|
|
196
|
+
instance.setZoomData(prevZoomData => {
|
|
197
|
+
const {
|
|
198
|
+
left,
|
|
199
|
+
top,
|
|
200
|
+
width,
|
|
201
|
+
height
|
|
202
|
+
} = selectorChartDrawingArea(store.value);
|
|
203
|
+
const zoomOptions = selectorChartAxisZoomOptionsLookup(store.value, axisId);
|
|
204
|
+
return prevZoomData.map(zoom => {
|
|
205
|
+
if (zoom.axisId === axisId) {
|
|
206
|
+
let newStart;
|
|
207
|
+
if (axisDirection === 'x') {
|
|
208
|
+
newStart = (point.x - left) / width * 100;
|
|
209
|
+
} else {
|
|
210
|
+
newStart = (top + height - point.y) / height * 100;
|
|
211
|
+
}
|
|
212
|
+
if (reverse) {
|
|
213
|
+
newStart = 100 - newStart;
|
|
214
|
+
}
|
|
215
|
+
return _extends({}, zoom, {
|
|
216
|
+
start: calculateZoomStart(newStart, zoom, zoomOptions)
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return zoom;
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
const onResizeEnd = event => {
|
|
224
|
+
const element = svgRef.current;
|
|
225
|
+
if (!element) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const point = getSVGPoint(element, event);
|
|
229
|
+
instance.setZoomData(prevZoomData => {
|
|
230
|
+
const {
|
|
231
|
+
left,
|
|
232
|
+
top,
|
|
233
|
+
width,
|
|
234
|
+
height
|
|
235
|
+
} = selectorChartDrawingArea(store.value);
|
|
236
|
+
const zoomOptions = selectorChartAxisZoomOptionsLookup(store.value, axisId);
|
|
237
|
+
return prevZoomData.map(zoom => {
|
|
238
|
+
if (zoom.axisId === axisId) {
|
|
239
|
+
let newEnd;
|
|
240
|
+
if (axisDirection === 'x') {
|
|
241
|
+
newEnd = (point.x - left) / width * 100;
|
|
242
|
+
} else {
|
|
243
|
+
newEnd = (top + height - point.y) / height * 100;
|
|
244
|
+
}
|
|
245
|
+
if (reverse) {
|
|
246
|
+
newEnd = 100 - newEnd;
|
|
247
|
+
}
|
|
248
|
+
return _extends({}, zoom, {
|
|
249
|
+
end: calculateZoomEnd(newEnd, zoom, zoomOptions)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return zoom;
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
let previewX;
|
|
257
|
+
let previewY;
|
|
258
|
+
let previewWidth;
|
|
259
|
+
let previewHeight;
|
|
260
|
+
let startHandleX;
|
|
261
|
+
let startHandleY;
|
|
262
|
+
let endHandleX;
|
|
263
|
+
let endHandleY;
|
|
264
|
+
if (axisDirection === 'x') {
|
|
265
|
+
previewX = zoomData.start / 100 * drawingArea.width;
|
|
266
|
+
previewY = 0;
|
|
267
|
+
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;
|
|
273
|
+
if (reverse) {
|
|
274
|
+
previewX = drawingArea.width - previewX - previewWidth;
|
|
275
|
+
startHandleX = drawingArea.width - startHandleX;
|
|
276
|
+
endHandleX = drawingArea.width - endHandleX;
|
|
277
|
+
}
|
|
278
|
+
startHandleX -= previewHandleWidth / 2;
|
|
279
|
+
endHandleX -= previewHandleWidth / 2;
|
|
280
|
+
} else {
|
|
281
|
+
previewX = 0;
|
|
282
|
+
previewY = drawingArea.height - zoomData.end / 100 * drawingArea.height;
|
|
283
|
+
previewWidth = ZOOM_SLIDER_FOREGROUND_SIZE;
|
|
284
|
+
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;
|
|
289
|
+
if (reverse) {
|
|
290
|
+
previewY = drawingArea.height - previewY - previewHeight;
|
|
291
|
+
startHandleY = drawingArea.height - startHandleY;
|
|
292
|
+
endHandleY = drawingArea.height - endHandleY;
|
|
293
|
+
}
|
|
294
|
+
startHandleY -= previewHandleHeight / 2;
|
|
295
|
+
endHandleY -= previewHandleHeight / 2;
|
|
296
|
+
}
|
|
297
|
+
const previewOffset = (ZOOM_SLIDER_HANDLE_HEIGHT - ZOOM_SLIDER_FOREGROUND_SIZE) / 2;
|
|
298
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
299
|
+
children: [/*#__PURE__*/_jsx(ZoomRangePreviewRect, {
|
|
300
|
+
ref: activePreviewRectRef,
|
|
301
|
+
x: previewX + (axisDirection === 'x' ? 0 : previewOffset),
|
|
302
|
+
y: previewY + (axisDirection === 'x' ? previewOffset : 0),
|
|
303
|
+
width: previewWidth,
|
|
304
|
+
height: previewHeight
|
|
305
|
+
}), /*#__PURE__*/_jsx(ChartAxisZoomSliderHandle, {
|
|
306
|
+
x: startHandleX,
|
|
307
|
+
y: startHandleY,
|
|
308
|
+
width: previewHandleWidth,
|
|
309
|
+
height: previewHandleHeight,
|
|
310
|
+
orientation: axisDirection === 'x' ? 'horizontal' : 'vertical',
|
|
311
|
+
onResize: onResizeStart,
|
|
312
|
+
placement: "start"
|
|
313
|
+
}), /*#__PURE__*/_jsx(ChartAxisZoomSliderHandle, {
|
|
314
|
+
x: endHandleX,
|
|
315
|
+
y: endHandleY,
|
|
316
|
+
width: previewHandleWidth,
|
|
317
|
+
height: previewHandleHeight,
|
|
318
|
+
orientation: axisDirection === 'x' ? 'horizontal' : 'vertical',
|
|
319
|
+
onResize: onResizeEnd,
|
|
320
|
+
placement: "end"
|
|
321
|
+
})]
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
export function calculateZoomStart(newStart, currentZoom, options) {
|
|
325
|
+
const {
|
|
326
|
+
minStart,
|
|
327
|
+
minSpan,
|
|
328
|
+
maxSpan
|
|
329
|
+
} = options;
|
|
330
|
+
return Math.max(minStart, currentZoom.end - maxSpan, Math.min(currentZoom.end - minSpan, newStart));
|
|
331
|
+
}
|
|
332
|
+
export function calculateZoomEnd(newEnd, currentZoom, options) {
|
|
333
|
+
const {
|
|
334
|
+
maxEnd,
|
|
335
|
+
minSpan,
|
|
336
|
+
maxSpan
|
|
337
|
+
} = options;
|
|
338
|
+
return Math.min(maxEnd, currentZoom.start + maxSpan, Math.max(currentZoom.start + minSpan, newEnd));
|
|
339
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ChartZoomSliderHandleOwnerState {
|
|
3
|
+
onResize: (event: PointerEvent) => void;
|
|
4
|
+
orientation: 'horizontal' | 'vertical';
|
|
5
|
+
placement: 'start' | 'end';
|
|
6
|
+
}
|
|
7
|
+
export interface ChartZoomSliderHandleProps extends Pick<React.ComponentProps<'rect'>, 'x' | 'y' | 'width' | 'height' | 'rx' | 'ry'>, ChartZoomSliderHandleOwnerState {}
|
|
8
|
+
/**
|
|
9
|
+
* Renders the zoom slider handle, which is responsible for resizing the zoom range.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const ChartAxisZoomSliderHandle: React.ForwardRefExoticComponent<ChartZoomSliderHandleProps & React.RefAttributes<SVGRectElement>>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
6
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
7
|
+
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
8
|
+
import { chartAxisZoomSliderHandleClasses, useUtilityClasses } from "./chartAxisZoomSliderHandleClasses.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const Rect = styled('rect')(({
|
|
11
|
+
theme
|
|
12
|
+
}) => ({
|
|
13
|
+
[`&.${chartAxisZoomSliderHandleClasses.root}`]: {
|
|
14
|
+
fill: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[300] : (theme.vars || theme).palette.common.white,
|
|
15
|
+
stroke: theme.palette.mode === 'dark' ? (theme.vars || theme).palette.grey[600] : (theme.vars || theme).palette.grey[500]
|
|
16
|
+
},
|
|
17
|
+
[`&.${chartAxisZoomSliderHandleClasses.horizontal}`]: {
|
|
18
|
+
cursor: 'ew-resize'
|
|
19
|
+
},
|
|
20
|
+
[`&.${chartAxisZoomSliderHandleClasses.vertical}`]: {
|
|
21
|
+
cursor: 'ns-resize'
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
/**
|
|
25
|
+
* Renders the zoom slider handle, which is responsible for resizing the zoom range.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export const ChartAxisZoomSliderHandle = /*#__PURE__*/React.forwardRef(function ChartPreviewHandle({
|
|
29
|
+
x,
|
|
30
|
+
y,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
onResize,
|
|
34
|
+
orientation,
|
|
35
|
+
placement,
|
|
36
|
+
rx = 4,
|
|
37
|
+
ry = 4
|
|
38
|
+
}, forwardedRef) {
|
|
39
|
+
const classes = useUtilityClasses({
|
|
40
|
+
onResize,
|
|
41
|
+
orientation,
|
|
42
|
+
placement
|
|
43
|
+
});
|
|
44
|
+
const handleRef = React.useRef(null);
|
|
45
|
+
const ref = useForkRef(handleRef, forwardedRef);
|
|
46
|
+
const onResizeEvent = useEventCallback(onResize);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
const handle = handleRef.current;
|
|
49
|
+
if (!handle) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const onPointerMove = rafThrottle(event => {
|
|
53
|
+
onResizeEvent(event);
|
|
54
|
+
});
|
|
55
|
+
const onPointerUp = () => {
|
|
56
|
+
handle.removeEventListener('pointermove', onPointerMove);
|
|
57
|
+
handle.removeEventListener('pointerup', onPointerUp);
|
|
58
|
+
};
|
|
59
|
+
const onPointerDown = event => {
|
|
60
|
+
// Prevent text selection when dragging the handle
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
handle.setPointerCapture(event.pointerId);
|
|
64
|
+
handle.addEventListener('pointerup', onPointerUp);
|
|
65
|
+
handle.addEventListener('pointermove', onPointerMove);
|
|
66
|
+
};
|
|
67
|
+
handle.addEventListener('pointerdown', onPointerDown);
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line consistent-return
|
|
70
|
+
return () => {
|
|
71
|
+
handle.removeEventListener('pointerdown', onPointerDown);
|
|
72
|
+
onPointerMove.clear();
|
|
73
|
+
};
|
|
74
|
+
}, [onResizeEvent, orientation]);
|
|
75
|
+
return /*#__PURE__*/_jsx(Rect, {
|
|
76
|
+
className: classes.root,
|
|
77
|
+
ref: ref,
|
|
78
|
+
x: x,
|
|
79
|
+
y: y,
|
|
80
|
+
width: width,
|
|
81
|
+
height: height,
|
|
82
|
+
rx: rx,
|
|
83
|
+
ry: ry
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChartZoomSliderHandleOwnerState } from "./ChartAxisZoomSliderHandle.js";
|
|
2
|
+
export interface ChartAxisZoomSliderHandleClasses {
|
|
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 handle. */
|
|
10
|
+
start: string;
|
|
11
|
+
/** Styles applied to the root element when it is an end handle. */
|
|
12
|
+
end: string;
|
|
13
|
+
}
|
|
14
|
+
export type ChartAxisZoomSliderHandleClassKey = keyof ChartAxisZoomSliderHandleClasses;
|
|
15
|
+
export declare const chartAxisZoomSliderHandleClasses: ChartAxisZoomSliderHandleClasses;
|
|
16
|
+
export declare function getAxisZoomSliderHandleUtilityClass(slot: string): string;
|
|
17
|
+
export declare const useUtilityClasses: (ownerState: ChartZoomSliderHandleOwnerState) => Record<"root", string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
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);
|
|
7
|
+
}
|
|
8
|
+
export const useUtilityClasses = ownerState => {
|
|
9
|
+
const {
|
|
10
|
+
orientation,
|
|
11
|
+
placement
|
|
12
|
+
} = ownerState;
|
|
13
|
+
const slots = {
|
|
14
|
+
root: ['root', orientation === 'horizontal' ? 'horizontal' : 'vertical', placement === 'start' ? 'start' : 'end']
|
|
15
|
+
};
|
|
16
|
+
return composeClasses(slots, getAxisZoomSliderHandleUtilityClass);
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Toolbar } from '@mui/x-charts/Toolbar';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useChartContext, useSelector } from '@mui/x-charts/internals';
|
|
4
|
+
import { selectorChartZoomIsEnabled } from "../internals/plugins/useChartProZoom/index.js";
|
|
5
|
+
import { ChartsToolbarZoomInButton } from "./internal/ChartsToolbarZoomInButton.js";
|
|
6
|
+
import { ChartsToolbarZoomOutButton } from "./internal/ChartsToolbarZoomOutButton.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export function ChartsToolbarPro() {
|
|
9
|
+
const {
|
|
10
|
+
store
|
|
11
|
+
} = useChartContext();
|
|
12
|
+
const isZoomEnabled = useSelector(store, selectorChartZoomIsEnabled);
|
|
13
|
+
const children = [];
|
|
14
|
+
if (isZoomEnabled) {
|
|
15
|
+
children.push(/*#__PURE__*/_jsx(ChartsToolbarZoomInButton, {}, "zoom-in"));
|
|
16
|
+
children.push(/*#__PURE__*/_jsx(ChartsToolbarZoomOutButton, {}, "zoom-out"));
|
|
17
|
+
}
|
|
18
|
+
if (children.length === 0) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/_jsx(Toolbar, {
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ChartsToolbarPro.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ChartsToolbarPro.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsSlotsPro } from "../../internals/material/index.js";
|
|
3
|
+
type ChartsToolbarZoomInButtonSlots = Partial<Pick<ChartsSlotsPro, 'baseTooltip' | 'zoomInIcon'>>;
|
|
4
|
+
type ChartsToolbarZoomInButtonSlotProps = { [K in keyof Required<ChartsToolbarZoomInButtonSlots>]: React.ComponentProps<Required<ChartsToolbarZoomInButtonSlots>[K]> };
|
|
5
|
+
interface ChartsToolbarZoomInButtonProps {
|
|
6
|
+
slots?: ChartsToolbarZoomInButtonSlots;
|
|
7
|
+
slotProps?: ChartsToolbarZoomInButtonSlotProps;
|
|
8
|
+
}
|
|
9
|
+
export declare function ChartsToolbarZoomInButton({
|
|
10
|
+
slots,
|
|
11
|
+
slotProps
|
|
12
|
+
}: ChartsToolbarZoomInButtonProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ToolbarButton } from '@mui/x-charts/Toolbar';
|
|
6
|
+
import { useChartContext } from '@mui/x-charts/internals';
|
|
7
|
+
import { useChartsLocalization } from '@mui/x-charts/hooks';
|
|
8
|
+
import { defaultSlotsMaterial } from "../../internals/material/index.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export function ChartsToolbarZoomInButton({
|
|
11
|
+
slots,
|
|
12
|
+
slotProps
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
instance
|
|
16
|
+
} = useChartContext();
|
|
17
|
+
const ZoomInIcon = slots?.zoomInIcon ?? defaultSlotsMaterial.zoomInIcon;
|
|
18
|
+
const Tooltip = slots?.baseTooltip ?? defaultSlotsMaterial.baseTooltip;
|
|
19
|
+
const {
|
|
20
|
+
localeText
|
|
21
|
+
} = useChartsLocalization();
|
|
22
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
23
|
+
title: localeText.zoomIn,
|
|
24
|
+
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
25
|
+
onClick: () => instance.zoomIn(),
|
|
26
|
+
children: /*#__PURE__*/_jsx(ZoomInIcon, _extends({}, slotProps?.zoomInIcon))
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsSlotsPro } from "../../internals/material/index.js";
|
|
3
|
+
type ChartsToolbarZoomOutButtonSlots = Partial<Pick<ChartsSlotsPro, 'baseTooltip' | 'zoomOutIcon'>>;
|
|
4
|
+
type ChartsToolbarZoomOutButtonSlotProps = { [K in keyof Required<ChartsToolbarZoomOutButtonSlots>]: React.ComponentProps<Required<ChartsToolbarZoomOutButtonSlots>[K]> };
|
|
5
|
+
interface ChartsToolbarZoomOutButtonProps {
|
|
6
|
+
slots?: ChartsToolbarZoomOutButtonSlots;
|
|
7
|
+
slotProps?: ChartsToolbarZoomOutButtonSlotProps;
|
|
8
|
+
}
|
|
9
|
+
export declare function ChartsToolbarZoomOutButton({
|
|
10
|
+
slots,
|
|
11
|
+
slotProps
|
|
12
|
+
}: ChartsToolbarZoomOutButtonProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ToolbarButton } from '@mui/x-charts/Toolbar';
|
|
6
|
+
import { useChartContext } from '@mui/x-charts/internals';
|
|
7
|
+
import { useChartsLocalization } from '@mui/x-charts/hooks';
|
|
8
|
+
import { defaultSlotsMaterial } from "../../internals/material/index.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export function ChartsToolbarZoomOutButton({
|
|
11
|
+
slots,
|
|
12
|
+
slotProps
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
instance
|
|
16
|
+
} = useChartContext();
|
|
17
|
+
const ZoomOutIcon = slots?.zoomOutIcon ?? defaultSlotsMaterial.zoomOutIcon;
|
|
18
|
+
const Tooltip = slots?.baseTooltip ?? defaultSlotsMaterial.baseTooltip;
|
|
19
|
+
const {
|
|
20
|
+
localeText
|
|
21
|
+
} = useChartsLocalization();
|
|
22
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
23
|
+
title: localeText.zoomOut,
|
|
24
|
+
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
25
|
+
onClick: () => instance.zoomOut(),
|
|
26
|
+
children: /*#__PURE__*/_jsx(ZoomOutIcon, _extends({}, slotProps?.zoomOutIcon))
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|