@mui/x-charts-pro 7.22.3 → 8.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChartPro/BarChartPro.d.ts +1 -1
- package/BarChartPro/BarChartPro.js +9 -59
- package/CHANGELOG.md +348 -12
- package/ChartContainerPro/ChartContainerPro.d.ts +1 -1
- package/ChartContainerPro/ChartContainerPro.js +21 -47
- package/ChartContainerPro/useChartContainerProProps.d.ts +6 -14
- package/ChartContainerPro/useChartContainerProProps.js +11 -25
- package/Heatmap/Heatmap.d.ts +16 -8
- package/Heatmap/Heatmap.js +6 -37
- package/Heatmap/HeatmapTooltip.d.ts +9 -0
- package/Heatmap/HeatmapTooltip.js +294 -0
- package/Heatmap/index.d.ts +1 -1
- package/Heatmap/index.js +1 -1
- package/LineChartPro/LineChartPro.d.ts +1 -1
- package/LineChartPro/LineChartPro.js +9 -60
- package/README.md +4 -4
- package/ScatterChartPro/ScatterChartPro.d.ts +1 -1
- package/ScatterChartPro/ScatterChartPro.js +9 -60
- package/context/ChartDataProviderPro/ChartDataProviderPro.d.ts +10 -0
- package/{modern/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js → context/ChartDataProviderPro/ChartDataProviderPro.js} +50 -33
- package/context/ChartDataProviderPro/index.d.ts +1 -0
- package/context/ChartDataProviderPro/index.js +1 -0
- package/context/ChartDataProviderPro/useChartDataProviderProProps.d.ts +14 -0
- package/context/ChartDataProviderPro/useChartDataProviderProProps.js +43 -0
- package/context/ZoomProvider/ZoomProvider.js +1 -0
- package/index.d.ts +0 -1
- package/index.js +1 -2
- package/internals/utils/releaseInfo.js +1 -1
- package/models/seriesType/heatmap.d.ts +2 -1
- package/modern/BarChartPro/BarChartPro.js +9 -59
- package/modern/ChartContainerPro/ChartContainerPro.js +21 -47
- package/modern/ChartContainerPro/useChartContainerProProps.js +11 -25
- package/modern/Heatmap/Heatmap.js +6 -37
- package/modern/Heatmap/HeatmapTooltip.js +294 -0
- package/modern/Heatmap/index.js +1 -1
- package/modern/LineChartPro/LineChartPro.js +9 -60
- package/modern/ScatterChartPro/ScatterChartPro.js +9 -60
- package/{ResponsiveChartContainerPro/ResponsiveChartContainerPro.js → modern/context/ChartDataProviderPro/ChartDataProviderPro.js} +50 -33
- package/modern/context/ChartDataProviderPro/index.js +1 -0
- package/modern/context/ChartDataProviderPro/useChartDataProviderProProps.js +43 -0
- package/modern/context/ZoomProvider/ZoomProvider.js +1 -0
- package/modern/index.js +1 -2
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/node/BarChartPro/BarChartPro.js +9 -59
- package/node/ChartContainerPro/ChartContainerPro.js +20 -46
- package/node/ChartContainerPro/useChartContainerProProps.js +11 -25
- package/node/Heatmap/Heatmap.js +6 -37
- package/node/Heatmap/HeatmapTooltip.js +300 -0
- package/node/Heatmap/index.js +4 -4
- package/node/LineChartPro/LineChartPro.js +9 -60
- package/node/ScatterChartPro/ScatterChartPro.js +9 -60
- package/node/{ResponsiveChartContainerPro/ResponsiveChartContainerPro.js → context/ChartDataProviderPro/ChartDataProviderPro.js} +48 -31
- package/node/context/ChartDataProviderPro/index.js +16 -0
- package/node/context/ChartDataProviderPro/useChartDataProviderProProps.js +50 -0
- package/node/context/ZoomProvider/ZoomProvider.js +1 -0
- package/node/index.js +1 -12
- package/node/internals/utils/releaseInfo.js +1 -1
- package/package.json +8 -8
- package/typeOverloads/modules.d.ts +1 -1
- package/Heatmap/DefaultHeatmapTooltip.d.ts +0 -7
- package/Heatmap/DefaultHeatmapTooltip.js +0 -99
- package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.d.ts +0 -7
- package/ResponsiveChartContainerPro/index.d.ts +0 -1
- package/ResponsiveChartContainerPro/index.js +0 -1
- package/ResponsiveChartContainerPro/package.json +0 -6
- package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.d.ts +0 -42
- package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +0 -27
- package/modern/Heatmap/DefaultHeatmapTooltip.js +0 -99
- package/modern/ResponsiveChartContainerPro/index.js +0 -1
- package/modern/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +0 -27
- package/node/Heatmap/DefaultHeatmapTooltip.js +0 -105
- package/node/ResponsiveChartContainerPro/index.js +0 -16
- package/node/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +0 -34
|
@@ -16,7 +16,7 @@ import { ChartsAxisHighlight } from '@mui/x-charts/ChartsAxisHighlight';
|
|
|
16
16
|
import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
|
|
17
17
|
import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
|
|
18
18
|
import { useBarChartProps } from '@mui/x-charts/internals';
|
|
19
|
-
import {
|
|
19
|
+
import { ChartContainerPro } from "../ChartContainerPro/index.js";
|
|
20
20
|
import { ZoomSetup } from "../context/ZoomProvider/ZoomSetup.js";
|
|
21
21
|
import { useZoom } from "../context/ZoomProvider/useZoom.js";
|
|
22
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -99,17 +99,17 @@ const BarChartPro = /*#__PURE__*/React.forwardRef(function BarChartPro(inProps,
|
|
|
99
99
|
chartsAxisProps,
|
|
100
100
|
axisHighlightProps,
|
|
101
101
|
legendProps,
|
|
102
|
-
tooltipProps,
|
|
103
102
|
children
|
|
104
103
|
} = useBarChartProps(other);
|
|
105
|
-
|
|
104
|
+
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
105
|
+
return /*#__PURE__*/_jsxs(ChartContainerPro, _extends({
|
|
106
106
|
ref: ref
|
|
107
107
|
}, chartContainerProps, {
|
|
108
108
|
zoom: zoom,
|
|
109
109
|
onZoomChange: onZoomChange,
|
|
110
110
|
children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
111
111
|
children: [/*#__PURE__*/_jsx(BarChartPlotZoom, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
112
|
-
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(
|
|
112
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), /*#__PURE__*/_jsx(ZoomSetup, {}), children]
|
|
113
113
|
}));
|
|
114
114
|
});
|
|
115
115
|
process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
@@ -121,7 +121,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
121
121
|
* The configuration of axes highlight.
|
|
122
122
|
* Default is set to 'band' in the bar direction.
|
|
123
123
|
* Depends on `layout` prop.
|
|
124
|
-
* @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
|
|
124
|
+
* @see See {@link https://mui.com/x/react-charts/highlighting/ highlighting docs} for more details.
|
|
125
125
|
*/
|
|
126
126
|
axisHighlight: PropTypes.shape({
|
|
127
127
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
@@ -174,6 +174,10 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
174
174
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
175
175
|
*/
|
|
176
176
|
height: PropTypes.number,
|
|
177
|
+
/**
|
|
178
|
+
* If `true`, the legend is not rendered.
|
|
179
|
+
*/
|
|
180
|
+
hideLegend: PropTypes.bool,
|
|
177
181
|
/**
|
|
178
182
|
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
179
183
|
*/
|
|
@@ -192,32 +196,6 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
192
196
|
* @default yAxisIds[0] The id of the first provided axis
|
|
193
197
|
*/
|
|
194
198
|
leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
195
|
-
/**
|
|
196
|
-
* @deprecated Consider using `slotProps.legend` instead.
|
|
197
|
-
*/
|
|
198
|
-
legend: PropTypes.shape({
|
|
199
|
-
classes: PropTypes.object,
|
|
200
|
-
direction: PropTypes.oneOf(['column', 'row']),
|
|
201
|
-
hidden: PropTypes.bool,
|
|
202
|
-
itemGap: PropTypes.number,
|
|
203
|
-
itemMarkHeight: PropTypes.number,
|
|
204
|
-
itemMarkWidth: PropTypes.number,
|
|
205
|
-
labelStyle: PropTypes.object,
|
|
206
|
-
markGap: PropTypes.number,
|
|
207
|
-
onItemClick: PropTypes.func,
|
|
208
|
-
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
209
|
-
bottom: PropTypes.number,
|
|
210
|
-
left: PropTypes.number,
|
|
211
|
-
right: PropTypes.number,
|
|
212
|
-
top: PropTypes.number
|
|
213
|
-
})]),
|
|
214
|
-
position: PropTypes.shape({
|
|
215
|
-
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
216
|
-
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
217
|
-
}),
|
|
218
|
-
slotProps: PropTypes.object,
|
|
219
|
-
slots: PropTypes.object
|
|
220
|
-
}),
|
|
221
199
|
/**
|
|
222
200
|
* If `true`, a loading overlay is displayed.
|
|
223
201
|
* @default false
|
|
@@ -260,16 +238,6 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
260
238
|
* @param {ZoomData[]} zoomData Updated zoom data.
|
|
261
239
|
*/
|
|
262
240
|
onZoomChange: PropTypes.func,
|
|
263
|
-
/**
|
|
264
|
-
* The chart will try to wait for the parent container to resolve its size
|
|
265
|
-
* before it renders for the first time.
|
|
266
|
-
*
|
|
267
|
-
* This can be useful in some scenarios where the chart appear to grow after
|
|
268
|
-
* the first render, like when used inside a grid.
|
|
269
|
-
*
|
|
270
|
-
* @default false
|
|
271
|
-
*/
|
|
272
|
-
resolveSizeBeforeRender: PropTypes.bool,
|
|
273
241
|
/**
|
|
274
242
|
* Indicate which axis to display the right of the charts.
|
|
275
243
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -298,30 +266,12 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
298
266
|
slots: PropTypes.object,
|
|
299
267
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
300
268
|
title: PropTypes.string,
|
|
301
|
-
/**
|
|
302
|
-
* The configuration of the tooltip.
|
|
303
|
-
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
304
|
-
*/
|
|
305
|
-
tooltip: PropTypes.shape({
|
|
306
|
-
axisContent: PropTypes.elementType,
|
|
307
|
-
classes: PropTypes.object,
|
|
308
|
-
itemContent: PropTypes.elementType,
|
|
309
|
-
slotProps: PropTypes.object,
|
|
310
|
-
slots: PropTypes.object,
|
|
311
|
-
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
312
|
-
}),
|
|
313
269
|
/**
|
|
314
270
|
* Indicate which axis to display the top of the charts.
|
|
315
271
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
316
272
|
* @default null
|
|
317
273
|
*/
|
|
318
274
|
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
319
|
-
viewBox: PropTypes.shape({
|
|
320
|
-
height: PropTypes.number,
|
|
321
|
-
width: PropTypes.number,
|
|
322
|
-
x: PropTypes.number,
|
|
323
|
-
y: PropTypes.number
|
|
324
|
-
}),
|
|
325
275
|
/**
|
|
326
276
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
327
277
|
*/
|
|
@@ -3,49 +3,29 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useLicenseVerifier } from '@mui/x-license/useLicenseVerifier';
|
|
6
|
+
import { Watermark } from '@mui/x-license/Watermark';
|
|
7
|
+
import { ResizableContainer } from '@mui/x-charts/internals';
|
|
8
|
+
import { ChartsSurface } from '@mui/x-charts';
|
|
10
9
|
import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
|
|
11
|
-
import {
|
|
12
|
-
import { ZoomProvider } from "../context/ZoomProvider/index.js";
|
|
10
|
+
import { ChartDataProviderPro } from "../context/ChartDataProviderPro/index.js";
|
|
13
11
|
import { useChartContainerProProps } from "./useChartContainerProProps.js";
|
|
14
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
13
|
const releaseInfo = getReleaseInfo();
|
|
16
|
-
const ChartContainerPro = /*#__PURE__*/React.forwardRef(function
|
|
14
|
+
const ChartContainerPro = /*#__PURE__*/React.forwardRef(function ChartContainerPro(props, ref) {
|
|
17
15
|
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
highlightedProviderProps,
|
|
23
|
-
cartesianProviderProps,
|
|
24
|
-
chartsSurfaceProps,
|
|
25
|
-
pluginProviderProps,
|
|
26
|
-
animationProviderProps,
|
|
27
|
-
children
|
|
16
|
+
chartDataProviderProProps,
|
|
17
|
+
children,
|
|
18
|
+
resizableContainerProps,
|
|
19
|
+
chartsSurfaceProps
|
|
28
20
|
} = useChartContainerProProps(props, ref);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
38
|
-
children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
|
|
39
|
-
children: /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
40
|
-
children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
|
|
41
|
-
}))
|
|
42
|
-
}))
|
|
43
|
-
})
|
|
44
|
-
}))
|
|
45
|
-
}))
|
|
46
|
-
}))
|
|
47
|
-
}))
|
|
48
|
-
}))
|
|
21
|
+
return /*#__PURE__*/_jsx(ChartDataProviderPro, _extends({}, chartDataProviderProProps, {
|
|
22
|
+
children: /*#__PURE__*/_jsxs(ResizableContainer, _extends({}, resizableContainerProps, {
|
|
23
|
+
children: [/*#__PURE__*/_jsx(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
24
|
+
children: children
|
|
25
|
+
})), /*#__PURE__*/_jsx(Watermark, {
|
|
26
|
+
packageName: "x-charts-pro",
|
|
27
|
+
releaseInfo: releaseInfo
|
|
28
|
+
})]
|
|
49
29
|
}))
|
|
50
30
|
}));
|
|
51
31
|
});
|
|
@@ -73,9 +53,9 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
73
53
|
*/
|
|
74
54
|
disableAxisListener: PropTypes.bool,
|
|
75
55
|
/**
|
|
76
|
-
* The height of the chart in px.
|
|
56
|
+
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
77
57
|
*/
|
|
78
|
-
height: PropTypes.number
|
|
58
|
+
height: PropTypes.number,
|
|
79
59
|
/**
|
|
80
60
|
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
81
61
|
*/
|
|
@@ -125,16 +105,10 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
125
105
|
skipAnimation: PropTypes.bool,
|
|
126
106
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
127
107
|
title: PropTypes.string,
|
|
128
|
-
viewBox: PropTypes.shape({
|
|
129
|
-
height: PropTypes.number,
|
|
130
|
-
width: PropTypes.number,
|
|
131
|
-
x: PropTypes.number,
|
|
132
|
-
y: PropTypes.number
|
|
133
|
-
}),
|
|
134
108
|
/**
|
|
135
|
-
* The width of the chart in px.
|
|
109
|
+
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
136
110
|
*/
|
|
137
|
-
width: PropTypes.number
|
|
111
|
+
width: PropTypes.number,
|
|
138
112
|
/**
|
|
139
113
|
* The configuration of the x-axes.
|
|
140
114
|
* If not provided, a default axis config is used.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
5
|
const _excluded = ["zoom", "onZoomChange"];
|
|
5
6
|
import { useChartContainerProps } from '@mui/x-charts/internals';
|
|
@@ -9,35 +10,20 @@ export const useChartContainerProProps = (props, ref) => {
|
|
|
9
10
|
onZoomChange
|
|
10
11
|
} = props,
|
|
11
12
|
baseProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
13
|
+
const chartDataProviderProProps = {
|
|
14
|
+
zoom,
|
|
15
|
+
onZoomChange
|
|
16
|
+
};
|
|
12
17
|
const {
|
|
13
|
-
|
|
14
|
-
drawingProviderProps,
|
|
15
|
-
seriesProviderProps,
|
|
16
|
-
cartesianProviderProps,
|
|
17
|
-
zAxisContextProps,
|
|
18
|
-
highlightedProviderProps,
|
|
18
|
+
chartDataProviderProps,
|
|
19
19
|
chartsSurfaceProps,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
xAxis,
|
|
23
|
-
yAxis
|
|
20
|
+
resizableContainerProps,
|
|
21
|
+
children
|
|
24
22
|
} = useChartContainerProps(baseProps, ref);
|
|
25
|
-
const zoomProviderProps = {
|
|
26
|
-
zoom,
|
|
27
|
-
onZoomChange,
|
|
28
|
-
xAxis,
|
|
29
|
-
yAxis
|
|
30
|
-
};
|
|
31
23
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
drawingProviderProps,
|
|
35
|
-
pluginProviderProps,
|
|
36
|
-
seriesProviderProps,
|
|
37
|
-
cartesianProviderProps,
|
|
38
|
-
zAxisContextProps,
|
|
39
|
-
highlightedProviderProps,
|
|
24
|
+
chartDataProviderProProps: _extends({}, chartDataProviderProps, chartDataProviderProProps),
|
|
25
|
+
resizableContainerProps,
|
|
40
26
|
chartsSurfaceProps,
|
|
41
|
-
|
|
27
|
+
children
|
|
42
28
|
};
|
|
43
29
|
};
|
|
@@ -7,14 +7,13 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
7
7
|
import useId from '@mui/utils/useId';
|
|
8
8
|
import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
|
|
9
9
|
import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
|
|
10
|
-
import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
|
|
11
10
|
import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
|
|
12
11
|
import { ChartsOnAxisClickHandler } from '@mui/x-charts/ChartsOnAxisClickHandler';
|
|
13
12
|
import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
|
|
14
|
-
import {
|
|
13
|
+
import { ChartContainerPro } from "../ChartContainerPro/index.js";
|
|
15
14
|
import { HeatmapPlot } from "./HeatmapPlot.js";
|
|
16
15
|
import { plugin as heatmapPlugin } from "./plugin.js";
|
|
17
|
-
import {
|
|
16
|
+
import { HeatmapTooltip } from "./HeatmapTooltip.js";
|
|
18
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
18
|
// The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
|
|
20
19
|
const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
|
|
@@ -34,7 +33,6 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
|
|
|
34
33
|
colors,
|
|
35
34
|
dataset,
|
|
36
35
|
sx,
|
|
37
|
-
tooltip,
|
|
38
36
|
topAxis,
|
|
39
37
|
leftAxis,
|
|
40
38
|
rightAxis,
|
|
@@ -65,7 +63,8 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
|
|
|
65
63
|
color: defaultColorMap
|
|
66
64
|
}
|
|
67
65
|
}], [zAxis]);
|
|
68
|
-
|
|
66
|
+
const Tooltip = props.slots?.tooltip ?? HeatmapTooltip;
|
|
67
|
+
return /*#__PURE__*/_jsxs(ChartContainerPro, {
|
|
69
68
|
ref: ref,
|
|
70
69
|
plugins: [heatmapPlugin],
|
|
71
70
|
series: series.map(s => _extends({
|
|
@@ -102,14 +101,7 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
|
|
|
102
101
|
bottomAxis: bottomAxis,
|
|
103
102
|
slots: slots,
|
|
104
103
|
slotProps: slotProps
|
|
105
|
-
}), !loading && /*#__PURE__*/_jsx(
|
|
106
|
-
trigger: "item"
|
|
107
|
-
}, tooltip, {
|
|
108
|
-
slots: _extends({
|
|
109
|
-
itemContent: DefaultHeatmapTooltip
|
|
110
|
-
}, slots),
|
|
111
|
-
slotProps: slotProps
|
|
112
|
-
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
104
|
+
}), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
113
105
|
id: clipPathId
|
|
114
106
|
}), children]
|
|
115
107
|
});
|
|
@@ -190,16 +182,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
190
182
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
191
183
|
*/
|
|
192
184
|
onHighlightChange: PropTypes.func,
|
|
193
|
-
/**
|
|
194
|
-
* The chart will try to wait for the parent container to resolve its size
|
|
195
|
-
* before it renders for the first time.
|
|
196
|
-
*
|
|
197
|
-
* This can be useful in some scenarios where the chart appear to grow after
|
|
198
|
-
* the first render, like when used inside a grid.
|
|
199
|
-
*
|
|
200
|
-
* @default false
|
|
201
|
-
*/
|
|
202
|
-
resolveSizeBeforeRender: PropTypes.bool,
|
|
203
185
|
/**
|
|
204
186
|
* Indicate which axis to display the right of the charts.
|
|
205
187
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -227,26 +209,13 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
227
209
|
* The configuration of the tooltip.
|
|
228
210
|
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
229
211
|
*/
|
|
230
|
-
tooltip: PropTypes.
|
|
231
|
-
axisContent: PropTypes.elementType,
|
|
232
|
-
classes: PropTypes.object,
|
|
233
|
-
itemContent: PropTypes.elementType,
|
|
234
|
-
slotProps: PropTypes.object,
|
|
235
|
-
slots: PropTypes.object,
|
|
236
|
-
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
237
|
-
}),
|
|
212
|
+
tooltip: PropTypes.object,
|
|
238
213
|
/**
|
|
239
214
|
* Indicate which axis to display the top of the charts.
|
|
240
215
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
241
216
|
* @default null
|
|
242
217
|
*/
|
|
243
218
|
topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
244
|
-
viewBox: PropTypes.shape({
|
|
245
|
-
height: PropTypes.number,
|
|
246
|
-
width: PropTypes.number,
|
|
247
|
-
x: PropTypes.number,
|
|
248
|
-
y: PropTypes.number
|
|
249
|
-
}),
|
|
250
219
|
/**
|
|
251
220
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
252
221
|
*/
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import { ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipRow, ChartsTooltipCell, ChartsTooltipMark, useItemTooltip, getChartsTooltipUtilityClass, ChartsTooltipContainer } from '@mui/x-charts/ChartsTooltip';
|
|
9
|
+
import { useXAxis, useYAxis } from '@mui/x-charts/hooks';
|
|
10
|
+
import { getLabel } from '@mui/x-charts/internals';
|
|
11
|
+
import { useHeatmapSeries } from "../hooks/useSeries.js";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const useUtilityClasses = ownerState => {
|
|
14
|
+
const {
|
|
15
|
+
classes
|
|
16
|
+
} = ownerState;
|
|
17
|
+
const slots = {
|
|
18
|
+
root: ['root'],
|
|
19
|
+
paper: ['paper'],
|
|
20
|
+
table: ['table'],
|
|
21
|
+
row: ['row'],
|
|
22
|
+
cell: ['cell'],
|
|
23
|
+
mark: ['mark'],
|
|
24
|
+
markCell: ['markCell'],
|
|
25
|
+
labelCell: ['labelCell'],
|
|
26
|
+
valueCell: ['valueCell']
|
|
27
|
+
};
|
|
28
|
+
return composeClasses(slots, getChartsTooltipUtilityClass, classes);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @ignore - internal component.
|
|
33
|
+
*/
|
|
34
|
+
function DefaultHeatmapTooltipContent(props) {
|
|
35
|
+
const {
|
|
36
|
+
classes
|
|
37
|
+
} = props;
|
|
38
|
+
const xAxis = useXAxis();
|
|
39
|
+
const yAxis = useYAxis();
|
|
40
|
+
const heatmapSeries = useHeatmapSeries();
|
|
41
|
+
const tooltipData = useItemTooltip();
|
|
42
|
+
if (!tooltipData || !heatmapSeries || heatmapSeries.seriesOrder.length === 0) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const {
|
|
46
|
+
series,
|
|
47
|
+
seriesOrder
|
|
48
|
+
} = heatmapSeries;
|
|
49
|
+
const seriesId = seriesOrder[0];
|
|
50
|
+
const {
|
|
51
|
+
color,
|
|
52
|
+
value,
|
|
53
|
+
identifier
|
|
54
|
+
} = tooltipData;
|
|
55
|
+
const [xIndex, yIndex] = value;
|
|
56
|
+
const formattedX = xAxis.valueFormatter?.(xAxis.data[xIndex], {
|
|
57
|
+
location: 'tooltip'
|
|
58
|
+
}) ?? xAxis.data[xIndex].toLocaleString();
|
|
59
|
+
const formattedY = yAxis.valueFormatter?.(yAxis.data[yIndex], {
|
|
60
|
+
location: 'tooltip'
|
|
61
|
+
}) ?? yAxis.data[yIndex].toLocaleString();
|
|
62
|
+
const formattedValue = series[seriesId].valueFormatter(value, {
|
|
63
|
+
dataIndex: identifier.dataIndex
|
|
64
|
+
});
|
|
65
|
+
const seriesLabel = getLabel(series[seriesId].label, 'tooltip');
|
|
66
|
+
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
67
|
+
className: classes?.paper,
|
|
68
|
+
children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
|
|
69
|
+
className: classes?.table,
|
|
70
|
+
children: [/*#__PURE__*/_jsx("thead", {
|
|
71
|
+
children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
72
|
+
className: classes?.row,
|
|
73
|
+
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
74
|
+
className: classes?.cell,
|
|
75
|
+
children: formattedX
|
|
76
|
+
}), formattedX && formattedY && /*#__PURE__*/_jsx(ChartsTooltipCell, {}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
77
|
+
className: classes?.cell,
|
|
78
|
+
children: formattedY
|
|
79
|
+
})]
|
|
80
|
+
})
|
|
81
|
+
}), /*#__PURE__*/_jsx("tbody", {
|
|
82
|
+
children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
83
|
+
className: classes?.row,
|
|
84
|
+
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
85
|
+
className: clsx(classes?.markCell, classes?.cell),
|
|
86
|
+
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
87
|
+
color: color,
|
|
88
|
+
className: classes?.mark
|
|
89
|
+
})
|
|
90
|
+
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
91
|
+
className: clsx(classes?.labelCell, classes?.cell),
|
|
92
|
+
children: seriesLabel
|
|
93
|
+
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
94
|
+
className: clsx(classes?.valueCell, classes?.cell),
|
|
95
|
+
children: formattedValue
|
|
96
|
+
})]
|
|
97
|
+
})
|
|
98
|
+
})]
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
process.env.NODE_ENV !== "production" ? DefaultHeatmapTooltipContent.propTypes = {
|
|
103
|
+
// ----------------------------- Warning --------------------------------
|
|
104
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
105
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
106
|
+
// ----------------------------------------------------------------------
|
|
107
|
+
/**
|
|
108
|
+
* Override or extend the styles applied to the component.
|
|
109
|
+
*/
|
|
110
|
+
classes: PropTypes.object
|
|
111
|
+
} : void 0;
|
|
112
|
+
function HeatmapTooltip(props) {
|
|
113
|
+
const classes = useUtilityClasses({
|
|
114
|
+
classes: props.classes
|
|
115
|
+
});
|
|
116
|
+
return /*#__PURE__*/_jsx(ChartsTooltipContainer, _extends({}, props, {
|
|
117
|
+
classes: classes,
|
|
118
|
+
trigger: "item",
|
|
119
|
+
children: /*#__PURE__*/_jsx(DefaultHeatmapTooltipContent, {
|
|
120
|
+
classes: classes
|
|
121
|
+
})
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
process.env.NODE_ENV !== "production" ? HeatmapTooltip.propTypes = {
|
|
125
|
+
// ----------------------------- Warning --------------------------------
|
|
126
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
127
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
128
|
+
// ----------------------------------------------------------------------
|
|
129
|
+
/**
|
|
130
|
+
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
131
|
+
* or a function that returns either.
|
|
132
|
+
* It's used to set the position of the popper.
|
|
133
|
+
* The return value will passed as the reference object of the Popper instance.
|
|
134
|
+
*/
|
|
135
|
+
anchorEl: PropTypes.oneOfType([(props, propName) => {
|
|
136
|
+
if (props[propName] == null) {
|
|
137
|
+
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
138
|
+
}
|
|
139
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
140
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}, PropTypes.func, PropTypes.shape({
|
|
144
|
+
contextElement: (props, propName) => {
|
|
145
|
+
if (props[propName] == null) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
149
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
},
|
|
153
|
+
getBoundingClientRect: PropTypes.func.isRequired
|
|
154
|
+
})]),
|
|
155
|
+
/**
|
|
156
|
+
* Override or extend the styles applied to the component.
|
|
157
|
+
*/
|
|
158
|
+
classes: PropTypes.object,
|
|
159
|
+
/**
|
|
160
|
+
* The component used for the root node.
|
|
161
|
+
* Either a string to use a HTML element or a component.
|
|
162
|
+
*/
|
|
163
|
+
component: PropTypes.elementType,
|
|
164
|
+
/**
|
|
165
|
+
* The components used for each slot inside the Popper.
|
|
166
|
+
* Either a string to use a HTML element or a component.
|
|
167
|
+
* @default {}
|
|
168
|
+
*/
|
|
169
|
+
components: PropTypes.shape({
|
|
170
|
+
Root: PropTypes.elementType
|
|
171
|
+
}),
|
|
172
|
+
/**
|
|
173
|
+
* The props used for each slot inside the Popper.
|
|
174
|
+
* @default {}
|
|
175
|
+
*/
|
|
176
|
+
componentsProps: PropTypes.shape({
|
|
177
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
178
|
+
}),
|
|
179
|
+
/**
|
|
180
|
+
* An HTML element or function that returns one.
|
|
181
|
+
* The `container` will have the portal children appended to it.
|
|
182
|
+
*
|
|
183
|
+
* You can also provide a callback, which is called in a React layout effect.
|
|
184
|
+
* This lets you set the container from a ref, and also makes server-side rendering possible.
|
|
185
|
+
*
|
|
186
|
+
* By default, it uses the body of the top-level document object,
|
|
187
|
+
* so it's simply `document.body` most of the time.
|
|
188
|
+
*/
|
|
189
|
+
container: PropTypes.oneOfType([(props, propName) => {
|
|
190
|
+
if (props[propName] == null) {
|
|
191
|
+
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
192
|
+
}
|
|
193
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
194
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}, PropTypes.func]),
|
|
198
|
+
/**
|
|
199
|
+
* The `children` will be under the DOM hierarchy of the parent component.
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
disablePortal: PropTypes.bool,
|
|
203
|
+
/**
|
|
204
|
+
* Always keep the children in the DOM.
|
|
205
|
+
* This prop can be useful in SEO situation or
|
|
206
|
+
* when you want to maximize the responsiveness of the Popper.
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
keepMounted: PropTypes.bool,
|
|
210
|
+
/**
|
|
211
|
+
* Popper.js is based on a "plugin-like" architecture,
|
|
212
|
+
* most of its features are fully encapsulated "modifiers".
|
|
213
|
+
*
|
|
214
|
+
* A modifier is a function that is called each time Popper.js needs to
|
|
215
|
+
* compute the position of the popper.
|
|
216
|
+
* For this reason, modifiers should be very performant to avoid bottlenecks.
|
|
217
|
+
* To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
|
|
218
|
+
*/
|
|
219
|
+
modifiers: PropTypes.arrayOf(PropTypes.shape({
|
|
220
|
+
data: PropTypes.object,
|
|
221
|
+
effect: PropTypes.func,
|
|
222
|
+
enabled: PropTypes.bool,
|
|
223
|
+
fn: PropTypes.func,
|
|
224
|
+
name: PropTypes.any,
|
|
225
|
+
options: PropTypes.object,
|
|
226
|
+
phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
|
|
227
|
+
requires: PropTypes.arrayOf(PropTypes.string),
|
|
228
|
+
requiresIfExists: PropTypes.arrayOf(PropTypes.string)
|
|
229
|
+
})),
|
|
230
|
+
/**
|
|
231
|
+
* If `true`, the component is shown.
|
|
232
|
+
*/
|
|
233
|
+
open: PropTypes.bool,
|
|
234
|
+
/**
|
|
235
|
+
* Popper placement.
|
|
236
|
+
* @default 'bottom'
|
|
237
|
+
*/
|
|
238
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
239
|
+
/**
|
|
240
|
+
* Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
|
|
241
|
+
* @default {}
|
|
242
|
+
*/
|
|
243
|
+
popperOptions: PropTypes.shape({
|
|
244
|
+
modifiers: PropTypes.array,
|
|
245
|
+
onFirstUpdate: PropTypes.func,
|
|
246
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
247
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed'])
|
|
248
|
+
}),
|
|
249
|
+
/**
|
|
250
|
+
* A ref that points to the used popper instance.
|
|
251
|
+
*/
|
|
252
|
+
popperRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
253
|
+
current: PropTypes.shape({
|
|
254
|
+
destroy: PropTypes.func.isRequired,
|
|
255
|
+
forceUpdate: PropTypes.func.isRequired,
|
|
256
|
+
setOptions: PropTypes.func.isRequired,
|
|
257
|
+
state: PropTypes.shape({
|
|
258
|
+
attributes: PropTypes.object.isRequired,
|
|
259
|
+
elements: PropTypes.object.isRequired,
|
|
260
|
+
modifiersData: PropTypes.object.isRequired,
|
|
261
|
+
options: PropTypes.object.isRequired,
|
|
262
|
+
orderedModifiers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
263
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']).isRequired,
|
|
264
|
+
rects: PropTypes.object.isRequired,
|
|
265
|
+
reset: PropTypes.bool.isRequired,
|
|
266
|
+
scrollParents: PropTypes.object.isRequired,
|
|
267
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed']).isRequired,
|
|
268
|
+
styles: PropTypes.object.isRequired
|
|
269
|
+
}).isRequired,
|
|
270
|
+
update: PropTypes.func.isRequired
|
|
271
|
+
})
|
|
272
|
+
})]),
|
|
273
|
+
/**
|
|
274
|
+
* The props used for each slot inside the Popper.
|
|
275
|
+
* @default {}
|
|
276
|
+
*/
|
|
277
|
+
slotProps: PropTypes.object,
|
|
278
|
+
/**
|
|
279
|
+
* The components used for each slot inside the Popper.
|
|
280
|
+
* Either a string to use a HTML element or a component.
|
|
281
|
+
* @default {}
|
|
282
|
+
*/
|
|
283
|
+
slots: PropTypes.object,
|
|
284
|
+
/**
|
|
285
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
286
|
+
*/
|
|
287
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
288
|
+
/**
|
|
289
|
+
* Help supporting a react-transition-group/Transition component.
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
transition: PropTypes.bool
|
|
293
|
+
} : void 0;
|
|
294
|
+
export { HeatmapTooltip };
|
package/modern/Heatmap/index.js
CHANGED