@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';
|
|
@@ -15,6 +15,8 @@ import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
|
|
|
15
15
|
import { ChartsAxisHighlight } from '@mui/x-charts/ChartsAxisHighlight';
|
|
16
16
|
import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
|
|
17
17
|
import { useScatterChartProps, ChartsWrapper } from '@mui/x-charts/internals';
|
|
18
|
+
import { ChartZoomSlider } from "../ChartZoomSlider/index.js";
|
|
19
|
+
import { ChartsToolbarPro } from "../ChartsToolbarPro/index.js";
|
|
18
20
|
import { useChartContainerProProps } from "../ChartContainerPro/useChartContainerProProps.js";
|
|
19
21
|
import { ChartDataProviderPro } from "../ChartDataProviderPro/index.js";
|
|
20
22
|
import { SCATTER_CHART_PRO_PLUGINS } from "./ScatterChartPro.plugins.js";
|
|
@@ -38,7 +40,8 @@ const ScatterChartPro = /*#__PURE__*/React.forwardRef(function ScatterChartPro(i
|
|
|
38
40
|
initialZoom,
|
|
39
41
|
zoomData,
|
|
40
42
|
onZoomChange,
|
|
41
|
-
apiRef
|
|
43
|
+
apiRef,
|
|
44
|
+
showToolbar
|
|
42
45
|
} = props,
|
|
43
46
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
44
47
|
const {
|
|
@@ -65,8 +68,8 @@ const ScatterChartPro = /*#__PURE__*/React.forwardRef(function ScatterChartPro(i
|
|
|
65
68
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
66
69
|
return /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
|
|
67
70
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
68
|
-
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
69
|
-
children: [/*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
71
|
+
children: [showToolbar ? /*#__PURE__*/_jsx(ChartsToolbarPro, {}) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
72
|
+
children: [/*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartZoomSlider, {}), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
70
73
|
"data-drawing-container": true,
|
|
71
74
|
children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
|
|
72
75
|
}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props?.slotProps?.tooltip, {
|
|
@@ -83,6 +86,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
83
86
|
// ----------------------------------------------------------------------
|
|
84
87
|
apiRef: PropTypes.shape({
|
|
85
88
|
current: PropTypes.shape({
|
|
89
|
+
exportAsImage: PropTypes.func.isRequired,
|
|
86
90
|
exportAsPrint: PropTypes.func.isRequired,
|
|
87
91
|
setZoomData: PropTypes.func.isRequired
|
|
88
92
|
})
|
|
@@ -181,7 +185,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
181
185
|
* The function called for onClick events.
|
|
182
186
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
183
187
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
184
|
-
* @param {null |
|
|
188
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
185
189
|
*/
|
|
186
190
|
onAxisClick: PropTypes.func,
|
|
187
191
|
/**
|
|
@@ -207,6 +211,11 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
207
211
|
* An array of [[ScatterSeriesType]] objects.
|
|
208
212
|
*/
|
|
209
213
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
214
|
+
/**
|
|
215
|
+
* If true, shows the default chart toolbar.
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
showToolbar: PropTypes.bool,
|
|
210
219
|
/**
|
|
211
220
|
* If `true`, animations are skipped.
|
|
212
221
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
@@ -299,6 +308,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
299
308
|
minSpan: PropTypes.number,
|
|
300
309
|
minStart: PropTypes.number,
|
|
301
310
|
panning: PropTypes.bool,
|
|
311
|
+
slider: PropTypes.shape({
|
|
312
|
+
enabled: PropTypes.bool
|
|
313
|
+
}),
|
|
302
314
|
step: PropTypes.number
|
|
303
315
|
}), PropTypes.bool])
|
|
304
316
|
}), PropTypes.shape({
|
|
@@ -359,6 +371,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
359
371
|
minSpan: PropTypes.number,
|
|
360
372
|
minStart: PropTypes.number,
|
|
361
373
|
panning: PropTypes.bool,
|
|
374
|
+
slider: PropTypes.shape({
|
|
375
|
+
enabled: PropTypes.bool
|
|
376
|
+
}),
|
|
362
377
|
step: PropTypes.number
|
|
363
378
|
}), PropTypes.bool])
|
|
364
379
|
}), PropTypes.shape({
|
|
@@ -414,6 +429,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
414
429
|
minSpan: PropTypes.number,
|
|
415
430
|
minStart: PropTypes.number,
|
|
416
431
|
panning: PropTypes.bool,
|
|
432
|
+
slider: PropTypes.shape({
|
|
433
|
+
enabled: PropTypes.bool
|
|
434
|
+
}),
|
|
417
435
|
step: PropTypes.number
|
|
418
436
|
}), PropTypes.bool])
|
|
419
437
|
}), PropTypes.shape({
|
|
@@ -469,6 +487,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
469
487
|
minSpan: PropTypes.number,
|
|
470
488
|
minStart: PropTypes.number,
|
|
471
489
|
panning: PropTypes.bool,
|
|
490
|
+
slider: PropTypes.shape({
|
|
491
|
+
enabled: PropTypes.bool
|
|
492
|
+
}),
|
|
472
493
|
step: PropTypes.number
|
|
473
494
|
}), PropTypes.bool])
|
|
474
495
|
}), PropTypes.shape({
|
|
@@ -524,6 +545,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
524
545
|
minSpan: PropTypes.number,
|
|
525
546
|
minStart: PropTypes.number,
|
|
526
547
|
panning: PropTypes.bool,
|
|
548
|
+
slider: PropTypes.shape({
|
|
549
|
+
enabled: PropTypes.bool
|
|
550
|
+
}),
|
|
527
551
|
step: PropTypes.number
|
|
528
552
|
}), PropTypes.bool])
|
|
529
553
|
}), PropTypes.shape({
|
|
@@ -579,6 +603,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
579
603
|
minSpan: PropTypes.number,
|
|
580
604
|
minStart: PropTypes.number,
|
|
581
605
|
panning: PropTypes.bool,
|
|
606
|
+
slider: PropTypes.shape({
|
|
607
|
+
enabled: PropTypes.bool
|
|
608
|
+
}),
|
|
582
609
|
step: PropTypes.number
|
|
583
610
|
}), PropTypes.bool])
|
|
584
611
|
}), PropTypes.shape({
|
|
@@ -634,6 +661,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
634
661
|
minSpan: PropTypes.number,
|
|
635
662
|
minStart: PropTypes.number,
|
|
636
663
|
panning: PropTypes.bool,
|
|
664
|
+
slider: PropTypes.shape({
|
|
665
|
+
enabled: PropTypes.bool
|
|
666
|
+
}),
|
|
637
667
|
step: PropTypes.number
|
|
638
668
|
}), PropTypes.bool])
|
|
639
669
|
}), PropTypes.shape({
|
|
@@ -689,6 +719,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
689
719
|
minSpan: PropTypes.number,
|
|
690
720
|
minStart: PropTypes.number,
|
|
691
721
|
panning: PropTypes.bool,
|
|
722
|
+
slider: PropTypes.shape({
|
|
723
|
+
enabled: PropTypes.bool
|
|
724
|
+
}),
|
|
692
725
|
step: PropTypes.number
|
|
693
726
|
}), PropTypes.bool])
|
|
694
727
|
})]).isRequired),
|
|
@@ -756,6 +789,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
756
789
|
minSpan: PropTypes.number,
|
|
757
790
|
minStart: PropTypes.number,
|
|
758
791
|
panning: PropTypes.bool,
|
|
792
|
+
slider: PropTypes.shape({
|
|
793
|
+
enabled: PropTypes.bool
|
|
794
|
+
}),
|
|
759
795
|
step: PropTypes.number
|
|
760
796
|
}), PropTypes.bool])
|
|
761
797
|
}), PropTypes.shape({
|
|
@@ -815,6 +851,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
815
851
|
minSpan: PropTypes.number,
|
|
816
852
|
minStart: PropTypes.number,
|
|
817
853
|
panning: PropTypes.bool,
|
|
854
|
+
slider: PropTypes.shape({
|
|
855
|
+
enabled: PropTypes.bool
|
|
856
|
+
}),
|
|
818
857
|
step: PropTypes.number
|
|
819
858
|
}), PropTypes.bool])
|
|
820
859
|
}), PropTypes.shape({
|
|
@@ -869,6 +908,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
869
908
|
minSpan: PropTypes.number,
|
|
870
909
|
minStart: PropTypes.number,
|
|
871
910
|
panning: PropTypes.bool,
|
|
911
|
+
slider: PropTypes.shape({
|
|
912
|
+
enabled: PropTypes.bool
|
|
913
|
+
}),
|
|
872
914
|
step: PropTypes.number
|
|
873
915
|
}), PropTypes.bool])
|
|
874
916
|
}), PropTypes.shape({
|
|
@@ -923,6 +965,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
923
965
|
minSpan: PropTypes.number,
|
|
924
966
|
minStart: PropTypes.number,
|
|
925
967
|
panning: PropTypes.bool,
|
|
968
|
+
slider: PropTypes.shape({
|
|
969
|
+
enabled: PropTypes.bool
|
|
970
|
+
}),
|
|
926
971
|
step: PropTypes.number
|
|
927
972
|
}), PropTypes.bool])
|
|
928
973
|
}), PropTypes.shape({
|
|
@@ -977,6 +1022,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
977
1022
|
minSpan: PropTypes.number,
|
|
978
1023
|
minStart: PropTypes.number,
|
|
979
1024
|
panning: PropTypes.bool,
|
|
1025
|
+
slider: PropTypes.shape({
|
|
1026
|
+
enabled: PropTypes.bool
|
|
1027
|
+
}),
|
|
980
1028
|
step: PropTypes.number
|
|
981
1029
|
}), PropTypes.bool])
|
|
982
1030
|
}), PropTypes.shape({
|
|
@@ -1031,6 +1079,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
1031
1079
|
minSpan: PropTypes.number,
|
|
1032
1080
|
minStart: PropTypes.number,
|
|
1033
1081
|
panning: PropTypes.bool,
|
|
1082
|
+
slider: PropTypes.shape({
|
|
1083
|
+
enabled: PropTypes.bool
|
|
1084
|
+
}),
|
|
1034
1085
|
step: PropTypes.number
|
|
1035
1086
|
}), PropTypes.bool])
|
|
1036
1087
|
}), PropTypes.shape({
|
|
@@ -1085,6 +1136,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
1085
1136
|
minSpan: PropTypes.number,
|
|
1086
1137
|
minStart: PropTypes.number,
|
|
1087
1138
|
panning: PropTypes.bool,
|
|
1139
|
+
slider: PropTypes.shape({
|
|
1140
|
+
enabled: PropTypes.bool
|
|
1141
|
+
}),
|
|
1088
1142
|
step: PropTypes.number
|
|
1089
1143
|
}), PropTypes.bool])
|
|
1090
1144
|
}), PropTypes.shape({
|
|
@@ -1139,6 +1193,9 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
1139
1193
|
minSpan: PropTypes.number,
|
|
1140
1194
|
minStart: PropTypes.number,
|
|
1141
1195
|
panning: PropTypes.bool,
|
|
1196
|
+
slider: PropTypes.shape({
|
|
1197
|
+
enabled: PropTypes.bool
|
|
1198
|
+
}),
|
|
1142
1199
|
step: PropTypes.number
|
|
1143
1200
|
}), PropTypes.bool])
|
|
1144
1201
|
})]).isRequired),
|
package/esm/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from '@mui/x-charts/RadarChart';
|
|
|
25
25
|
export * from '@mui/x-charts/ChartsSurface';
|
|
26
26
|
export * from '@mui/x-charts/ChartDataProvider';
|
|
27
27
|
export * from '@mui/x-charts/ChartsLabel';
|
|
28
|
+
export { ZoomData, ZoomFilterMode, ZoomOptions, ZoomSliderOptions } from '@mui/x-charts/internals';
|
|
28
29
|
export * from "./hooks/index.js";
|
|
29
30
|
export * from "./Heatmap/index.js";
|
|
30
31
|
export * from "./ChartContainerPro/index.js";
|
|
@@ -32,4 +33,6 @@ export * from "./ChartDataProviderPro/index.js";
|
|
|
32
33
|
export * from "./ScatterChartPro/index.js";
|
|
33
34
|
export * from "./BarChartPro/index.js";
|
|
34
35
|
export * from "./LineChartPro/index.js";
|
|
35
|
-
export * from "./FunnelChart/index.js";
|
|
36
|
+
export * from "./FunnelChart/index.js";
|
|
37
|
+
export * from "./ChartZoomSlider/index.js";
|
|
38
|
+
export * from "./ChartsToolbarPro/index.js";
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts-pro v8.
|
|
2
|
+
* @mui/x-charts-pro v8.3.0
|
|
3
3
|
*
|
|
4
4
|
* @license MUI X Commercial
|
|
5
5
|
* This source code is licensed under the commercial license found in the
|
|
@@ -34,6 +34,7 @@ export * from '@mui/x-charts/RadarChart';
|
|
|
34
34
|
export * from '@mui/x-charts/ChartsSurface';
|
|
35
35
|
export * from '@mui/x-charts/ChartDataProvider';
|
|
36
36
|
export * from '@mui/x-charts/ChartsLabel';
|
|
37
|
+
export { ZoomData, ZoomFilterMode, ZoomOptions, ZoomSliderOptions } from '@mui/x-charts/internals';
|
|
37
38
|
|
|
38
39
|
// Pro components
|
|
39
40
|
export * from "./hooks/index.js";
|
|
@@ -43,4 +44,6 @@ export * from "./ChartDataProviderPro/index.js";
|
|
|
43
44
|
export * from "./ScatterChartPro/index.js";
|
|
44
45
|
export * from "./BarChartPro/index.js";
|
|
45
46
|
export * from "./LineChartPro/index.js";
|
|
46
|
-
export * from "./FunnelChart/index.js";
|
|
47
|
+
export * from "./FunnelChart/index.js";
|
|
48
|
+
export * from "./ChartZoomSlider/index.js";
|
|
49
|
+
export * from "./ChartsToolbarPro/index.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createSvgIcon } from '@mui/x-charts/internals';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
export const ChartsZoomInIcon = createSvgIcon(/*#__PURE__*/_jsxs(React.Fragment, {
|
|
5
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
6
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"
|
|
7
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
8
|
+
d: "M12 10h-2v2H9v-2H7V9h2V7h1v2h2z"
|
|
9
|
+
})]
|
|
10
|
+
}), 'ZoomIn');
|
|
11
|
+
export const ChartsZoomOutIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
|
|
12
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14M7 9h5v1H7z"
|
|
13
|
+
}), 'ZoomOut');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
3
|
+
import { defaultSlotsMaterial as communityDefaultSlotsMaterial } from '@mui/x-charts/internals';
|
|
4
|
+
import { ChartsZoomInIcon, ChartsZoomOutIcon } from "./icons.js";
|
|
5
|
+
const baseSlots = {
|
|
6
|
+
baseTooltip: Tooltip
|
|
7
|
+
};
|
|
8
|
+
const iconSlots = {
|
|
9
|
+
zoomInIcon: ChartsZoomInIcon,
|
|
10
|
+
zoomOutIcon: ChartsZoomOutIcon
|
|
11
|
+
};
|
|
12
|
+
export const defaultSlotsMaterial = _extends({}, communityDefaultSlotsMaterial, baseSlots, iconSlots);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createExportIframe(title?: string): HTMLIFrameElement;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function createExportIframe(title) {
|
|
2
|
+
const iframeEl = document.createElement('iframe');
|
|
3
|
+
iframeEl.style.position = 'absolute';
|
|
4
|
+
iframeEl.style.width = '0px';
|
|
5
|
+
iframeEl.style.height = '0px';
|
|
6
|
+
iframeEl.title = title || document.title;
|
|
7
|
+
return iframeEl;
|
|
8
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChartImageExportOptions } from "./useChartProExport.types.js";
|
|
2
|
+
export declare const getDrawDocument: () => Promise<typeof import("rasterizehtml").drawDocument>;
|
|
3
|
+
export declare function exportImage(element: HTMLElement | SVGElement, params?: ChartImageExportOptions): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import ownerDocument from '@mui/utils/ownerDocument';
|
|
2
|
+
import { loadStyleSheets } from '@mui/x-internals/export';
|
|
3
|
+
import { createExportIframe } from "./common.js";
|
|
4
|
+
export const getDrawDocument = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const module = await import('rasterizehtml');
|
|
7
|
+
return module.drawDocument;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
throw new Error(`MUI X Charts: Failed to import 'rasterizehtml' module. This dependency is mandatory when exporting a chart as an image. Make sure you have it installed as a dependency.`, {
|
|
10
|
+
cause: error
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export async function exportImage(element, params) {
|
|
15
|
+
const {
|
|
16
|
+
fileName,
|
|
17
|
+
type = 'image/png',
|
|
18
|
+
quality = 0.9
|
|
19
|
+
} = params ?? {};
|
|
20
|
+
const drawDocumentPromise = getDrawDocument();
|
|
21
|
+
const {
|
|
22
|
+
width,
|
|
23
|
+
height
|
|
24
|
+
} = element.getBoundingClientRect();
|
|
25
|
+
const doc = ownerDocument(element);
|
|
26
|
+
const canvas = document.createElement('canvas');
|
|
27
|
+
const ratio = window.devicePixelRatio || 1;
|
|
28
|
+
canvas.width = width * ratio;
|
|
29
|
+
canvas.height = height * ratio;
|
|
30
|
+
canvas.style.width = `${width}px`;
|
|
31
|
+
canvas.style.height = `${height}px`;
|
|
32
|
+
const iframe = createExportIframe(fileName);
|
|
33
|
+
let resolve;
|
|
34
|
+
const iframeLoadPromise = new Promise(res => {
|
|
35
|
+
resolve = res;
|
|
36
|
+
});
|
|
37
|
+
iframe.onload = async () => {
|
|
38
|
+
const exportDoc = iframe.contentDocument;
|
|
39
|
+
const elementClone = element.cloneNode(true);
|
|
40
|
+
const container = document.createElement('div');
|
|
41
|
+
container.appendChild(elementClone);
|
|
42
|
+
exportDoc.body.innerHTML = container.innerHTML;
|
|
43
|
+
exportDoc.body.style.margin = '0px';
|
|
44
|
+
const rootCandidate = element.getRootNode();
|
|
45
|
+
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
|
|
46
|
+
await Promise.all(loadStyleSheets(exportDoc, root));
|
|
47
|
+
resolve();
|
|
48
|
+
};
|
|
49
|
+
doc.body.appendChild(iframe);
|
|
50
|
+
const [drawDocument] = await Promise.all([drawDocumentPromise, iframeLoadPromise]);
|
|
51
|
+
try {
|
|
52
|
+
await drawDocument(iframe.contentDocument, canvas, {
|
|
53
|
+
// Handle retina displays: https://github.com/cburgmer/rasterizeHTML.js/blob/262b3404d1c469ce4a7750a2976dec09b8ae2d6c/examples/retina.html#L71
|
|
54
|
+
zoom: ratio
|
|
55
|
+
});
|
|
56
|
+
} finally {
|
|
57
|
+
doc.body.removeChild(iframe);
|
|
58
|
+
}
|
|
59
|
+
let resolveBlobPromise;
|
|
60
|
+
const blobPromise = new Promise(res => {
|
|
61
|
+
resolveBlobPromise = res;
|
|
62
|
+
});
|
|
63
|
+
canvas.toBlob(blob => resolveBlobPromise(blob), type, quality);
|
|
64
|
+
let blob;
|
|
65
|
+
try {
|
|
66
|
+
blob = await blobPromise;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
throw new Error('MUI X Charts: Failed to create blob from canvas.', {
|
|
69
|
+
cause: error
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (!blob) {
|
|
73
|
+
throw new Error('MUI X Charts: Failed to create blob from canvas.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const url = URL.createObjectURL(blob);
|
|
77
|
+
triggerDownload(url, fileName || document.title);
|
|
78
|
+
URL.revokeObjectURL(url);
|
|
79
|
+
}
|
|
80
|
+
function triggerDownload(url, name) {
|
|
81
|
+
const a = document.createElement('a');
|
|
82
|
+
a.href = url;
|
|
83
|
+
a.download = name;
|
|
84
|
+
a.click();
|
|
85
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import ownerDocument from '@mui/utils/ownerDocument';
|
|
2
|
+
import { loadStyleSheets } from '@mui/x-internals/export';
|
|
3
|
+
import { createExportIframe } from "./common.js";
|
|
2
4
|
export function printChart(element, {
|
|
3
5
|
fileName
|
|
4
6
|
} = {}) {
|
|
5
|
-
const printWindow =
|
|
7
|
+
const printWindow = createExportIframe(fileName);
|
|
6
8
|
const doc = ownerDocument(element);
|
|
7
9
|
printWindow.onload = async () => {
|
|
8
10
|
const printDoc = printWindow.contentDocument;
|
|
@@ -10,7 +12,9 @@ export function printChart(element, {
|
|
|
10
12
|
const container = document.createElement('div');
|
|
11
13
|
container.appendChild(elementClone);
|
|
12
14
|
printDoc.body.innerHTML = container.innerHTML;
|
|
13
|
-
|
|
15
|
+
const rootCandidate = element.getRootNode();
|
|
16
|
+
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
|
|
17
|
+
await Promise.all(loadStyleSheets(printDoc, root));
|
|
14
18
|
printWindow.contentWindow.print();
|
|
15
19
|
const mediaQueryList = printWindow.contentWindow.matchMedia('print');
|
|
16
20
|
mediaQueryList.addEventListener('change', mql => {
|
|
@@ -21,52 +25,4 @@ export function printChart(element, {
|
|
|
21
25
|
});
|
|
22
26
|
};
|
|
23
27
|
doc.body.appendChild(printWindow);
|
|
24
|
-
}
|
|
25
|
-
function buildPrintWindow(title) {
|
|
26
|
-
const iframeEl = document.createElement('iframe');
|
|
27
|
-
iframeEl.style.position = 'absolute';
|
|
28
|
-
iframeEl.style.width = '0px';
|
|
29
|
-
iframeEl.style.height = '0px';
|
|
30
|
-
iframeEl.title = title || document.title;
|
|
31
|
-
return iframeEl;
|
|
32
|
-
}
|
|
33
|
-
function loadStyleSheets(printDoc, element) {
|
|
34
|
-
const stylesheetLoadPromises = [];
|
|
35
|
-
const doc = ownerDocument(element);
|
|
36
|
-
const rootCandidate = element.getRootNode();
|
|
37
|
-
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
|
|
38
|
-
const headStyleElements = root.querySelectorAll("style, link[rel='stylesheet']");
|
|
39
|
-
for (let i = 0; i < headStyleElements.length; i += 1) {
|
|
40
|
-
const node = headStyleElements[i];
|
|
41
|
-
if (node.tagName === 'STYLE') {
|
|
42
|
-
const newHeadStyleElements = printDoc.createElement(node.tagName);
|
|
43
|
-
const sheet = node.sheet;
|
|
44
|
-
if (sheet) {
|
|
45
|
-
let styleCSS = '';
|
|
46
|
-
// NOTE: for-of is not supported by IE
|
|
47
|
-
for (let j = 0; j < sheet.cssRules.length; j += 1) {
|
|
48
|
-
if (typeof sheet.cssRules[j].cssText === 'string') {
|
|
49
|
-
styleCSS += `${sheet.cssRules[j].cssText}\r\n`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
newHeadStyleElements.appendChild(printDoc.createTextNode(styleCSS));
|
|
53
|
-
printDoc.head.appendChild(newHeadStyleElements);
|
|
54
|
-
}
|
|
55
|
-
} else if (node.getAttribute('href')) {
|
|
56
|
-
// If `href` tag is empty, avoid loading these links
|
|
57
|
-
|
|
58
|
-
const newHeadStyleElements = printDoc.createElement(node.tagName);
|
|
59
|
-
for (let j = 0; j < node.attributes.length; j += 1) {
|
|
60
|
-
const attr = node.attributes[j];
|
|
61
|
-
if (attr) {
|
|
62
|
-
newHeadStyleElements.setAttribute(attr.nodeName, attr.nodeValue || '');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
stylesheetLoadPromises.push(new Promise(resolve => {
|
|
66
|
-
newHeadStyleElements.addEventListener('load', () => resolve());
|
|
67
|
-
}));
|
|
68
|
-
printDoc.head.appendChild(newHeadStyleElements);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return Promise.all(stylesheetLoadPromises);
|
|
72
28
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { printChart } from "./print.js";
|
|
3
|
+
import { exportImage } from "./exportImage.js";
|
|
3
4
|
function waitForAnimationFrame() {
|
|
4
5
|
let resolve;
|
|
5
6
|
const promise = new Promise(res => {
|
|
@@ -22,6 +23,23 @@ export const useChartProExport = ({
|
|
|
22
23
|
// Wait for animation frame to ensure the animation finished
|
|
23
24
|
await waitForAnimationFrame();
|
|
24
25
|
printChart(chartRoot, options);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('MUI X Charts: Error exporting chart as print:', error);
|
|
28
|
+
} finally {
|
|
29
|
+
enableAnimation();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const exportAsImage = async options => {
|
|
34
|
+
const chartRoot = chartRootRef.current;
|
|
35
|
+
if (chartRoot) {
|
|
36
|
+
const enableAnimation = instance.disableAnimation();
|
|
37
|
+
try {
|
|
38
|
+
// Wait for animation frame to ensure the animation finished
|
|
39
|
+
await waitForAnimationFrame();
|
|
40
|
+
await exportImage(chartRoot, options);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('MUI X Charts: Error exporting chart as image:', error);
|
|
25
43
|
} finally {
|
|
26
44
|
enableAnimation();
|
|
27
45
|
}
|
|
@@ -29,10 +47,12 @@ export const useChartProExport = ({
|
|
|
29
47
|
};
|
|
30
48
|
return {
|
|
31
49
|
publicAPI: {
|
|
32
|
-
exportAsPrint
|
|
50
|
+
exportAsPrint,
|
|
51
|
+
exportAsImage
|
|
33
52
|
},
|
|
34
53
|
instance: {
|
|
35
|
-
exportAsPrint
|
|
54
|
+
exportAsPrint,
|
|
55
|
+
exportAsImage
|
|
36
56
|
}
|
|
37
57
|
};
|
|
38
58
|
};
|
|
@@ -16,6 +16,30 @@ export interface ChartPrintExportOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
fileName?: string;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The options to apply on the image export.
|
|
21
|
+
* @demos
|
|
22
|
+
* - [Image export](/x/react-charts/export/#export-as-image)
|
|
23
|
+
*/
|
|
24
|
+
export interface ChartImageExportOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The value to be used as the print window title.
|
|
27
|
+
* @default The title of the page.
|
|
28
|
+
*/
|
|
29
|
+
fileName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The format of the image to be exported.
|
|
32
|
+
* Browsers are required to support 'image/png'. Some browsers also support 'image/jpeg' and 'image/webp'.
|
|
33
|
+
* @default 'image/png'
|
|
34
|
+
*/
|
|
35
|
+
type?: 'image/png' | string;
|
|
36
|
+
/**
|
|
37
|
+
* The quality of the image to be exported between 0 and 1. This is only applicable for lossy formats, such as
|
|
38
|
+
* 'image/jpeg' and 'image/webp'. 'image/png' does not support this option.
|
|
39
|
+
* @default 0.9
|
|
40
|
+
*/
|
|
41
|
+
quality?: number;
|
|
42
|
+
}
|
|
19
43
|
export interface UseChartProExportPublicApi {
|
|
20
44
|
/**
|
|
21
45
|
* Opens the browser's print dialog, which can be used to print the chart or export it as PDF.
|
|
@@ -23,6 +47,14 @@ export interface UseChartProExportPublicApi {
|
|
|
23
47
|
* @returns {void}
|
|
24
48
|
*/
|
|
25
49
|
exportAsPrint: (options?: ChartPrintExportOptions) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Exports the chart as an image.
|
|
52
|
+
* If the provided `type` is not supported by the browser, it will default to `image/png`.
|
|
53
|
+
*
|
|
54
|
+
* @param {ChartPrintExportOptions} options Options to customize the print export.
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
exportAsImage: (options?: ChartImageExportOptions) => void;
|
|
26
58
|
}
|
|
27
59
|
export interface UseChartProExportInstance extends UseChartProExportPublicApi {}
|
|
28
60
|
export type UseChartProExportSignature = ChartPluginSignature<{
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DefaultizedZoomOptions, ZoomData } from '@mui/x-charts/internals';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the new zoom range based on the current zoom, step, and constraints.
|
|
4
|
+
*
|
|
5
|
+
* A step of 0.1 or -0.1 means that 10% of the current range will be subtracted/added, respectively, and assuming no
|
|
6
|
+
* constraints (e.g., minSpan, maxEnd) are faced.
|
|
7
|
+
*
|
|
8
|
+
* @param zoom Current zoom range with start and end values.
|
|
9
|
+
* @param step Percentage of the current zoom range to adjust (positive to zoom in, negative to zoom out). Ranges from 0 to 1.
|
|
10
|
+
* @param minSpan Minimum allowed span between start and end values.
|
|
11
|
+
* @param maxSpan Maximum allowed span between start and end values.
|
|
12
|
+
* @param minStart Minimum allowed start value.
|
|
13
|
+
* @param maxEnd Maximum allowed end value.
|
|
14
|
+
*/
|
|
15
|
+
export declare function calculateZoom<T extends Readonly<Pick<ZoomData, 'start' | 'end'>>>(zoom: T, step: number, {
|
|
16
|
+
minSpan,
|
|
17
|
+
maxSpan,
|
|
18
|
+
minStart,
|
|
19
|
+
maxEnd
|
|
20
|
+
}: Pick<DefaultizedZoomOptions, 'minSpan' | 'maxSpan' | 'minStart' | 'maxEnd'>): T & {
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the new zoom range based on the current zoom, step, and constraints.
|
|
4
|
+
*
|
|
5
|
+
* A step of 0.1 or -0.1 means that 10% of the current range will be subtracted/added, respectively, and assuming no
|
|
6
|
+
* constraints (e.g., minSpan, maxEnd) are faced.
|
|
7
|
+
*
|
|
8
|
+
* @param zoom Current zoom range with start and end values.
|
|
9
|
+
* @param step Percentage of the current zoom range to adjust (positive to zoom in, negative to zoom out). Ranges from 0 to 1.
|
|
10
|
+
* @param minSpan Minimum allowed span between start and end values.
|
|
11
|
+
* @param maxSpan Maximum allowed span between start and end values.
|
|
12
|
+
* @param minStart Minimum allowed start value.
|
|
13
|
+
* @param maxEnd Maximum allowed end value.
|
|
14
|
+
*/
|
|
15
|
+
export function calculateZoom(zoom, step, {
|
|
16
|
+
minSpan,
|
|
17
|
+
maxSpan,
|
|
18
|
+
minStart,
|
|
19
|
+
maxEnd
|
|
20
|
+
}) {
|
|
21
|
+
const span = zoom.end - zoom.start;
|
|
22
|
+
let delta = span * step / 2;
|
|
23
|
+
if (delta > 0) {
|
|
24
|
+
delta = Math.min(delta, (span - minSpan) / 2);
|
|
25
|
+
} else {
|
|
26
|
+
delta = Math.max(delta, (span - maxSpan) / 2);
|
|
27
|
+
}
|
|
28
|
+
return _extends({}, zoom, {
|
|
29
|
+
start: Math.max(minStart, zoom.start + delta),
|
|
30
|
+
end: Math.min(maxEnd, zoom.end - delta)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ChartPlugin, AxisId, DefaultizedZoomOptions, ZoomData } from '@mui/x-charts/internals';
|
|
2
2
|
import { UseChartProZoomSignature } from "./useChartProZoom.types.js";
|
|
3
|
-
export declare function initializeZoomData(options: Record<AxisId, DefaultizedZoomOptions
|
|
3
|
+
export declare function initializeZoomData(options: Record<AxisId, Pick<DefaultizedZoomOptions, 'axisId' | 'minStart' | 'maxEnd'>>, zoomData?: readonly ZoomData[]): ZoomData[];
|
|
4
4
|
export declare const useChartProZoom: ChartPlugin<UseChartProZoomSignature>;
|