@mui/x-charts-pro 8.1.0 → 8.3.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.
- package/BarChartPro/BarChartPro.d.ts +7 -1
- package/BarChartPro/BarChartPro.js +62 -5
- package/CHANGELOG.md +233 -7
- package/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -2
- 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 +9 -8
- package/FunnelChart/FunnelPlot.d.ts +5 -0
- package/FunnelChart/FunnelPlot.js +36 -18
- 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 +27 -0
- package/FunnelChart/curves/bump.js +81 -0
- package/FunnelChart/curves/curve.types.d.ts +38 -0
- package/FunnelChart/curves/curve.types.js +5 -0
- package/FunnelChart/curves/getFunnelCurve.d.ts +3 -0
- package/FunnelChart/curves/getFunnelCurve.js +30 -0
- package/FunnelChart/curves/index.d.ts +2 -0
- package/FunnelChart/curves/index.js +27 -0
- package/FunnelChart/curves/linear.d.ts +32 -0
- package/FunnelChart/curves/linear.js +88 -0
- 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 +25 -4
- package/FunnelChart/funnelPlotSlots.types.d.ts +1 -1
- package/FunnelChart/funnelSectionClasses.d.ts +6 -2
- package/FunnelChart/funnelSectionClasses.js +5 -2
- package/FunnelChart/index.d.ts +3 -2
- package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +1 -0
- package/FunnelChart/useFunnelChartProps.d.ts +1 -6
- package/FunnelChart/useFunnelChartProps.js +7 -15
- package/Heatmap/Heatmap.d.ts +3 -3
- package/Heatmap/Heatmap.js +3 -21
- package/LineChartPro/LineChartPro.d.ts +7 -1
- package/LineChartPro/LineChartPro.js +62 -5
- package/ScatterChartPro/ScatterChartPro.d.ts +7 -1
- package/ScatterChartPro/ScatterChartPro.js +62 -5
- package/esm/BarChartPro/BarChartPro.d.ts +7 -1
- package/esm/BarChartPro/BarChartPro.js +62 -5
- package/esm/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -2
- 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 +9 -8
- package/esm/FunnelChart/FunnelPlot.d.ts +5 -0
- package/esm/FunnelChart/FunnelPlot.js +37 -19
- 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 +27 -0
- package/esm/FunnelChart/curves/bump.js +74 -0
- package/esm/FunnelChart/curves/curve.types.d.ts +38 -0
- package/esm/FunnelChart/curves/curve.types.js +1 -0
- package/esm/FunnelChart/curves/getFunnelCurve.d.ts +3 -0
- package/esm/FunnelChart/curves/getFunnelCurve.js +23 -0
- package/esm/FunnelChart/curves/index.d.ts +2 -0
- package/esm/FunnelChart/curves/index.js +2 -0
- package/esm/FunnelChart/curves/linear.d.ts +32 -0
- package/esm/FunnelChart/curves/linear.js +82 -0
- 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 +25 -4
- package/esm/FunnelChart/funnelPlotSlots.types.d.ts +1 -1
- package/esm/FunnelChart/funnelSectionClasses.d.ts +6 -2
- package/esm/FunnelChart/funnelSectionClasses.js +5 -2
- package/esm/FunnelChart/index.d.ts +3 -2
- package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +1 -0
- package/esm/FunnelChart/useFunnelChartProps.d.ts +1 -6
- package/esm/FunnelChart/useFunnelChartProps.js +7 -15
- package/esm/Heatmap/Heatmap.d.ts +3 -3
- package/esm/Heatmap/Heatmap.js +3 -21
- package/esm/LineChartPro/LineChartPro.d.ts +7 -1
- package/esm/LineChartPro/LineChartPro.js +62 -5
- package/esm/ScatterChartPro/ScatterChartPro.d.ts +7 -1
- package/esm/ScatterChartPro/ScatterChartPro.js +62 -5
- package/esm/index.d.ts +4 -1
- package/esm/index.js +5 -2
- 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/useChartProExport/common.d.ts +1 -0
- package/esm/internals/plugins/useChartProExport/common.js +8 -0
- package/esm/internals/plugins/useChartProExport/exportImage.d.ts +3 -0
- package/esm/internals/plugins/useChartProExport/exportImage.js +85 -0
- package/esm/internals/plugins/useChartProExport/print.js +6 -50
- package/esm/internals/plugins/useChartProExport/useChartProExport.js +22 -2
- package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +32 -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 +46 -4
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +84 -32
- 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/themeAugmentation/components.d.ts +0 -4
- package/esm/themeAugmentation/components.js +1 -0
- package/esm/themeAugmentation/index.d.ts +3 -3
- package/esm/themeAugmentation/overrides.d.ts +0 -3
- package/esm/themeAugmentation/overrides.js +2 -0
- package/esm/themeAugmentation/props.d.ts +0 -6
- package/esm/themeAugmentation/props.js +2 -0
- package/esm/typeOverloads/modules.d.ts +1 -1
- package/index.d.ts +4 -1
- package/index.js +90 -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/useChartProExport/common.d.ts +1 -0
- package/internals/plugins/useChartProExport/common.js +14 -0
- package/internals/plugins/useChartProExport/exportImage.d.ts +3 -0
- package/internals/plugins/useChartProExport/exportImage.js +95 -0
- package/internals/plugins/useChartProExport/print.js +6 -50
- package/internals/plugins/useChartProExport/useChartProExport.js +22 -2
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +32 -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 +45 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +84 -32
- 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 +10 -7
- package/themeAugmentation/components.d.ts +0 -4
- package/themeAugmentation/components.js +5 -0
- package/themeAugmentation/index.d.ts +3 -3
- package/themeAugmentation/overrides.d.ts +0 -3
- package/themeAugmentation/overrides.js +5 -0
- package/themeAugmentation/props.d.ts +0 -6
- package/themeAugmentation/props.js +5 -0
- package/typeOverloads/modules.d.ts +1 -1
- package/FunnelChart/funnelStepCurve.d.ts +0 -4
- package/FunnelChart/funnelStepCurve.js +0 -74
- package/esm/FunnelChart/funnelStepCurve.d.ts +0 -4
- package/esm/FunnelChart/funnelStepCurve.js +0 -67
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef"];
|
|
5
|
+
const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef", "showToolbar"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useThemeProps } from '@mui/material/styles';
|
|
@@ -16,6 +16,8 @@ import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
|
|
|
16
16
|
import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
|
|
17
17
|
import { useBarChartProps, ChartsWrapper } from '@mui/x-charts/internals';
|
|
18
18
|
import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
|
|
19
|
+
import { ChartZoomSlider } from "../ChartZoomSlider/index.js";
|
|
20
|
+
import { ChartsToolbarPro } from "../ChartsToolbarPro/index.js";
|
|
19
21
|
import { useChartContainerProProps } from "../ChartContainerPro/useChartContainerProProps.js";
|
|
20
22
|
import { ChartDataProviderPro } from "../ChartDataProviderPro/index.js";
|
|
21
23
|
import { BAR_CHART_PRO_PLUGINS } from "./BarChartPro.plugins.js";
|
|
@@ -40,7 +42,8 @@ const BarChartPro = /*#__PURE__*/React.forwardRef(function BarChartPro(inProps,
|
|
|
40
42
|
initialZoom,
|
|
41
43
|
zoomData,
|
|
42
44
|
onZoomChange,
|
|
43
|
-
apiRef
|
|
45
|
+
apiRef,
|
|
46
|
+
showToolbar
|
|
44
47
|
} = props,
|
|
45
48
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
46
49
|
const {
|
|
@@ -69,10 +72,10 @@ const BarChartPro = /*#__PURE__*/React.forwardRef(function BarChartPro(inProps,
|
|
|
69
72
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
70
73
|
return /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
|
|
71
74
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
72
|
-
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
75
|
+
children: [showToolbar ? /*#__PURE__*/_jsx(ChartsToolbarPro, {}) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
73
76
|
children: [/*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
74
77
|
children: [/*#__PURE__*/_jsx(BarPlot, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
75
|
-
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
78
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartZoomSlider, {}), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
76
79
|
}))]
|
|
77
80
|
}))
|
|
78
81
|
}));
|
|
@@ -84,6 +87,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
84
87
|
// ----------------------------------------------------------------------
|
|
85
88
|
apiRef: PropTypes.shape({
|
|
86
89
|
current: PropTypes.shape({
|
|
90
|
+
exportAsImage: PropTypes.func.isRequired,
|
|
87
91
|
exportAsPrint: PropTypes.func.isRequired,
|
|
88
92
|
setZoomData: PropTypes.func.isRequired
|
|
89
93
|
})
|
|
@@ -195,7 +199,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
195
199
|
* The function called for onClick events.
|
|
196
200
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
197
201
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
198
|
-
* @param {null |
|
|
202
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
199
203
|
*/
|
|
200
204
|
onAxisClick: PropTypes.func,
|
|
201
205
|
/**
|
|
@@ -221,6 +225,11 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
221
225
|
* An array of [[BarSeriesType]] objects.
|
|
222
226
|
*/
|
|
223
227
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
228
|
+
/**
|
|
229
|
+
* If true, shows the default chart toolbar.
|
|
230
|
+
* @default false
|
|
231
|
+
*/
|
|
232
|
+
showToolbar: PropTypes.bool,
|
|
224
233
|
/**
|
|
225
234
|
* If `true`, animations are skipped.
|
|
226
235
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
@@ -308,6 +317,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
308
317
|
minSpan: PropTypes.number,
|
|
309
318
|
minStart: PropTypes.number,
|
|
310
319
|
panning: PropTypes.bool,
|
|
320
|
+
slider: PropTypes.shape({
|
|
321
|
+
enabled: PropTypes.bool
|
|
322
|
+
}),
|
|
311
323
|
step: PropTypes.number
|
|
312
324
|
}), PropTypes.bool])
|
|
313
325
|
}), PropTypes.shape({
|
|
@@ -368,6 +380,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
368
380
|
minSpan: PropTypes.number,
|
|
369
381
|
minStart: PropTypes.number,
|
|
370
382
|
panning: PropTypes.bool,
|
|
383
|
+
slider: PropTypes.shape({
|
|
384
|
+
enabled: PropTypes.bool
|
|
385
|
+
}),
|
|
371
386
|
step: PropTypes.number
|
|
372
387
|
}), PropTypes.bool])
|
|
373
388
|
}), PropTypes.shape({
|
|
@@ -423,6 +438,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
423
438
|
minSpan: PropTypes.number,
|
|
424
439
|
minStart: PropTypes.number,
|
|
425
440
|
panning: PropTypes.bool,
|
|
441
|
+
slider: PropTypes.shape({
|
|
442
|
+
enabled: PropTypes.bool
|
|
443
|
+
}),
|
|
426
444
|
step: PropTypes.number
|
|
427
445
|
}), PropTypes.bool])
|
|
428
446
|
}), PropTypes.shape({
|
|
@@ -478,6 +496,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
478
496
|
minSpan: PropTypes.number,
|
|
479
497
|
minStart: PropTypes.number,
|
|
480
498
|
panning: PropTypes.bool,
|
|
499
|
+
slider: PropTypes.shape({
|
|
500
|
+
enabled: PropTypes.bool
|
|
501
|
+
}),
|
|
481
502
|
step: PropTypes.number
|
|
482
503
|
}), PropTypes.bool])
|
|
483
504
|
}), PropTypes.shape({
|
|
@@ -533,6 +554,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
533
554
|
minSpan: PropTypes.number,
|
|
534
555
|
minStart: PropTypes.number,
|
|
535
556
|
panning: PropTypes.bool,
|
|
557
|
+
slider: PropTypes.shape({
|
|
558
|
+
enabled: PropTypes.bool
|
|
559
|
+
}),
|
|
536
560
|
step: PropTypes.number
|
|
537
561
|
}), PropTypes.bool])
|
|
538
562
|
}), PropTypes.shape({
|
|
@@ -588,6 +612,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
588
612
|
minSpan: PropTypes.number,
|
|
589
613
|
minStart: PropTypes.number,
|
|
590
614
|
panning: PropTypes.bool,
|
|
615
|
+
slider: PropTypes.shape({
|
|
616
|
+
enabled: PropTypes.bool
|
|
617
|
+
}),
|
|
591
618
|
step: PropTypes.number
|
|
592
619
|
}), PropTypes.bool])
|
|
593
620
|
}), PropTypes.shape({
|
|
@@ -643,6 +670,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
643
670
|
minSpan: PropTypes.number,
|
|
644
671
|
minStart: PropTypes.number,
|
|
645
672
|
panning: PropTypes.bool,
|
|
673
|
+
slider: PropTypes.shape({
|
|
674
|
+
enabled: PropTypes.bool
|
|
675
|
+
}),
|
|
646
676
|
step: PropTypes.number
|
|
647
677
|
}), PropTypes.bool])
|
|
648
678
|
}), PropTypes.shape({
|
|
@@ -698,6 +728,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
698
728
|
minSpan: PropTypes.number,
|
|
699
729
|
minStart: PropTypes.number,
|
|
700
730
|
panning: PropTypes.bool,
|
|
731
|
+
slider: PropTypes.shape({
|
|
732
|
+
enabled: PropTypes.bool
|
|
733
|
+
}),
|
|
701
734
|
step: PropTypes.number
|
|
702
735
|
}), PropTypes.bool])
|
|
703
736
|
})]).isRequired),
|
|
@@ -765,6 +798,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
765
798
|
minSpan: PropTypes.number,
|
|
766
799
|
minStart: PropTypes.number,
|
|
767
800
|
panning: PropTypes.bool,
|
|
801
|
+
slider: PropTypes.shape({
|
|
802
|
+
enabled: PropTypes.bool
|
|
803
|
+
}),
|
|
768
804
|
step: PropTypes.number
|
|
769
805
|
}), PropTypes.bool])
|
|
770
806
|
}), PropTypes.shape({
|
|
@@ -824,6 +860,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
824
860
|
minSpan: PropTypes.number,
|
|
825
861
|
minStart: PropTypes.number,
|
|
826
862
|
panning: PropTypes.bool,
|
|
863
|
+
slider: PropTypes.shape({
|
|
864
|
+
enabled: PropTypes.bool
|
|
865
|
+
}),
|
|
827
866
|
step: PropTypes.number
|
|
828
867
|
}), PropTypes.bool])
|
|
829
868
|
}), PropTypes.shape({
|
|
@@ -878,6 +917,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
878
917
|
minSpan: PropTypes.number,
|
|
879
918
|
minStart: PropTypes.number,
|
|
880
919
|
panning: PropTypes.bool,
|
|
920
|
+
slider: PropTypes.shape({
|
|
921
|
+
enabled: PropTypes.bool
|
|
922
|
+
}),
|
|
881
923
|
step: PropTypes.number
|
|
882
924
|
}), PropTypes.bool])
|
|
883
925
|
}), PropTypes.shape({
|
|
@@ -932,6 +974,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
932
974
|
minSpan: PropTypes.number,
|
|
933
975
|
minStart: PropTypes.number,
|
|
934
976
|
panning: PropTypes.bool,
|
|
977
|
+
slider: PropTypes.shape({
|
|
978
|
+
enabled: PropTypes.bool
|
|
979
|
+
}),
|
|
935
980
|
step: PropTypes.number
|
|
936
981
|
}), PropTypes.bool])
|
|
937
982
|
}), PropTypes.shape({
|
|
@@ -986,6 +1031,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
986
1031
|
minSpan: PropTypes.number,
|
|
987
1032
|
minStart: PropTypes.number,
|
|
988
1033
|
panning: PropTypes.bool,
|
|
1034
|
+
slider: PropTypes.shape({
|
|
1035
|
+
enabled: PropTypes.bool
|
|
1036
|
+
}),
|
|
989
1037
|
step: PropTypes.number
|
|
990
1038
|
}), PropTypes.bool])
|
|
991
1039
|
}), PropTypes.shape({
|
|
@@ -1040,6 +1088,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
1040
1088
|
minSpan: PropTypes.number,
|
|
1041
1089
|
minStart: PropTypes.number,
|
|
1042
1090
|
panning: PropTypes.bool,
|
|
1091
|
+
slider: PropTypes.shape({
|
|
1092
|
+
enabled: PropTypes.bool
|
|
1093
|
+
}),
|
|
1043
1094
|
step: PropTypes.number
|
|
1044
1095
|
}), PropTypes.bool])
|
|
1045
1096
|
}), PropTypes.shape({
|
|
@@ -1094,6 +1145,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
1094
1145
|
minSpan: PropTypes.number,
|
|
1095
1146
|
minStart: PropTypes.number,
|
|
1096
1147
|
panning: PropTypes.bool,
|
|
1148
|
+
slider: PropTypes.shape({
|
|
1149
|
+
enabled: PropTypes.bool
|
|
1150
|
+
}),
|
|
1097
1151
|
step: PropTypes.number
|
|
1098
1152
|
}), PropTypes.bool])
|
|
1099
1153
|
}), PropTypes.shape({
|
|
@@ -1148,6 +1202,9 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
1148
1202
|
minSpan: PropTypes.number,
|
|
1149
1203
|
minStart: PropTypes.number,
|
|
1150
1204
|
panning: PropTypes.bool,
|
|
1205
|
+
slider: PropTypes.shape({
|
|
1206
|
+
enabled: PropTypes.bool
|
|
1207
|
+
}),
|
|
1151
1208
|
step: PropTypes.number
|
|
1152
1209
|
}), PropTypes.bool])
|
|
1153
1210
|
})]).isRequired),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChartAnyPluginSignature, ChartSeriesType, UseChartContainerPropsReturnValue } from '@mui/x-charts/internals';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ChartDataProviderProps } from '@mui/x-charts/ChartDataProvider';
|
|
4
|
-
import type { ChartContainerProProps } from
|
|
4
|
+
import type { ChartContainerProProps } from "./ChartContainerPro.js";
|
|
5
5
|
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
6
6
|
export type UseChartContainerProPropsReturnValue<TSeries extends ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[]> = Pick<UseChartContainerPropsReturnValue<TSeries, TSignatures>, 'chartsSurfaceProps' | 'children'> & {
|
|
7
7
|
chartDataProviderProProps: ChartDataProviderProps<TSeries, TSignatures>;
|
|
@@ -10,7 +10,7 @@ import { useLicenseVerifier } from '@mui/x-license/useLicenseVerifier';
|
|
|
10
10
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
11
11
|
import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
const releaseInfo = "
|
|
13
|
+
const releaseInfo = "MTc0NjY1NTIwMDAwMA==";
|
|
14
14
|
const packageIdentifier = 'x-charts-pro';
|
|
15
15
|
/**
|
|
16
16
|
* Orchestrates the data providers for the chart components and hooks.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartAnyPluginSignature, ChartSeriesType } from '@mui/x-charts/internals';
|
|
2
|
-
import type { ChartDataProviderProProps } from
|
|
3
|
-
import type { AllPluginSignatures } from
|
|
2
|
+
import type { ChartDataProviderProProps } from "./ChartDataProviderPro.js";
|
|
3
|
+
import type { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
4
4
|
export declare const useChartDataProviderProProps: <TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>>(props: ChartDataProviderProProps<TSeries, TSignatures>) => {
|
|
5
5
|
children: import("react").ReactNode;
|
|
6
6
|
localeText: Partial<import("@mui/x-charts/locales").ChartsLocaleText> | undefined;
|
|
@@ -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>>;
|