@mui/x-charts-pro 7.0.0-alpha.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 +18 -0
- package/BarChartPro/BarChartPro.js +417 -0
- package/BarChartPro/index.d.ts +1 -0
- package/BarChartPro/index.js +1 -0
- package/BarChartPro/package.json +6 -0
- package/CHANGELOG.md +4404 -0
- package/ChartContainerPro/ChartContainerPro.d.ts +7 -0
- package/ChartContainerPro/ChartContainerPro.js +282 -0
- package/ChartContainerPro/index.d.ts +1 -0
- package/ChartContainerPro/index.js +1 -0
- package/ChartContainerPro/package.json +6 -0
- package/ChartContainerPro/useChartContainerProProps.d.ts +15 -0
- package/ChartContainerPro/useChartContainerProProps.js +39 -0
- package/Heatmap/DefaultHeatmapTooltip.d.ts +7 -0
- package/Heatmap/DefaultHeatmapTooltip.js +97 -0
- package/Heatmap/Heatmap.d.ts +49 -0
- package/Heatmap/Heatmap.js +387 -0
- package/Heatmap/HeatmapItem.d.ts +49 -0
- package/Heatmap/HeatmapItem.js +106 -0
- package/Heatmap/HeatmapPlot.d.ts +9 -0
- package/Heatmap/HeatmapPlot.js +57 -0
- package/Heatmap/extremums.d.ts +2 -0
- package/Heatmap/extremums.js +8 -0
- package/Heatmap/formatter.d.ts +3 -0
- package/Heatmap/formatter.js +20 -0
- package/Heatmap/getColor.d.ts +3 -0
- package/Heatmap/getColor.js +15 -0
- package/Heatmap/heatmapClasses.d.ts +11 -0
- package/Heatmap/heatmapClasses.js +13 -0
- package/Heatmap/index.d.ts +4 -0
- package/Heatmap/index.js +4 -0
- package/Heatmap/package.json +6 -0
- package/Heatmap/plugin.d.ts +2 -0
- package/Heatmap/plugin.js +10 -0
- package/LICENSE +11 -0
- package/LineChartPro/LineChartPro.d.ts +17 -0
- package/LineChartPro/LineChartPro.js +473 -0
- package/LineChartPro/index.d.ts +1 -0
- package/LineChartPro/index.js +1 -0
- package/LineChartPro/package.json +6 -0
- package/README.md +26 -0
- package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.d.ts +7 -0
- package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +259 -0
- package/ResponsiveChartContainerPro/index.d.ts +1 -0
- package/ResponsiveChartContainerPro/index.js +1 -0
- package/ResponsiveChartContainerPro/package.json +6 -0
- package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.d.ts +41 -0
- package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +25 -0
- package/ScatterChartPro/ScatterChartPro.d.ts +17 -0
- package/ScatterChartPro/ScatterChartPro.js +388 -0
- package/ScatterChartPro/index.d.ts +1 -0
- package/ScatterChartPro/index.js +1 -0
- package/ScatterChartPro/package.json +6 -0
- package/context/CartesianProviderPro/CartesianProviderPro.d.ts +6 -0
- package/context/CartesianProviderPro/CartesianProviderPro.js +54 -0
- package/context/CartesianProviderPro/index.d.ts +1 -0
- package/context/CartesianProviderPro/index.js +1 -0
- package/context/ZoomProvider/Zoom.types.d.ts +134 -0
- package/context/ZoomProvider/Zoom.types.js +1 -0
- package/context/ZoomProvider/ZoomContext.d.ts +4 -0
- package/context/ZoomProvider/ZoomContext.js +16 -0
- package/context/ZoomProvider/ZoomProvider.d.ts +3 -0
- package/context/ZoomProvider/ZoomProvider.js +53 -0
- package/context/ZoomProvider/ZoomSetup.d.ts +9 -0
- package/context/ZoomProvider/ZoomSetup.js +16 -0
- package/context/ZoomProvider/defaultizeZoom.d.ts +2 -0
- package/context/ZoomProvider/defaultizeZoom.js +31 -0
- package/context/ZoomProvider/index.d.ts +3 -0
- package/context/ZoomProvider/index.js +3 -0
- package/context/ZoomProvider/initializeZoomData.d.ts +6 -0
- package/context/ZoomProvider/initializeZoomData.js +13 -0
- package/context/ZoomProvider/useSetupPan.d.ts +1 -0
- package/context/ZoomProvider/useSetupPan.js +104 -0
- package/context/ZoomProvider/useSetupZoom.d.ts +1 -0
- package/context/ZoomProvider/useSetupZoom.js +272 -0
- package/context/ZoomProvider/useZoom.d.ts +7 -0
- package/context/ZoomProvider/useZoom.js +17 -0
- package/context/index.d.ts +3 -0
- package/context/index.js +5 -0
- package/context/package.json +6 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/package.json +6 -0
- package/hooks/useSeries.d.ts +11 -0
- package/hooks/useSeries.js +14 -0
- package/index.d.ts +31 -0
- package/index.js +45 -0
- package/internals/utils/releaseInfo.d.ts +1 -0
- package/internals/utils/releaseInfo.js +13 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/package.json +6 -0
- package/models/seriesType/heatmap.d.ts +28 -0
- package/models/seriesType/heatmap.js +1 -0
- package/models/seriesType/index.d.ts +1 -0
- package/models/seriesType/index.js +1 -0
- package/modern/BarChartPro/BarChartPro.js +417 -0
- package/modern/BarChartPro/index.js +1 -0
- package/modern/ChartContainerPro/ChartContainerPro.js +282 -0
- package/modern/ChartContainerPro/index.js +1 -0
- package/modern/ChartContainerPro/useChartContainerProProps.js +39 -0
- package/modern/Heatmap/DefaultHeatmapTooltip.js +97 -0
- package/modern/Heatmap/Heatmap.js +387 -0
- package/modern/Heatmap/HeatmapItem.js +106 -0
- package/modern/Heatmap/HeatmapPlot.js +57 -0
- package/modern/Heatmap/extremums.js +8 -0
- package/modern/Heatmap/formatter.js +20 -0
- package/modern/Heatmap/getColor.js +15 -0
- package/modern/Heatmap/heatmapClasses.js +13 -0
- package/modern/Heatmap/index.js +4 -0
- package/modern/Heatmap/plugin.js +10 -0
- package/modern/LineChartPro/LineChartPro.js +473 -0
- package/modern/LineChartPro/index.js +1 -0
- package/modern/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +259 -0
- package/modern/ResponsiveChartContainerPro/index.js +1 -0
- package/modern/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +25 -0
- package/modern/ScatterChartPro/ScatterChartPro.js +388 -0
- package/modern/ScatterChartPro/index.js +1 -0
- package/modern/context/CartesianProviderPro/CartesianProviderPro.js +54 -0
- package/modern/context/CartesianProviderPro/index.js +1 -0
- package/modern/context/ZoomProvider/Zoom.types.js +1 -0
- package/modern/context/ZoomProvider/ZoomContext.js +16 -0
- package/modern/context/ZoomProvider/ZoomProvider.js +53 -0
- package/modern/context/ZoomProvider/ZoomSetup.js +16 -0
- package/modern/context/ZoomProvider/defaultizeZoom.js +31 -0
- package/modern/context/ZoomProvider/index.js +3 -0
- package/modern/context/ZoomProvider/initializeZoomData.js +13 -0
- package/modern/context/ZoomProvider/useSetupPan.js +104 -0
- package/modern/context/ZoomProvider/useSetupZoom.js +272 -0
- package/modern/context/ZoomProvider/useZoom.js +17 -0
- package/modern/context/index.js +5 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/useSeries.js +14 -0
- package/modern/index.js +45 -0
- package/modern/internals/utils/releaseInfo.js +13 -0
- package/modern/models/index.js +1 -0
- package/modern/models/seriesType/heatmap.js +1 -0
- package/modern/models/seriesType/index.js +1 -0
- package/modern/typeOverloads/index.js +1 -0
- package/modern/typeOverloads/modules.js +1 -0
- package/node/BarChartPro/BarChartPro.js +425 -0
- package/node/BarChartPro/index.js +16 -0
- package/node/ChartContainerPro/ChartContainerPro.js +290 -0
- package/node/ChartContainerPro/index.js +16 -0
- package/node/ChartContainerPro/useChartContainerProProps.js +47 -0
- package/node/Heatmap/DefaultHeatmapTooltip.js +105 -0
- package/node/Heatmap/Heatmap.js +395 -0
- package/node/Heatmap/HeatmapItem.js +114 -0
- package/node/Heatmap/HeatmapPlot.js +65 -0
- package/node/Heatmap/extremums.js +15 -0
- package/node/Heatmap/formatter.js +27 -0
- package/node/Heatmap/getColor.js +21 -0
- package/node/Heatmap/heatmapClasses.js +21 -0
- package/node/Heatmap/index.js +47 -0
- package/node/Heatmap/plugin.js +17 -0
- package/node/LineChartPro/LineChartPro.js +481 -0
- package/node/LineChartPro/index.js +16 -0
- package/node/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +267 -0
- package/node/ResponsiveChartContainerPro/index.js +16 -0
- package/node/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +33 -0
- package/node/ScatterChartPro/ScatterChartPro.js +396 -0
- package/node/ScatterChartPro/index.js +16 -0
- package/node/context/CartesianProviderPro/CartesianProviderPro.js +61 -0
- package/node/context/CartesianProviderPro/index.js +16 -0
- package/node/context/ZoomProvider/Zoom.types.js +5 -0
- package/node/context/ZoomProvider/ZoomContext.js +24 -0
- package/node/context/ZoomProvider/ZoomProvider.js +62 -0
- package/node/context/ZoomProvider/ZoomSetup.js +20 -0
- package/node/context/ZoomProvider/defaultizeZoom.js +39 -0
- package/node/context/ZoomProvider/index.js +38 -0
- package/node/context/ZoomProvider/initializeZoomData.js +20 -0
- package/node/context/ZoomProvider/useSetupPan.js +114 -0
- package/node/context/ZoomProvider/useSetupZoom.js +281 -0
- package/node/context/ZoomProvider/useZoom.js +25 -0
- package/node/context/index.js +27 -0
- package/node/hooks/index.js +12 -0
- package/node/hooks/useSeries.js +21 -0
- package/node/index.js +354 -0
- package/node/internals/utils/releaseInfo.js +20 -0
- package/node/models/index.js +16 -0
- package/node/models/seriesType/heatmap.js +5 -0
- package/node/models/seriesType/index.js +16 -0
- package/node/typeOverloads/index.js +6 -0
- package/node/typeOverloads/modules.js +5 -0
- package/package.json +64 -0
- package/typeOverloads/index.d.ts +1 -0
- package/typeOverloads/index.js +1 -0
- package/typeOverloads/modules.d.ts +17 -0
- package/typeOverloads/modules.js +1 -0
- package/typeOverloads/package.json +6 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["zoom", "onZoomChange"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
|
|
7
|
+
import { ScatterPlot } from '@mui/x-charts/ScatterChart';
|
|
8
|
+
import { ZAxisContextProvider } from '@mui/x-charts/context';
|
|
9
|
+
import { ChartsVoronoiHandler } from '@mui/x-charts/ChartsVoronoiHandler';
|
|
10
|
+
import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
|
|
11
|
+
import { ChartsGrid } from '@mui/x-charts/ChartsGrid';
|
|
12
|
+
import { ChartsLegend } from '@mui/x-charts/ChartsLegend';
|
|
13
|
+
import { ChartsAxisHighlight } from '@mui/x-charts/ChartsAxisHighlight';
|
|
14
|
+
import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
|
|
15
|
+
import { useScatterChartProps } from '@mui/x-charts/internals';
|
|
16
|
+
import { ResponsiveChartContainerPro } from '../ResponsiveChartContainerPro';
|
|
17
|
+
import { ZoomSetup } from '../context/ZoomProvider/ZoomSetup';
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
/**
|
|
20
|
+
* Demos:
|
|
21
|
+
*
|
|
22
|
+
* - [Scatter](https://mui.com/x/react-charts/scatter/)
|
|
23
|
+
* - [Scatter demonstration](https://mui.com/x/react-charts/scatter-demo/)
|
|
24
|
+
*
|
|
25
|
+
* API:
|
|
26
|
+
*
|
|
27
|
+
* - [ScatterChart API](https://mui.com/x/api/charts/scatter-chart/)
|
|
28
|
+
*/
|
|
29
|
+
const ScatterChartPro = /*#__PURE__*/React.forwardRef(function ScatterChartPro(props, ref) {
|
|
30
|
+
const {
|
|
31
|
+
zoom,
|
|
32
|
+
onZoomChange
|
|
33
|
+
} = props,
|
|
34
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
35
|
+
const {
|
|
36
|
+
chartContainerProps,
|
|
37
|
+
zAxisProps,
|
|
38
|
+
voronoiHandlerProps,
|
|
39
|
+
chartsAxisProps,
|
|
40
|
+
gridProps,
|
|
41
|
+
scatterPlotProps,
|
|
42
|
+
overlayProps,
|
|
43
|
+
legendProps,
|
|
44
|
+
axisHighlightProps,
|
|
45
|
+
tooltipProps,
|
|
46
|
+
children
|
|
47
|
+
} = useScatterChartProps(other);
|
|
48
|
+
return /*#__PURE__*/_jsx(ResponsiveChartContainerPro, _extends({
|
|
49
|
+
ref: ref
|
|
50
|
+
}, chartContainerProps, {
|
|
51
|
+
zoom: zoom,
|
|
52
|
+
onZoomChange: onZoomChange,
|
|
53
|
+
children: /*#__PURE__*/_jsxs(ZAxisContextProvider, _extends({}, zAxisProps, {
|
|
54
|
+
children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
55
|
+
"data-drawing-container": true,
|
|
56
|
+
children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
|
|
57
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ZoomSetup, {}), children]
|
|
58
|
+
}))
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
62
|
+
// ----------------------------- Warning --------------------------------
|
|
63
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
64
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
65
|
+
// ----------------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* The configuration of axes highlight.
|
|
68
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
69
|
+
* @default { x: 'none', y: 'none' }
|
|
70
|
+
*/
|
|
71
|
+
axisHighlight: PropTypes.shape({
|
|
72
|
+
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
73
|
+
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
74
|
+
}),
|
|
75
|
+
/**
|
|
76
|
+
* Indicate which axis to display the bottom of the charts.
|
|
77
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
78
|
+
* @default xAxisIds[0] The id of the first provided axis
|
|
79
|
+
*/
|
|
80
|
+
bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
81
|
+
children: PropTypes.node,
|
|
82
|
+
className: PropTypes.string,
|
|
83
|
+
/**
|
|
84
|
+
* Color palette used to colorize multiple series.
|
|
85
|
+
* @default blueberryTwilightPalette
|
|
86
|
+
*/
|
|
87
|
+
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
88
|
+
/**
|
|
89
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
90
|
+
*/
|
|
91
|
+
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
92
|
+
desc: PropTypes.string,
|
|
93
|
+
/**
|
|
94
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
95
|
+
* It might break interactive features, but will improve performance.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
disableAxisListener: PropTypes.bool,
|
|
99
|
+
/**
|
|
100
|
+
* If true, the interaction will not use the Voronoi cell and fall back to hover events.
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
disableVoronoi: PropTypes.bool,
|
|
104
|
+
/**
|
|
105
|
+
* Option to display a cartesian grid in the background.
|
|
106
|
+
*/
|
|
107
|
+
grid: PropTypes.shape({
|
|
108
|
+
horizontal: PropTypes.bool,
|
|
109
|
+
vertical: PropTypes.bool
|
|
110
|
+
}),
|
|
111
|
+
/**
|
|
112
|
+
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
113
|
+
*/
|
|
114
|
+
height: PropTypes.number,
|
|
115
|
+
/**
|
|
116
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
117
|
+
*/
|
|
118
|
+
highlightedItem: PropTypes.shape({
|
|
119
|
+
dataIndex: PropTypes.number,
|
|
120
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
121
|
+
}),
|
|
122
|
+
/**
|
|
123
|
+
* Indicate which axis to display the left of the charts.
|
|
124
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
125
|
+
* @default yAxisIds[0] The id of the first provided axis
|
|
126
|
+
*/
|
|
127
|
+
leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
130
|
+
*/
|
|
131
|
+
legend: PropTypes.shape({
|
|
132
|
+
classes: PropTypes.object,
|
|
133
|
+
direction: PropTypes.oneOf(['column', 'row']),
|
|
134
|
+
hidden: PropTypes.bool,
|
|
135
|
+
position: PropTypes.shape({
|
|
136
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
137
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
138
|
+
}),
|
|
139
|
+
slotProps: PropTypes.object,
|
|
140
|
+
slots: PropTypes.object
|
|
141
|
+
}),
|
|
142
|
+
/**
|
|
143
|
+
* If `true`, a loading overlay is displayed.
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
loading: PropTypes.bool,
|
|
147
|
+
/**
|
|
148
|
+
* The margin between the SVG and the drawing area.
|
|
149
|
+
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
150
|
+
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
151
|
+
* @default object Depends on the charts type.
|
|
152
|
+
*/
|
|
153
|
+
margin: PropTypes.shape({
|
|
154
|
+
bottom: PropTypes.number,
|
|
155
|
+
left: PropTypes.number,
|
|
156
|
+
right: PropTypes.number,
|
|
157
|
+
top: PropTypes.number
|
|
158
|
+
}),
|
|
159
|
+
/**
|
|
160
|
+
* The callback fired when the highlighted item changes.
|
|
161
|
+
*
|
|
162
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
163
|
+
*/
|
|
164
|
+
onHighlightChange: PropTypes.func,
|
|
165
|
+
/**
|
|
166
|
+
* Callback fired when clicking on a scatter item.
|
|
167
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element if using Voronoi cells. Or the Mouse event from the scatter element, when `disableVoronoi=true`.
|
|
168
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
169
|
+
*/
|
|
170
|
+
onItemClick: PropTypes.func,
|
|
171
|
+
/**
|
|
172
|
+
* Callback fired when the zoom has changed.
|
|
173
|
+
*
|
|
174
|
+
* @param {ZoomData[]} zoomData Updated zoom data.
|
|
175
|
+
*/
|
|
176
|
+
onZoomChange: PropTypes.func,
|
|
177
|
+
/**
|
|
178
|
+
* Indicate which axis to display the right of the charts.
|
|
179
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
180
|
+
* @default null
|
|
181
|
+
*/
|
|
182
|
+
rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
183
|
+
/**
|
|
184
|
+
* The series to display in the scatter chart.
|
|
185
|
+
* An array of [[ScatterSeriesType]] objects.
|
|
186
|
+
*/
|
|
187
|
+
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
188
|
+
/**
|
|
189
|
+
* The props used for each component slot.
|
|
190
|
+
* @default {}
|
|
191
|
+
*/
|
|
192
|
+
slotProps: PropTypes.object,
|
|
193
|
+
/**
|
|
194
|
+
* Overridable component slots.
|
|
195
|
+
* @default {}
|
|
196
|
+
*/
|
|
197
|
+
slots: PropTypes.object,
|
|
198
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
199
|
+
title: PropTypes.string,
|
|
200
|
+
/**
|
|
201
|
+
* The configuration of the tooltip.
|
|
202
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
203
|
+
* @default { trigger: 'item' }
|
|
204
|
+
*/
|
|
205
|
+
tooltip: PropTypes.shape({
|
|
206
|
+
axisContent: PropTypes.elementType,
|
|
207
|
+
classes: PropTypes.object,
|
|
208
|
+
itemContent: PropTypes.elementType,
|
|
209
|
+
slotProps: PropTypes.object,
|
|
210
|
+
slots: PropTypes.object,
|
|
211
|
+
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
212
|
+
}),
|
|
213
|
+
/**
|
|
214
|
+
* Indicate which axis to display the top of the charts.
|
|
215
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
216
|
+
* @default null
|
|
217
|
+
*/
|
|
218
|
+
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
219
|
+
viewBox: PropTypes.shape({
|
|
220
|
+
height: PropTypes.number,
|
|
221
|
+
width: PropTypes.number,
|
|
222
|
+
x: PropTypes.number,
|
|
223
|
+
y: PropTypes.number
|
|
224
|
+
}),
|
|
225
|
+
/**
|
|
226
|
+
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
227
|
+
* If `undefined`, the radius is assumed to be infinite.
|
|
228
|
+
*/
|
|
229
|
+
voronoiMaxRadius: PropTypes.number,
|
|
230
|
+
/**
|
|
231
|
+
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
232
|
+
*/
|
|
233
|
+
width: PropTypes.number,
|
|
234
|
+
/**
|
|
235
|
+
* The configuration of the x-axes.
|
|
236
|
+
* If not provided, a default axis config is used.
|
|
237
|
+
* An array of [[AxisConfig]] objects.
|
|
238
|
+
*/
|
|
239
|
+
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
240
|
+
classes: PropTypes.object,
|
|
241
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
242
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
243
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
244
|
+
unknownColor: PropTypes.string,
|
|
245
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
246
|
+
}), PropTypes.shape({
|
|
247
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
248
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
249
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
250
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
251
|
+
}), PropTypes.shape({
|
|
252
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
253
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
254
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
255
|
+
})]),
|
|
256
|
+
data: PropTypes.array,
|
|
257
|
+
dataKey: PropTypes.string,
|
|
258
|
+
disableLine: PropTypes.bool,
|
|
259
|
+
disableTicks: PropTypes.bool,
|
|
260
|
+
fill: PropTypes.string,
|
|
261
|
+
hideTooltip: PropTypes.bool,
|
|
262
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
263
|
+
label: PropTypes.string,
|
|
264
|
+
labelFontSize: PropTypes.number,
|
|
265
|
+
labelStyle: PropTypes.object,
|
|
266
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
267
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
268
|
+
position: PropTypes.oneOf(['bottom', 'top']),
|
|
269
|
+
reverse: PropTypes.bool,
|
|
270
|
+
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
271
|
+
slotProps: PropTypes.object,
|
|
272
|
+
slots: PropTypes.object,
|
|
273
|
+
stroke: PropTypes.string,
|
|
274
|
+
tickFontSize: PropTypes.number,
|
|
275
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
276
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
277
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
278
|
+
tickLabelStyle: PropTypes.object,
|
|
279
|
+
tickMaxStep: PropTypes.number,
|
|
280
|
+
tickMinStep: PropTypes.number,
|
|
281
|
+
tickNumber: PropTypes.number,
|
|
282
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
283
|
+
tickSize: PropTypes.number,
|
|
284
|
+
valueFormatter: PropTypes.func,
|
|
285
|
+
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
286
|
+
maxEnd: PropTypes.number,
|
|
287
|
+
maxSpan: PropTypes.number,
|
|
288
|
+
minSpan: PropTypes.number,
|
|
289
|
+
minStart: PropTypes.number,
|
|
290
|
+
panning: PropTypes.bool,
|
|
291
|
+
step: PropTypes.number
|
|
292
|
+
}), PropTypes.bool])
|
|
293
|
+
})),
|
|
294
|
+
/**
|
|
295
|
+
* The configuration of the y-axes.
|
|
296
|
+
* If not provided, a default axis config is used.
|
|
297
|
+
* An array of [[AxisConfig]] objects.
|
|
298
|
+
*/
|
|
299
|
+
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
300
|
+
classes: PropTypes.object,
|
|
301
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
302
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
303
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
304
|
+
unknownColor: PropTypes.string,
|
|
305
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
306
|
+
}), PropTypes.shape({
|
|
307
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
308
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
309
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
310
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
311
|
+
}), PropTypes.shape({
|
|
312
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
313
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
314
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
315
|
+
})]),
|
|
316
|
+
data: PropTypes.array,
|
|
317
|
+
dataKey: PropTypes.string,
|
|
318
|
+
disableLine: PropTypes.bool,
|
|
319
|
+
disableTicks: PropTypes.bool,
|
|
320
|
+
fill: PropTypes.string,
|
|
321
|
+
hideTooltip: PropTypes.bool,
|
|
322
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
323
|
+
label: PropTypes.string,
|
|
324
|
+
labelFontSize: PropTypes.number,
|
|
325
|
+
labelStyle: PropTypes.object,
|
|
326
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
327
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
328
|
+
position: PropTypes.oneOf(['left', 'right']),
|
|
329
|
+
reverse: PropTypes.bool,
|
|
330
|
+
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
331
|
+
slotProps: PropTypes.object,
|
|
332
|
+
slots: PropTypes.object,
|
|
333
|
+
stroke: PropTypes.string,
|
|
334
|
+
tickFontSize: PropTypes.number,
|
|
335
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
336
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
337
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
338
|
+
tickLabelStyle: PropTypes.object,
|
|
339
|
+
tickMaxStep: PropTypes.number,
|
|
340
|
+
tickMinStep: PropTypes.number,
|
|
341
|
+
tickNumber: PropTypes.number,
|
|
342
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
343
|
+
tickSize: PropTypes.number,
|
|
344
|
+
valueFormatter: PropTypes.func,
|
|
345
|
+
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
346
|
+
maxEnd: PropTypes.number,
|
|
347
|
+
maxSpan: PropTypes.number,
|
|
348
|
+
minSpan: PropTypes.number,
|
|
349
|
+
minStart: PropTypes.number,
|
|
350
|
+
panning: PropTypes.bool,
|
|
351
|
+
step: PropTypes.number
|
|
352
|
+
}), PropTypes.bool])
|
|
353
|
+
})),
|
|
354
|
+
/**
|
|
355
|
+
* The configuration of the z-axes.
|
|
356
|
+
*/
|
|
357
|
+
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
358
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
359
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
360
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
361
|
+
unknownColor: PropTypes.string,
|
|
362
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
363
|
+
}), PropTypes.shape({
|
|
364
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
365
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
366
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
367
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
368
|
+
}), PropTypes.shape({
|
|
369
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
370
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
371
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
372
|
+
})]),
|
|
373
|
+
data: PropTypes.array,
|
|
374
|
+
dataKey: PropTypes.string,
|
|
375
|
+
id: PropTypes.string,
|
|
376
|
+
max: PropTypes.number,
|
|
377
|
+
min: PropTypes.number
|
|
378
|
+
})),
|
|
379
|
+
/**
|
|
380
|
+
* The list of zoom data related to each axis.
|
|
381
|
+
*/
|
|
382
|
+
zoom: PropTypes.arrayOf(PropTypes.shape({
|
|
383
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
384
|
+
end: PropTypes.number.isRequired,
|
|
385
|
+
start: PropTypes.number.isRequired
|
|
386
|
+
}))
|
|
387
|
+
} : void 0;
|
|
388
|
+
export { ScatterChartPro };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ScatterChartPro';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ScatterChartPro';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CartesianContextProviderProps } from '@mui/x-charts/internals';
|
|
3
|
+
export interface CartesianContextProviderProProps extends CartesianContextProviderProps {
|
|
4
|
+
}
|
|
5
|
+
declare function CartesianContextProviderPro(props: CartesianContextProviderProProps): React.JSX.Element;
|
|
6
|
+
export { CartesianContextProviderPro };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useDrawingArea, useSeries, CartesianContext, cartesianProviderUtils, useXExtremumGetter, useYExtremumGetter } from '@mui/x-charts/internals';
|
|
3
|
+
import { useZoom } from '../ZoomProvider/useZoom';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const {
|
|
6
|
+
computeValue
|
|
7
|
+
} = cartesianProviderUtils;
|
|
8
|
+
function CartesianContextProviderPro(props) {
|
|
9
|
+
const {
|
|
10
|
+
xAxis,
|
|
11
|
+
yAxis,
|
|
12
|
+
dataset,
|
|
13
|
+
children
|
|
14
|
+
} = props;
|
|
15
|
+
const formattedSeries = useSeries();
|
|
16
|
+
const drawingArea = useDrawingArea();
|
|
17
|
+
const {
|
|
18
|
+
zoomData
|
|
19
|
+
} = useZoom();
|
|
20
|
+
const xExtremumGetters = useXExtremumGetter();
|
|
21
|
+
const yExtremumGetters = useYExtremumGetter();
|
|
22
|
+
const xValues = React.useMemo(() => computeValue({
|
|
23
|
+
drawingArea,
|
|
24
|
+
formattedSeries,
|
|
25
|
+
axis: xAxis,
|
|
26
|
+
extremumGetters: xExtremumGetters,
|
|
27
|
+
dataset,
|
|
28
|
+
axisDirection: 'x',
|
|
29
|
+
zoomData
|
|
30
|
+
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters, dataset, zoomData]);
|
|
31
|
+
const yValues = React.useMemo(() => computeValue({
|
|
32
|
+
drawingArea,
|
|
33
|
+
formattedSeries,
|
|
34
|
+
axis: yAxis,
|
|
35
|
+
extremumGetters: yExtremumGetters,
|
|
36
|
+
dataset,
|
|
37
|
+
axisDirection: 'y',
|
|
38
|
+
zoomData
|
|
39
|
+
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters, dataset, zoomData]);
|
|
40
|
+
const value = React.useMemo(() => ({
|
|
41
|
+
isInitialized: true,
|
|
42
|
+
data: {
|
|
43
|
+
xAxis: xValues.axis,
|
|
44
|
+
yAxis: yValues.axis,
|
|
45
|
+
xAxisIds: xValues.axisIds,
|
|
46
|
+
yAxisIds: yValues.axisIds
|
|
47
|
+
}
|
|
48
|
+
}), [xValues, yValues]);
|
|
49
|
+
return /*#__PURE__*/_jsx(CartesianContext.Provider, {
|
|
50
|
+
value: value,
|
|
51
|
+
children: children
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export { CartesianContextProviderPro };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CartesianProviderPro';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CartesianProviderPro';
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { AxisId } from '@mui/x-charts/internals';
|
|
2
|
+
export type ZoomProviderProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* The configuration of the x-axes.
|
|
6
|
+
* If not provided, a default axis config is used.
|
|
7
|
+
* An array of [[AxisConfig]] objects.
|
|
8
|
+
*/
|
|
9
|
+
xAxis?: AxisConfigForZoom[];
|
|
10
|
+
/**
|
|
11
|
+
* The configuration of the y-axes.
|
|
12
|
+
* If not provided, a default axis config is used.
|
|
13
|
+
* An array of [[AxisConfig]] objects.
|
|
14
|
+
*/
|
|
15
|
+
yAxis?: AxisConfigForZoom[];
|
|
16
|
+
} & ZoomProps;
|
|
17
|
+
/**
|
|
18
|
+
* Represents the state of the ZoomProvider.
|
|
19
|
+
*/
|
|
20
|
+
export type ZoomState = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether zooming is enabled.
|
|
23
|
+
*/
|
|
24
|
+
isZoomEnabled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether panning is enabled.
|
|
27
|
+
*/
|
|
28
|
+
isPanEnabled: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The zoom options for each axis.
|
|
31
|
+
*/
|
|
32
|
+
options: Record<AxisId, DefaultizedZoomOptions>;
|
|
33
|
+
/**
|
|
34
|
+
* The zoom data for each axis
|
|
35
|
+
* @default []
|
|
36
|
+
*/
|
|
37
|
+
zoomData: ZoomData[];
|
|
38
|
+
/**
|
|
39
|
+
* Set the zoom data for each axis.
|
|
40
|
+
* @param {ZoomData[]} zoomData The new zoom data.
|
|
41
|
+
*/
|
|
42
|
+
setZoomData: (zoomData: ZoomData[] | ((zoomData: ZoomData[]) => ZoomData[])) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the user is currently interacting with the chart.
|
|
45
|
+
* This is useful to prevent animations from running while the user is interacting.
|
|
46
|
+
*/
|
|
47
|
+
isInteracting: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Set the interaction state of the chart.
|
|
50
|
+
* @param {boolean} isInteracting The new interaction state.
|
|
51
|
+
*/
|
|
52
|
+
setIsInteracting: (isInteracting: boolean) => void;
|
|
53
|
+
};
|
|
54
|
+
export type ZoomOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* The starting percentage of the zoom range. In the range of 0 to 100.
|
|
57
|
+
*
|
|
58
|
+
* @default 0
|
|
59
|
+
*/
|
|
60
|
+
minStart?: number;
|
|
61
|
+
/**
|
|
62
|
+
* The ending percentage of the zoom range. In the range of 0 to 100.
|
|
63
|
+
*
|
|
64
|
+
* @default 100
|
|
65
|
+
*/
|
|
66
|
+
maxEnd?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The step size of the zooming function. Defines the granularity of the zoom.
|
|
69
|
+
*
|
|
70
|
+
* @default 5
|
|
71
|
+
*/
|
|
72
|
+
step?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Restricts the minimum span size in the range of 0 to 100.
|
|
75
|
+
*
|
|
76
|
+
* If the span size is smaller than the minSpan, the span will be resized to the minSpan.
|
|
77
|
+
*
|
|
78
|
+
* @default 10
|
|
79
|
+
*/
|
|
80
|
+
minSpan?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Restricts the maximum span size in the range of 0 to 100.
|
|
83
|
+
*
|
|
84
|
+
* If the span size is larger than the maxSpan, the span will be resized to the maxSpan.
|
|
85
|
+
*
|
|
86
|
+
* @default 100
|
|
87
|
+
*/
|
|
88
|
+
maxSpan?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Set to `false` to disable panning. Useful when you want to pan programmatically,
|
|
91
|
+
* or to show only a specific section of the chart.
|
|
92
|
+
*
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
panning?: boolean;
|
|
96
|
+
};
|
|
97
|
+
export type ZoomData = {
|
|
98
|
+
/**
|
|
99
|
+
* The starting percentage of the zoom range. In the range of 0 to 100.
|
|
100
|
+
*
|
|
101
|
+
* @default 0
|
|
102
|
+
*/
|
|
103
|
+
start: number;
|
|
104
|
+
/**
|
|
105
|
+
* The ending percentage of the zoom range. In the range of 0 to 100.
|
|
106
|
+
*
|
|
107
|
+
* @default 100
|
|
108
|
+
*/
|
|
109
|
+
end: number;
|
|
110
|
+
/**
|
|
111
|
+
* The axis id that the zoom data belongs to.
|
|
112
|
+
*/
|
|
113
|
+
axisId: AxisId;
|
|
114
|
+
};
|
|
115
|
+
export type ZoomProps = {
|
|
116
|
+
/**
|
|
117
|
+
* The list of zoom data related to each axis.
|
|
118
|
+
*/
|
|
119
|
+
zoom?: ZoomData[];
|
|
120
|
+
/**
|
|
121
|
+
* Callback fired when the zoom has changed.
|
|
122
|
+
*
|
|
123
|
+
* @param {ZoomData[]} zoomData Updated zoom data.
|
|
124
|
+
*/
|
|
125
|
+
onZoomChange?: (zoomData: ZoomData[] | ((zoomData: ZoomData[]) => ZoomData[])) => void;
|
|
126
|
+
};
|
|
127
|
+
export type DefaultizedZoomOptions = Required<ZoomOptions> & {
|
|
128
|
+
axisId: AxisId;
|
|
129
|
+
axisDirection: 'x' | 'y';
|
|
130
|
+
};
|
|
131
|
+
export type AxisConfigForZoom = {
|
|
132
|
+
id: AxisId;
|
|
133
|
+
zoom?: ZoomOptions | boolean;
|
|
134
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const ZoomContext = /*#__PURE__*/React.createContext({
|
|
3
|
+
isInitialized: false,
|
|
4
|
+
data: {
|
|
5
|
+
isZoomEnabled: false,
|
|
6
|
+
isPanEnabled: false,
|
|
7
|
+
options: {},
|
|
8
|
+
zoomData: [],
|
|
9
|
+
setZoomData: () => {},
|
|
10
|
+
isInteracting: false,
|
|
11
|
+
setIsInteracting: () => {}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
+
ZoomContext.displayName = 'ZoomContext';
|
|
16
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useControlled from '@mui/utils/useControlled';
|
|
3
|
+
import { ZoomContext } from './ZoomContext';
|
|
4
|
+
import { defaultizeZoom } from './defaultizeZoom';
|
|
5
|
+
import { initializeZoomData } from './initializeZoomData';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function ZoomProvider({
|
|
8
|
+
children,
|
|
9
|
+
xAxis,
|
|
10
|
+
yAxis,
|
|
11
|
+
zoom,
|
|
12
|
+
onZoomChange
|
|
13
|
+
}) {
|
|
14
|
+
const [isInteracting, setIsInteracting] = React.useState(false);
|
|
15
|
+
const options = React.useMemo(() => [...defaultizeZoom(xAxis, 'x'), ...defaultizeZoom(yAxis, 'y')].reduce((acc, v) => {
|
|
16
|
+
acc[v.axisId] = v;
|
|
17
|
+
return acc;
|
|
18
|
+
}, {}), [xAxis, yAxis]);
|
|
19
|
+
|
|
20
|
+
// Default zoom data is initialized only once when uncontrolled. If the user changes the options
|
|
21
|
+
// after the initial render, the zoom data will not be updated until the next zoom interaction.
|
|
22
|
+
// This is required to avoid warnings about controlled/uncontrolled components.
|
|
23
|
+
const defaultZoomData = React.useRef(initializeZoomData(options));
|
|
24
|
+
const [zoomData, setZoomData] = useControlled({
|
|
25
|
+
controlled: zoom,
|
|
26
|
+
default: defaultZoomData.current,
|
|
27
|
+
name: 'ZoomProvider',
|
|
28
|
+
state: 'zoom'
|
|
29
|
+
});
|
|
30
|
+
const setZoomDataCallback = React.useCallback(newZoomData => {
|
|
31
|
+
setZoomData(newZoomData);
|
|
32
|
+
onZoomChange?.(newZoomData);
|
|
33
|
+
}, [setZoomData, onZoomChange]);
|
|
34
|
+
const value = React.useMemo(() => ({
|
|
35
|
+
isInitialized: true,
|
|
36
|
+
data: {
|
|
37
|
+
isZoomEnabled: Object.keys(options).length > 0,
|
|
38
|
+
isPanEnabled: isPanEnabled(options),
|
|
39
|
+
options,
|
|
40
|
+
zoomData,
|
|
41
|
+
setZoomData: setZoomDataCallback,
|
|
42
|
+
isInteracting,
|
|
43
|
+
setIsInteracting
|
|
44
|
+
}
|
|
45
|
+
}), [zoomData, isInteracting, setIsInteracting, options, setZoomDataCallback]);
|
|
46
|
+
return /*#__PURE__*/_jsx(ZoomContext.Provider, {
|
|
47
|
+
value: value,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function isPanEnabled(options) {
|
|
52
|
+
return Object.values(options).some(v => v.panning) || false;
|
|
53
|
+
}
|